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.
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.