Page 1 of 1

Whole Body Angular Momentum?

Posted: Sun Apr 11, 2021 5:17 pm
by pgolyski
I am using a full body opensim model (Hamner 2010) and am hoping to calculate whole body angular momentum with respect to the center of mass of the whole body. I see I can get segment positions, velocities, orientations, and angular velocities from the Body Kinematics tool, but I want to make sure I am understanding the coordinate systems correctly.

Right now, I have "express_results_in_body_local_frame" unchecked in the Body Kinematics, so my translations and linear velocities of my individual segment centers of mass and the whole body center of mass are relative to the lab coordinate frame, which is great.

However, I would like to calculate the product of the moment of inertia of each body segment with its angular velocity and express that in the global coordinate frame. Is the moment of inertia of each segment given by Opensim expressed relative to the center of mass of each segment, while the angular velocity is expressed relative to the origin of the segment?

Re: Whole Body Angular Momentum?

Posted: Mon Apr 12, 2021 3:10 pm
by ongcf
The moment of inertia for bodies in OpenSim are defined as about the body's center of mass. For angular velocity, if "express_results_in_body_local_frame" is unchecked, then the angular velocity of the body is given with respect to the lab (ground) frame.

Re: Whole Body Angular Momentum?

Posted: Tue Apr 13, 2021 6:07 am
by pgolyski
Thank you! So this is the case even though the .sto file generated by Body Kinematics says: "Angular velocities and accelerations are given about the body-local axes." ?

Re: Whole Body Angular Momentum?

Posted: Tue Apr 13, 2021 3:49 pm
by ongcf
Ah, thanks for pointing that out. That header does not seem to update correctly. I'll look into this issue, but I think this issue only affects the header text and not the results.

The code for calculating the angular velocity is given here: https://github.com/opensim-org/opensim- ... s.cpp#L502

To be precise here, this is what the calculations seem to be doing:
1. Angular velocity is always the angular velocity of the body with respect to the ground frame.
2a. If "express_results_in_body_local_frame" is checked, then the angular velocity is re-expressed in the body's frame.
2b. If "express_results_in_body_local_frame" is not checked, then the angular velocity is expressed in the ground frame.

Re: Whole Body Angular Momentum?

Posted: Tue Dec 05, 2023 5:23 am
by sshokouhi
Hi,

I am trying to the same. I got each segments inertia from the .osim file which apparently it's with respect to the segement's com. Do you know how can I get it with respect to whole body cenetr of mass? or in the global frame?

I really appreciate your help.

Thanks!
Shabnam

Re: Whole Body Angular Momentum?

Posted: Tue Dec 05, 2023 10:26 am
by nicos1993
Hello Shabnam,

Do you want the whole body angular momentum expressed in the ground frame? As there are API methods to do this for you search for 'calcBodyMomentum' and you should see a few options!

If you want to calculate a body's inertia about a different point and in a different frame you can use the methods for a body's MassProperties: https://simtk.org/api_docs/molmodel/api ... ies__.html - see for example calcShiftedInertia... although now I look more I think this method would be cleaner: https://simtk.org/api_docs/molmodel/api ... eb1142b661

Thanks,

Nicos

Re: Whole Body Angular Momentum?

Posted: Wed Dec 06, 2023 6:21 am
by kernalnet
Hi, whole body momentum (angular and linear) of a full-body model can be calculated directly via SimTK::SimbodyMatterSubsystem::calcSystemCentralMomentum:

Code: Select all

state = model.initSystem()
matter = model.getMatterSubsystem()
model.realizeVelocity(state)
momentum = matter.calcSystemCentralMomentum(state)
angularMomentum = momentum.get(0)
linearMomentum = momentum.get(1)

Re: Whole Body Angular Momentum?

Posted: Thu Dec 07, 2023 9:45 am
by kernalnet
Since version 4.4.1, it's been exposed under Model class:

Code: Select all

model.calcAngularMomentum(state)

Re: Whole Body Angular Momentum?

Posted: Thu Dec 07, 2023 2:28 pm
by sshokouhi
Hi Nicos,

I got the inertial tensor directly from the model osim file. I was wondering if the inertial tensor is in the lab frame or the body's local frame.

Thanks,
Shabnam

Re: Whole Body Angular Momentum?

Posted: Fri Dec 08, 2023 6:46 am
by nicos1993
Hey Shabnam,

I believe they are expressed about a given body's center of mass and in the frame of the body. The model you are using potentially describes this information in an associated publication more than likely!

Hope that helps!

Nicos