ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you are subscribing to the laser scan topic (which I am assuming you are) can access the values for the distances using:

message.ranges

which contains all distance values from message.angle_min to message.angle_max with a message.angle_increment incremental step.

let's say you want the distance in the exact center of the array then use the len(message.ranges) to get the total number of scan beams and extract the center message.ranges[center_index].

You may want to use a range of angles (one angle is not reliable) like message.ranges[50:70] then extract the minimum value in that range and use it as a reference for your distance calculation logic.