Page 1 of 1

About TugOfWar_createModel example problem

Posted: Mon Jun 15, 2015 1:51 am
by bio
Hi,
I'm trying to compile TugOfWar_createModel Examples in the depelopers guide.
I wrote the code I attached below(Prescribe Muscle Controls from functions in 'Performing a simulation part three').
It can be built in VS,
but the error (PrescribedController does not have muscle1 in its list of actuators to control.) appears.
Does anyone know why the error appears??

Code: Select all

// Create a prescribed controller that simply applies control as function of time
PrescribedController *muscleController = new PrescribedController();
muscleController->setActuators(osimModel.updActuators());

// Define linear function for the control values for the two muslces
Array<double> slopeAndIntercept1(0.0, 2); // array of 2 doubles
Array<double> slopeAndIntercept2(0.0, 2);

// muscle1 control has slope of -1 starting 1 at t = 0
slopeAndIntercept1[0] = -1.0/(finalTime-initialTime); slopeAndIntercept1[1] = 1.0;
// muscle2 control has slope of 1 starting 0.05 at t = 0	
slopeAndIntercept2[0] = 1.0/(finalTime-initialTime); slopeAndIntercept2[1] = 0.05;

// Set the indiviudal musle control functions for the prescribed muscle controller
muscleController->prescribeControlForActuator("muscle1", new LinearFunction(slopeAndIntercept1));
muscleController->prescribeControlForActuator("muscle2", new LinearFunction(slopeAndIntercept2));

// Add the muscle controller to the model
osimModel.addController(muscleController);

It would be great if someone could help me to solve this issue.
Best regards,

Shoko Horibata

Re: About TugOfWar_createModel example problem

Posted: Mon Jun 15, 2015 2:42 am
by ex10192
Hi Shoko,

Perhaps, you could check if your .osim file, you have loaded for the simulation has a muscle named "muscle1" , may be you renamed it for convenience. Or you have missed to created a muscle actuator via coding as explained in the initial steps of the simulation tutorial.

regards,

nithin

Re: About TugOfWar_createModel example problem

Posted: Mon Jun 15, 2015 8:51 pm
by bio
Hi, nithin,

Thank you for replying.
I took muscle name '*muscle1' for force name 'muscle1'.
Thank you so much.

Best regards,

Shoko