Python API: rotation relative to toolhead

Hello,
I have a project where the xarm5 follows a position (3d vector coming from other applications via OSC) in absolute coordinate space in realtime using arm.set_mode(7). This works very well for movements where roll/pitch/yaw are staying at the default value:

# postion pos being an array with the vector coordinates
arm.set_position(x=pos[0], y=pos[1], z=pos[2], roll=-180,
                 pitch=0, yaw=0, speed=speed, wait=False)

Now I want to add a rotation to the toolhead. However, working with roll/pitch/yaw in absolute space gets me in trouble pretty fast. Can I break up the movement into an absolute positional move and a relative rotation like so:

# postion pos being an array with the vector coordinates
arm.set_position(x=pos[0], y=pos[1], z=pos[2], speed=speed, wait=False)

# postion rpy being an array with the rpy values
arm.set_position(roll=rpy[0], pitch=rpy[1], yaw=rpy[2], speed=speed, relative=True, wait=False)

Am I missing something? Unfortunately I don’t have a working xarm in front of me right now. I thought I’d need more advanced inverse kinematics to do that but then I saw this VR Controlled Robotic Arm - xArm7 and it seems to be possible to do everything I need with what the API offers.

Basically the functionality of what’s shown in the video is what I’m after.

Hi Nifihek,

Due to the robot configuration, for xArm5, the actual flexible degrees of freedom of linear and circular motions in Cartesian space is 4, which means you need to make sure the end flange is level during TCP movement with xArm5.

2 suggestions:

  1. You can use joint motion instead with xArm5.
  2. Use xArm6/xarm7 instead.

Best regards,
Minna

Hi Minna, thanks for the reply. We have multiple xArm5, so I need to find a solution that works with what we have. Could you point me in the right direction regarding the joint motion?

If I want to do set_servo_angle I need to use get_inverse_kinematics to translate my pose into servo angles, right?

But then I have the same problem I had before: I need to pass the full pose into inverse kinematics: position and rpy. Isn’t it possible with the API to say: keep the toolhead position but change the pitch value and the api figures out the motion planning?

Hi Nifihek,

We did do the IK internally, if the end tool is not level, we can’t get the solution due to limitations of the xarm5 configuration and mathematics.

Please try joint motion, or you can choose to upgrade xArm5 to xArm6. If you want, please provide the SN to support@ufactory.cc

Best regards,

Thanks Minna,
ok, I understand some of it. But in your first post you suggested I can try to use joint motion instead. Do you mean without tracking the exact position? Like in the API examples?

arm.set_servo_angle(servo_id=1, angle=90, speed=speed, wait=True)
print(arm.get_servo_angle(), arm.get_servo_angle(is_radian=True))
arm.set_servo_angle(servo_id=3, angle=-60, speed=speed, wait=True)
print(arm.get_servo_angle(), arm.get_servo_angle(is_radian=True))
arm.set_servo_angle(servo_id=2, angle=-30, speed=speed, wait=True)
print(arm.get_servo_angle(), arm.get_servo_angle(is_radian=True))
...

Regarding xArm6 or xArm7: would the code I have in my first post work with one of those robots?

Hi Nifihek,

Yes, you are right, you can try set_servo_angle like this, and the code should work in xArm6/7.

Best,