playback motion issue in Python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Alessia Giordan
Posts: 10
Joined: Tue Jul 20, 2021 3:53 pm

playback motion issue in Python

Post by Alessia Giordan » Wed Feb 02, 2022 6:11 am

Dear all,
I am working with Opensim API 4.2 in Python and I'd like to load and show an exisisting .mot motion file. I used the function showMotion(Model, TimeSeriesTable) (of VisualizerUtilities, see
https://simtk.org/api_docs/opensim/api_ ... e63984624b for more details), giving my model and the the TimeSeriesTable of my .mot file.
It seems to work, because it didn't give me any errors, but the visualizer window was empty, for all motion time. (see the attachments)
Does anyone know how to solve it?
ps: Using the IMUInverseKinematicsTool.run(true) method doesn't give me any errors.

Thank you for your time,

Alessia

The code is:

myModel = osim.Model('./OpenSense/' + modelFileName) # Load the model into the GUI
myModel.initSystem()
table = osim.TimeSeriesTable('./'+folder_name+'/IKResults/ik_'+root_name+'_orientations.mot')
print(table.getNumColumns())
print(table.getNumRows())

print(table.getColumnLabels())

timeVector = table.getIndependentColumn()
print(timeVector[2])

osim.VisualizerUtilities.showMotion(myModel, table)
Attachments
prompt.png
prompt.png (68.86 KiB) Viewed 1433 times
visualizer.png
visualizer.png (13.51 KiB) Viewed 1433 times

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

Re: playback motion issue in Python

Post by Ayman Habib » Thu Feb 03, 2022 11:49 am

Hello,

As the messages point out the mesh files are not found and so are not shown. The solution is to call

Code: Select all

ModelVisualizer::addDirToGeometrySearchPaths(dir) 
and pass in the directory where the mesh files are located on your local machine before calling the showMotion method.

Please let us know how that goes,
-Ayman

User avatar
Alessia Giordan
Posts: 10
Joined: Tue Jul 20, 2021 3:53 pm

Re: playback motion issue in Python

Post by Alessia Giordan » Fri Feb 04, 2022 8:26 am

Hi Ayman,
thank you for your reply. I tried what you said but it gives me the same issue. (there weren't the model and also the "ground and sky property" that is used as default)
Furthermore, when I tried to use the other function VisualizerUtilities::showModel(myModel) I got the same warning messages in the command prompt but the model was present in the Visualizer Window (see attachments).
Do you have any other suggestions?
I'd also like to change the default background property (set to "ground and sky" right now)
Thank for your time,

Alessia
Attachments
dd.png
dd.png (48.03 KiB) Viewed 1327 times
c.png
c.png (39.35 KiB) Viewed 1327 times

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

Re: playback motion issue in Python

Post by Ayman Habib » Fri Feb 04, 2022 12:15 pm

Alessia,

As long as you're getting the messages about the missing vtp files I wouldn't be surprised that bones don't show up. The missing files refer to the bones of the hand so they are missing but the rest of the model is shown. There's no magic here, the order of serach paths is specified here:
https://simtk-confluence.stanford.edu/d ... references

There's a command line utility opensim_cmd included with OpenSim distributions that allows you to specify geometry-search-path, a model file and a motion file that you can try outside your python environment, without trying to reconstruct your specific settings. Not sure where you got your OpenSim distribution or if you're building your own or if you have multiple versions (in earlier versions we used OPENSIM_HOME to search for geometry mesh files so that may pollute the picture).

Hope this helps,
-Ayman

User avatar
Alessia Giordan
Posts: 10
Joined: Tue Jul 20, 2021 3:53 pm

Re: playback motion issue in Python

Post by Alessia Giordan » Tue Feb 08, 2022 10:01 am

Dear Ayman,

thanks for your reply. I have added the missing files in the Geometry folder and now there isn't no warning messages. However, the Visualizer window is still blank ...
Do you have any other tips to follow?
Thank you for your time.

Kindly,
Alessia

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

Re: playback motion issue in Python

Post by Ayman Habib » Tue Feb 08, 2022 10:26 am

Hi Alessia,

To decouple python issues from other installation/environment issues I'd recommend to use the opensim-cmd utility which allows you to specify the model, geometry and trajectory on the command line (check the help and availability by typing

Code: Select all

opensim-cmd viz -h
If that works then the issue is within your python setting/call-sequence, if not then we can reproduce it independently and you can file a bug and attach all the files to it and we'll investigate further. Keep in mind if you're using a plugin that it needs to be specified/loaded on the command line as well.

Hope this helps,
-Ayman

User avatar
Alessia Giordan
Posts: 10
Joined: Tue Jul 20, 2021 3:53 pm

Re: playback motion issue in Python

Post by Alessia Giordan » Wed Feb 09, 2022 2:02 am

Dear Ayman,
thanks for your help.
I got the same error typing this line in the command prompt:

opensim-cmd viz model ScapulothorachicJoint_Shoulder.osim ik_XSENS_04_02_2022_11_54_04_orientations.mot

Hoping there is a solution, I attach all the files. https://drive.google.com/drive/folders/ ... sp=sharing
Thanks for your time.

Kindly,

Alessia Giordan

User avatar
Alessia Giordan
Posts: 10
Joined: Tue Jul 20, 2021 3:53 pm

Re: playback motion issue in Python

Post by Alessia Giordan » Mon Feb 21, 2022 5:25 am

Hi,
Is there any news about this issue? Thank you

Alessia

User avatar
Alessia Giordan
Posts: 10
Joined: Tue Jul 20, 2021 3:53 pm

Re: playback motion issue in Python

Post by Alessia Giordan » Mon Apr 04, 2022 7:47 am

Hi,
Is there any news about this issue on playback motion window? Thank you for your time.

Alessia

POST REPLY