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

How to calculate sensor_msgs/LaserScan data ?

asked 2021-02-23 04:45:57 -0600

Tricia279 gravatar image

I have made a bag: 2021-02-15-11-32-28.bag and converted it in the: rplidarA1.csv File. So I have 2 Mb data and the following fields: %time field.header.seq field.header.stamp field.header.frame_id field.angle_min field.angle_max field.angle_increment field.time_increment field.scan_time field.range_min field.range_max field.ranges0 bis field.ranges719 field.intensity

My question: With which of these fields, I can calculate the distance to a object ?

I real appreciate your comments :-)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-25 22:37:12 -0600

loguna gravatar image

The Lidar's laserscan/ranges work in this way:

It detects and record in terms of an array in a string of Float32.

So in the lets say the object is 2 meters between the Lidar 0 degree to 3 degree:

Range: [2.0 2.0 2.0 0.0 0.0 0.0 ....]

More on: http://docs.ros.org/en/api/sensor_msg...

Hope it helps.

edit flag offensive delete link more

Comments

As @loguna have mentioned, but you should notice that the angle increment play a role in it. In @loguna example, the angle_increment is 1 degree, assumed that the measure unit of angle_increment is degree(but it's rad)

drtritm gravatar image drtritm  ( 2021-02-26 03:34:42 -0600 )edit

@loguna: I have 3 additional questions: The "range" in your example is it the field_range ? range_min or range_max ? I use RViz: How I can set the angle in rad there ? and How I can get these Range: [2.0 2.0 2.0 0.0 0.0 0.0 ....] ?

Tricia279 gravatar image Tricia279  ( 2021-03-02 06:11:59 -0600 )edit

Its in Field range. So the lidar spins 360 degree, it collects signals and place them into an array in meters. So lets say the Lidar collect a signal per degree (Check with your Lidar manufacturer), your array should contain [360] meters values. To obtain the signal, import the LaserScan from sensor_msgs.msg. Than try printing "LaserScan.ranges".

If you wish to detect obstacle at a specific direction: The way i usually do is place an object in front of the Lidar. Next I set a random value like LaserScan.range[180] to see if the lidar did pick up the object. If it didnt, i change the "value" of LaserScan.range[value] until i get a hit.

N usually 360 degree Lidar is use more towards mapping and not really to detect obstacles at a specific direction. Hence in RVIZ, it will show all the points in 360 degree.

loguna gravatar image loguna  ( 2021-03-03 02:42:26 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2021-02-23 04:45:57 -0600

Seen: 544 times

Last updated: Feb 25 '21