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
57 stars 16 forks source link

MATLAB example fixes #519

Open carmichaelong opened 4 years ago

carmichaelong commented 4 years ago

Tested on Windows 10, MATLAB R2019a

exampleMarkerTracking10DOF: set_weight doesn't exist for scripting https://github.com/opensim-org/opensim-moco/blob/master/Moco/Bindings/Java/Matlab/Examples/exampleMarkerTracking10DOF/exampleMarkerTracking10DOF.m#L108

exampleSitToStand: as noted in #481

exampleMocoTrack: issue with muscleDrivenStateTracking() with unseal(), possibly related to #494? Error below:

MocoCasADiSolver did NOT succeed:
  Invalid_Number_Detected
===============================================================================
Error using exampleMocoTrack>muscleDrivenStateTracking (line 194)
Java exception occurred:
java.lang.RuntimeException: This iterate is sealed, to force you to acknowledge the
solver failed; call unseal() to gain access.
    Thrown at MocoTrajectory.cpp:1302 in ensureUnsealed().

    at org.opensim.modeling.opensimMocoJNI.MocoStudy_visualize(Native Method)

    at org.opensim.modeling.MocoStudy.visualize(MocoStudy.java:129)

Error in exampleMocoTrack (line 54)
muscleDrivenStateTracking();

I can definitely make quick fixes to the first two. Likely would need some direction about the third issue.

nickbianco commented 4 years ago

@carmichaelong just to clarify, you are calling unseal(), as in study.solve().unseal()? Per #494, it would be good to try both that and

solution = study.solve()
solutionUnsealed = solution.unseal()
study.visualize(solutionUnsealed)
nickbianco commented 4 years ago

@chrisdembia we should update that message to say This trajectory is sealed, to force you....

carmichaelong commented 4 years ago

I didn't explicitly call unseal() from MATLAB. I was running exampleMocoTrack as is, and that error occurs, pointing at https://github.com/opensim-org/opensim-moco/blob/master/Moco/Bindings/Java/Matlab/Examples/exampleMocoTrack/exampleMocoTrack.m#L194

Maybe an unseal() call needs to be added to the example then?

chrisdembia commented 4 years ago

I think we shouldn't add unseal() to any examples unless we are demonstrating unseal().

carmichaelong commented 4 years ago

Invalid_Number_Detected also occurred for me in the C++ example for the muscle driven part of ExampleMocoTrack

chrisdembia commented 4 years ago

We need to disable tendon compliance for that example

chrisdembia commented 4 years ago

Sorry I didn’t realize you were working on exampleMocoTrack. Use ModOpIgnoreTendonCompliance.