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
Roll, Pitch and Yaw of head/neck model for the hole simulation time
- Thomas Lober
- Posts: 3
- Joined: Tue Apr 16, 2019 5:49 am
Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time
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.
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)];
- Thomas Lober
- Posts: 3
- Joined: Tue Apr 16, 2019 5:49 am
Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time
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
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
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
viewtopicPhpbb.php?f=91&t=10624&p=0&sta ... e51eab1e07
- Thomas Lober
- Posts: 3
- Joined: Tue Apr 16, 2019 5:49 am
Re: Roll, Pitch and Yaw of head/neck model for the hole simulation time
Thank you James. I will have a look at this.