showMotion()

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ben Sonnabend
Posts: 5
Joined: Wed Apr 24, 2024 12:27 pm

showMotion()

Post by Ben Sonnabend » Thu May 02, 2024 9:52 am

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

Tags:

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

Re: showMotion()

Post by Mohammadreza Rezaie » Thu May 02, 2024 3:45 pm

Hi, if you intend to visualize the coordinates only, the IK output file would be enough.

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)
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.

User avatar
Ben Sonnabend
Posts: 5
Joined: Wed Apr 24, 2024 12:27 pm

Re: showMotion()

Post by Ben Sonnabend » Fri May 03, 2024 3:23 am

Thank you so much for your reply. It is probably a dumb question but how do I get the IK File?

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

Re: showMotion()

Post by Mohammadreza Rezaie » Fri May 03, 2024 3:29 am

I meant your motion file; for instance the output of Inverse Kinematics tool.

User avatar
Ben Sonnabend
Posts: 5
Joined: Wed Apr 24, 2024 12:27 pm

Re: showMotion()

Post by Ben Sonnabend » Fri May 03, 2024 12:57 pm

Thank you
And do you know how I can change the Unit of the angles to degree?

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

Re: showMotion()

Post by Mohammadreza Rezaie » Fri May 03, 2024 1:55 pm

SimbodyEngine::convertRadiansToDegrees may help:

Code: Select all

model.initSystem()
if table.getTableMetaDataString('inDegrees') == 'no':
    model.getSimbodyEngine().convertRadiansToDegrees(table)
But simbody-visualizer works with both units.
Last edited by Mohammadreza Rezaie on Thu May 09, 2024 11:56 pm, edited 2 times in total.

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: showMotion()

Post by Ayman Habib » Fri May 03, 2024 1:58 pm

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

POST REPLY