CMC does not work with some muscle/no-muscle models.

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

CMC does not work with some muscle/no-muscle models.

Post by Sietse Achterop » Sat Feb 25, 2023 9:17 am

Hello List,

It seems that CMC does not always work if there are joints not controlled by muscles but only with coordinate actuators (think motors).
Like with an exo-skeleton, or someone with an artificial arm or leg.
In my use case, a rower in a rowing boat, I come across it in developing it, because for simplicity I started with a simple model without muscles at all.
Because that didn't work I simplified it but still couldn't get it to work, see my issue #3345 on opensim-core.

The static optimization does not work properly for the model there, please find it attached.
What seems to happen is that there are 2 actuators that interact with each other in such a way that the constraints C_j keep being met but the performance (objective function) J increases all the time as seen by the movement of at least one joint in an incorrect way.
Look at the controls calculated in each step.
At one point a force is exceeding its maximum value and the optimization ends the tool.

The trajectory in the attachment keeps the model completely fixed in the same position the entire time.
The first few seconds it works perfectly, but after a few seconds, probably due to rounding errors, the model starts to oscillate.
Other trajectories perform in a similar fashion, see below.

Maybe we need a different formulation of the optimization problem, taking into account the joints with only coordinate actuators?
Keeping the no-muscle actuators out of the optimization somehow?

I would of course like to make it work, maybe by creating a (more general) version of CMC that can cope with this situation.
But first I need to know whether I am right in concluding that CMC is not working correct here and why!

When I understand that I probably am able to correct it.
Is there anybody with some experience in this area that can help me a bit further?

Thanks in advance, Sietse

PS. Setting all values in the 5-th column of the trajectory to 17 (instead of 117) creates a trajectory that is stable.
Using trajectory.trc you can get a "normal" trajectory that also fails after a few seconds.

PS. I have already created a version of CMC.cpp where the SO step is completely removed, meaning that the error value of the PD part is send directly to the actuator.
The algorithm is now reduced to a collection of simple PD controllers.
I think that this should work in this case. Am I correct?
But I cannot get it to become stable, so maybe I am missing something.
Attachments
Test_cmc.zip
(72.79 KiB) Downloaded 14 times

Tags:

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

Re: CMC does not work with some muscle/no-muscle models.

Post by Sietse Achterop » Thu Mar 09, 2023 5:47 am

I found a few articles which simulated a person with an exoskeleton using CMC.
So apparently it should work, also when using only generalized actuators in a joint.
But my simple model, both on windows and linux, does not!
I really want/need to make this work!
The first step is to get a conformation that my diagnose is correct.

Here some additional data from the log to hopefully make the problem more clear.
As mentioned, the trajectory used is to keep the model in the same position at all times, in this case something like:

Code: Select all

   [info]  -- Qdesired =  -0.684724 0.119718 0.934394 2.04378 -0.409413
   [info]  -- Udesired =  3.05311e-14 -4.04769e-15 -1.0177e-14 -4.44089e-14 5.08852e-15
The first few seconds it works perfectly as seen from data from the log:

Code: Select all

   [info] CMC_Joint.computeDesiredAcceleration: seatpos:      aDes=3.85756e-10   vErr=3.3694e-12   pErr=3.14804e-12
   [info] CMC_Joint.computeDesiredAcceleration: lbackangle:   aDes=-6.11542e-10  vErr=-1.54763e-11 pErr=-3.01681e-12
   [info] CMC_Joint.computeDesiredAcceleration: uarmleft_out: aDes=8.1641e-10    vErr=-1.46294e-12 pErr=8.52729e-12
   [info] CMC_Joint.computeDesiredAcceleration: uarmleft_trn: aDes=8.25145e-11   vErr=-4.95668e-12 pErr=2.19602e-12
   [info] CMC_Joint.computeDesiredAcceleration: uarmleft_up:  aDes=-7.00907e-10  vErr=1.80099e-11  pErr=-1.06101e-11
In the contrainFunc we see the desired actuator forces and the constraints:

Code: Select all

     x           = ~[-3.91919e-10 -48.498 1.18752 2.66121 -3.78238]
     constraints = ~[3.68424e-10 -6.89805e-10 8.14741e-10 7.76086e-11 -6.22236e-10]
So pErr, vErr and constrains are very small. The first 4 seconds it stays like this, all good!

But after about 4.8 seconds the model begins to move more and more violantly.
After 5.8 seconds the situation is as follows:

Code: Select all

   [info] CMC_Joint.computeDesiredAcceleration: seatpos:      aDes=-1.24911     vErr=-0.0648996 pErr=0.000488866
   [info] CMC_Joint.computeDesiredAcceleration: lbackangle:   aDes=2.69631      vErr=0.111554   pErr=0.00465225
   [info] CMC_Joint.computeDesiredAcceleration: uarmleft_out: aDes=-15.2080     vErr=-5.41779   pErr=0.931478
   [info] CMC_Joint.computeDesiredAcceleration: uarmleft_trn: aDes=-16.1106     vErr=5.25273    pErr=-1.21165
   [info] CMC_Joint.computeDesiredAcceleration: uarmleft_up:  aDes=-298.265     vErr=70.0555    pErr=-16.9938
In the contrainFunc the desired actuator forces and the constraints now are:

Code: Select all

     x          = ~[-2663.11 1050.34 -41.0186 10.2978 -318.565]
     constraint = ~[2.13163e-14 0 -7.10543e-15 -1.77636e-15 0]
The constraints are STILL being met but the position (Q) and speed (U) are COMPLETELY OFF as see by pErr and vErr!
So the model is not steered towards the intended position.
The optimization does not compensate when the accelleration is "drifting" away; maybe Q should be added to
the optimization problem in some form?

Is my assessment of the situation correct?
And more importantly, what can I do to make it work?

Hoping for a reaction,
regards, Sietse

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

Re: CMC does not work with some muscle/no-muscle models.

Post by Sietse Achterop » Mon Mar 27, 2023 11:57 am

I simplified the model even further, but the instabilities remain!
There now remain only 2 bodies, a pin-joint and a ball-joint.
opensim_snapshot.png
opensim_snapshot.png (322.55 KiB) Viewed 518 times
For more details please see the last message of my issue 3345 from opensim-core. It includes the model, the trajectory and a video of the problem.

Please help.
Regards Sietse

POST REPLY