ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The variable that you create for each sensor is only valid inside its callback.
Your callbacks will be called asynchronously, whenever there is new data on a topic. This means that you can't assume that callbacks will be called in order.
Instead of trying to write all four reading to your database in the callback for one sensor (where you only have data from one sensor), I suggest a different approach. You have a few choices: