Error using arm26Force (line 24)
Java exception occurred:
java.lang.RuntimeException: ModelComponent: Cannot include subcomponent after addToSystem().
at org.opensim.modeling.opensimModelJNI.Model_private_addForce(Native Method)
at org.opensim.modeling.Model.private_addForce(Model.java:291)
at org.opensim.modeling.Model.addForce(Model.java:88)
Code: Select all
import org.opensim.modeling.*
model = Model('C:\Users\Yong Cho\Documents\OpenSim 3.3\Models\Arm26\arm26.osim');
cSet = model.getCoordinateSet()
initState = model.initSystem()
r_shoulder_elevation = cSet.get(0)
r_elbow_flex = cSet.get(1)
r_shoulder_elevation.setDefaultLocked(1)
r_elbow_flex.setDefaultLocked(1)
body = model.getBodySet().get('r_ulna_radius_hand');
force = PrescribedForce(body);
force.setForceFunctions(Constant(15), Constant(0), Constant(0));
force.setPointFunctions(Constant(0), Constant(-0.180496), Constant(0))
force.setPointIsInGlobalFrame(0);
force.setForceIsInGlobalFrame(0);
model.addForce(force) % line 24 where the error happens
model.print('C:\Users\Yong Cho\Documents\OSFolder\arm26e2PrescribedForce1.osim');