We encountered some problems with the dimension compensation. The first is to compensate the tool offset, and the second is to compensate the workbench's real position in RoboDK.
1. We have a robot that needs to be equipped with lots of tools. Dimensions of the tools should be compensated automatically in the controller, which means that when attached with different tools, the NC code should always be the same.
In our case, we want to realize the compensation in the Post-processor. Is it possible?
2. When we program a toolpath of a workpiece on the workbench, we need to know the relative position between the workpiece and the robot base, due to the installation error. Therefore, we attach a probe to the robot to measure the error. After we get the error, how should we compensate it in RoboDK? Is it correct to set a coordinate system including the error?
(05-09-2025, 11:39 AM)Albert Wrote: Yes, it is possible to customize the post processor to account for different tools. The toolpath can be the same. You can find more information here: https://robodk.com/doc/en/Post-Processors.html#EditPost
You can compensate tools in the post processor. The post processor is aware of the tool, the coordinate system and the target.
If you can share your RoboDK project with different tools we may be able to help you better.
Hi Albert,
thanks for the reply, you can find our RoboDK project in the attachment. The path we would like to test is already established in the project. Because our controller cannot handle the tool offset compensation. As a result, for the same toolpath in RoboDK, by selecting different tools, our postprocessor generates different NC codes corresponding to the tool.
I developped a simple Python Script to cope with it.
Code:
from robodk import *
import re
import math
# 0 -946.175 -68.302 -91.524 29.991 179.238
# 0 -1146.170 278.165 150 0 -180 correct 0 -1296.17 537.973 150 0 -180
# 0 -1096.170 191.562 150 0 -180
# X=-13.824 Y=-1095.172 Z=579.832 Q1=150.194 Q2=3.578 Q3=-182.047
# Euler Angle(ABC,unit:degree)
x = [0,0,-13.824,-27.36,-40.328,-48.087,-48.085,-73.085]
y = [-1146.170,-1096.170,-1095.172,-1092.196,-1087.306,-1083.302,-1083.286,-1126.587]
z = [278.165,191.562,191.562,191.562,191.562,191.554,191.562,278.165]
a = [150,150,150.194,150.787,151.806,152.691,152.688,152.688] # RX
b = [0,0,3.578,7.149,10.702,12.919,12.921,12.921] # RY
c = [-180,-180,-182.047,-183.981,-185.685,-186.590,-186.587,-186.587] # RZ
Tool = [110,0,255,0,90,0]
if Tool[0]==0 and Tool[1]==0:
Tool[3]=Tool[4]=Tool[5]=0
# deg2rad
def deg2rad(angle):
return angle * math.pi / 180.0
# Calculate rotation matrix,Euler sequence:RX-RY-RZ
def euler_to_rotation_matrix(a_deg, b_deg, c_deg):
a = deg2rad(a_deg)
b = deg2rad(b_deg)
c = deg2rad(c_deg)
def mat_mult(A, B):
return [[sum(A[i][k] * B[k][j] for k in range(4)) for j in range(4)] for i in range(4)]
Comp_Matrix = mat_mult(EE_Matrix,Tool_Matrix)
return Comp_Matrix
for i in range (8):
EE_Rotation_Matrix = euler_to_rotation_matrix(a[i], b[i], c[i])
EE_PT_Matrix = Pose_Transformation_Matrix(0,0,0,EE_Rotation_Matrix)
Tool_Rotation_Matrix = euler_to_rotation_matrix(Tool[3],Tool[4],Tool[5])
Tool_PT_Matrix = Pose_Transformation_Matrix(Tool[0],Tool[1],Tool[2],Tool_Rotation_Matrix)
Comp_Matrix = Compensation_Matrix(EE_PT_Matrix,Tool_PT_Matrix)
# print("Rotation Matrix R =")
# for row in EE_PT_Matrix:
# print(["{:+.3f}".format(val) for val in row])
# print("Tool PT Matrix R =")
# for row in Tool_PT_Matrix:
# print(["{:+.3f}".format(val) for val in row])
# print("Tool Compensation Matrix R =")
# for row in Comp_Matrix:
# print(["{:+.3f}".format(val) for val in row])
In my scipt, it reads the NC code and tool dimension, and then generate the Pose Transformation Matrix. By doing so, I can compensate the tool only has offset along axial direction. But for other tools like a spindle which TCP has 90 degree difference from the nominal direction of the end-effector.