Let's say that I want to build a four-bar linkage in OpenSim and solve a minimum effort point-to-point movement (torque actuator on one joint, goal to move from initial to position to final position).
I have built the OSIM model in a MATLAB script. No issues there. I can open it in the OpenSim GUI and simulate forward dynamics to see that everything is working.
Now I want to build a MoCo problem to solve the minimum effort optimal control problem. I import the OSIM model, use a ModelProcessor to add it to the problem (just like in example2DWalking.m), and finish setting up the problem. However, when I initialize the solver (either CasADI or Tropter) I get the following error message:
Error using FourBarP2P (line 44)
Java exception occurred:
java.lang.RuntimeException: Component 'linkC_slave_0_weld' of type WeldConstraint has no owner and is not the root.
Verify that finalizeFromProperties() has been invoked on the root Component or that this Component is not a clone, which has
not been added to another Component.
Thrown at Component.cpp:1681 in initComponentTreeTraversal().
at org.opensim.modeling.opensimMocoJNI.MocoStudy_initTropterSolver(Native Method)
at org.opensim.modeling.MocoStudy.initTropterSolver(MocoStudy.java:117)
However, if I run
Code: Select all
c = model.findComponent('linkC_slave_0_weld');
c.hasOwner()
If I break the kinematic loop by building the same model without one of the joints in the linkage (no longer a closed chain linkage), I do not get the error. Instead I get a one single pendulum and one double pendulum and the problem is solved for a trivial solution with no issues.
Is there a step that I am missing in the process for a model that has a closed kinematic chain? Is it possible this is a bug? I can provide the model file, and MATLAB script to anyone interested.