Python Moco 2D walking examples#4019
Conversation
|
@nicos1993 you can test the examples on using the latest version of OpenSim via |
nickbianco
left a comment
There was a problem hiding this comment.
Good start @nicos1993! I did a pass through and left a few comments.
It would be good to confirm that all the scripts produce the same results as the Matlab scripts.
| # limitations under the License. # | ||
| # -------------------------------------------------------------------------- # | ||
|
|
||
| # This is a Matlab implementation of an example optimal control |
There was a problem hiding this comment.
"This is a Python implementation..."
| # Define the optimal control problem | ||
| # ================================== | ||
| track = osim.MocoTrack() | ||
| track.setName("gaitTracking") |
There was a problem hiding this comment.
My preference is use single for strings, e.g., 'gaitTracking'.
| # -------------------------------------------------------------------------- # | ||
| # OpenSim Moco: example2DWalking.py # | ||
| # -------------------------------------------------------------------------- # | ||
| # Copyright (c) 2019 Stanford University and the Authors # |
There was a problem hiding this comment.
You could set the copyright year to 2025 for all the files.
There was a problem hiding this comment.
This still needs to be set to 2025.
| # limitations under the License. # | ||
| # -------------------------------------------------------------------------- # | ||
|
|
||
| # This is a Matlab implementation of an example optimal control |
There was a problem hiding this comment.
"...Python implementation..."
| # 'setContactForceThreshold()'. | ||
| # | ||
| # Users must provide the target asymmetry value via 'setTargetAsymmetry()'. | ||
| # Asymmetry values ranges from -1.0 to 1.0. For example, 0.20 is 20# positive |
There was a problem hiding this comment.
"...0.20 is 20% positive..."
|
Thanks for the quick review! @nickbianco Will take on board the changes! I definitely agree that ensuring the results between python/matlab is paramount. |
|
Hey @nickbianco I have implemented the suggestions you made! I have also confirmed that the results from these python examples match with the equivalent matlab examples. Thanks, Nicos |
nickbianco
left a comment
There was a problem hiding this comment.
Looks great @nicos1993!
A couple minor things left: 1) you need to update the copyright year on two of the files and 2) can you confirm that the reference files install correctly? You could either install locally or download a GitHub Actions artifact to check.
| # -------------------------------------------------------------------------- # | ||
| # OpenSim Moco: example2DWalking.py # | ||
| # -------------------------------------------------------------------------- # | ||
| # Copyright (c) 2019 Stanford University and the Authors # |
There was a problem hiding this comment.
This still needs to be set to 2025.
| # -------------------------------------------------------------------------- # | ||
| # OpenSim Moco: example2DWalkingMetabolics.py # | ||
| # -------------------------------------------------------------------------- # | ||
| # Copyright (c) 2021 Stanford University and the Authors # |
| install(FILES ${EXAMPLE_2D_WALKING_FILES} | ||
| DESTINATION "${OPENSIM_INSTALL_MATLABEXDIR}/Moco/example2DWalking") | ||
|
|
||
| file(COPY ${EXAMPLE_2D_WALKING_FILES} |
There was a problem hiding this comment.
I assume that you tested that this CMake code correctly installs the reference files in the Python example directory?
There was a problem hiding this comment.
I can confirm that it installs the reference files except the Geometry folder. The CMake file doesn't seem to mention anything about the Geometry folder for the equivalent matlab examples, so I am wondering if there is another file that needs to be tweaked?
There was a problem hiding this comment.
There is no Geometry folder for this example, so no worries.
Building on PR #3242
conda install -c opensim-org opensim-mocobased on: https://opensimconfluence.atlassian.net/wiki/spaces/OpenSim/pages/53085346/Scripting+in+Python#:~:text=OpenSim%20Conda%20packages%20that%20include%20Moco%20are - is this the latest release?Nicos
This change is