Dear OpenSim Experts,
I trying to extract the positions of the center of masses for each body segment (e.g.: torso/toes_l) in my model with respect to the ground reference frame. Currently, I am using getPositionInGround(), however I believe that this gives the position of the body reference frame with respect to the ground reference frame. In the API documentation I cannot find the right function for extracting the positions of the center of masses for each body segment with respect to the ground reference frame.
Does anyone have a suggestions for solving my issue?
Best,
Jan
Extracting positions of CoM body segments w.r.t. ground reference frame
- Jan Grutters
- Posts: 7
- Joined: Mon Feb 04, 2019 6:07 am
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Extracting positions of CoM body segments w.r.t. ground reference frame
Hello Jan,
You can get the local COM position of a body by using getMassCenter(), something like this I believe:
COM_pos_myBody = myBody.getMassCenter();
https://simtk.org/api_docs/opensim/api_ ... 48d5a4c5a6
Afterwards you can express this position in the global frame using the method you posted previously. Hope that helps.
Kind regards,
Nicos Haralabidis
You can get the local COM position of a body by using getMassCenter(), something like this I believe:
COM_pos_myBody = myBody.getMassCenter();
https://simtk.org/api_docs/opensim/api_ ... 48d5a4c5a6
Afterwards you can express this position in the global frame using the method you posted previously. Hope that helps.
Kind regards,
Nicos Haralabidis
- Jan Grutters
- Posts: 7
- Joined: Mon Feb 04, 2019 6:07 am
Re: Extracting positions of CoM body segments w.r.t. ground reference frame
Dear Nicos,
Thank you for your response.
I donnot really see how this would work.
Firstly, myBody.getMassCentre() returns a Vec3 object providing me the position of the center of mass defined by the .osim model. I donnot get how the getPositionInGround() function can be used to transform this position to the center of mass position with respect to the ground reference frame during a simulation. As the getPositionInGround() function takes a state as input argument and is also not an attribute of the Vec3 object returned by the myBody.getMassCentre() function. Or am I missing something here?
Best,
Jan
Thank you for your response.
I donnot really see how this would work.
Firstly, myBody.getMassCentre() returns a Vec3 object providing me the position of the center of mass defined by the .osim model. I donnot get how the getPositionInGround() function can be used to transform this position to the center of mass position with respect to the ground reference frame during a simulation. As the getPositionInGround() function takes a state as input argument and is also not an attribute of the Vec3 object returned by the myBody.getMassCentre() function. Or am I missing something here?
Best,
Jan
- Jan Grutters
- Posts: 7
- Joined: Mon Feb 04, 2019 6:07 am
Re: Extracting positions of CoM body segments w.r.t. ground reference frame
Ahhh one sec.
You just have to add them. (But donnot forget about taking the orientation into account )
Thank you for your insight!!
Best,
Jan
You just have to add them. (But donnot forget about taking the orientation into account )
Thank you for your insight!!
Best,
Jan
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Extracting positions of CoM body segments w.r.t. ground reference frame
Hello Jan,
After getting the COM position of a body in its local you can transform its position into the ground frame using the function findStationLocationInGround(), you just need to ensure you have realised the State of the system to Position and updated the system's positional states as you desire. This function performs the necessary transform you need I believe, no additional steps.
https://simtk.org/api_docs/opensim/api_ ... 2c12b2083c
Hope that helps!
Kind regards,
Nicos Haralabidis
After getting the COM position of a body in its local you can transform its position into the ground frame using the function findStationLocationInGround(), you just need to ensure you have realised the State of the system to Position and updated the system's positional states as you desire. This function performs the necessary transform you need I believe, no additional steps.
https://simtk.org/api_docs/opensim/api_ ... 2c12b2083c
Hope that helps!
Kind regards,
Nicos Haralabidis