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

How to make a callback function for range topic [closed]

asked 2013-06-11 06:21:33 -0600

Hello,

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?

Thanks

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Icehawk101
close date 2013-06-11 13:05:53

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-06-11 09:44:35 -0600

SL Remy gravatar image

updated 2013-06-11 09:46:28 -0600

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

edit flag offensive delete link more

Comments

I am using IR sensors. Thanks for your help!

Icehawk101 gravatar image Icehawk101  ( 2013-06-11 09:52:05 -0600 )edit

Question Tools

Stats

Asked: 2013-06-11 06:21:33 -0600

Seen: 527 times

Last updated: Jun 11 '13