OpenSense- sensor to earth angle (trunk flexion angle)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Therese Parr
Posts: 9
Joined: Mon Dec 02, 2019 9:47 am

OpenSense- sensor to earth angle (trunk flexion angle)

Post by Therese Parr » Mon Mar 21, 2022 8:04 am

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!

Tags:

User avatar
Ayman Habib
Posts: 2238
Joined: Fri Apr 01, 2005 12:24 pm

Re: OpenSense- sensor to earth angle (trunk flexion angle)

Post by Ayman Habib » Mon Mar 21, 2022 12:39 pm

Hello,

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)
To extract angles from Transform you get the rotation part

Code: Select all

.R()
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

User avatar
Therese Parr
Posts: 9
Joined: Mon Dec 02, 2019 9:47 am

Re: OpenSense- sensor to earth angle (trunk flexion angle)

Post by Therese Parr » Thu Mar 24, 2022 8:17 am

Thanks for the quick response, Ayman! That gave me a good start. Here is the code I currently have running.
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();
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.

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!!

POST REPLY