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:
I also tried another version as:
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.
center of mass positions of bodies using findStationLocationInGround()::
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: center of mass positions of bodies using findStationLocationInGround()::
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
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()::
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
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()::
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.
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.
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: center of mass positions of bodies using findStationLocationInGround()::
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
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