Skip to content

Commit 9395f43

Browse files
committed
Add Jupyter notebooks with OpenSim Python tutorials
1 parent 3f69b6f commit 9395f43

35 files changed

+40968
-0
lines changed

Bindings/Python/tutorials/Tutorial 1 - Introduction to OpenSim.ipynb

Lines changed: 387 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 2 - Creating and Simulating a simple arm Model.ipynb

Lines changed: 613 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 3 - Loading and Modifying OpenSim Models.ipynb

Lines changed: 484 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 4 - Musculoskeletal models, Motion Files and MuscleAnalysis.ipynb

Lines changed: 995 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 5 - Scaling, Inverse Kinematics, and Inverse Dynamics.ipynb

Lines changed: 1126 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 6 - Static Optimization.ipynb

Lines changed: 2148 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 7 - Introduction to OpenSim Moco.ipynb

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.

Bindings/Python/tutorials/Tutorial 8 - Creating Muscle-driven Simulations with OpenSim Moco.ipynb

Lines changed: 1003 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSimDocument Version="30501">
3+
<Model name="double_pendulum">
4+
<!--Acceleration due to gravity, expressed in ground.-->
5+
<gravity>0 -9.80665 0</gravity>
6+
<!--Credits (e.g., model author names) associated with the model.-->
7+
<credits>Ajay Seth</credits>
8+
<!--Publications and references associated with the model.-->
9+
<publications>For testing</publications>
10+
<!--Units for all lengths.-->
11+
<length_units>meters</length_units>
12+
<!--Units for all forces.-->
13+
<force_units>N</force_units>
14+
<!--List of bodies that make up this model.-->
15+
<BodySet>
16+
<objects>
17+
<Body name="rod1">
18+
<!--The mass of the body (kg)-->
19+
<mass>1</mass>
20+
<!--The location (Vec3) of the mass center in the body frame.-->
21+
<mass_center>0 0.2 0</mass_center>
22+
<!--The elements of the inertia tensor (Vec6) as [Ixx Iyy Izz Ixy Ixz Iyz] measured about the mass_center and not the body origin.-->
23+
<inertia>0 0 0 0 0 0</inertia>
24+
<!--Set of wrap objects fixed to this body that GeometryPaths can wrap over.-->
25+
<WrapObjectSet>
26+
<objects />
27+
<groups />
28+
</WrapObjectSet>
29+
<!--For visualization in the Simbody visualizer or OpenSim GUI.-->
30+
<VisibleObject>
31+
<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
32+
<GeometrySet>
33+
<objects>
34+
<DisplayGeometry>
35+
<!--Name of geometry file .vtp, .stl, .obj-->
36+
<geometry_file>cylinder.vtp</geometry_file>
37+
<!--Color used to display the geometry when visible-->
38+
<color> 1 1 1</color>
39+
<!--Name of texture file .jpg, .bmp-->
40+
<texture_file />
41+
<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
42+
<transform> 0 0 0 0 0.25 0</transform>
43+
<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
44+
<scale_factors> 0.02 0.5 0.02</scale_factors>
45+
<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
46+
<display_preference>4</display_preference>
47+
<!--Display opacity between 0.0 and 1.0-->
48+
<opacity>1</opacity>
49+
</DisplayGeometry>
50+
<DisplayGeometry>
51+
<!--Name of geometry file .vtp, .stl, .obj-->
52+
<geometry_file>sphere.vtp</geometry_file>
53+
<!--Color used to display the geometry when visible-->
54+
<color> 1 1 1</color>
55+
<!--Name of texture file .jpg, .bmp-->
56+
<texture_file />
57+
<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
58+
<transform> 0 0 0 0 0 0</transform>
59+
<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
60+
<scale_factors> 0.1 0.1 0.1</scale_factors>
61+
<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
62+
<display_preference>4</display_preference>
63+
<!--Display opacity between 0.0 and 1.0-->
64+
<opacity>1</opacity>
65+
</DisplayGeometry>
66+
</objects>
67+
<groups />
68+
</GeometrySet>
69+
<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
70+
<scale_factors> 1 1 1</scale_factors>
71+
<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
72+
<transform> 0 0 0 0 0 0</transform>
73+
<!--Whether to show a coordinate frame-->
74+
<show_axes>true</show_axes>
75+
<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
76+
<display_preference>4</display_preference>
77+
</VisibleObject>
78+
</Body>
79+
<Body name="rod2">
80+
<!--The mass of the body (kg)-->
81+
<mass>1</mass>
82+
<!--The location (Vec3) of the mass center in the body frame.-->
83+
<mass_center>0 0 0</mass_center>
84+
<!--The elements of the inertia tensor (Vec6) as [Ixx Iyy Izz Ixy Ixz Iyz] measured about the mass_center and not the body origin.-->
85+
<inertia>0 0 0 0 0 0</inertia>
86+
<!--Set of wrap objects fixed to this body that GeometryPaths can wrap over.-->
87+
<WrapObjectSet>
88+
<objects />
89+
<groups />
90+
</WrapObjectSet>
91+
<!--For visualization in the Simbody visualizer or OpenSim GUI.-->
92+
<VisibleObject>
93+
<!--Set of geometry files and associated attributes, allow .vtp, .stl, .obj-->
94+
<GeometrySet>
95+
<objects>
96+
<DisplayGeometry>
97+
<!--Name of geometry file .vtp, .stl, .obj-->
98+
<geometry_file>cylinder.vtp</geometry_file>
99+
<!--Color used to display the geometry when visible-->
100+
<color> 1 1 1</color>
101+
<!--Name of texture file .jpg, .bmp-->
102+
<texture_file />
103+
<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
104+
<transform> 0 0 0 0 0.25 0</transform>
105+
<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
106+
<scale_factors> 0.02 0.5 0.02</scale_factors>
107+
<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
108+
<display_preference>4</display_preference>
109+
<!--Display opacity between 0.0 and 1.0-->
110+
<opacity>1</opacity>
111+
</DisplayGeometry>
112+
<DisplayGeometry>
113+
<!--Name of geometry file .vtp, .stl, .obj-->
114+
<geometry_file>sphere.vtp</geometry_file>
115+
<!--Color used to display the geometry when visible-->
116+
<color> 1 1 1</color>
117+
<!--Name of texture file .jpg, .bmp-->
118+
<texture_file />
119+
<!--in body transform specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
120+
<transform> 0 0 0 0 0 0</transform>
121+
<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
122+
<scale_factors> 0.1 0.1 0.1</scale_factors>
123+
<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded-->
124+
<display_preference>4</display_preference>
125+
<!--Display opacity between 0.0 and 1.0-->
126+
<opacity>1</opacity>
127+
</DisplayGeometry>
128+
</objects>
129+
<groups />
130+
</GeometrySet>
131+
<!--Three scale factors for display purposes: scaleX scaleY scaleZ-->
132+
<scale_factors> 1 1 1</scale_factors>
133+
<!--transform relative to owner specified as 3 rotations (rad) followed by 3 translations rX rY rZ tx ty tz-->
134+
<transform> 0 0 0 0 0 0</transform>
135+
<!--Whether to show a coordinate frame-->
136+
<show_axes>true</show_axes>
137+
<!--Display Pref. 0:Hide 1:Wire 3:Flat 4:Shaded Can be overriden for individual geometries-->
138+
<display_preference>4</display_preference>
139+
</VisibleObject>
140+
</Body>
141+
</objects>
142+
<groups />
143+
</BodySet>
144+
<!--List of Frames that various objects can be anchored to or expressed in, Body frames are builtin and not included in this list.-->
145+
<FrameSet>
146+
<objects>
147+
</objects>
148+
<groups />
149+
</FrameSet>
150+
<!--List of joints that connect the bodies.-->
151+
<JointSet>
152+
<objects>
153+
<PinJoint name="pin1">
154+
<!--List of connectors (structural dependencies) that this component has.-->
155+
<connectors>
156+
<Connector_PhysicalFrame_ name="parent_body">
157+
<!--Name of the component this Connector should be connected to.-->
158+
<connectee_name>../ground</connectee_name>
159+
</Connector_PhysicalFrame_>
160+
<Connector_PhysicalFrame_ name="child_body">
161+
<!--Name of the component this Connector should be connected to.-->
162+
<connectee_name>../rod1</connectee_name>
163+
</Connector_PhysicalFrame_>
164+
</connectors>
165+
<!--Location of the joint in the parent body specified in the parent reference frame. Default is (0,0,0).-->
166+
<location_in_parent>0 0 0</location_in_parent>
167+
<!--Orientation of the joint in the parent body specified in the parent reference frame. Euler XYZ body-fixed rotation angles (in radians) are used to express the orientation. Default is (0,0,0).-->
168+
<orientation_in_parent>0 0 0</orientation_in_parent>
169+
<!--Location of the joint in the child body specified in the child reference frame. Default is (0,0,0).-->
170+
<location_in_child>0 0.5 0</location_in_child>
171+
<!--Orientation of the joint in the child body specified in the child body reference frame. Euler XYZ body-fixed rotation angles (in radians) are used to express the orientation. Default is (0,0,0)-->
172+
<orientation_in_child>0 0 0</orientation_in_child>
173+
<!--Set holding the generalized coordinates (q's) that parmeterize this joint.-->
174+
<CoordinateSet>
175+
<objects>
176+
<Coordinate name="q1">
177+
<!--Coordinate can describe rotational, translational, or coupled motion. Defaults to rotational.-->
178+
<motion_type>rotational</motion_type>
179+
<!--The value of this coordinate before any value has been set. Rotational coordinate value is in radians and Translational in meters.-->
180+
<default_value>-0.78539816</default_value>
181+
<!--The speed value of this coordinate before any value has been set. Rotational coordinate value is in rad/s and Translational in m/s.-->
182+
<default_speed_value>0</default_speed_value>
183+
<!--The minimum and maximum values that the coordinate can range between. Rotational coordinate range in radians and Translational in meters.-->
184+
<range>-1.57079633 1.57079633</range>
185+
<!--Flag indicating whether or not the values of the coordinates should be limited to the range, above.-->
186+
<clamped>false</clamped>
187+
<!--Flag indicating whether or not the values of the coordinates should be constrained to the current (e.g. default) value, above.-->
188+
<locked>false</locked>
189+
<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
190+
<prescribed_function />
191+
<!--Flag indicating whether or not the values of the coordinates should be prescribed according to the function above. It is ignored if the no prescribed function is specified.-->
192+
<prescribed>false</prescribed>
193+
</Coordinate>
194+
</objects>
195+
<groups />
196+
</CoordinateSet>
197+
<!--Advanced option. Specify the direction of the joint in the multibody tree: parent->child (forward, reverse == false) or child->parent (reverse == true) NOTE: the Joint transform and its coordinates maintain a parent->child sense, even if the Joint is reversed.-->
198+
<reverse>false</reverse>
199+
</PinJoint>
200+
<PinJoint name="pin2">
201+
<!--List of connectors (structural dependencies) that this component has.-->
202+
<connectors>
203+
<Connector_PhysicalFrame_ name="parent_body">
204+
<!--Name of the component this Connector should be connected to.-->
205+
<connectee_name>rod1</connectee_name>
206+
</Connector_PhysicalFrame_>
207+
<Connector_PhysicalFrame_ name="child_body">
208+
<!--Name of the component this Connector should be connected to.-->
209+
<connectee_name>rod2</connectee_name>
210+
</Connector_PhysicalFrame_>
211+
</connectors>
212+
<!--Location of the joint in the parent body specified in the parent reference frame. Default is (0,0,0).-->
213+
<location_in_parent>0 0 0</location_in_parent>
214+
<!--Orientation of the joint in the parent body specified in the parent reference frame. Euler XYZ body-fixed rotation angles (in radians) are used to express the orientation. Default is (0,0,0).-->
215+
<orientation_in_parent>0 0 0</orientation_in_parent>
216+
<!--Location of the joint in the child body specified in the child reference frame. Default is (0,0,0).-->
217+
<location_in_child>0 0.5 0</location_in_child>
218+
<!--Orientation of the joint in the child body specified in the child body reference frame. Euler XYZ body-fixed rotation angles (in radians) are used to express the orientation. Default is (0,0,0)-->
219+
<orientation_in_child>0 0 0</orientation_in_child>
220+
<!--Set holding the generalized coordinates (q's) that parmeterize this joint.-->
221+
<CoordinateSet>
222+
<objects>
223+
<Coordinate name="q2">
224+
<!--Coordinate can describe rotational, translational, or coupled motion. Defaults to rotational.-->
225+
<motion_type>rotational</motion_type>
226+
<!--The value of this coordinate before any value has been set. Rotational coordinate value is in radians and Translational in meters.-->
227+
<default_value>-1.04719755</default_value>
228+
<!--The speed value of this coordinate before any value has been set. Rotational coordinate value is in rad/s and Translational in m/s.-->
229+
<default_speed_value>0</default_speed_value>
230+
<!--The minimum and maximum values that the coordinate can range between. Rotational coordinate range in radians and Translational in meters.-->
231+
<range>-1.57079633 1.57079633</range>
232+
<!--Flag indicating whether or not the values of the coordinates should be limited to the range, above.-->
233+
<clamped>false</clamped>
234+
<!--Flag indicating whether or not the values of the coordinates should be constrained to the current (e.g. default) value, above.-->
235+
<locked>false</locked>
236+
<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
237+
<prescribed_function />
238+
<!--Flag indicating whether or not the values of the coordinates should be prescribed according to the function above. It is ignored if the no prescribed function is specified.-->
239+
<prescribed>false</prescribed>
240+
</Coordinate>
241+
</objects>
242+
<groups />
243+
</CoordinateSet>
244+
<!--Advanced option. Specify the direction of the joint in the multibody tree: parent->child (forward, reverse == false) or child->parent (reverse == true) NOTE: the Joint transform and its coordinates maintain a parent->child sense, even if the Joint is reversed.-->
245+
<reverse>false</reverse>
246+
</PinJoint>
247+
</objects>
248+
</JointSet>
249+
<!--Controllers that provide the control inputs for Actuators.-->
250+
<ControllerSet>
251+
<objects />
252+
<groups />
253+
</ControllerSet>
254+
<!--Constraints in the model.-->
255+
<ConstraintSet>
256+
<objects />
257+
<groups />
258+
</ConstraintSet>
259+
<!--Forces in the model (includes Actuators).-->
260+
<ForceSet>
261+
<objects />
262+
<groups />
263+
</ForceSet>
264+
<!--Markers in the model.-->
265+
<MarkerSet>
266+
<objects />
267+
<groups />
268+
</MarkerSet>
269+
<!--Geometry to be used in contact forces.-->
270+
<ContactGeometrySet>
271+
<objects />
272+
<groups />
273+
</ContactGeometrySet>
274+
</Model>
275+
</OpenSimDocument>

0 commit comments

Comments
 (0)