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

How should I interpret the sensor_msgs/LaserScan.angle_min?

asked 2019-08-16 03:36:42 -0600

erugo gravatar image

updated 2019-08-16 03:37:05 -0600


I am using the RPLidar A2 on my ROSbot 2.0 for environment detection.

I am currently trying to implement a side-distance measurer that measures the distance of four sides, let's say NORTH, EAST, SOUTH and WEST. However, rather than being the directions relative to the robot body, I want to measure the sides in exact degrees of 0, 90, 180 and 270, with respect to the initial theta orientation of the robot being 0.

To do this, I implemented a function that takes in a global angle, and based on scan attributes and current yaw, returns the index in ranges that the degree is at.

angle_to_index = lambda angle: int( ((angle - (yaw+scan.angle_min)) % (2*math.pi))/scan.angle_increment )

Let's assume that the initial orientation is robot facing NORTH. When I request the readings at degree 0 with angle_to_index(0), the readings fit that of the SOUTH direction.

That makes me think, if the scan.angle_min value is -3.12, which I suppose is relative to the front of the robot, then scan.ranges[0] should return a reading from the back of the vehicle, right? But in this case, it looks like readings around the scan.angle_min correspond to the front of the robot, which confused me.

So, how should I interpret the sensor_msgs/LaserScan.angle_min?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-08-16 03:56:07 -0600

mgruhler gravatar image

As the message definition for sensor_msgs/LaserScan specifies, angle_min is the start angle of the scan, i.e. equivalent to ranges[0].

However, i.e. all w.r.t. the frame in which the laser scan is published. For the RPLiDAR A2 (and assuming you are using the rplidar_ros package), you can see the frame orientation on this GitHub wiki page. Also, angle_min is set to 0.0, i.e. along the x-axis.

As to your question: your function is (at least) missing the angle with which your lidar is mounted on your robot. This would allow you to transform this accordingly.

But also note that angle_min is actually implementation defined, depending on how you want to send out messages and how the communication with the lidar is specified. most 360°-Lidars actually have angle_min as -M_PI, RPLiDAR being the exception...

edit flag offensive delete link more



Thanks for the detailed answer.

My LaserScan readings claim that angle_min: -3.12413907051, angle_increment: 0.0174532923847, but I did not take into account the static transform between base_link and laser, I assumed publishing that to the nodes would set the frame of LaserScan.angle_min in global coordinates.

So I guess instead of using scan.angle_min, I should use something like scan.angle_min + static_yaw_of_laser_wrt_baselink.

erugo gravatar image erugo  ( 2019-08-16 04:02:42 -0600 )edit

Yes, correct. You need to adjust for that static yaw. Also, you are right, angle_mincould be different. Missed that before...

mgruhler gravatar image mgruhler  ( 2019-08-16 06:33:00 -0600 )edit

Got it, thanks. The issue seems fixed with this update. Best.

erugo gravatar image erugo  ( 2019-08-16 06:38:46 -0600 )edit

Question Tools



Asked: 2019-08-16 03:36:42 -0600

Seen: 1,404 times

Last updated: Aug 16 '19