Script "MoveRelativBase"

Hallo,
I have written a script to move the Robot relativ to the Base feature (see below).
But it works only with offsetz in X,Y,Z. If I want to move relativ in Rx,Ry,Rz the movement
isn`t what I expect.
What is wrong in my script?

define function

def MovelRelativBase(cpRelativ=p[0,0,0,0,0,0],OffsetX=0,OffsetY=0,OffsetZ=0,OffsetRx=0,OffsetRy=0,OffsetRz=0,)

#################################1.0#################################
#1.0 calculate offset
cpRelativ[0]=cpRelativ[0]+(OffsetX/1000)
cpRelativ[1]=cpRelativ[1]+(OffsetY/1000)
cpRelativ[2]=cpRelativ[2]+(OffsetZ/1000)
cpRelativ[3]=cpRelativ[3]+ d2r(OffsetRx)
cpRelativ[4]=cpRelativ[4]+ d2r(OffsetRy)
cpRelativ[5]=cpRelativ[5]+ d2r(OffsetRz)

#################################2.0#################################
#3.0 Move to point
movel(cpRelativ, a=1.2, v0.25, r=0.0)
end

Regards

Hi Franz…
The UR system uses something called “Axis Angle”, This means that the rotations is not really intuitive, (not that rotations in 3 dimensions really is anyway)…

I would suggest you try using the rpy2rotvec(rpy_vector), which lets you use roll-picth-yaw values instead, which people tent to find more intuitive

The second thing is that you cannot simply add rotational offsets (one rason is because rotations in 3D are not commutative meaning ab != ba ) it might work in simple cases, but not necessarily always.
Therefore the most commen thing is to use the script function pose_trans ex: Pose_offest = pose_trans(base_offset , pose) instead.
or if you need it in the tool frame Pose_offest = pose_trans(pose , offset_tool).

Hi I have test this script:
But it dosesnt refers to the tool feature and not to the base feature:

###define function###
def MovelRelativBase(cpRelativ=p[0,0,0,0,0,0],OffsetX=0,OffsetY=0,OffsetZ=0,OffsetRx=0,OffsetRy=0,OffsetRz=0,)

#################################1.0#################################
#1.0 calculate offset
cpRelativSave=cpRelativ

Rotation=[d2r(OffsetRx),d2r(OffsetRy),d2r(OffsetRz)]
newRotation=rpy2rotvec(Rotation)

cpRelativ=pose_trans(cpRelativSave, OffsetX/1000),OffsetY/1000),OffsetZ/1000),newRotation[0],newRotation[1],newRotation[2]])

#################################2.0#################################
#3.0 Move to point
movel(cpRelativ, a=1.2, v0.25, r=0.0)
end

Sorry but the offset calculation was wrong. Here the correct code:

cpRelativ=pose_trans(cpRelativSave, p[(OffsetX/1000),(OffsetY/1000),(OffsetZ/1000),newRotation[0],newRotation[1],newRotation[2]])