Page 1 of 1

Adding degrees of freedom to the knee joint

Posted: Wed Nov 21, 2018 7:06 am
by 00ocai
Hi, I'm using the Hamner full body model and want to add a rotational degree of freedom around the X axis to allow for slight genu valgum/varum when scaling the model. Does anyone know how this is accomplishable? So far my attempts have resulted in my model displaying extreme genu varum...

Code: Select all

<Joint>
						<CustomJoint name="knee_r">
							<!--Name of the parent body to which this joint connects its owner body.-->
							<parent_body>femur_r</parent_body>
							<!--Location of the joint in the parent body specified in the parent reference frame. Default is (0,0,0).-->
							<location_in_parent>0 0 0</location_in_parent>
							<!--Orientation of the joint in the parent body specified in the parent reference frame. Euler XYZ body-fixed rotation angles are used to express the orientation. Default is (0,0,0).-->
							<orientation_in_parent>0 0 0</orientation_in_parent>
							<!--Location of the joint in the child body specified in the child reference frame. For SIMM models, this vector is always the zero vector (i.e., the body reference frame coincides with the joint). -->
							<location>0 0 0</location>
							<!--Orientation of the joint in the owing body specified in the owning body reference frame.  Euler XYZ body-fixed rotation angles are used to express the orientation. -->
							<orientation>0 0 0</orientation>
							<!--Set holding the generalized coordinates (q's) that parmeterize this joint.-->
							<CoordinateSet>
								<objects>
									<Coordinate name="knee_angle_r">
										<!--Coordinate can describe rotational, translational, or coupled motion. Defaults to rotational.-->
										<motion_type>rotational</motion_type>
										<!--The value of this coordinate before any value has been set. Rotational coordinate value is in radians and Translational in meters.-->
										<default_value>0</default_value>
										<!--The speed value of this coordinate before any value has been set. Rotational coordinate value is in rad/s and Translational in m/s.-->
										<default_speed_value>0</default_speed_value>
										<!--The minimum and maximum values that the coordinate can range between. Rotational coordinate range in radians and Translational in meters.-->
										<range>-2.0943951 0.17453293</range>
										<!--Flag indicating whether or not the values of the coordinates should be limited to the range, above.-->
										<clamped>true</clamped>
										<!--Flag indicating whether or not the values of the coordinates should be constrained to the current (e.g. default) value, above.-->
										<locked>false</locked>
										<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
										<prescribed_function />
										<!--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.-->
										<prescribed>false</prescribed>
									</Coordinate>
									<Coordinate name="knee_adduction_r">
										<!--Coordinate can describe rotational, translational, or coupled motion. Defaults to rotational.-->
										<motion_type>rotational</motion_type>
										<!--The value of this coordinate before any value has been set. Rotational coordinate value is in radians and Translational in meters.-->
										<default_value>0</default_value>
										<!--The speed value of this coordinate before any value has been set. Rotational coordinate value is in rad/s and Translational in m/s.-->
										<default_speed_value>0</default_speed_value>
										<!--The minimum and maximum values that the coordinate can range between. Rotational coordinate range in radians and Translational in meters.-->
										<range>-0.34 0.34</range>
										<!--Flag indicating whether or not the values of the coordinates should be limited to the range, above.-->
										<clamped>true</clamped>
										<!--Flag indicating whether or not the values of the coordinates should be constrained to the current (e.g. default) value, above.-->
										<locked>false</locked>
										<!--If specified, the coordinate can be prescribed by a function of time. It can be any OpenSim Function with valid second order derivatives.-->
										<prescribed_function />
										<!--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.-->
										<prescribed>false</prescribed>
									</Coordinate>
								</objects>
								<groups />
							</CoordinateSet>
							<!--Whether the joint transform defines parent->child or child->parent.-->
							<reverse>false</reverse>
							<!--Defines how the child body moves with respect to the parent as a function of the generalized coordinates.-->
							<SpatialTransform>
								<!--3 Axes for rotations are listed first.-->
								<TransformAxis name="rotation1">
									<!--Names of the coordinates that serve as the independent variables         of the transform function.-->
									<coordinates>knee_angle_r</coordinates>
									<!--Rotation or translation axis for the transform.-->
									<axis>0 0 1</axis>
									<!--Transform function of the generalized coordinates used to        represent the amount of transformation along a specified axis.-->
									<function>
										<LinearFunction>
											<coefficients> 1 0</coefficients>
										</LinearFunction>
									</function>
								</TransformAxis>
								<TransformAxis name="rotation2">
									<!--Names of the coordinates that serve as the independent variables         of the transform function.-->
									<coordinates></coordinates>
									<!--Rotation or translation axis for the transform.-->
									<axis>0 1 0</axis>
									<!--Transform function of the generalized coordinates used to        represent the amount of transformation along a specified axis.-->
									<function>
										<Constant>
											<value>0</value>
										</Constant>
									</function>
								</TransformAxis>
								<TransformAxis name="rotation3">
									<!--Names of the coordinates that serve as the independent variables         of the transform function.-->
									<coordinates>knee_adduction_r</coordinates>
									<!--Rotation or translation axis for the transform.-->
									<axis>1 0 0</axis>
									<!--Transform function of the generalized coordinates used to        represent the amount of transformation along a specified axis.-->
									<function>
										<Constant>
											<value>1 0</value>
										</Constant>
									</function>
								</TransformAxis>
								<!--3 Axes for translations are listed next.-->
								<TransformAxis name="translation1">
									<!--Names of the coordinates that serve as the independent variables         of the transform function.-->
									<coordinates>knee_angle_r</coordinates>
									<!--Rotation or translation axis for the transform.-->
									<axis>1 0 0</axis>
									<!--Transform function of the generalized coordinates used to        represent the amount of transformation along a specified axis.-->
									<function>
										<SimmSpline>
											<x> -2.0944 -1.74533 -1.39626 -1.0472 -0.698132 -0.349066 -0.174533 0.197344 0.337395 0.490178 1.52146 2.0944</x>
											<y> -0.0032 0.00179 0.00411 0.0041 0.00212 -0.001 -0.0031 -0.005227 -0.005435 -0.005574 -0.005435 -0.00525</y>
										</SimmSpline>
									</function>
								</TransformAxis>
								<TransformAxis name="translation2">
									<!--Names of the coordinates that serve as the independent variables         of the transform function.-->
									<coordinates>knee_angle_r</coordinates>
									<!--Rotation or translation axis for the transform.-->
									<axis>0 1 0</axis>
									<!--Transform function of the generalized coordinates used to        represent the amount of transformation along a specified axis.-->
									<function>
										<SimmSpline>
											<x> -2.0944 -1.22173 -0.523599 -0.349066 -0.174533 0.159149 2.0944</x>
											<y> -0.4226 -0.4082 -0.399 -0.3976 -0.3966 -0.395264 -0.396</y>
										</SimmSpline>
									</function>
								</TransformAxis>
								<TransformAxis name="translation3">
									<!--Names of the coordinates that serve as the independent variables         of the transform function.-->
									<coordinates></coordinates>
									<!--Rotation or translation axis for the transform.-->
									<axis>0 0 1</axis>
									<!--Transform function of the generalized coordinates used to        represent the amount of transformation along a specified axis.-->
									<function>
										<Constant>
											<value>0</value>
										</Constant>
									</function>
								</TransformAxis>
							</SpatialTransform>
						</CustomJoint>
					</Joint>

Re: Adding degrees of freedom to the knee joint

Posted: Wed Nov 21, 2018 7:29 am
by nicos1993
Hello Cai,

From the code snippet it looks like your range of knee adduction/abduction is +- 19.4 deg. The 'range' tag is in radians - have you tried to lower the range value?

Kind regards,

Nicos Haralabidis

Re: Adding degrees of freedom to the knee joint

Posted: Wed Nov 21, 2018 7:37 am
by 00ocai
Hi Nicos,

Yeah, I've tried reducing the knee abduction/aduction range to +-0.1 radians but it hasn't had any effect. The scaling still results in an extreme genu varum (approx 30ish deg) :/

Re: Adding degrees of freedom to the knee joint

Posted: Wed Nov 21, 2018 9:12 am
by jimmy
It may help to change the <TransformAxis> function from a Constant to a Linear function (similar to knee_angle_r)

Re: Adding degrees of freedom to the knee joint

Posted: Wed Nov 28, 2018 5:00 am
by 00ocai
Thanks James, That worked grand.