Access violation adding Controller
Posted: Sat Dec 17, 2016 12:38 pm
Hello,
I am creating my first Controller to my model before doing a Forward Simulation like this:
and I am getting this Unhandled Exception:
Has anyone any ideas on what is wrong?
The exception triggers when I am adding the controller (when line "model.addController( controller);" is added).
I am creating my first Controller to my model before doing a Forward Simulation like this:
Code: Select all
OpenSim::Model model("../mymodel.osim");
PrescribedController* controller = new PrescribedController();
controller->setName( "my_controller");
controller->setActuators( model.getActuators());
double control_time[2] = {0, 0.5}; // time nodes for linear function
double control_acts[2] = {0.1, 1.0}; // force values at t1 and t2
PiecewiseLinearFunction *control_func = new PiecewiseLinearFunction( 2, control_time, control_acts);
control_func->setName( "lin_control_func");
controller->prescribeControlForActuator( "bifemlh_r", control_func);
model.addController( controller);
SimTK::State& si = model.initSystem();
// Add reporters
ForceReporter* forceReporter = new ForceReporter(&model);
model.addAnalysis(forceReporter);
// Create the integrator and manager for the simulation.
SimTK::RungeKuttaMersonIntegrator integrator(model.getMultibodySystem());
Manager manager(model, integrator);
// Define the initial and final simulation times
double initialTime = 0;
double finalTime = 0.5;
// Integrate from initial time to final time
manager.setInitialTime(initialTime);
manager.setFinalTime(finalTime);
manager.integrate(si);
Code: Select all
Unhandled exception at 0x598bb3e3 in Mysim.exe: 0xC0000005: Access violation reading location 0xbaadf00d.
The exception triggers when I am adding the controller (when line "model.addController( controller);" is added).