Share 
Follow 
AboutDownloadsDocumentsForumsSource CodeIssuesNews
Date:
2019-11-29 17:17
Priority:
3
State:
Open
Submitted by:
Scott Brandon (s_brandon)
Assigned to:
Nobody (None)
Summary:
CustomJoint Coordinate Index by Order, not Name

Detailed description
I attached a new body "backpack" to a torso model. I assumed I could define coordinates in any order (e.g. tx then ty ; versus ty then tx). However, when I then associate each coordinate with a DOF in the custom joint, I found that the model would incorrectly move along the x-axis when the value of "ty" changed.
- this is despite specifying that tx should follow (1,0,0), etc.

It turns out that if you define coordinates out of order, the constructor is loading coordinates by index instead of by name.

See attached model files, line 5397

<Coordinate name="backpack_torso_ty">
<!--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>-1 1</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="backpack_torso_tx">
<!--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>-1 1</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>
</coordinates>

Add A Comment: Notepad

Message  ↓
Date: 2021-01-02 06:42
Sender: B.J. Fregly

I was just about to submit this bug in a different flavor, but I believe it is the same underlying problem, so I will just add a comment here. If you assign the coordinates to DOFs in a different order than the order in which they were defined in the .osim model file, then when you load the model into the GUI and use the coordinate sliders, the sliders will not be connected to the correct coordinate names.

For example, if I create a CustomJoint with three rotational coordinates rx, ry, and rz (in that order), and then I want to use a z-x-y rotation sequence in that joint, when I assign the coordinates to the DOFs, the order will be rz, then rz, and finally ry. When you load that model into the GUI and try changing the rotations, you will see that there is a mismatch between the coordinate name displayed in the slider and the DOF that actually moves.

The fix is easy (define coordinates in the same order in which they will be assigned to DOFs), but if you don't know this bug exists, it can really mess you up!

Attachments:
Size Name Date By Download
908 KiBincorrectModel.osim2019-11-29 17:17s_brandonincorrectModel.osim
908 KiBScaledManModel_addBP.osim2019-11-29 17:17s_brandonScaledManModel_addBP.osim
Field Old Value Date By
File Added692: incorrectModel.osim2019-11-29 17:17s_brandon
File Added693: ScaledManModel_addBP.osim2019-11-29 17:17s_brandon
Feedback