Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

How to get target position and orientation or rotation using the API

#1
Code:
I have programmed as:
#1. Connect to RoboDK using the Robolink module:
from robolink import *
# Connect to RoboDK
RDK = Robolink()
#2. Get the target using the `Item` method and specify the name of the target:
# Get the target
target = RDK.Item('상1_T0')
#3. Get the pose of the target using the `Pose` method:
# Get the pose of the target
pose = target.Pose()
#4. Extract the position and rotation data from the pose:
# Extract the position data
x, y, z = pose.Pos()
# Extract the rotation data
rx, ry, rz = pose.Rot().Euler()
#5. Print the position and rotation data:
# Print the position data
print('Position: X={}, Y={}, Z={}'.format(x, y, z))
# Print the rotation data
print('Rotation: RX={}, RY={}, RZ={}'.format(rx, ry, rz))

But I have an error when running this line:
rx, ry, rz = pose.Rot().Euler()
AttributeError: 'Mat' object has no attribute 'Rot'. Did you mean: 'Row'?

I can not resolve this, please help me.
#2
You can use one of the following functions to convert a pose to position and Euler orentation values:
  • Pose_2_TxyzRxyz
  • Pose_2_ABB
  • Pose_2_Adept
  • Pose_2_KUKA
  • Pose_2_Motoman
  • Pose_2_Nachi
  • Pose_2_Staubli
These fuctions return 6 values: X,Y,Z,A,B,C, where X,Y,Z are the position coordinates: same as pose.Pos(). And A,B,C are the Euler rotation angles based on the Euler format used by the robot controller of your choice. Note that different manufacturer use different Euler notation formats. You can learn more about Euler angles here:
https://robodk.com/doc/en/Basic-Guide.html#RefFrames

There are also more functions that provide orientation in a different notation such as Quaternion (pose_2_quaternion) or UVW vector (Pose_2_UR), but these 2 last notations are not of type Euler.

You can find more information about the Pose_2_TxyzRxyz function here:
https://robodk.com/doc/en/PythonAPI/robo...2_TxyzRxyz
  




Users browsing this thread:
1 Guest(s)