Set External Torque through Matlab
Posted: Sat Feb 16, 2019 9:47 pm
Hi, I tried to apply external torque at knee through Matlab scripting, and below is my code. The Matlab code was ran successfully, but when I started the forward dynamics simulation in OpenSim, nothing happened except that the model just fell. I was wondering is it because some Matlab commands are missing? Or is it because I didn't set up OpenSim correctly? Thank you so much for your help!
import org.opensim.modeling.*;
model=Model("gait2354_simbody.osim");
bodyList=model.getBodyList();
coordinateSet=model.updCoordinateSet();
model.setUseVisualizer(true);
%Create a Troque Actuator for the Knee Joint
femur_r=model.getBodySet().get('femur_r');
tibia_r=model.getBodySet().get('pelvis');
zAxis=Vec3(0,1,0);
torqueActuator = TorqueActuator;
torqueActuator.setBodyA(femur_r);
torqueActuator.setBodyB(tibia_r);
torqueActuator.setAxis(zAxis);
torqueActuator.setOptimalForce(5);
import org.opensim.modeling.*;
model=Model("gait2354_simbody.osim");
bodyList=model.getBodyList();
coordinateSet=model.updCoordinateSet();
model.setUseVisualizer(true);
%Create a Troque Actuator for the Knee Joint
femur_r=model.getBodySet().get('femur_r');
tibia_r=model.getBodySet().get('pelvis');
zAxis=Vec3(0,1,0);
torqueActuator = TorqueActuator;
torqueActuator.setBodyA(femur_r);
torqueActuator.setBodyB(tibia_r);
torqueActuator.setAxis(zAxis);
torqueActuator.setOptimalForce(5);