opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
758 stars 307 forks source link

command-line application for Moco #3813

Closed mrrezaie closed 1 week ago

mrrezaie commented 1 week ago

Hi, this is merely a suggestion. It would be great if opensim-cmd supports OpenSim Moco. Users will be able to create a Moco study in XML format. This will be beneficial for non-scripting users. Thank you.

nickbianco commented 1 week ago

@mrrezaie opensim-cmd does support MocoStudy! If you have a MocoStudy saved to an XML file, you can simply run the following in the command line:

opensim-cmd run-tool MyMocoStudy.xml
mrrezaie commented 1 week ago

Thanks for your response @nickbianco, it's really great to see this option is available, and sorry I missed it. I asked because I couldn't find any documentation in this regard.

I just converted a MocoInverse to MocoStudy (study = inverse.initialize()), wrote it to an XML file (study.printToXML('test.xml')), and finally, opensim-cmd ran it successfully. However, I couldn't find a way to write the solution to a file. Is there any specific argument (XML tag) for this, e.g. output_solution_file? Also, does it support visualization, e.g. use_visualizer? Thank you.

nickbianco commented 1 week ago

@mrrezaie just set the write_solultion and results_directory properties in MocoStudy to print the solution automatically.

mrrezaie commented 1 week ago

Hi @nickbianco I just tested the torque driven marker tracking simulation. These are the MocoTrack and MocoStudy written in XML format: study.txt track.txt It works well in Python. But there isn't any info about the markers TRC file or its data in the written files, and when I run it in opensim-cmd, this error appears: [error] Table has no column labels. Use setColumnLabels() to add labels. Thrown at AbstractDataTable.cpp:93 in getColumnLabels().

I also tested setMarkersReference with TableProcessor instead of setMarkersReferenceFromTRC. Any idea what is wrong with that? Thank you.

nickbianco commented 2 days ago

Hi @mrrezaie.

Ah yes, the one downside of this approach is that any reference tables provided to the MocoStudy will not get propagated to the XML file. As a workaround, you can save any reference tables to a STO file and provide the filepath to it in the MocoStudy XML file.

A similar issue exists for guesses provided programatically to a MocoStudy: https://github.com/opensim-org/opensim-core/issues/3671.