Trouble running MocoTrack in implicit mode?

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Daniel Gordon
Posts: 34
Joined: Fri May 06, 2016 7:57 am

Trouble running MocoTrack in implicit mode?

Post by Daniel Gordon » Thu Sep 09, 2021 7:42 am

Hello,

I'm trying to run the MocoTrack tool for a problem in implicit mode using Matlab, but am running in to this error:
java.lang.RuntimeException: casVector should be 1-dimensional, but has size 0 x 0.
Thrown at MocoCasOCProblem.h:108 in convertToSimTKVector().
The same code when run in explicit mode seems to work fine and produces a solution in 70-100 iterations or so.

To enter implicit mode, I've been using the following:

Code: Select all

solver = MocoCasADiSolver.safeDownCast(study.updSolver());
solver.set_multibody_dynamics_mode('implicit');
Has anyone else run in to this problem, or is anyone a bit more familiar with the error message to point me in the right direction?

Cheers

User avatar
Nicholas Bianco
Posts: 972
Joined: Thu Oct 04, 2012 8:09 pm

Re: Trouble running MocoTrack in implicit mode?

Post by Nicholas Bianco » Thu Sep 09, 2021 11:09 am

Hi Daniel,

How are you creating the initial guess? This type of error usually has something with the guess being incompatible, which can happen when switching between implicit and explicit mode due to missing acceleration variables. (This is technically a bug though, we should account for this during the compatibility checks we do).

You could try creating a fresh initial guess after changing the dynamics mode, that way you can ensure the guess is compatible with the problem.

-Nick

POST REPLY