Hello,
I'm trying to verify some Moco outputs that I receive when running a predict study on my model. While the results from moco appear to be correct and also the visualization is nice and smooth, I get really weird (much higher) results for my states in the forward simulation. Also the visualization shows that my bodies are spinning around.
My model consists of the lower back vertebrae (L3 to sacrum), connected by PinJoints. I use coordinate actuators for the torques.
I spent so much time looking for the bug and I would appreciate if anyone had some feedback, or maybe hast encountered this issue before and could share their insight.
I put my code for the forward simulation in the attachments.
Cheers,
Matthias
Verification of Moco Predict Study with Integrator
- Matthias Kindler
- Posts: 9
- Joined: Tue Dec 06, 2022 1:02 am
Verification of Moco Predict Study with Integrator
- Attachments
-
- mocoverify_python.txt
- (3.23 KiB) Downloaded 29 times
-
- sto_file.txt
- (9.33 KiB) Downloaded 29 times
Tags:
- Matthias Kindler
- Posts: 9
- Joined: Tue Dec 06, 2022 1:02 am
Re: Verification of Moco Predict Study with Integrator
Quick update: Now, the forward sim results look ok(ish) until about 1.4secs (total simulation time 3s). I made a mistake in the model, and basically wrong controls where assigned to an actuator. However, I still not understand why the state values diverge so much after 1.4secs.
Could anyone help me? Let me know if I need to explain my issue better...
Could anyone help me? Let me know if I need to explain my issue better...
- Matthias Kindler
- Posts: 9
- Joined: Tue Dec 06, 2022 1:02 am
Re: Verification of Moco Predict Study with Integrator
I noticed that this issue of diverging forward dynamics only occurs when there is gravitational force turned on.
I ran the whole process (obtaining torques from moco, feeding those torques in the FD) without gravity and it went smoothly and the error between the first predicted kinematics and the ones obtained from the FD were low. However, the same thing does not work with gravity turned on, and the model "goes crazy".
Could someone explain this to me?
I ran the whole process (obtaining torques from moco, feeding those torques in the FD) without gravity and it went smoothly and the error between the first predicted kinematics and the ones obtained from the FD were low. However, the same thing does not work with gravity turned on, and the model "goes crazy".
Could someone explain this to me?
- Ton van den Bogert
- Posts: 164
- Joined: Thu Apr 27, 2006 11:37 am
Re: Verification of Moco Predict Study with Integrator
Matthias,
If you get a good agreement for almost a second, that is actually quite good and you can conclude that Moco and forward integration are in agreement. This is typically what I have seen when I validate my optimal control solutions.
When balancing against gravity, the system is unstable. Small errors will grow exponentially as a function of time, and the time constants are typically about 0.1 seconds, so errors grow very fast.
Moco does open loop optimal control on a time grid. The integrator probably does variable steps on a different time grid. Both have a small error tolerance and the system is just very sensitive to small changes in muscle controls. This is a real sensititivity and not an error. The human system needs feedback control to stabilize this. Moco is fine without it.
Ton van den Bogert
If you get a good agreement for almost a second, that is actually quite good and you can conclude that Moco and forward integration are in agreement. This is typically what I have seen when I validate my optimal control solutions.
When balancing against gravity, the system is unstable. Small errors will grow exponentially as a function of time, and the time constants are typically about 0.1 seconds, so errors grow very fast.
Moco does open loop optimal control on a time grid. The integrator probably does variable steps on a different time grid. Both have a small error tolerance and the system is just very sensitive to small changes in muscle controls. This is a real sensititivity and not an error. The human system needs feedback control to stabilize this. Moco is fine without it.
Ton van den Bogert
- Matthias Kindler
- Posts: 9
- Joined: Tue Dec 06, 2022 1:02 am
Re: Verification of Moco Predict Study with Integrator
Hello Ton,
first of all, thank you very much for this explanation. I am still new to the topic and appreciate your experience!
For clarification: Both Moco and the Integrator are open-loop and since they are on different time grids, errors accumulate and the forward simulation becomes unstable?
I have a few follow-ups:
1) Does this mean, on the other hand, that a shorter simulation might be the key to stable one?
2) What other options do I have to increase stability? I found a forum entry about correction controllers, could this help?
I need a framework to test whether my calculated torques/muscle forces, coming from different approaches (such as Moco, etc), result in a comparable motion.
Thank you.
first of all, thank you very much for this explanation. I am still new to the topic and appreciate your experience!
For clarification: Both Moco and the Integrator are open-loop and since they are on different time grids, errors accumulate and the forward simulation becomes unstable?
I have a few follow-ups:
1) Does this mean, on the other hand, that a shorter simulation might be the key to stable one?
2) What other options do I have to increase stability? I found a forum entry about correction controllers, could this help?
I need a framework to test whether my calculated torques/muscle forces, coming from different approaches (such as Moco, etc), result in a comparable motion.
Thank you.
- Ton van den Bogert
- Posts: 164
- Joined: Thu Apr 27, 2006 11:37 am
Re: Verification of Moco Predict Study with Integrator
It sounds like you want to do simulation-based predictions where you keep the muscle controls constant and experiment with the mechanical system or environment. Yes, that is only possible for shorter simulations. I have done a lot of research like that on ACL injuries and the simulations were only 200 ms so there is not enough time to completely fall apart while experimenting [1].
There are two options if you want to do simulation experiments on longer movements.
Ideally, you can use Moco to formulate the prediction problem. You can experiment with the mechanical environment (muscle properties, braces, exoskeletons) and allow Moco to adapt the muscle controls and still get a well coordinated movement [2].
There is also a new tool called SCONE that uses feedback control to stabilize the system. Then you can alter the mechanical system, run the simulation again without altering the controller, and the movement will still be good [3]. This is easier than Moco, because the prediction does not require solving a new optimal control problem. I would generally prefer the open loop (Moco) approach because results will not depend on an assumed feedback controller. Almost certainly, real human feedback control is very different from the simple (though effective) models that SCONE uses. But Moco can give unrealistic predictions also. This is an ongoing question!
This answer may go far beyond what you need. If you just need to confirm that different simulation tools give the same results, you need to be happy with good agreement for half a second or so...
Ton
[1] McLean SG, et al. (2008) Investigating isolated neuromuscular control contributions to non-contact Anterior Cruciate Ligament injury risk via computer simulation. Clin Biomech 23(7): 926-939.
[2] Dorschky E, et al. (2019) Optimal Control Simulation Predicts Effects of Midsole Materials on Energy Cost of Running. Computer Methods in Biomechanics and Biomedical Engineering 22(8): 869-879.
[3] Waterval NFJ et al. (2021) Validation of forward simulations to predict the effects of bilateral plantarflexor weakness on gait. Gait Posture 87:33-42.
There are two options if you want to do simulation experiments on longer movements.
Ideally, you can use Moco to formulate the prediction problem. You can experiment with the mechanical environment (muscle properties, braces, exoskeletons) and allow Moco to adapt the muscle controls and still get a well coordinated movement [2].
There is also a new tool called SCONE that uses feedback control to stabilize the system. Then you can alter the mechanical system, run the simulation again without altering the controller, and the movement will still be good [3]. This is easier than Moco, because the prediction does not require solving a new optimal control problem. I would generally prefer the open loop (Moco) approach because results will not depend on an assumed feedback controller. Almost certainly, real human feedback control is very different from the simple (though effective) models that SCONE uses. But Moco can give unrealistic predictions also. This is an ongoing question!
This answer may go far beyond what you need. If you just need to confirm that different simulation tools give the same results, you need to be happy with good agreement for half a second or so...
Ton
[1] McLean SG, et al. (2008) Investigating isolated neuromuscular control contributions to non-contact Anterior Cruciate Ligament injury risk via computer simulation. Clin Biomech 23(7): 926-939.
[2] Dorschky E, et al. (2019) Optimal Control Simulation Predicts Effects of Midsole Materials on Energy Cost of Running. Computer Methods in Biomechanics and Biomedical Engineering 22(8): 869-879.
[3] Waterval NFJ et al. (2021) Validation of forward simulations to predict the effects of bilateral plantarflexor weakness on gait. Gait Posture 87:33-42.