MoCoInverse : Objective Function not Converging

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Sivaprasad Kunnath
Posts: 11
Joined: Mon Jun 03, 2024 2:13 am

Re: MoCoInverse : Objective Function not Converging

Post by Sivaprasad Kunnath » Tue Aug 27, 2024 12:14 am

Hello Nicholas,

Thank you for your help. Following the instructions, I was able to get consistent result in activation. The activation values when analysed, followed the expected behavior. However, the muscle forces that accompanies the activation values, are distorted. It seems to be oscillating between 0 and 1 for all muscles.
TricepLong.jpg
TricepLong.jpg (134.41 KiB) Viewed 459 times
This type of oscillatory pattern is consistent for all dominant muscle groups. The muscle force sets are bounded between 0.1 to 1, and we are using DeGroote Muscle with added damping. I am curious to know whey the muscle forces are saturated at 1?

Thanks for your constant support.

Regards,
Siva

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

Re: MoCoInverse : Objective Function not Converging

Post by Nicholas Bianco » Tue Aug 27, 2024 3:37 pm

Hi Siva,

Those look like the muscle excitations, not the muscle forces. Muscle force should be proportional to activation (if passive force is excluded).

How are you computing "Force Normalized"?

Best,
Nick

User avatar
Sivaprasad Kunnath
Posts: 11
Joined: Mon Jun 03, 2024 2:13 am

Re: MoCoInverse : Objective Function not Converging

Post by Sivaprasad Kunnath » Wed Aug 28, 2024 5:00 pm

Hi Nicholas,

The plot on the left side was the output of \forceset\Trilong from the output .sto file after performing invserseStudy.solve. I presumed the output from the mocoinverse is activation values and the corresponding muscle forces! These variables are scaled down to the range of 0.01 to 1, by default. It was my understanding, it was the muscle forces normalised by their maximum force capacity of the muscle. Please correct me if i'm wrong. If i'm wrong, how can i find muscle forces from excitations and activation values?

Thank you,
Warm Regards,
Siva

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

Re: MoCoInverse : Objective Function not Converging

Post by Nicholas Bianco » Fri Aug 30, 2024 10:50 am

Hi Siva,

No, the values in the Moco trajectory with format "\forceset\Trilong" are muscle excitations. You can use MocoStudy::analyze() to compute muscle forces based on the Muscle class Outputs.

Best,
Nick

User avatar
Sivaprasad Kunnath
Posts: 11
Joined: Mon Jun 03, 2024 2:13 am

Re: MoCoInverse : Objective Function not Converging

Post by Sivaprasad Kunnath » Fri Sep 20, 2024 6:23 pm

Hey Nicholas,

Thank you for your constant support. I was able to plot the needed solution using the analyse methods you recommended. I got a couple more questions regarding the iterations I'm working on. It is in regards to muscle moments and Reserve actuators.

1. When i perform a mocoInverse study on a static iteration, I observe the reserve actuators contribution are less than 10^-2. This I believe makes my solution very reliable. However, when I use analyse tool, by the following method, I am printing all the information i can extract from the muscle class, in four different conditions,

Code: Select all

STOFileAdapter::write(solution.exportToStatesTable(), "Muscle_states.sto");
		STOFileAdapter::write(solution.exportToControlsTable(), "Muscle_controls.sto");
		////try 0.5 initial stop, 0.5 moving, 0.2 stop

		{
			// Create an AnalyzeTool setup file.
			AnalyzeTool analyze;
			analyze.setName("analyze");
			analyze.setModelFilename(model_path);
			analyze.setStatesFileName("Muscle_states.sto");
			analyze.updAnalysisSet().adoptAndAppend(new MuscleAnalysis());
			analyze.updExternalLoads();
			analyze.updControllerSet().adoptAndAppend(
				new PrescribedController("Muscle_controls.sto"));
			analyze.setResultsDir("Gravity_Extended");
			analyze.print("results.xml");
		}
		AnalyzeTool analyze("results.xml");
		analyze.run();
a. With Gravity, with external assisting force.
b. Without Gravity, with external assisting force.

c. With Gravity, without external assisting force.
d. Without Gravity, without external assisting force.

The pose I input for the kinematics is a static pose with arm extended ( not fully extended to avoid singularity).

In all these cases, the muscle active fibre forces are different and as expected, whereas the moment contribution of the individual muscle on a particular joint remains the same. For example, the contribution of long triceps muscle towards elbow flexion moment remain same for all the four iterations. This is consistent for moment arms as well. This shouldn't be right, since with an external assisting force, we should see a difference in the moment contributions. Can you suggest some reasons for the same?

2. When I perform mocoInverse on a kinematic data trial (simulated one) where I start with relaxed shoulder and elbow flexed at 90 degree to extended arm, the reserve forces are really high in the order of 100's and for some joints 500's. This provides faulty muscle excitations and muscle forces. Is there a way to relax the tracking accuracy in mocoInverse, so that we observe the expected muscle activations and less reserve forces? Or is it because of any other reasons. Hope to get your insights on these.

Thank you.
Warm Regards,
Siva

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

Re: MoCoInverse : Objective Function not Converging

Post by Nicholas Bianco » Tue Sep 24, 2024 9:54 am

Hi Siva,
This shouldn't be right, since with an external assisting force, we should see a difference in the moment contributions. Can you suggest some reasons for the same?
The best way to investigate this is to plot all of the moment contributions from all muscles, the reserves, and your assistive device against the net joint moment so you can visualize all the contributions. It might also be helpful to plot the sum of all actuator contributions to confirm that they match the net joint moments.
Is there a way to relax the tracking accuracy in mocoInverse, so that we observe the expected muscle activations and less reserve forces? Or is it because of any other reasons.
There is no way to relax the kinematic tracking. In fact, the kinematics are prescribed exactly, so any discrepancies between the kinematics and ground reaction forces will result in large residual forces and incorrect joint moments. I would recommend running inverse dynamics on your data as a start. If you can get good inverse dynamics moments then you have a much better chance of getting good muscle activity from MocoInverse.

Best,
Nick

POST REPLY