Rosanswers logo


I am subscribing to a range message but am unsure what to do. I need to save the range value as a double into a global array variable. I have:

void front(const sensor_msgs::Range &msg)
     data[0] = ???;

I am unsure was goes in the ??? obviously. I think it is something like msg->range.size() but I am not sure. Is this correct?


Originally posted by Icehawk101 on ROS Answers with karma: 955 on 2013-06-11

Post score: 0


1 Answer 1


Rosanswers logo

According to sensor_msgs/Range.msg, the data is in msg->range. The range is a float32 (a single number).

If you were to use the sensor_msgs/LaserScan.msg instead, the set of ranges would be found in msg->ranges. Then msg->range.size() would have some meaning (since it's a vector).

Originally posted by SL Remy with karma: 2022 on 2013-06-11

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by Icehawk101 on 2013-06-11:
I am using IR sensors. Thanks for your help!


Your Answer

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