0
$\begingroup$

Rosanswers logo

I have made a subscriber to pioneer/laser/scan for the scan values of laser on P3AT.

When I run the subscriber, it just doesn't stop. It keeps on running. I want only a single value of the scan i.e. the ranges[] array.

And also the value of any index in ranges[] array fluctuates ranges[i] - .2 to ranges[i] + .2

How to get only a single array ranges[] when subscribing to the scan?

P.S. I am using these lines of code and obstaclesCallBack is my function for printing the scan values.

ros::NodeHandle laser_n;
ros::Subscriber sub = laser_n.subscribe<sensor_msgs::LaserScan>("pioneer/laser/scan", 1000, obstaclesCallback);

Originally posted by Arpit on ROS Answers with karma: 3 on 2016-03-23

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

When I run the subscriber, it just doesn't stop. It keeps on running.

That is the normal (and desired) behaviour of subscribers, yes.

I want only a single value of the scan i.e. the ranges[] array.

Easiest is probably to use ros::topic::waitForMessage(..) for that.


Originally posted by gvdhoorn with karma: 86574 on 2016-03-23

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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