All Collections
xArm-Python/C++ SDK
Guide to use set_position_aa and servo_cartesian_aa interfaces
Guide to use set_position_aa and servo_cartesian_aa interfaces
W
Written by Wang Daniel
Updated over a week ago

Angle-Axis(Rx/Ry/Rz) and Roll-Pitch-Yaw(RPY) are two different ways to represent the tool center point(TCP) attitude.

Roll/Pitch/Yaw:

sequentially rotates around the X/Y/Z axis of the reference coordinate system (base coordinate system) by three angles(roll, pitch, yaw) respectively.

Angle-Axis:

also uses 3 values for attitude representation (but not as three rotation angles), which is the product of a three-dimensional rotation vector [x, y, z] and the rotation angle[phi (scalar)].

How to choose between Axis-Angle and RPY:

1. If you are more familiar with Quaternion representation, it is recommended to use Angle-Axis instead of RPY, angle-axis has similar meanings with quaternion and transfer between these two can be calculated easily.

2. In relative motions which only involve Attitude(orientation) change, giving a command in Axis-Angle has an advantage over the RPY representation, the motion can be more intuitive and predictable.

Check out the example code and video:

set_position_aa (axis_angle_pose=[0,0,0,100,0,0], relative=True, is_tool_coord=False, is_radian=False):
- the robot TCP will change its orientation by rotating along X+ axis of base coordinate by 100 degrees, No matter what the starting orientation is.

(If "is_tool_coord=True", TCP will rotate along X+ axis of tool coordinate.)

However, relative attitude motion in RPY is not intuitive. As shown in the video, if only change roll angle and leaving pitch and yaw (non-zero) the same, the motion is always not predictable. For accurate attitude change, you have to use Rotation matrices to calculate first and then transfer back to target RPY angles. Please note set_position() interface uses RPY representation.

Appendix

set_position_aa.py

import os

import sys
import time
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
from xarm.wrapper import XArmAPI
arm = XArmAPI('192.168.1.xxx')
arm.motion_enable(enable=True)
arm.set_mode(0)
arm.set_state(state=0)
time.sleep(1)

arm.set_position(398.7,0,185.1,-167.9,44.7,92.4)
#test roll, roll+100
arm.set_position_aa(axis_angle_pose=[0,0,0,100,0,0],relative=True,wait=True, is_radian=False)
#test roll, roll-100
arm.set_position_aa(axis_angle_pose=[0,0,0,-100,0,0],relative=True,wait=True, is_radian=False)

set_servo_cartesian_aa.py

import os

import sys
import time
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
from xarm.wrapper import XArmAPI
arm = XArmAPI('192.168.1.XXX')
arm.motion_enable(enable=True)
arm.set_mode(0)
arm.set_state(state=0)
time.sleep(1)

#go to start position
print(arm.set_position(398.7,0,185.1,-167.9,44.7,92.4),wait=True)
time.sleep(0.5)

#set to mode 1
arm.set_mode(1)
arm.set_state(state=0)
time.sleep(1)
#test move pitch continually, roll+90
rp=0.2
for i in range (450):
time.sleep(0.005)
print(arm.set_servo_cartesian_aa([0,0,0,0,rp,0],relative=True,wait=False,is_radian=False))
print("i=",i,"rp",rp)

Did this answer your question?