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);
calcAngularMomentum() functionality
- Anushka Rathi
- Posts: 1
- Joined: Wed Feb 28, 2024 11:35 am
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: calcAngularMomentum() functionality
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:
Hope that helps.
Nicos
[1] https://simtk.org/api_docs/opensim/api_ ... f2e88d7c42
[2] https://simtk.org/api_docs/opensim/api_ ... dd7a8febd3
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);
Nicos
[1] https://simtk.org/api_docs/opensim/api_ ... f2e88d7c42
[2] https://simtk.org/api_docs/opensim/api_ ... dd7a8febd3
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: calcAngularMomentum() functionality
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
An example in GUI can be found here: https://opensimconfluence.atlassian.net ... Simulation