I am looking to find trunk flexion angle with OpenSense during sit-to-stand trials. The model runs great and simulation looks correct. However, I would like to find the angle of the torso to the earth (OpenSim coordinate system) and do not see it in the motion output from OpenSim. The only outputs seem to be relating one sensor to another (closest relevant outputs are torso to pelvis- lumbar bending OR pelvis to femur- hip flexion). Is there a way to get the angle of one sensor to the earth, particularly AP trunk flexion about the east/Z axis? I may have missed it on the output or it may be something I can find with pre or post processing of the quaternions.
Thanks in advance!
OpenSense- sensor to earth angle (trunk flexion angle)
- Therese Parr
- Posts: 9
- Joined: Mon Dec 02, 2019 9:47 am
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: OpenSense- sensor to earth angle (trunk flexion angle)
Hello,
There's a call that you can make on any Frame (Body, or JointFrame for example) to compute the orientation in Ground
To extract angles from Transform you get the rotation part and then extract Angles as needed:
https://simtk.org/api_docs/molmodel/api ... orm__.html
https://simtk.org/api_docs/molmodel/api ... ion__.html
Hope this helps,
-Ayman
There's a call that you can make on any Frame (Body, or JointFrame for example) to compute the orientation in Ground
Code: Select all
SimTK::Transform& getTransformInGround(const State& s)
Code: Select all
.R()
https://simtk.org/api_docs/molmodel/api ... orm__.html
https://simtk.org/api_docs/molmodel/api ... ion__.html
Hope this helps,
-Ayman
- Therese Parr
- Posts: 9
- Joined: Mon Dec 02, 2019 9:47 am
Re: OpenSense- sensor to earth angle (trunk flexion angle)
Thanks for the quick response, Ayman! That gave me a good start. Here is the code I currently have running.
I am unsure how the dynamic motion file can play a role in finding the angle for each time point of motion because the state is currently just the calibrated static model. Is there a place I should've imported the .sto file input or .mot file output?
Also, finding the rotation relative to the global coordinate gives me SWIGTYPE_p_SimTK for the torso.getRotationInGround(state) and [1,0,0];[0,1,0];[0,0,1] for the torso_transformation.R() function, which don't seem particular to the model/trial I am using.
Thanks again for the help!!
This code runs, but doesn't give me any useful results. I am not sure how to make these rotations relate to the body (torso) and be dynamic.import org.opensim.modeling.*
addpath ('C:/OpenSim 4.3/bin')
modelFileName = 'Rajagopal2015_opensense_calibrated.osim'; % The path to an input model
model = Model(modelFileName);
state = model.initSystem();
%Get relevant frame (body)
ground = model.getGround();
torso = model.getBodySet().get('torso');
% Get frame, position and transformation in ground
torso_position = torso.getPositionInGround(state);
torso_rotation = torso.getRotationInGround(state);
% Get the Transform (translation and rotation) in ground
torso_transformation = torso.getTransformInGround(state);
% Get translation
translation = torso_transformation.p();
% Get Rotation
rotation = torso_transformation.R();
I am unsure how the dynamic motion file can play a role in finding the angle for each time point of motion because the state is currently just the calibrated static model. Is there a place I should've imported the .sto file input or .mot file output?
Also, finding the rotation relative to the global coordinate gives me SWIGTYPE_p_SimTK for the torso.getRotationInGround(state) and [1,0,0];[0,1,0];[0,0,1] for the torso_transformation.R() function, which don't seem particular to the model/trial I am using.
Thanks again for the help!!