ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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
}
}
2 | No.2 Revision |
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.