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

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Musa Audu
Posts: 47
Joined: Mon Nov 24, 2008 11:30 am

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

Post by Musa Audu » Tue Dec 18, 2018 10:12 am

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 36 times
I also tried another version as:
snippe2.c
(1.19 KiB) Downloaded 25 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.

Tags:

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

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

Post by Nicos Haralabidis » Tue Dec 18, 2018 10:31 am

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

User avatar
Musa Audu
Posts: 47
Joined: Mon Nov 24, 2008 11:30 am

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

Post by Musa Audu » Tue Dec 18, 2018 10:51 am

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

User avatar
Musa Audu
Posts: 47
Joined: Mon Nov 24, 2008 11:30 am

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

Post by Musa Audu » Tue Dec 18, 2018 11:26 am

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.

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

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

Post by Nicos Haralabidis » Tue Dec 18, 2018 2:28 pm

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

POST REPLY