How should I interpret the sensor_msgs/LaserScan.angle_min?

Hello,

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 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 close merge delete

Sort by » oldest newest most voted As the message definition for sensor_msgs/LaserScan specifies, angle_min is the start angle of the scan, i.e. equivalent to ranges.

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...

more

Hi,

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.

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

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