Get customjoint in Python to work (solved)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sietse Achterop
Posts: 72
Joined: Tue Sep 14, 2021 3:01 am

Get customjoint in Python to work (solved)

Post by Sietse Achterop » Tue Oct 26, 2021 7:16 am

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

Tags:

POST REPLY