opensim-org / opensim-moco

Solve optimal control problems for musculoskeletal models using OpenSim and direct collocation.
https://opensim.stanford.edu/moco
Apache License 2.0
56 stars 15 forks source link

Create Python and Matlab versions of example2DWalking #471

Open chrisdembia opened 4 years ago

chrisdembia commented 4 years ago

@carmichaelong or @brocksam , are you interested? Converting an existing example is a nice way to get familiar with the codebase.

chrisdembia commented 4 years ago

Some additional background: example2DWalking is in C++ and in Python in the mocopaper repo (https://github.com/stanfordnmbl/mocopaper/blob/052664140a393eefdfa087667328cb35a503a272/sandbox.py#L2). It's our current example of predictive simulation (though more might be coming soon!).

@antoinefalisse, maybe you're interested too.

brocksam commented 4 years ago

Yes! I'm keen. I'm on "vacation" for two weeks from Wednesday 23rd so that would be a perfect time for me to have a crack as I'll have no PhD or work commitments.

chrisdembia commented 4 years ago

Great, I've assigned you. :)

antoinefalisse commented 4 years ago

I am quite busy for the next two weeks preparing my defense. I will have some time afterwards to do stuff.

brocksam commented 4 years ago

Where do we want the Python and Matlab examples to go? In opensim-moco/Moco/Examples/Python and opensim-moco/Moco/Examples/Matlab respectively? Or in opensim-moco/Moco/Bindings/Python/examples and opensim-moco/Moco/Bindings/Java/Matlab/Examples?

I'm assuming we want to import the OpenSim model from the 2D_gait.osim file using Moco's model processor like the C++ example does? If so are we okay with creating duplicates of this file in both the Python and Matlab examples directories? Or should we store one version of the model in opensim-moco/opensim-models/Models and access via relative file paths?

chrisdembia commented 4 years ago

Best of luck @antoinefalisse !!

@brocksam the latter paths are correct (Or in opensim-moco/Moco/Bindings/Python/examples and opensim-moco/Moco/Bindings/Java/Matlab/Examples). The organization in the installation is different than in the source tree. In the installation, the examples all live in Resources/Code.

Look at exampleMocoTrack, which is in all 3 languages; we avoid duplicating files by copying them during the build process with CMake.

https://github.com/stanfordnmbl/opensim-moco/blob/9e0b3a1d96e6aa0761976230819831d0371eb357/Moco/Examples/C%2B%2B/exampleMocoTrack/CMakeLists.txt#L11-L37

In the repo, you can leave the model where it currently is.

chrisdembia commented 4 years ago

@noahggordon you could also work on this.