Skip to content

Gazebo ROS Ray Sensors

Bruce Allen edited this page Apr 25, 2020 · 16 revisions

ROS provides Ray sensors along with its other sensors under gazebo_ros_pkgs in its repository at https://github.com/ros-simulation/gazebo_ros_pkgs under gazebo_plugins. A tutorial overview of ROS plugins is at http://gazebosim.org/tutorials?tut=ros_gzplugins. We are interested in Ray-based plugins that produce point cloud messages of type sensor_msgs/PointCloud2 or sensor_msgs/PointCloud.

These ray sensors publish these sensor messages:

  • sensor_msgs/Range: The closest distance in the scan.
  • sensor_msgs/LaserScan: One horizontal scan from the center vertical ray.
  • sensor_msgs/PointCloud: The point cloud of range and retro values given a height, width, scan angle, and horizontal angle.
  • sensor_msgs/PointCloud2: Version 2 of sensor_msgs/PointCloud.

These ray sensors detect using either Physics (non-gpu) or graphics (gpu).

Documentation about ROS Ray sensors is here: https://github.com/ros-simulation/gazebo_ros_pkgs/wiki/ROS-2-Migration:-Ray-sensors. Here are some key points:

  • ROS provides four ray sensors:
    • gazebo_ros_laser - This publishes sensor_msgs/LaserScan, one horizontal scan from the center vertical ray, rather than a sensor_msgs/PointCloud2 containing multiple rows.
    • gazebo_ros_gpu_laser - Same as gazebo_ros_laser, but is faster because it uses the GPU to identify points reflected from graphics information rather than from physics information.
    • gazebo_ros_block_laser - Publishes sensor_msgs/PointCloud.
    • gazebo_ros_range - Returns the minimum range value rather than sensor_msgs/PointCloud2.
  • In ROS 2, there is one plugin for all of this: gazebo_ros_ray_sensor. Select ray or gpu_ray for detection approach. Select output_type, one of Range, LaserScan, PointCloud, or PointCloud2, for the desired output. They are all compatible with GPU or Physics-based sensing.

Simulating Sonar

The gazebo_ros_block_laser sensor identifies length and retro values along straight lines. It performs horizontal and vertical sweeps to produce a point cloud from which shape can be inferred. Unlike laser, sonar spreads out in distance and weakens as it spreads. To model sonar with the gazebo_ros_block_laser plugin, we turn the point cloud into a sonar ray trace:

Here are some adjustments we can make:

  • Adjust sensor ray parameters, see http://sdformat.org/spec?ver=1.7&elem=sensor. Here we define the horizontal and vertical angular widths and the number of rays horizontally and vertically. Each ray contributes a point to the point cloud.
  • Convert the point-cloud to a 2-dimensional view. Here we can apply randomization and coloring algorithms to make the point cloud look like a 2D view that we are targeting.
  • Calculate a sonar ray trace from a laser point cloud.
  • Note that currently, values returned for range and retro are the average of four points along the horizontal and vertical grid requested, specifically the requested point, the point to the right, the point below, and the point below and right.
  • To model ray reflections, simulate sonar transmitters at points of reflections, see how gazebo/physics/ode/ODEMultiRayShape.cc calls SetLength and SetRetro on RayShape.
Clone this wiki locally