RoboDK Forum
Create target from a txt file- Printable Version

+- RoboDK Forum (//m.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//m.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//m.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Create target from a txt file (/Thread-Create-target-from-a-txt-file)



Create target from a txt file-95kvdko-12-03-2019

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.


RE: Create target from txt-Jeremy-12-03-2019

Hi there,

This piece of Python code should help you create your target:

Code:
# Name of the reference frame to be use
帧= RDK。项目(“框架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.

希望它可以帮助。
Jeremy


RE: Create target from txt-95kvdko-12-04-2019

(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
帧= RDK。项目(“框架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.

希望它可以帮助。
Jeremy

Hi Jeremy,

It has worked perfectly! Thank you for your quick response.

Regards,
Kevin


RE: Create target from txt-bender-06-02-2021

(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
帧= RDK。项目(“框架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.

希望它可以帮助。
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?

[attachment=2212]

[attachment=2213]

Best regards,
bender


RE: Create target from txt-Vineet-06-02-2021

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''


RE: Create target from txt-bender-06-10-2021

(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 wasnotlike 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 :).