Linear move with rotating last axis on a UR3
Example is valid for:
CB3 Software version: 3.3.3.292
Note that older or newer software versions may behave differently.
This example can be used for UR CB3
In some application (e.g. polishing) it's needed that the robot should move in a normal linear movement with a rotation of the last axis (Wrist 3). Therefore the attached script-file that includes the script function rotate2target could be used. The also attached urp-example explains how the script function could be used.
Script Syntax
The function rotate to target contains the following syntax:
rotate2target(target_position, rotation_speed, linear_speed, linear_acc)
where,
target_position is the position in karthesian space wehre the TCP should move to,
rotation_speed defines the roation speed of wrist 3 in °/s,
linear_speed defines the Tool speed in mm/s, and
linear_acc defines the accelartion of the Tool in mm/s²
Note: The accelaration of the rotation will be calculated by the value rotation_speed and the relation of linear_speed and linear_acc.
Script function rotate2target:
def rotate2target(target,rot_speed,linear_speed,linear_acc):
linear_speed=linear_speed/1000
linear_acc=linear_acc/1000
act_pos=get_actual_tcp_pose()
dist=point_dist(act_pos,target)
dt_a=linear_speed/linear_acc
ds_a=(linear_acc/2)*pow(dt_a,2)
dt_v=(dist-(2*ds_a))/linear_speed
rot_acc=d2r(rot_speed)/dt_a
time=dt_a+dt_v
direction=pose_sub(target,act_pos)
xyz_movement=sqrt(pow(direction[0],2)+pow(direction[1],2)+pow(direction[2],2)) sp=linear_speed/xyz_movement
speed_vec=[sp*direction[0],sp*direction[1],sp*direction[2],0,0,d2r(rot_speed)]
speedl(speed_vec,linear_acc,time,rot_acc) stopl(linear_acc,rot_acc)
end
the script function above calculates a vector from the actual TCP-position to the target_position and use this vector the value of linear_speed to calculate a speed vector.
This speed vector will be used inside of the speedl command that accelerates the TCP with this vector into the directon of the target_position. After the speedl command has accelerate the TCP to the value of linear_speed the speedl will hold the robot on that speed until the function will be returned.
The whole time until the speedl will be returned is calculated by the given linear_speed and linear_acc. After the sppedl has returned, a stopl command will be executed that will deaccelerate the TCP by the given linear_acc value. So the way from a Waypoint A to a Waypoint B will be done by a summary of the accelartion- and on-speed-part of the speedl command and the deaccelartion-part of the stopl command.