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

If your callbacks are member functions of a class they can write the received data into the class, in example (pseudocode):

void Robot::LaserCallback(const sensor_msgs::LaserScan::ConstPtr& msg){

for ( range_data in msg) {
    this->rangedata = msg->ranges
    }
}

If your callbacks are you just want to get the value, declare the callback as member functions function of a class they class. Then, you can write the received data into the that class, in example (pseudocode):

void Robot::LaserCallback(const sensor_msgs::LaserScan::ConstPtr& msg){

for ( range_data in msg) {
    this->rangedata = msg->ranges
    }
}

In this way from your main you could just call a get method to obtain the latest data available.