Hello everyone,
does anyone of you have experience with the function 'showMotion()'? My plan is to collect the coordinate data in a matrix, turn it into a TimeSeriesTable and use showMotion to visualize the Motion. On Doxygen it only tells you that the storage should contain all the generalized coordinates but I don't which coordinates to include, only those of the bodies or those of all components? Also, I don't know how to structure the matrix, so that the function works. If anyone can help me there it would be much appreciated
Thanks in advance
showMotion()
- Ben Sonnabend
- Posts: 5
- Joined: Wed Apr 24, 2024 12:27 pm
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: showMotion()
Hi, if you intend to visualize the coordinates only, the IK output file would be enough.
Here I removed muscles just for simplicity. You can use a state file (e.g. CMC output) or create a new table and put all the required values with appropriate labels (model.getStateVariableNames()).
Hope this helps.
Code: Select all
import opensim as osim
# set path to the required files/folders
model_path = '...'
IK_path = '...'
geometry_path = '...'
osim.ModelVisualizer.addDirToGeometrySearchPaths(geometry_path)
model = osim.Model(model_path)
newModel = model.clone()
newModel.set_ForceSet(osim.ForceSet())
table = osim.TimeSeriesTable(IK_path)
viz = osim.VisualizerUtilities()
viz.showMotion(newModel, table)
Hope this helps.
- Ben Sonnabend
- Posts: 5
- Joined: Wed Apr 24, 2024 12:27 pm
Re: showMotion()
Thank you so much for your reply. It is probably a dumb question but how do I get the IK File?
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: showMotion()
I meant your motion file; for instance the output of Inverse Kinematics tool.
- Ben Sonnabend
- Posts: 5
- Joined: Wed Apr 24, 2024 12:27 pm
Re: showMotion()
Thank you
And do you know how I can change the Unit of the angles to degree?
And do you know how I can change the Unit of the angles to degree?
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: showMotion()
SimbodyEngine::convertRadiansToDegrees may help:
But simbody-visualizer works with both units.
Code: Select all
model.initSystem()
if table.getTableMetaDataString('inDegrees') == 'no':
model.getSimbodyEngine().convertRadiansToDegrees(table)
Last edited by Mohammadreza Rezaie on Thu May 09, 2024 11:56 pm, edited 2 times in total.
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: showMotion()
Hello,
There's a line in the header of sto (and mot) files that specifies whether the angles are in degrees or radians. Motion files are assumed to have rotational coordinates in degrees (inDegrees=yes) so you can set it to match the data in the file. For OpenSim use the .mot and .sto are interchangeable except that the latter may have more flexibility and more meta data in the header.
Hope this helps,
-Ayman
There's a line in the header of sto (and mot) files that specifies whether the angles are in degrees or radians. Motion files are assumed to have rotational coordinates in degrees (inDegrees=yes) so you can set it to match the data in the file. For OpenSim use the .mot and .sto are interchangeable except that the latter may have more flexibility and more meta data in the header.
Hope this helps,
-Ayman