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

Revision history [back]

click to hide/show revision 1
initial version

The answer you linked is just an example where the person didn't modify his code. AutoExp::processLaserScan just means that this person created a method processLaserScan (exactly how you defined LaserCallback) within a class named AutoExp.

The relevant part of the answer is :

//scan->ranges[] are laser readings

You need to use the field ranges to get the laser scan data. For your question, you want to use the field range_max so you just have to do this :

void LaserCallback(const sensor_msgs::LaserScan::ConstPtr& scan)
{
   float x = scan->range_max;
}

You can see here all the fields from sensor_msgs/LaserScan.msg.