Child not rotating according to parent
I have a articulated arm with 3 joints and a rotating base. All rotations are provided by the MLAgents Python API as continuous vector actions.
The base and all pivots have the scale (1,1,1). As no arm is a parent of another object, the scale of these shouldn't affect anything.
Manually moving these joints (Heuristically) and by manually changing rotations in the inspector makes the arm move as expected. However when running in training mode, the first joint is not rotated according to the base. When pausing the program mid training, the base has some rotation and the child has from somewhere also gotten a y-rotation. Setting this to 0 sets the child into the correct rotation (as expected as this is the rotation relative to the parent).
This is the code that rotates each joint:
float arm1rot = Mathf.Clamp(vectorAction[1], 0, 1f);
float arm2rot = Mathf.Clamp(vectorAction[2], 0, 1f);
float arm3rot = Mathf.Clamp(vectorAction[3], 0, 1f);
float baseRot = Mathf.Clamp(vectorAction[0], 0, 1f);
robotBase.transform.rotation = Quaternion.Euler(0, 360 * baseRot, 0);
arm1.transform.rotation = Quaternion.Euler(90 * arm1rot, 0, 0);
arm2.transform.rotation = Quaternion.Euler(90 * arm2rot, 0, 0);
arm3.transform.rotation = Quaternion.Euler(90 * arm3rot, 0, 0);
So from where does this child get its y-rotation from? Are the Quaternion Euler angles not relative to the parent?
Your answer
Follow this Question
Related Questions
Check when rotation of child object has stopped? 0 Answers
Rotate child on z axis 0 Answers
How does child's rigid body affect parent's rigidbody? 1 Answer
Child object not rotating as parent 0 Answers