Posts: 5
Threads: 3
Joined: Dec 2019
Reputation:
0
12-03-2019, 04:30 PM
(This post was last modified: 06-27-2021, 09:27 AM by Albert.)
Hi everyone,
I want to know the possibilities of communication between Python and RoboDK. I'm doing a simulation in RoboDK and i want to move the robotic arm ur5e to a desired target (using Python). I have a python program which generates the position (x, y, z) and export it to a txt file. I want to know if there is an option to create a target from this coordinates in python and import it to RoboDK or just import the coordinates from the txt file to a target in RoboDK.
Thanks in advance,
Regards.
Posts: 1,829
Threads: 2
Joined: Oct 2018
Reputation:
74
Hi there,
This piece of Python code should help you create your target:
Code: # Name of the reference frame to be use
frame = RDK.Item('Frame Name')
# Create new target at [0,0,0] (XYZ) from reference frame
Target = RDK.AddTarget('Target name ' + str(target_number), frame)
# Offset the new target position
Target.setPose(Offset(eye(), pos_X, pos_Y, pos_Z, rot_X, rot_Y, rot_Z))
Remember that you also need the orientation of the target.
Simply using [X,Y,Z] is a point, not a target.
Hope it helps.
Jeremy
Posts: 5
Threads: 3
Joined: Dec 2019
Reputation:
0
(12-03-2019, 07:31 PM)Jeremy Wrote: Hi there,
This piece of Python code should help you create your target:
Code: # Name of the reference frame to be use
frame = RDK.Item('Frame Name')
# Create new target at [0,0,0] (XYZ) from reference frame
Target = RDK.AddTarget('Target name ' + str(target_number), frame)
# Offset the new target position
Target.setPose(Offset(eye(), pos_X, pos_Y, pos_Z, rot_X, rot_Y, rot_Z))
Remember that you also need the orientation of the target.
Simply using [X,Y,Z] is a point, not a target.
Hope it helps.
Jeremy
Hi Jeremy,
It has worked perfectly! Thank you for your quick response.
Regards,
Kevin
Posts: 2
Threads: 0
Joined: May 2021
Reputation:
0
06-02-2021, 01:09 PM
(This post was last modified: 06-02-2021, 01:13 PM by bender.)
(12-03-2019, 07:31 PM)Jeremy Wrote: Hi there,
This piece of Python code should help you create your target:
Code: # Name of the reference frame to be use
frame = RDK.Item('Frame Name')
# Create new target at [0,0,0] (XYZ) from reference frame
Target = RDK.AddTarget('Target name ' + str(target_number), frame)
# Offset the new target position
Target.setPose(Offset(eye(), pos_X, pos_Y, pos_Z, rot_X, rot_Y, rot_Z))
Remember that you also need the orientation of the target.
Simply using [X,Y,Z] is a point, not a target.
Hope it helps.
Jeremy
Hi all,
the code almost works, but in my case the values for rot_X to rot_Z in the roboDK target differs from the python printed values. does anybody know why this happens?
Best regards,
bender
Posts: 66
Threads: 0
Joined: Jan 2021
Reputation:
5
Hello
Try changing the orientation angle order from the drop down menu, it should be X, Y, Z. Right now you are viewing: Z,Y',X''
Posts: 2
Threads: 0
Joined: May 2021
Reputation:
0
(06-02-2021, 01:25 PM)Vineet Wrote: Hello
Try changing the orientation angle order from the drop down menu, it should be X, Y, Z. Right now you are viewing: Z,Y',X''
Hi,
to show the correct values in RoboDK that might help. However, the target orientation from the imported targets was not like the original orientation (which comes from kuka .dat file) when I just used this function:
Code: Target.setPose(Offset(eye(), x, y, z, a, b, c))
First I had to convert the XYZABC with KUKA_2_Pose(XYZABC) function:
Code: Target = RDK.AddTarget('Target ' + str(i), frame)
XYZABC = [x, y, z, a, b, c]
Pose = KUKA_2_Pose(XYZABC)
Target.setPose(Pose)
Now it works perfectly. Thanks for your help :).
|