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

extracting values from laser scan data!

asked 2022-08-06 05:20:27 -0600

Delbina gravatar image

updated 2022-08-08 05:05:44 -0600

Hi,

I have three objects in front of my robot. I want to specify distance to these objects. i have converted pointcloud into laser scan. now i want to extract the least values from the laser scan data. it seems it provides data from the environment as well. how can i access to the values for instance less than 10 in my laser scan data??

thanks

image description

ranges: [19.067832946777344, inf, inf, inf, inf, 6.741373538970947, 6.757254123687744, 6.757254123687744, 6.773134708404541, 6.773135185241699, 6.794971466064453, 6.791001319885254, 6.7870306968688965, 6.785045623779297, 6.785045623779297, 6.7691650390625, 6.743358612060547, 6.691746234893799, 6.6679253578186035, 6.7413740158081055, 6.9517927169799805, 7.049062252044678, 7.2495574951171875, 7.410350322723389, 7.428215503692627, 7.634665489196777, 7.819278240203857, 7.952279567718506, inf, inf, inf, inf, inf, inf, 11.731189727783203, 11.695326805114746, 11.687356948852539, 11.683372497558594, 11.711265563964844, 11.755098342895508, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, 19.015905380249023, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, 6.43577766418457, 6.289599895477295, 6.252068042755127, 6.175027847290039, 5.9537858963012695, 5.901679515838623] intensities: []

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2022-08-07 06:28:55 -0600

ravijoshi gravatar image

i have converted pointcloud into laser scan....

From you question, I am guessing that you are using depthimage_to_laserscan package. If not, then you can consider using it. Because it does exactly what you are looking for.

how can i access to the values for instance less than 10 in my laser scan data??

"less than 10", I assume the unit is in meters. In you are using the depthimage_to_laserscan package, you should set the ~range_max parameter. Surprisingly, the default value is 10 meters. I suggest you check out the wiki page for more information.

edit flag offensive delete link more

Comments

@Ravi Joshi thanks, i received the point cloud from 3d lidar. and i used pointcloud_to_laserscan package. as i checked depthimage_to_laserscan, it is for melodic and noetic. i am working with kinetic 16.04.

I have converted pointcloud from 3d lidar, to laserscan. i just wanted to extract the first three minimum values (as i have three objects infront of my robot).

Delbina gravatar image Delbina  ( 2022-08-08 03:09:57 -0600 )edit

How about sorting the received scan, say ranges attribute in sensor_msgs/LaserScan.msg, and then take the first 3 values? Of course, this assumes that there is only one point on every object, which is not a correct approach. But please check your LaserScan.msg by plotting it. You may apply clustering to get 3 clusters (instead of 3 points). BTW, do not forget to set ~range_min and ~range_max in pointcloud_to_laserscan_node.

ravijoshi gravatar image ravijoshi  ( 2022-08-08 03:22:00 -0600 )edit

@Ravi Joshi , sorry, is there any way to first remove/or filter the environment noise from the point cloud, and then convert the point cloud to the laser scan data? becasue when i convert the pointcloud into laser scan, it provides me the ranges of the points that are too far from the robot and relate to the environment, if i could remove them it was good.

Delbina gravatar image Delbina  ( 2022-08-08 04:33:44 -0600 )edit

I am having difficulty understanding the problem correctly. When you say "that are too far from the robot", I wonder why don't you set ~range_max param in the first place.

ravijoshi gravatar image ravijoshi  ( 2022-08-08 04:37:46 -0600 )edit

Dear @Ravi Joshi I know what you are mening. i have set the range_max = 10 , but as you can see in the attached image, in the right side top, those points are showing to me. i donot want them. i want the points in the middle.

Delbina gravatar image Delbina  ( 2022-08-08 05:00:04 -0600 )edit

@Ravi Joshi Thanks a lot for your support. The issue solved.

Delbina gravatar image Delbina  ( 2022-08-08 05:32:25 -0600 )edit
1

answered 2022-08-08 05:15:43 -0600

ljaniec gravatar image

You can check the laser_filters package from there:

Assorted filters designed to operate on 2D planar laser scanners, which use the sensor_msgs/LaserScan type.

There is an old branch for Kinetic. Worth a try.

The Wiki has a lot of examples too. Especially 4.5 LaserScanRangeFilter seems suitable for your case.

edit flag offensive delete link more

Comments

@ljaniec Thanks

Delbina gravatar image Delbina  ( 2022-08-08 05:31:56 -0600 )edit
1

answered 2022-08-06 06:14:03 -0600

Ammar Albakri gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-08-06 05:20:27 -0600

Seen: 218 times

Last updated: Aug 08 '22