Urscript move single joint angle of a specific angle instead of set coordinate position

Here’s a script I wrote a while ago for a UR5e – I’m assuming I tested it and it worked . . . . .

It lets you rotate a specified joint TO a specified angle:

def move_joint(joint_num, angle_deg):

global move_pos= get_actual_joint_positions()
angle_rad = angle_deg*3.14159/180
move_pos[joint_num]=angle_rad
movej(move_pos, a=0.5, v=0.4)

end

By changing the angle definition slightly, this should let you change the angle of a specified joint BY a specified angle:

def move_joint(joint_num, angle_deg):

global move_pos= get_actual_joint_positions()
angle_rad = move_pos[joint_num] + angle_deg*3.14159/180
move_pos[joint_num]=angle_rad
movej(move_pos, a=0.5, v=0.4)

end