Main Content

Obtain Collision Data for Manipulator Collision Checking

This example shows three ways to obtain a rigidBodyTree model with collision data. To see more in-depth examples that check for self-collisions or environment collision detection, see these other examples:

URDF Import

Many robots come with collision meshes or primitives specified in the Unified Robot Definition Format (URDF) file.

The KUKA® IIWA robot comes with a set of collision meshes which are simplified versions of the visual meshes. Call the importrobotfunction to generate a rigidBodyTree object from the URDF file. Set the output format for configurations to "column".

iiwa = importrobot("iiwa14.urdf");
iiwa.DataFormat = "column";

Visually inspect the collision meshes of the robot.


Check for Self-Collisions at a Specified Configuration

Specify a configuration that has a self collision. The checkCollision function indicates whether a robot is colliding with itself in a particular configuration. Visualize the configuration.

config = [0 -pi/4 pi 0.9*pi 0 -pi/2 0]';
ans = logical


Load Provided Models

Robotics System Toolbox™ provides common robot models with collision data accessed using the loadrobot function.

kukaIiwa14 = loadrobot("kukaIiwa14","DataFormat","column");
ans = logical

config = [0 -pi/4 pi 0.9*pi 0 -pi/2 0]';

Visualize the robot with the collision meshes visible.


Adding Individual Collision Obects

The addCollision function enables you to add collision objects to any rigid body on the robot as basic shapes (box, sphere,cylinder). You could build your entire robot with these collision geometries, but this is generally less accurate than higher fidelity mesh definitions.

For this example, notice that the loaded IIWA robot model is missing a gripper. Add a gripper made of collision primitives to the iiwa_link_ee body on the robot.


Visualize the robot. Notice the gripper is attached.