problem with my actor coordinates

Hello, I am trying to create a model of a robot which can select parts of its body and move them and then the robot will move them according to what the user has done.

My problem comes with the movements of the robot parts.

The design of the robot is created with Blender and then passed to .egg, in the design I created a skeleton with its joints to be able to use them and move the robot parts.

First of all I think that each of the joints has its own local coordinates. I think they are the ones they had when creating joints in Blender, I think this is normal.

My problem is when I move the shoulder of the robot in this case, I move it up, and for that, doing tests I do self.controlhombro.setR (90), since bone is parallel to the ground and the axis of rotation is Y.

The arm goes up well but now when I want to open the arm with another joint it seems as if the local coordinate axes of this joint have been deformed, I try to make a turn on the X axis that is the one that allows me to open and close the arm Blender) and the arm opens diagonally.

Putting self.controlbrazo.setP (90) rotates me diagonally doing odd things, instead if I use self.controlbrazo.setP (self.controlbrazo, 90) it seems to keep the coordinates without deforming.

I put some code to see if anyone can give me a little light.

Thank you

self.pandaActor = Actor("models/rapiroojorojoconesqueletofinal4.egg")
            self.pandaActor.setScale(0.05,0.05,0.05)
            self.pandaActor.setPos(0, 0, 0.5)
            self.pandaActor.reparentTo(self.render)
            self.controlhombro = self.pandaActor.controlJoint(None, "modelRoot", "hombro_L")
            self.controlbrazo=self.pandaActor.controlJoint(None, "modelRoot", "brazo_L")

            self.parentnode = self.render.attachNewNode('camparent')
            self.parentnode.reparentTo(self.pandaActor)
            self.parentnode.setEffect(CompassEffect.make(self.render))

            self.camera.reparentTo(self.parentnode)
            self.camera.lookAt(self.parentnode)
            self.camera.setY(-198.0)     
            self.parentnode.setHpr(-448.99999999976717, -359.0000000000291, 0)

            self.accept("h",self.saludo)

            direccional1 = DirectionalLight('mi luz')
            direccional2 = DirectionalLight('mi luz2')
            direccional1NP = self.render.attachNewNode(direccional1)
            direccional2NP = self.render.attachNewNode(direccional2)
            direccional1NP.setHpr(180,-20,0)
            direccional2NP.setHpr(0, -20, 0)
            self.render.setLight(direccional1NP)
            self.render.setLight(direccional2NP)

            def saludo(self):
                 self.controlhombro.setR(90)
                 self.controlbrazo.setP(90)

I would like to know if there is any method to know the orientation of the coordinate axes of the joints, and to know if after moving a joint, the joint that hangs from it also has moved or has its orientation rotated.

1 Like

Here is my blender design, the bone in yellow is the joint brazo_l that is controlling by self.controlbrazo.
The shoulder is the next left bone that is controlling by self.controlhombro:

when i write :

self.controlhombro.setR(90) the actor do the right thing, he rotetes the joint 90 in the Y axi:

Then i do self.controlbrazo.setH(90) that should rotate the joint (brazo_L) in the X axi (as is in Blender design) but it rotates like this :

It is like the local axis of the second joint has changed and

Well, I’ve been researching and I know how to fix the problem.

What I’m going to do is move each of the Joints manually indicating that I want to do it on its own coordinate axis using setH (Nodepatch, whatever).

My problem is that I need to know the initial rotation position and the current position of each joint and using GetH (Nodepatch) gives me 0 result, whatever it does gives me 0.

I have tried to go moving the Joint using SetH (nodepatch, nodepatch + 1), with this the Joint is moving correctly but I can not know in which position it is.

I’m doing it through a little bad technique and it’s with a counter, if I want to move the arm 90 degrees what I do is add +1 to a counter and if it reaches 90 I know I’ve moved the Joint 90 degrees, but it’s very Wrongly scheduled as well.

Does anyone know how to get the angle of rotation of a joint in its own coordinate system?

Thank you.