I am trying to run forward dynamics from a mexfile that we created. When it is executed for the first time, it seems to work properly. But, when it is executed for the second time, Matlab crashes. It seems to be a memory issue, but I don't know how to solve it. Then, the only option is restarting Matlab.
The model is torque driven. It has correction controllers to try to follow the kinematics.
The second time that it is executed it crashes when adding the controls to the model. It is at the 4th line of the following piece of code:
Code: Select all
ControlSetController* controller = new ControlSetController;
ControlSet* controlset = new ControlSet(controls); // controls is a Storage variable that contains the controls (from RRA)
controller->setControlSet(controlset);
osimModel->addController(controller); // It crashes here
Thank you very much in advance,
Gil