Cliff Detection and Avoidance using Range Sensor Layer

Sanjula Thiranjaya
Arimac
4 min readJan 10, 2021

--

In autonomous robotic exploration, two main types of obstacles can be encountered — namely, positive obstacles and negative obstacles. Cliffs are considered to be negative obstacles as the absence of the floor has to be detected as an obstacle. Cliff detection is important in autonomous navigation and exploration to detect and avoid obstacles such as staircases and putholes.

The Basic Idea

In an autonomous mobile robot, one possible way to implement cliff detection and avoidance is to detect cliffs using range sensors and to add the detected cliff data into the existing ROS navigation stack. The range sensor layer in ROS layered costmap model can be used to accomplish this task as it allows to mark obstacles in costmaps using data received from range sensors.

Here, the range sensors which are pointed at the floor are used to detect the absence of the floor. As the range sensor layer marks closer range values as obstacles, if we feed the original data from range sensors to the range sensor layer the floor will be marked as an obstacle. Hence the idea is to invert the data received by range sensors before feeding the data into the range sensor layer. An intermediate node can be implemented in ROS in order to facilitate this inversion.

As shown in the diagram, the distance d2 should be converted to a smaller value so that it will be marked as an obstacle and the distance d1 should be converted to a large value so that it won’t be marked as an obstacle.

Detection of cliffs using tilted range sensors

This article provides a step-by-step guide to integrate cliff detection to ROS navigation stack using the above idea.

Step 1 — Tilt the range sensors to point the IR beam at the floor

This can be done by changing the “pitch” of the joint corresponding to the IR sensor. In this case the pitch is set to be 0.15 radians.

Now the IR sensor messages will contain the distance at which the floor is detected. (Note that this distance vary according to the pitch of the IR sensor joint.)

Step 2— Create a package to contain the ROS node.

Functional block diagram for Cliff_data package

Initiate a package named as ‘cliff_data’ and create the src/cliff_data_node.cpp file within the newly initiated cliff_data package.

The node should subscribe to the topic published by the range sensors and it should publish the inverted range sensor readings. Hence the node should act as a subscriber as well as a publisher. Code for the used ROS node can be found here.

The data inversion is done using the following method inside the ROS node.

Step 3— Creating the parameter file.

Parameters that has to be tuned can be loaded into the ROS parameter server using a .yaml file. This can be very useful as it eliminates the need to build the workspace every time a parameter is changed.

Create the param/cliff_param.yaml file within the cliff_data package.

Step 4— Creating the launch file.

Launch files specifies the parameters to set and the nodes to launch in the ROS package.

Create the launch/ir_to_cliff.launch file within the cliff_data package.

Now the package responsible cliff detection is complete. Final package structure should be as following.

Step 5— Creating a new range sensor layer with inverted range data.

A new range sensor layer can be created by adding the following code block to the costmap_common_parameter.yaml file in the ROS navigational stack. This new layer should subscribe to the inverted range messages published by the aforementioned node.

Step 6— Adding the new range sensor layer to costmaps.

The newly created range sensor layer can be added to the local and global costmaps as a plugin.

Step 7— Building the workspace and launching the node.

Now the integration of cliff detection and avoidance into the ROS navigational stack is complete. Remember to save all the modified files and to build the workspace before launching the nodes. After launching the ROS navigational stack, the node responsible for data inversion can be launched using the following command.

$ roslaunch cliff_data ir_to_cliff.launch

Results

Following are some results obtained after implementing this cliff detection and avoidance method using Gazebo. The complete workspace used to generate the results can be cloned from here.

Cliff Detection and Avoidance

--

--