How to send a command from PC to make universal robot move normal to a given plane in workspace at a gievn point?

I want to make a UR5 robot to be moved to a point at a given orientation. The orientation is given by the normal axis of a given plane in workspace. How can this be done using URScript/From PC over ethernet?

1 Like

Perhaps start here:
https://www.universal-robots.com/articles/ur/interface-communication/remote-operation-of-robots/

You can use the Direction node and select your plane as the Feature. Then you can just select whichever direction corresponds to that plane’s normal. Write this in Polyscope, save the program, and open the script inside a Script node to see how Polyscope uses Pose_trans() to shift relative to a Feature. This will be the script you need to emulate via URScript or what you send via PC.

For example, I have the following plane:
image

Here, Z is normal to my plane. If I want to move specifically up from the plane, that’s Z-.

So in Polyscope I can do this, which will move my TCP 5 inches along the Plane’s normal (straight up). If I had tilted this plane at an angle, and still made Z its normal, then this same line would move it 5 inches along that same angle.

Opening this as scripts results in the following:

def calculate_point_to_move_towards(feature, direction, position_distance):
    local posDir=[direction[0], direction[1], direction[2]]
    if (norm(posDir) < 1e-6):
      return get_target_waypoint()
    end
    local direction_vector_normalized=normalize(posDir)
    local displacement_pose=p[direction_vector_normalized[0] * position_distance,direction_vector_normalized[1] * position_distance,direction_vector_normalized[2] * position_distance,0,0,0]
    local wanted_displacement_in_base_frame=pose_sub(pose_trans(feature, displacement_pose), feature)
    return pose_add(get_target_waypoint(), wanted_displacement_in_base_frame)
  end

Then actually generating the pose is done via the function call below:

towardsPos=calculate_point_to_move_towards(p[-0.14396865671352163,-0.43562006080319216,0.5079997256801482,2.221441469211093,2.221441468947273,-1.6535458124015906E-9], [0.0,0.0,-1.0], 0.12699999916180002)

towardsPos is now a point 5 inches away along Plane_1’s Z- (its normal).

1 Like