retaining hpr with controlJoint

Hello, I am working with controlJoint to implement procedural animations. I want the joints to retain their initial hpr after implementing controlJoint (controlJoint sets the joint to T-pose orientation). Problem is, when the joint is re set to the initial hpr, the result is incorrect and seemingly random. The result also seems to differ from joint to joint.

I am attempting to first store the hpr data of a joint as a variable, set joint as controlJoint, then set current hpr as initial hpr.

#expose joint
    self.l_elbow = self.eve.exposeJoint(None, 'modelRoot', 'l_elbow')

#get initial HPR
    self.l_elbow_origHpr = self.l_elbow.getHpr()

#set as control joint
    self.l_elbow = self.eve.controlJoint(None, 'modelRoot', 'l_elbow')

#set to initial hpr
    self.l_elbow.setHpr(self.l_elbow_origHpr )

Can anyone shed some light on this issue?

Much thanks in advance.

exposeJoint() and controlJoint() do not operate in the same coordinate space, unfortunately. controlJoint() always receives the local transform of the joint itself. However, exposeJoint(), by default, exposes the net transform of the joint and all of the parent joints as well. So they won’t match.

However, you can force exposeJoint() to give you the local transform, by passing localTransform = True to the exposeJoint() call. Then you can use the value of the exposed joint’s transform as the initial value for controlJoint().


Thanks for the fast response.

Ok i reassessed my problem and the real issue is that joints which implement controlJoint() override the animation. Let me explain:

What I have is a looping 2-frame idle animation and I am adding some perlin noise to certain joints for realistic movement. So when I use controlJoint(), I want the joint to retain the hpr from the animation. This way I will have the idle animation + perlin noise movement.

The problem is that controlJoint() overrides the animation back to the default pose of the skeleton. Is this correct? And is there a way to set the hpr to the correct rotation? Trying the method for your last reply does not seem to move the joint at all.

Maybe there is a better way, but what I do is add a dummy joint in the rig as the parent of the joint I want to offset then I do controlJoint on that dummy joint and leave the original one alone.

I agree with teedee’s suggestion. This is how we have solved similar problems.


I’m sorry but I do not understand how parenting to a dummy joint will solve this problem. To control the dummy joint wont I again have to use controlJoint()? Which would mean running into the exact same problem again.

Right, but then you won’t mind that controlJoint() completely replaces the source animation, because the dummy joint has no animation anyway. It will still inherit the source animation from its parent joints.


Ok so if I understand correctly, the parenting of the joint to the dummy joint is all done in the modeling program (blender for me). If this is so, I am wondering how this can be achieved. At least in blender, a bone can only have one parent, so parenting a bone to a dummy would break the existing parent hierarchy in my skeleton.

I tried another approach where I created the dummy bones in blender, then I tried to reparent the joint to its dummy in the panda code. But this did nothing.

This is a tricky problem, could I be doing something wrong?

Yes you need to change the hierarchy. In Blender, parent the dummy joint in the same place as the animated one, then reparent the animated joint under the dummy. This way when you take control of the dummy it will move the child node (the animated joint) with it.

Yes, but if i connect a joint to the dummy joint, say, the wrist joint, then it will no longer be connected to the forearm. I cannot have a wrist joint that is disconnected the forearm it in the skeleton. I cannot have them be disconnected because I am also doing animation blending, and disconnected joints result in undesired drifting-joints when two animations are blended.

Is there any way to do this without disconnecting one joint from the one preceding it in the skeleton?


ok i got it to work, but using a different method. I added another (very tiny) bone in between each bone i wanted to control and its preceding bone in the skeleton. This way you can parent the joint to the dummy and leave the bones connected.

The whole process is quite hacky, but it seems to work for now.


Yes, this is the same method, maybe I explained it a bit confusingly.