Page 1 of 1

Roll, Pitch and Yaw of head/neck model for the hole simulation time

Posted: Tue Jul 09, 2019 6:25 am
by tholob91
Hello everybody,

im working with the head and neck model. I want to get the orientations of the model first and calculate the rotational matrix out of it. For this I need the roll, pitch and yaw of the joints for every moment during a simulation. First I thought that I can use a reporter, but unfortunately I can not get them via the outputs of the joints.

With the fallowing code, I can access the value of the angle, but I only get one. And not all of them.

C = h.model.getCoordinateSet().get('roll1'); % roll1
v = C.getStateVariableValue(h.state,'value');

How can I get all of the angles during the hole simulation?

Thanks in advance for your help.

Thomas

Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time

Posted: Tue Jul 09, 2019 11:04 am
by jimmy
You are dealing with General Coordinates, so they only give you values for their current state, not a global orientation value.

I think you are after the Orientations (Roll/Pitch/Yaw) of Bodies, not joints. Below is some Matlab code that shows how to get a Body Transform in Ground.

Code: Select all


import org.opensim.modeling.*

model = Model('generic_gait_model.osim');

s = model.initSystem();

pelvis = model.getBodySet().get(0);

TinG = pelvis.getTransformInGround(s);

rotation_Matrix = TinG.R();
translation_Matrix = TinG.p();

rotation_Matrix_Matlab = ...
[rotation_Matrix.get(0,0) rotation_Matrix.get(0,1) rotation_Matrix.get(0,2);...
rotation_Matrix.get(1,0) rotation_Matrix.get(1,1) rotation_Matrix.get(1,2);...
rotation_Matrix.get(2,0) rotation_Matrix.get(2,1) rotation_Matrix.get(2,2)];


Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time

Posted: Wed Jul 10, 2019 3:23 am
by tholob91
Thank you James for the quick and helpful answer. You were right, that I need the orientation of the body.
With your code I get only one rotation matrix, but I need the rotation matrix of each position during the simulation.
I am using a IMU sensor in Matlab and there I need the acceleration and angular velocity of the skull, which I get from the outputs of the body.
But I need also the orientation of this body for each time step. Do you have an idea how to do this?
Thanks again for your help.

Thomas

Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time

Posted: Wed Jul 10, 2019 7:24 am
by jimmy
You will have to read in a motion and set all the coordinates at a time step, get the body transforms, and then cycle to the next time step. There is some example of someone doing this here;
viewtopicPhpbb.php?f=91&t=10624&p=0&sta ... e51eab1e07

Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time

Posted: Thu Jul 11, 2019 12:17 am
by tholob91
Thank you James. I will have a look at this.