calcAngularMomentum() functionality

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Anushka Rathi
Posts: 1
Joined: Wed Feb 28, 2024 11:35 am

calcAngularMomentum() functionality

Post by Anushka Rathi » Thu Sep 05, 2024 6:40 am

Hello! I am fairly new to using OpenSim and am having some trouble with MATLAB scripting. I want to use the calcAngularMomentum() function on the walking data that I have processed. I have a scaled model and have been able to run IK on this model by uploading the file with marker data that I had. I am not sure how this function works however. This is the script I am running in MATLAB, however, I do not think that this takes into account the walking data since I am opening the placed static trial. How do I affiliate the walking data to this?

import org.opensim.modeling.*;
model_path = 'C:\modelPath\\FullBodyModelCGM\CGM24_FullBody\CGM24FullBody_placed.osim';

model = Model(model_path);
state = model.initSystem();
ground_frame = model.getGround();

angular_momentum = model.calcAngularMomentum(state);

Tags:

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

Re: calcAngularMomentum() functionality

Post by Nicos Haralabidis » Thu Sep 05, 2024 10:00 pm

Hello Anushka,

For each frame of your walking data you need to set each of your model's coordinates positions [1] and speeds [2] using your IK data.
As an example:

Code: Select all

model.getCoordinateSet.get('coordinate_X').setValue(state,position_data(frame_i, coordinate_X_index);
model.getCoordinateSet.get('coordinate_X').setSpeedValue(state,speed_data(frame_i, coordinate_X_index);
angular_momentum(frame_i, 1:3) = model.calcAngularMomentum(state);
Hope that helps.

Nicos

[1] https://simtk.org/api_docs/opensim/api_ ... f2e88d7c42
[2] https://simtk.org/api_docs/opensim/api_ ... dd7a8febd3

User avatar
Mohammadreza Rezaie
Posts: 407
Joined: Fri Nov 24, 2017 12:48 am

Re: calcAngularMomentum() functionality

Post by Mohammadreza Rezaie » Sat Sep 07, 2024 11:25 pm

Hi, it might be out of the scope of this post; you can also get angular momentum through OutputReporter.
An example in GUI can be found here: https://opensimconfluence.atlassian.net ... Simulation

POST REPLY