API crashes when editing joint splines
Posted: Tue Jun 26, 2018 6:53 pm
Hello all,
I have a problem where when I am adding custom joint splines (to a Custom Joint) through both the MATLAB and Python API in both OpenSim version 3.2 and 3.3, the MATLAB or Python instance crashes. Even though it does crash, the splines are successfully added to the model and the model is saved correctly.
I am editing both the tibiofemoral and patellofemoral joints and the associated splines. I have included a brief summary of the API functions I use and also attached the Python script I am using.
-----------------------------
# load the model
currModel = osim.Model(dirToModel)
# safeDownCast to the joint
lKneeJoint = osim.CustomJoint.safeDownCast(currModel.getJointSet().get('knee_l'))
# get the Transform Axis of the joints
lKneeRotAxis1 = lKneeJoint.getSpatialTransform().getTransformAxis(2) # adduction
# create the splines
TFaddSpline = osim.SimmSpline()
# define the coordinate Array
lTFCoordArray = osim.ArrayStr()
lTFCoordArray.setSize(1)
lTFCoordArray.set(0,'knee_angle_l')
# loop through the solution and add the spline values
for vals in spline:
TFaddSpline.addPoint(float(TFflex[x]) , float(TFadd[x]) )
# add the spline to the function
lKneeRotAxis1.setFunction(TFaddSpline)
lKneeRotAxis1.setCoordinateNames(lTFCoordArray)
# print/save the model
currModel.printToXML(newModelDir)
---------------------------
While it isn't a problem that is crashes when adding a single spline solution, I am trying to loop through multiple solutions, in this scenario, the first model is saved but when I get to a seemingly random point in the code (calling the TransformAxis) it will crash. I initially thought it could be a problem with the looping however is still crashes even when I only add a single solution without looping.
Any experience or advice would be greatly appreciated
Thanks in advance
Bryce Killen
I have a problem where when I am adding custom joint splines (to a Custom Joint) through both the MATLAB and Python API in both OpenSim version 3.2 and 3.3, the MATLAB or Python instance crashes. Even though it does crash, the splines are successfully added to the model and the model is saved correctly.
I am editing both the tibiofemoral and patellofemoral joints and the associated splines. I have included a brief summary of the API functions I use and also attached the Python script I am using.
-----------------------------
# load the model
currModel = osim.Model(dirToModel)
# safeDownCast to the joint
lKneeJoint = osim.CustomJoint.safeDownCast(currModel.getJointSet().get('knee_l'))
# get the Transform Axis of the joints
lKneeRotAxis1 = lKneeJoint.getSpatialTransform().getTransformAxis(2) # adduction
# create the splines
TFaddSpline = osim.SimmSpline()
# define the coordinate Array
lTFCoordArray = osim.ArrayStr()
lTFCoordArray.setSize(1)
lTFCoordArray.set(0,'knee_angle_l')
# loop through the solution and add the spline values
for vals in spline:
TFaddSpline.addPoint(float(TFflex[x]) , float(TFadd[x]) )
# add the spline to the function
lKneeRotAxis1.setFunction(TFaddSpline)
lKneeRotAxis1.setCoordinateNames(lTFCoordArray)
# print/save the model
currModel.printToXML(newModelDir)
---------------------------
While it isn't a problem that is crashes when adding a single spline solution, I am trying to loop through multiple solutions, in this scenario, the first model is saved but when I get to a seemingly random point in the code (calling the TransformAxis) it will crash. I initially thought it could be a problem with the looping however is still crashes even when I only add a single solution without looping.
Any experience or advice would be greatly appreciated
Thanks in advance
Bryce Killen