Rotation

Recently discovered a problem that is quite large relating to my project.

Initially I create RevoluteJoints:

worldJoint = new RevoluteJoint.
worldJoint link parent 0 to-child robotPart{0}
with-parent-point (0, 0, 0) with-child-point (0, -.5, 0) with-normal (0, 1, 0).

revoluteJoint{1} link parent robotPart{2} to-child robotPart{3}
with-parent-point (0, point1, 0) with-child-point (0, point2, 0) with-normal (0, 0, 1).

revoluteJoint{2} link parent robotPart{5} to-child robotPart{6}
with-parent-point (0, point1, 0) with-child-point (0, point2, 0) with-normal (0, 0, 1).

All of these are stacked on top of each other. The problem arises after these two commands:

# Rotate the base 1.57 radians about the Y-axis
robotPart{0} relative-rotate around-axis axis by radians. (where I pass in axis to be (0, 1, 0) and radians 1.57)

# Rotate the arm .785 radians about the old X-axis
robotPart{3} relative-rotate around-axis axis by radians. (where I pass in axis to be (0, 0, 1) and radians 1.57)

If I execute the second statement without doing the first statement, the arm moves the specified amount and stops. It's only after I do the first and then the second statement does the arm get momentum and does not stop moving.

My question is how can I fix this momentum or what is the best way to simulate a robot that can turn about the Y-axis at the base and two links that go about the X-axis? It seems to me that after you rotate 90 degrees about the Y, the Z-axis becomes the X-axis. It should be notes the user can rotate any amount of degrees about the Y and both X-axis.

Thank you.