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

Minimizing Acceleration in Predictive Cycling Motion #672

Open ChrisD1993 opened 2 years ago

ChrisD1993 commented 2 years ago

Hello, I am trying to create a predictive model for steady state cycling. However, I am running into an issue with the acceleration of the crank. I am thinking that minimizing the crank acceleration is necessary to ensure steady state. I was attempting to use the MocoOutputGoal with the below lines of code. However, I am receiving a "bad dynamic cast" error in the solver line of the moco study.

CrankAccel = MocoOutputGoal('Crank_Acceleration',5); CrankAccel.setOutputPath('bodyset/crank|acceleration'); CrankAccel.setDivideByDisplacement(false); CrankAccel.setDivideByMass(false); problem.addGoal(CrankAccel);

I do not have a lot of experience with the Opensim API so much of the above could be very wrong. Please let me know if there is a way to minimize acceleration of a particular bodyset of the model.

Error text: Error using Cycle_Sandbox_File (line 216) Java exception occurred: java.lang.RuntimeException: Bad dynamic_cast!

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

at
org.opensim.modeling.MocoStudy.initCasADiSolver(MocoStudy.java:229) 
nickbianco commented 2 years ago

Hi @ChrisD1993, since you opened an issue here, I wanted first to make sure that you're using the correct version of OpenSim Moco. We've moved all development of the project to the OpenSim repo, and the latest versions of Moco can be found in the latest OpenSim downloads.

With that out of the way, I don't see anything in the code snippet you shared that would be causing a bad dynamic cast error. It looks like you have a custom model built in a sandbox file. Perhaps you could share some of that code to help debug.

If you are using the latest version of OpenSim (with Moco), then I would prefer moving this issue over to the main OpenSim repo.