Page 1 of 1

Extracting positions of CoM body segments w.r.t. ground reference frame

Posted: Sun Nov 15, 2020 1:51 pm
by jangrutters
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

Re: Extracting positions of CoM body segments w.r.t. ground reference frame

Posted: Mon Nov 16, 2020 1:02 am
by nicos1993
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

Re: Extracting positions of CoM body segments w.r.t. ground reference frame

Posted: Mon Nov 16, 2020 2:02 am
by jangrutters
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

Re: Extracting positions of CoM body segments w.r.t. ground reference frame

Posted: Mon Nov 16, 2020 2:47 am
by jangrutters
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

Re: Extracting positions of CoM body segments w.r.t. ground reference frame

Posted: Mon Nov 16, 2020 8:19 am
by nicos1993
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