Page 1 of 1

Get customjoint in Python to work (solved)

Posted: Tue Oct 26, 2021 7:16 am
by sietse
I really am struggling to get a customjoint in Python.
Concretely, how do I translate this fragment from an example from testJoints.cpp into python?

Code: Select all

    SpatialTransform hipTransform;
    hipTransform[0].setCoordinateNames(
            OpenSim::Array<std::string>("hip_q0", 1, 1));
    hipTransform[0].setFunction(new LinearFunction());
        ......
      CustomJoint hip("hip", ground, hipInPelvis, Vec3(0), osim_thigh, hipInFemur,
            Vec3(0), hipTransform);
 
In python hipTransform is not subscriptable.

UPDATE: Finally cracked it.

Code: Select all

spatialTransform = osim.SpatialTransform()
pupdown= osim.ArrayStr()
pupdown.append("p_updown")
spatialTransform.updTransformAxis(0).setCoordinateNames(pupdown)
spatialTransform.updTransformAxis(0).set_function(osim.LinearFunction())
Note the different set_function().

Thanks in advance, Sietse