The laserscan_to_ranges package offers simplification and intuitive representation of the LaserScan messages.
The package subscribes to a LaserScan data and splits it into three equal sectors: left, front, and right. Each sector is describe by only a single floating point value calculation of which can be specified via a parameter. By default, the closest point of the given sector will be used. The package is useful for building simple navigation and obstacle avoidance algorithms.
The resulting data is published as a custom SimpleRanges message containing the following fields:
left
: range of the left sectorfront
: range of the front sectorright
: range of the right sector
~/scan
(sensor_msgs/LaserScan) - the LaserScan data
~/simple_ranges
(laserscan_to_ranges/SimpleRanges) - the simplified LaserScan data- Optional topics (enabled via the
enable_ranges
parameter):~/ranges_left
(sensor_msgs/Range) - the left sector range~/ranges_front
(sensor_msgs/Range) - the front sector range~/ranges_right
(sensor_msgs/Range) - the right sector range
The package has the following parameters:
method
(string
, default:min
) - specifies the method for the range calculation. The following options are available:min
: the closest distance in the sectormean
: the mean distance in the sectormax
: the farthest distance in the sector
field_of_view
(double
, default:0.0
) - specifies the field of view of the sensor in degrees. If the value is set to0.0
, the field of view will be calculated from theangle_min
andangle_max
fields of the LaserScan message.angle_offset
(double
, default:0.0
) - specifies the angle offset in degrees. The offset is added to the angle_min and angle_max of the LaserScan messages. For example, if the sensors field of view is [-90, 90] degrees and the offset is 10 degrees, the 60 degree front sector will be shifted from [-30, 30] to [-20, 40].enable_ranges
(bool
, default:false
) - By default the node publish only SimpleRanges messages on thesimple_ranges
topic. Enable this parameter to additionally publish the sensor_msgs/Range messages on theranges_right
,ranges_front
, andranges_left
topics. Transforms for each sector are also published. This option is useful for visualization the ranges in RViz.debug
(bool
, default:false
) - enable this parameter to start the node with log level set toDEBUG
.
To run the node, simply enter:
ros2 run laserscan_to_ranges laserscan_to_ranges
To run the node with parameters, enter:
ros2 run laserscan_to_ranges laserscan_to_ranges --ros-args -p enable_ranges -p method:=mean -p debug:=true
or use the launch file:
ros2 launch laserscan_to_ranges laserscan_to_ranges.launch.py --ros-args -p enable_ranges -p method:=mean -p debug:=true