RoboDK Forum
Python API来移动/Rotate in the tool frame- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Python API to Move/Rotate in the tool frame (/Thread-Python-API-to-Move-Rotate-in-the-tool-frame)



Python API来移动/Rotate in the tool frame-edon-03-27-2020

In RoboDK GUI it is possible to choose "Tool Frame" and then using the virtual knob one can change the position and rotate accordingly.

I need this functionality to retract/approach the welding torch from the start welding point


RE: Python API to Move/Rotate in the tool frame-Jeremy-03-27-2020

Hi Edo,

I'm not so sure that I'm following you.

引用: In RoboDK GUI it is possible to choose "Tool Frame"


Do you mean in a "Curve follow project" or just by double-clicking the tool in the station?


引用: I need this functionality to retract/approach the welding torch from the start welding point

As I'm not so sure what you mean in the first sentence, this one doesn't make sense to me.
Could you add a print screen showing what you do with the GUI? It would help us help you.

Jeremy


RE: Python API to Move/Rotate in the tool frame-edon-03-27-2020


In the figure you can see the steps of making the welding gun retract from the weld position:
1/ choose the ToolFrame
2/ Set to axis Z
3/ Turn the knob
4/ Result is that the welding gun will retract in the tool -Z direction

I want to do the same thing but with Python API.

I know I can calculate the tools position and get the angles compare to the reference frame, but for sure you have some build-in command to do this.

I hope this clears my question.

Regards,
Edo


RE: Python API to Move/Rotate in the tool frame-Albert-03-30-2020

Hi Edo,

I recommend you to use the RelTool function:
//www.sinclairbody.com/doc/en/PythonAPI/robodk.html#robodk.Mat.RelTool
It is very similar to ABB's RelTool function in Rapid.

You can take a look at the source code to better understand how to do such transformations:
Code:
def RelTool(target_pose, x, y, z, rx=0,ry=0,rz=0):
"""Calculates a relative target with respect to the tool coordinates. This procedure has exactly the same behavior as ABB's RelTool instruction.
X,Y,Z are in mm, W,P,R are in degrees."""
new_target = target_pose*transl(x,y,z)*rotx(rx*pi/180)*roty(ry*pi/180)*rotz(rz*pi/180)
return new_target

Albert


RE: Python API to Move/Rotate in the tool frame-Jeremy-03-31-2020

Hi Edo,
Thanks for the clarification.
Albert's answer is your goto here.

Jeremy