Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create target from a txt file
#1
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.
#2
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
#3
(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
#4
(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
#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''
#6
(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 :).
  




Users browsing this thread:
2 Guest(s)