Some problems with tugOfWar example
Posted: Tue Dec 20, 2011 7:11 pm
Hi,
I am trying to compile the tugOfWar example in the "OpenSim Developers Guide" step by step. I want to modify step 15 (which uses some functions to make the muscle control history at page 34) and replace the LinearFunction with PiecewiseLinearFunction. So I replaced this piece of code:
with this:
The code does not return any errors and OpenSim integrates the equations from initial time to the final time. But the activation of muscles is not a piece wise linear function.
It would be great if someone could help me to solve this issue.
Regards,
Sina
I am trying to compile the tugOfWar example in the "OpenSim Developers Guide" step by step. I want to modify step 15 (which uses some functions to make the muscle control history at page 34) and replace the LinearFunction with PiecewiseLinearFunction. So I replaced this piece of code:
Code: Select all
PrescribedController *muscleController = new PrescribedController();
muscleController->setActuators(osimModel.updActuators());
Array<double> slopeAndIntercept1(0.0, 2); // array of 2 doubles
Array<double> slopeAndIntercept2(0.0, 2);
slopeAndIntercept1[0] = -1.0/(finalTime-initialTime);
slopeAndIntercept1[1] = 1.0;
slopeAndIntercept2[0] = 1.0/(finalTime-initialTime);
slopeAndIntercept2[1] = 0.05;
muscleController->prescribeControlForActuator("muscle1", new LinearFunction(slopeAndIntercept1));
muscleController->prescribeControlForActuator("muscle2", new LinearFunction(slopeAndIntercept2));
Code: Select all
PrescribedController *muscleController = new PrescribedController();
muscleController->setActuators(osimModel.updActuators());
double time[3] = {0, finalTime/2, finalTime};
double value1[3] = {0.5, 1.0, 0.5};
double value2[3] = {0.25, 0.5, 0.75};
muscleController->prescribeControlForActuator("muscle1", new PiecewiseLinearFunction(3,time,value1));
muscleController->prescribeControlForActuator("muscle2", new PiecewiseLinearFunction(3,time,value2));
It would be great if someone could help me to solve this issue.
Regards,
Sina