Why does the first optimization in CMC fail in this model?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sietse Achterop
Posts: 77
Joined: Tue Sep 14, 2021 3:01 am

Why does the first optimization in CMC fail in this model?

Post by Sietse Achterop » Sun Dec 18, 2022 9:17 am

I have asked this before, see issue #3183 on opensim-core.
I simplified the model more but it still is failing. I really am stuck!

The model now consists of 1 sliderjoint, 4 pinjoints and 1 customjoint, all with coordinate-actuators.
There are no muscles and one weld-constraint to close a kinematic loop.
rower.png
rower.png (67.36 KiB) Viewed 576 times
Think rower in a boat.
The complete example is in the zip-file. The model is created from the python file.
The trajectory.trc that is used is created in a python program, so I am only simulating.
The problem is that CMC almost immediately fails, both on Linux and Windows.

Code: Select all

[2022-12-18 16:33:16.143] [info] CMC::computeControls, t = 0.02
[2022-12-18 16:33:16.181] [error] SimTK Exception thrown at InteriorPointOptimizer.cpp:270:
  Optimizer failed: Ipopt: Infeasible problem detected (status 2)
[2022-12-18 16:33:16.181] [error] OPTIMIZATION FAILED...
[2022-12-18 16:33:16.181] [error] CMC::computeControls: Optimizer could not find a solution.
Unable to find a feasible solution at time = 0.02.
It fails already in the very first optimization to prepare for the actual simulation.
In function CMCTool:run the function CMC:computeControls is called (for the very first time) in line 802.
In that function the ipopt-optimizer is called in SimTKmath/Optimizers/src/InteriorPointOptimizer.cpp line 97.
There the call to IpoptSolve fails with a status of 2.

This all before the main loop of the simulation, just before the following is in the log:
[info] Using CMC to track the specified kinematics:

The question is of course, why does it fail, and more importantly, how can I make it to work.
I would assume that because each joint has a coordinate actuator, actuator values can be derived to get the model in the proper (initial?) position.
It probably has to do with the weld-constraint in the lower leg. Removing it makes it "work", but with a broken leg:(.


Thanks in advance, Sietse.


PS. I assume that it could have been simplified even more by removing the torso and head. I left them there because there is a marker in the shoulder that is used and it is fairly complicated to create another dataset.
Attachments
Test1.zip
(126.72 KiB) Downloaded 15 times

User avatar
Nicos Haralabidis
Posts: 191
Joined: Tue Aug 16, 2016 1:46 am

Re: Why does the first optimization in CMC fail in this model?

Post by Nicos Haralabidis » Tue Dec 20, 2022 3:25 am

Hey Sietse,

Super cool model! I ran the setup file for CMC you provided and I got the same issue. After inspecting the model I realized it is somewhat similar to a slider-crank mechanism, so the seatpos, hipangle, kneeangle, footangle degrees of freedom are not independent I think. If you know the footangle you can then determine the others. I noticed in the tasks file you were trying to track all of those coordinates - I removed seatpos, hipangle and kneeangle (keeping footangle) and CMC runs, producing something that resembles rowing. Removing hipangle, kneeangle and footangle (keeping seatpos) still runs also. In summary, I think the error stems from trying to track all the coordinates, when some are coupled.

I hope that helps!

Nicos

User avatar
Sietse Achterop
Posts: 77
Joined: Tue Sep 14, 2021 3:01 am

Re: Why does the first optimization in CMC fail in this model?

Post by Sietse Achterop » Tue Dec 20, 2022 10:11 am

Thanks very much Nicos!
This sound logical and it works. I now am starting building up the model a little bit further, please see https://github.com/SietseAchterop/Rowing-simulator for more on this.

I added a ContactMesh, ElasticFoundationForce etc to make the boat "float on the water". And when excluding the proper joints/actuators the boat is moving on the water when the body moves as it should. So good so far!
But after adding the upperarms and markers in the elbow CMC starts to work OK, but after almost a second the model becomes unstable, the arms start turning wildly. After that CMC fails.
I played around with the PD settings of the controller, increased the mass of the upperarms and also generated the trajectory.trc with a rate of 200Hz, but nothing helps.
What could be the problem?
Maybe make a new question for it. The attached file contains the code including a small video of the model in action.

Thanks again,
Sietse
Attachments
Test2.zip
(610.85 KiB) Downloaded 14 times

User avatar
Nicos Haralabidis
Posts: 191
Joined: Tue Aug 16, 2016 1:46 am

Re: Why does the first optimization in CMC fail in this model?

Post by Nicos Haralabidis » Wed Dec 21, 2022 5:50 am

Hey Sietse,

I am wondering whether it would be more sensible to first get CMC to work as we did initially, but just further including the two upper arms? Simplifying the problem may help to isolate why the arms behave strange like you observe in the video. Is the goal eventually for the arms to push against the water and make the boat move?

Best wishes,

Nicos Haralabidis

User avatar
Sietse Achterop
Posts: 77
Joined: Tue Sep 14, 2021 3:01 am

Re: Why does the first optimization in CMC fail in this model?

Post by Sietse Achterop » Thu Dec 22, 2022 4:00 am

In the full model the arms pull on the oars and via the blades push on the water. I model the blade like a plate on the water/ground with a very high friction coefficient. I created a custom force in Simbody for that.
Removing the 2 elbow marks from the model above makes CMC work perfectly. Only adding one elbow marker makes the model fail already.
See the plot: figure 5 is part of the trajectory.trc that I generated, figure 6 the trajectory.mot (from IK). Figure 7 is the result of CMC up until the point where it fails. This is what is in the video.
The current point in the simulation (the vertical line) is where it starts to go wrong.
cmc_plot.png
cmc_plot.png (403.36 KiB) Viewed 436 times
I see 2 different problems.
  • There is a discontinuity at 1.0 second in the elbow. This cannot happen in reality. I can imagine that CMC fails on that. I will correct that.
  • Figure 7 shows that from 0.5 seconds the elbow starts to rotate. Figure 6 with the mot data show only gradual changes. This I don't understand.
    Why can't CMC keep the the upper arm on track? The errors become very high, but the forces stay well below the maximum value of +-10000.
    This is not how a PD controller would react. As said I played with PD values and mass of the upper arm.
Maybe something to do with the fact that no muscles are used, are they implicitly assumed? For simplicity I first wanted to get a basic version that works without muscles and add them later.

Best Wishes, Sietse.

User avatar
Sietse Achterop
Posts: 77
Joined: Tue Sep 14, 2021 3:01 am

Re: Why does the first optimization in CMC fail in this model?

Post by Sietse Achterop » Mon Jan 02, 2023 3:41 am

I made a little bit of progress, but I will now create an issue on opensim-core for it, issue 3345.

I simplified the model even further, removed the leg (including the constraint) and connected the moving seat directly to the ground.
Also the rest of the boat and right arm were removed, so a very simple model was left, but the instability still occurs!
But when the moving of the seat was removed it became much more stable! See the issue for details.
Thanks the help!
Sietse

POST REPLY