Tool Contact example
Univeral Robots’ tool contact mode allows detecting collisions between the robot’s tool and the environment and interrupting motions when that happens. This example demonstrates how to use the tool contact mode to detect collisions and stop the robot.
As a basic concept, we will move the robot linearly in the negative z axis until the tool hits something or the program’s timeout is hit.
At first, we create a initialize a driver as usual:
We use a small helper function to make sure that the reverse interface is active and connected before proceeding.
When a tool contact is detected, a callback will be triggered. For that we define a function to handle this event:
This function is registered as a callback to the driver and then tool_contact mode is enabled:
Once everything is initialized, we can start a control loop commanding the robot to move in the negative z direction until the program timeout is hit or a tool contact is detected: