Trouble with Inverse Dynamics with exoskeletons

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Guillermo Muñoz
Posts: 6
Joined: Sat Nov 23, 2019 11:08 am

Trouble with Inverse Dynamics with exoskeletons

Post by Guillermo Muñoz » Sat Jun 26, 2021 3:53 pm

Hello everyone. My name is Guillermo, and I started to work with OpenSim and Moco some months ago. I already wrote this message in the OpenSim forum but I think it fits better here. I would like to ask for some piece of help for a project I'm involved in. I am working with the 3D model, subject_walk_armless.osim, and I've built an exoskeleton on it, as it can be seen in the picture.

Image.

The exoskeleton is composed of two bodies in each leg, the upper bodies are connected to the hip through CustomJoints with 3 DOF each, all of them rotations, while the lower bodies are connected to the tibia through PointConstraints so as to close the loop.

First of all, I performed a Inverse Kinematic analysis in OpenSim by loading marker_trajectories.trc, obtaining the evolution of generalized coordinates in time. Then, I tried to perform a dynamical analysis in Moco so as to obtain generalized forces and torques. For that purpose, I built a Matlab script based in exampleMocoInverse.m, adapted to my problem, using my .osim model, and the .mot file I obtained by doing the Inverse Kinematics. The file can be seen in this picture.

Image

Here the problems arrive. When I make the optimization problem begin, it never reaches a solution, the problem takes so many iterations until reaching the maximum number of iterations allowed, and I don't know what could be happening. I tried to reduce the time interval in the Moco script, and increase the mesh interval, but none of these worked to obtain a solution. Please, could someone give me an idea to solve this problem? Thank you very much.

User avatar
Nicholas Bianco
Posts: 1044
Joined: Thu Oct 04, 2012 8:09 pm

Re: Trouble with Inverse Dynamics with exoskeletons

Post by Nicholas Bianco » Mon Jul 12, 2021 9:53 am

Hi Guillermo,

Thanks for trying out Moco!

There's several things that could be causing you to hit the max number of iterations (which you can change by the way, but ideally this is not necessary). My first thought is that the problem is related to how the exoskeleton is connected to the body. The problem might be having trouble enforcing the PointConstraints, depending on how the exo is actuated. Did you add CoordinateActuators to the 3 DOF hip joint and/or the "knee" joint of the exo?

-Nick

User avatar
Guillermo Muñoz
Posts: 6
Joined: Sat Nov 23, 2019 11:08 am

Re: Trouble with Inverse Dynamics with exoskeletons

Post by Guillermo Muñoz » Thu Jul 15, 2021 3:47 am

Hi Nicholas,

Thank you very much for your response. Yes, I added Coordinate Actuators to every coordinate created in the exoskeleton, but the optimization algorithm never stops. Maybe is it related to the predetermined tolerance? Aproximately at 300 iterations, the value of cost function barely changes, I've tried to change optimization parameters but Matlab does not recognize the following sentences:

solver.set_convergence_tolerance(1e-3);
solver.set_constraint_tolerance(1e-3);

What else could we do?

Thank you very much,
Guillermo

User avatar
Nicholas Bianco
Posts: 1044
Joined: Thu Oct 04, 2012 8:09 pm

Re: Trouble with Inverse Dynamics with exoskeletons

Post by Nicholas Bianco » Mon Jul 19, 2021 4:16 pm

Hi Guillermo,

If the cost isn't changing much at 300 iterations you might be close to a solution (even if the iteration-to-iteration time is slow). Are you currently trying to solve the problem with muscles? You could try removing the muscles from the model and replacing them to torque actuators to speed up the problem significantly. Once you have confidence that the constraints are being met, then you could reintroduce the muscles.

If you're using the a MocoSolver directly, those lines will need to be

Code: Select all

solver.set_optim_convergence_tolerance(1e-3);
solver.set_optim_constraint_tolerance(1e-3);
Best,
-Nick

User avatar
Guillermo Muñoz
Posts: 6
Joined: Sat Nov 23, 2019 11:08 am

Re: Trouble with Inverse Dynamics with exoskeletons

Post by Guillermo Muñoz » Tue Jul 20, 2021 9:10 am

Thank you very much Nicholas, I'll try what you said and I'll tell you what results.

Greetings,
Guillermo

POST REPLY