Page 1 of 1

center of mass positions of bodies using findStationLocationInGround()::

Posted: Tue Dec 18, 2018 10:12 am
by mlaudu
Hi,
I am having difficulty using "findStationLocationInGround()" to output the location of the center of mass of a body segment. Below is a snippet of my code:
snippet.c
(1.07 KiB) Downloaded 32 times
I also tried another version as:
snippe2.c
(1.19 KiB) Downloaded 22 times
In both cases, even though the body calcn_r reference frame moved far from the ground coordinate reference frame, the results for foot position remain absolutely the same for all time points. Am I missing something? Please advise.
Thanks.

Re: center of mass positions of bodies using findStationLocationInGround()::

Posted: Tue Dec 18, 2018 10:31 am
by nicos1993
Hello Musa,

I have done something like this in the past to get the position of a point in the global:

int mbi_calcR = myModel.getBodySet().get("calcn_r").getIndex();

myModel.updMultibodySystem().realize(myState, Stage::Position);

Vec3 Rsph1G = myModel.getMatterSubsystem().getMobilizedBody(MobilizedBodyIndex(mbi_calcR)).findStationLocationInGround(myState,Rsph1L);

Where Rsph1L is a Vec3 and defined relative to calcaneus LCS.

I hope that helps.

Kind regards,

Nicos Haralabidis

Re: center of mass positions of bodies using findStationLocationInGround()::

Posted: Tue Dec 18, 2018 10:51 am
by mlaudu
Hi Nicos,
Thank you very much for your help. I am exploring it; even though the first line: int mbi_calcR = myModel.getBodySet().get("calcn_r").getIndex(); results in the error message; "class "OpenSim::Body" has no member "getIndex"" I am exploring why this is so. Did you use this in OpenSim 4.0 API? They have made some changes.
Thanks.
Musa

Re: center of mass positions of bodies using findStationLocationInGround()::

Posted: Tue Dec 18, 2018 11:26 am
by mlaudu
Hi Nicos,
I followed your idea with the following code snippet that worked to get the CoM position:


BodySet bd = osimModel.getBodySet();
int Indx = bd.getIndex("calcn_r");
const auto& lfoot = bd[Indx];
Vec3 FmassCenter = lfoot.getMassCenter();
osimModel.updMultibodySystem().realize(si, Stage::Position);
Vec3 footpos = osimModel.getMatterSubsystem().getMobilizedBody(MobilizedBodyIndex(Indx)).findStationLocationInGround(si, FmassCenter);

However, with the previous code set the CoM position is still the same at all time steps. It appears there is something in the integration loop that is not updating the system enough to cause the required change in the CoM position.

Re: center of mass positions of bodies using findStationLocationInGround()::

Posted: Tue Dec 18, 2018 2:28 pm
by nicos1993
Hello Musa,

Sorry, I should have mentioned I am using OpenSim 3.3.

I just realised/remembered that the Arm26 Optimization within the API examples may be of relevance to you as it involves integrating and extracting the velocity of a body's COM - perhaps you could follow the code as a guide and adapt for your purposes?

Sorry I cannot be of any further assistance!

Kind regards,

Nicos Haralabidis