Universal Robots Forum

Orientation of tool based on sensor input


I’m trying to orient the tool based on the orientation of the box with the help of a photoelectric sensor(laser type).

Can someone help me with this on how I can identify the orientation of the box and orient my tool also based on the box orientation?


Based on my interpretation of your scenario, my first approach would be the following:

  1. Move to some set waypoint, let’s call it waypoint_1, near the box where your sensor is capable of determining the box orientation.

  2. Assign a variable, let’s call it var_1, equal to a mathematic equation that will use your sensor input to determine the relationship between waypoint_1 and the box.

  3. Define a pose, let’s call it box_pose, using info from var_1. So if you’re sensor and var_1 were helping determine a rotation, you would have box_pose := [0,0,0,0,0,var_1].

  4. Assign another variable, we’ll call it box_point, using pose_trans() to transform waypoint_1 with box_pose. That would look like box_point := pose_trans(waypoint_1, box_pose).

  5. Add a variable waypoint, and select box_point as the variable.

The resulting waypoint would be the original waypoint 1, with a rotation around the tool z axis equal to var_1.

You can also consolidate steps 2 and 3, and do the math right inside the pose list.

Hopefully this is helpful. Let me know if you were looking for something else.

Thanks for your reply.

I have tried it and I got the orientation but the x_offset and y_offset keep on changing every time the orientation of the box gets change.

How I can maintain the same offset with respect to the different orientations of the box?

I’m detecting the edges of the box with the sensor and based on that I’m calculating the offset.
When the box is not oriented, the x_offset and y_offset works fine but whenever the box orientation gets change then these offsets don’t work even though the tool is oriented correctly.

Can you please help me with this?

Are you only making offsets in x-y-z, or are you also making rotational changes?

If you’re making rotation changes, is it only in the tool z axis?

What are you using as a sensor to detect the box position?


I’m using a photoelectric sensor (laser type) to detect the edges of the box.

I will tell you my application which I’m working on so the UR robot will be mounted on an AMR(autonomous mobile robot). The AMR will not come to the exact position every time because of it’s positional repeatability and orientation repeatability.

So I’m using this sensor to detect the box edges and based on that I’m getting the actual TCP value and based on the mathematical calculation I’m getting the orientation.

I’m only making the offset in the X-axis, Y-axis and I’m also doing some rotational changes based on the box orientation because if the box is at different orientation and if I don’t align the gripper properly then it will unable to pick up the box.

Can you please help me with this or can you suggest some other solution?