0
$\begingroup$

Rosanswers logo

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[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?


Originally posted by erugo on ROS Answers with karma: 1 on 2019-08-16

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by mgruhler with karma: 12390 on 2019-08-16

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by erugo on 2019-08-16:
Hi,

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.

Comment by mgruhler on 2019-08-16:
Yes, correct. You need to adjust for that static yaw. Also, you are right, angle_min could be different. Missed that before...

Comment by erugo on 2019-08-16:
Got it, thanks. The issue seems fixed with this update. Best.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.