OdeJoint axis problem

Hey everyone, I just have a (not so) little problem with some of my Python code, and with OdeJoints.

Basically, what I want to do is make some code that binds one model with a joint, to another, with joint movements constrained around one axis.

Here is the code I came up with:

joint1 = OdeUniversalJoint(get_phys_world())
        joint2 = OdeUniversalJoint(get_phys_world())
        joint3 = OdeUniversalJoint(get_phys_world())
        joint4 = OdeUniversalJoint(get_phys_world())
        joint5 = OdeUniversalJoint(get_phys_world())

        joint1.setAxis1(0, 0, 0)
        joint1.setAxis2(0, 0, 0)

        joint2.setAxis1(0, 0, 0)
        joint2.setAxis2(0, 0, 0)

        joint3.setAxis1(0, 0, 0)
        joint3.setAxis2(0, 0, 0)

        joint4.setAxis1(0, 0, 0)
        joint4.setAxis2(0, 0, 0)

        joint5.setAxis1(0, 0, 0)
        joint5.setAxis2(0, 0, 0)

        joint1.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_larm'].phys_obj.body)
        joint2.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_rarm'].phys_obj.body)
        joint3.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_lleg'].phys_obj.body)
        joint4.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_rleg'].phys_obj.body)
        joint5.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_head'].phys_obj.body)

phys_obj.body is the OdeBody for the model I’m trying to bind.

When I run this code, though, the following happens:

See the figure on the left, rolled up in a ball? That’s the figure affected by the above code.

Could someone please tell me whats wrong?

Thanks,

DangerOnTheRanger

Bump!

I think the problem is that you are setting both of the axises on the universal joint to the same value (and axis of zero length?).
Consult the ODE manual for proper usage.
http://opende.sourceforge.net/wiki/index.php/Manual_%28Joint_Types_and_Functions%29#Universal

I think your right. I looked at the manual(and the Panda3D API Reference), and came up with this:

        head_joint_pos = []
        larm_joint_pos = []
        lleg_joint_pos = []
        rarm_joint_pos = []
        rleg_joint_pos = []

        for index, val in enumerate(self.world.element[self.name + '_torso'].brick.coords):


            head_joint_pos.append(val - self.world.element[self.name + '_head'].brick.coords[index])
            larm_joint_pos.append(self.world.element[self.name + '_larm'].brick.coords[index])
            lleg_joint_pos.append(self.world.element[self.name + '_lleg'].brick.coords[index])
            rarm_joint_pos.append(self.world.element[self.name + '_rarm'].brick.coords[index])
            rleg_joint_pos.append(self.world.element[self.name + '_rleg'].brick.coords[index])

        joint1 = OdeHingeJoint(get_phys_world())
        joint2 = OdeHingeJoint(get_phys_world())
        joint3 = OdeHingeJoint(get_phys_world())
        joint4 = OdeHingeJoint(get_phys_world())
        joint5 = OdeHingeJoint(get_phys_world())

        joint1.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_larm'].phys_obj.body)
        joint2.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_rarm'].phys_obj.body)
        joint3.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_lleg'].phys_obj.body)
        joint4.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_rleg'].phys_obj.body)
        joint5.attach(self.world.element[self.name + '_torso'].phys_obj.body, self.world.element[self.name + '_head'].phys_obj.body)

        joint1.setAxis(0, 1, 0)
        joint1.setAnchor(larm_joint_pos[0], larm_joint_pos[1], larm_joint_pos[2])

        joint2.setAxis(0, 1, 0)
        joint2.setAnchor(rarm_joint_pos[0], rarm_joint_pos[1], rarm_joint_pos[2])

        joint3.setAxis(0, 1, 0)
        joint3.setAnchor(lleg_joint_pos[0], lleg_joint_pos[1], lleg_joint_pos[2])

        joint4.setAxis(0, 1, 0)
        joint4.setAnchor(rleg_joint_pos[0], rleg_joint_pos[1], rleg_joint_pos[2])

        joint5.setAxis(0, 0, 1)
        joint5.setAnchor(head_joint_pos[0], head_joint_pos[1], head_joint_pos[2])

And it looks like this:

Basically, I change the joints to hinge joints, and set proper anchors.

Thanks! I don’t think I would have thought to look at the actual ODE manual!

Now I will go to the actual API’s manual, in the future, to prevent a repeat of this problem…[/img]