# Define the movement distance in the K1 coordinate system
move_distance_x = 0.0 # Move X.X m along the x-axis of K1
move_distance_y = 0.0 # Move X.X m along the y-axis of K1
move_distance_z = 0.1 # Move X.X m along the z-axis of K1
tcp_position = rtde_receiver.getActualTCPPose()
# an example value could look like this: tcp_position = [0.11089816829193276, 0.47492341756375106, 0.6089207876444199, 0.9147791731417009, -1.5661091016471673, 1.5132271359967038]
# Matrix transformation
origin_K1_wrt_K0 = tcp_position[:3] # Origin of the TCP w.r.t. the Robot Base
angles_K1_wrt_K0 = tcp_position[3:6] # Orientation of the origin of the TCP w.r.t. the Robot Base
# Create a rotation matrix based on the angles with scipy transform
rot_K0_to_K1 = tf.Rotation.from_rotvec(angles_K1_wrt_K0)
rot_mat_K0_to_K1 = rot_K0_to_K1.as_matrix()
print(f"Rotation Matrix K0 to K1: {rot_mat_K0_to_K1}")
rot_mat_K1_to_K0 = rot_mat_K0_to_K1.T
# Create the movement vector in the K1 coordinate system
move_vector_K1 = np.array([move_distance_x, move_distance_y, move_distance_z])
# Convert the movement vector from K1 to K0 coordinate system
move_vector_K0 = rot_mat_K1_to_K0 @ move_vector_K1 # This is the original line
print(f"Move Vector K0: {move_vector_K0}", f"Shape of Move Vector K0: {move_vector_K0.shape}")
# Calculate the new TCP position in the K0 coordinate system
new_tcp_position_K0 = origin_K1_wrt_K0 + move_vector_K0
# Move the robot to the new TCP position
rtde_controler.moveL(new_tcp_position_K0.tolist() + [tcp_position[3], tcp_position[4], tcp_position[5]], 0.1, 0.2)
this is a part of my python code for my UR5 CB3. I know the location of an object I want to pick up, relative to the TCP, in this example it is at the position [0,0,0.1] from the TCP. Now I want to transform the location of the object into base frame coordinates, K0. I thought I can use scipy tranform rotation from rotvec. But this makes the robot move in a nonsensical direction, not to a place 10 cm in front of the TCP, as it should. What am I doing wrong ? Are the angles_K1_wrt_K0 not given as a rotvec? are they euler angles? I cant find a definitive description, it always says “these values are the rotation” or something imprecise. Maybe I am doing an other obvious mistake.
Help is highly appreciated!!!