normalized tendon force not in the trajectory

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
Sheeba Davis
Posts: 16
Joined: Wed Oct 27, 2021 5:21 am

normalized tendon force not in the trajectory

Post by Sheeba Davis » Wed May 11, 2022 8:45 am

Hi,

I was trying to generate a tracking solution without a guess file (by uncommenting the code to set the normalized tendon forces to reasonable values in the guess) in order to use that solution to run the predictive simulation. The tracking solution looks fine but the file does not have 'normalized tendon force' and hence the predictive solution shows the following error:
Java exception occurred:
java.lang.RuntimeException: The trajectory and provided problem are not compatible. The following state(s) are in the problem but not the trajectory:
/forceset/bifemsh_l/normalized_tendon_force
/forceset/bifemsh_r/normalized_tendon_force
/forceset/dorsiflexors_l/normalized_tendon_force
/forceset/dorsiflexors_r/normalized_tendon_force
/forceset/gastroc_l/normalized_tendon_force
/forceset/gastroc_r/normalized_tendon_force
/forceset/glut_max_l/normalized_tendon_force
/forceset/glut_max_r/normalized_tendon_force
/forceset/hamstrings_l/normalized_tendon_force
/forceset/hamstrings_r/normalized_tendon_force
/forceset/iliopsoas_l/normalized_tendon_force
/forceset/iliopsoas_r/normalized_tendon_force
/forceset/rect_fem_l/normalized_tendon_force
/forceset/rect_fem_r/normalized_tendon_force
/forceset/soleus_l/normalized_tendon_force
/forceset/soleus_r/normalized_tendon_force
/forceset/vasti_l/normalized_tendon_force
/forceset/vasti_r/normalized_tendon_force


Thrown at MocoTrajectory.cpp:1028 in MocoTrajectory::isCompatible()().

at org.opensim.modeling.opensimMocoJNI.MocoStudy_solve(Native Method)

at org.opensim.modeling.MocoStudy.solve(MocoStudy.java:270)
Am not sure whether i need to include them manually (as i find some posts mentioning that). Thanks in advance.

Regards
Sheeba

User avatar
Ross Miller
Posts: 372
Joined: Tue Sep 22, 2009 2:02 pm

Re: normalized tendon force not in the trajectory

Post by Ross Miller » Wed May 11, 2022 9:39 am

Hi Sheeba,

I've previously run into the problem where my guess did not have normalized tendon forces and I had to put them into the guess, which I did like this:

Code: Select all

guess = solver.createGuess();
numRows = guess.getNumTimes();
StateNames = model.getStateVariableNames();
for i = 1:model.getNumStateVariables();
	currentStateName = string(StateNames.getitem(i-1));
	if contains(currentStateName,'normalized_tendon_force')
		MusName = currentStateName;
		guess.setState(currentStateName, linspace(0.2,0.2,numRows));
	end
end
If you're getting this error despite a successful tracking problem, my guess would be tendon dynamics are disabled in the tracking problem but not in the prediction problem. If you enable them in the tracking problem, then the tracking solution should have those normalized tendon forces as states in it (at the cost of making the problem bigger/slower/more complex).

Code: Select all

baseModel = Model('model.osim');
modelProcessor = ModelProcessor(baseModel);
modelProcessor.append(ModOpTendonComplianceDynamicsModeDGF('implicit'));
track.setModel(ModelProcessor);
Ross

User avatar
Sheeba Davis
Posts: 16
Joined: Wed Oct 27, 2021 5:21 am

Re: normalized tendon force not in the trajectory

Post by Sheeba Davis » Fri May 13, 2022 8:08 am

Hi Ross

Thank you very much for your suggestion.

I have enabled
modelProcessor.append(ModOpTendonComplianceDynamicsModeDGF('implicit'));
and ran the tracking simulation and used the solution to run predictive simulation. Initially with a MetabolicCostWeight = 1.0, the solution did not converge and i tried again with a MetabolicCostWeight = 0.5. this time the solution converged at iteration 1491 with a metabolic cost 5.3202 J/kg/m, but it looks like the model is still struggling to walk (even with a lower MetabolicCostWeight).

(Tried attaching a .gif file here but it says the file is too large)

Regards
Sheeba

POST REPLY