I am not sure why but the MocoInverse matlab code provided as an example: exampleMocoInverse() (as it is), runs only if I ignore tendon Compliance. It is suggested in the forum to changed tendon compliance to implicit formulation to run the simulation. So I did it using either
modelProcessor.append(ModOpUseImplicitTendonComplianceDynamicsDGF());
or
modelProcessor.append(ModOpTendonComplianceDynamicsModeDGF('implicit'));
and allowing/ignoring passive force. But in all cases, my simulation either fails or stops at the third iteration (for a very long time).
Here is the code:
Code: Select all
import org.opensim.modeling.*;
% Construct the MocoInverse tool.
inverse = MocoInverse();
modelProcessor = ModelProcessor('subject_walk_armless.osim');
modelProcessor.append(ModOpAddExternalLoads('grf_walk.xml'));
modelProcessor.append(ModOpTendonComplianceDynamicsModeDGF('implicit'));
modelProcessor.append(ModOpReplaceMusclesWithDeGrooteFregly2016());
% modelProcessor.append(ModOpIgnorePassiveFiberForcesDGF());
modelProcessor.append(ModOpScaleActiveFiberForceCurveWidthDGF(1.5));
modelProcessor.append(ModOpAddReserves(1.0));
inverse.setModel(modelProcessor);
inverse.setKinematics(TableProcessor('coordinates.sto'));
% Initial time, final time, and mesh interval.
inverse.set_initial_time(0.81);
inverse.set_final_time(1.79);
inverse.set_mesh_interval(0.02);
inverse.set_kinematics_allow_extra_columns(true);
% Solve the problem and write the solution to a Storage file.
solution = inverse.solve();
solution.getMocoSolution().write('example3DWalking_MocoInverse_solution.sto');
When it fails, it says the following:
[CasOC] Warning: NaN encountered when detecting sparsity of Jacobian; entry (133, 224). And also
java.lang.RuntimeException: This trajectory is sealed, to force you to acknowledge the
solver failed; call unseal() to gain access.
Thrown at MocoTrajectory.cpp:1347 in ensureUnsealed().
In addition, Dr. Miller shared a code where he used MocoTrack with tendon Compliance https://simtk.org/projects/umocod, and he initialized tendon force (initial guess). I tried this approach, but I did not work. Maybe I did not implement it correctly.
I would appreciate it if someone could suggest ways to solve this problem.