I am trying to run ForwardTool in the Matlab. All of my codes was working perfectly yesterday and the codes were able to save analysis results in .sto file. But today I encountered a problem. When I am running Matlab codes, Matlab crashes and gives me this error:
"Matlab has encountered an internal problem and needs to close". I checked err.log and out.log. err.log was blank and there was no error or warning in out.log. I saw Forum topic 7978 (viewtopicPhpbb.php?f=91&t=7978). One hypothesis was that Matlab script expecting the output immediately after calling iktool.run (in my case ForwardTool.run) and because it does not have enough time it runs into this problem. To solve this issue, I used pause() function to give some time in order to generate the output. But it still does not work. I don't know what is the problem. Below are my codes to get a better idea of what's going on.
Code: Select all
import org.opensim.modeling.*;
model = Model('arm26.osim');
state = model.initSystem;
muscles= model.getMuscles();
nMuscles = muscles.getSize();
Activation = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05];
maxIsometricForce = [798.52, 624.3, 624.3, 624.3, 435.56, 987.26];
optimalFiberLength = [0.134, 0.1134, 0.1138, 0.1157, 0.1321, 0.0858];
tendonSlackLength = [0.134, 0.098, 0.0908, 0.2723, 0.1923, 0.0535];
pennationAngle = [0.20943951, 0.15707963, 0.15707963, 0, 0, 0];
for i = 0:nMuscles-1
muscles.get(i).setActivation(state, Activation(i+1));
muscles.get(i).setMaxIsometricForce(maxIsometricForce(i+1));
muscles.get(i).setOptimalFiberLength(optimalFiberLength(i+1));
muscles.get(i).setTendonSlackLength(tendonSlackLength(i+1));
muscles.get(i).setPennationAngleAtOptimalFiberLength(pennationAngle(i+1));
end
%Setting up the controller
initialTime = 0.0;
finalTime = 3.0;
muscleController = PrescribedController();
muscleController.setName('Constant Controller');
muscleController.setActuators(model.updActuators());
Excitation1=0.1;
Excitation2=0.1;
Excitation3=0.1;
Excitation4=0.1;
Excitation5=0.1;
Excitation6=0.1;
muscleController.prescribeControlForActuator('TRIlong', Constant(Excitation1));
muscleController.prescribeControlForActuator('TRIlat', Constant(Excitation2));
muscleController.prescribeControlForActuator('TRImed', Constant(Excitation3));
muscleController.prescribeControlForActuator('BIClong', Constant(Excitation4));
muscleController.prescribeControlForActuator('BICshort', Constant(Excitation5));
muscleController.prescribeControlForActuator('BRA', Constant(Excitation6));
model.addController(muscleController);
model.disownAllComponents();
model.print('arm26_controller.osim');
osimModel = Model('arm26_controller.osim');
osimModel.setUseVisualizer(true);
state=osimModel.initSystem;
tool = ForwardTool();
tool.setModel(osimModel);
tool.setStartTime(0);
tool.setFinalTime(2);
tool.setSolveForEquilibrium(true);
Muscle_AnL = MuscleAnalysis('arm26_controller.osim');
KinMtic=Kinematics('arm26_controller.osim');
PnT_KinMtic=PointKinematics('arm26_controller.osim');
Actu=Actuation('arm26_controller.osim');
BdY_KinMtic=BodyKinematics('arm26_controller.osim');
Joint_React=JointReaction('arm26_controller.osim');
InduCd_Acc=InducedAccelerations('arm26_controller.osim');
Force_RporT=ForceReporter('arm26_controller.osim');
osimModel.addAnalysis(Muscle_AnL);
osimModel.addAnalysis(KinMtic);
osimModel.addAnalysis(PnT_KinMtic);
osimModel.addAnalysis(Actu);
osimModel.addAnalysis(BdY_KinMtic);
osimModel.addAnalysis(Joint_React);
osimModel.addAnalysis(InduCd_Acc);
osimModel.addAnalysis(Force_RporT);
tool.setName('FORWARD_ARM26_RESULT');
% Run the simulation
tool.run();
pause(5);
I have OpenSim 3.3, Matlab 2014b, Windows 8.1, 64 bit everything.
I will appreciate if anybody can help me to solve this issue and get my codes work again.
RoZi