You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Helper functions that "main_script.py" uses for running simulations.
3
+
Helper functions that "simulate.py" uses for running simulations.
4
4
"""
5
5
6
6
@@ -23,16 +23,22 @@
23
23
dend=85
24
24
25
25
# Model and kinematic generation functions:
26
-
defgenerate_scaled_model(reach_dir):
26
+
defgenerate_scaled_model(reach_dir: str):
27
27
"""
28
28
Uses a known set of kinematics to scale "model_toScale.osim" to the data.
29
-
Requires:
30
-
a kinematics file, e.g. "kinematics_1.csv" below.
31
-
the kinematics should include a paw, wrist, elbow and shoulder set of markers. I will work with you to make it work with a subset, if necessary.
32
-
You also need Scale_Setup.xml.
33
29
34
-
This generates "mouse_tracked.trc", which is the formal opensim requires for its scale tool. it will also generate a new model local to the kinematics.
30
+
Args:
31
+
reach_dir (str, required): Directory containing kinematics CSV files and Scale_Setup.xml.
32
+
33
+
Produces:
34
+
"mouse_tracked.trc": marker tracking file required for scaling.
35
+
"scaled_mouse.osim": scaled model specific to the dataset.
36
+
"scaled_mouse_params.xml": XML containing scaling parameters.
35
37
38
+
Requires:
39
+
a kinematics file, e.g. "kinematics_1.csv" below.
40
+
the kinematics should include a paw, wrist, elbow and shoulder set of markers. I will work with you to make it work with a subset, if necessary.
Converts Cartesian coordinates to spherical coordinates.
283
+
284
+
Args:
285
+
x (float): X-coordinate.
286
+
y (float): Y-coordinate.
287
+
z (float): Z-coordinate.
288
+
289
+
Returns:
290
+
tuple: (r, elevation, azimuth) corresponding to radius, polar angle, and azimuthal angle.
271
291
"""
272
292
XsqPlusYsq=x**2+y**2
273
293
r=m.sqrt(XsqPlusYsq+z**2) # r
@@ -279,6 +299,14 @@ def cart2sph(x,y,z):
279
299
defgenerate_initial_pose(reach_dir):
280
300
"""
281
301
Constraining the joint angles to their solved initial values is hugely helpful for accuracy in the "full" simulation, so I recommend performing this step. You can skip end pose if you want to.
302
+
303
+
Estimates initial joint angles for each reach using adjusted kinematics.
- "initpose_*.csv": initial joint angles suitable for full simulation.
282
310
"""
283
311
284
312
# Itterate through the adjusted kinematic files that come from generate_scaled_kinematics_rigid(), then simulate them to get approximate starting joint angles.
# After this, you'll have the synthetic kinematics and muscle excitations in the same folder as your initial emg and kinematics. This will take several hours to run.
0 commit comments