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 I understand your problem correctly, use ros::spinOnce() to manually spin. Somewhat along the lines of:

while(ros::ok() && !got_all_data) {
    ros::spinOnce();
    loop_rate.sleep();
}

Alternatively if you want to collect all data first and write afterwards, just use ros::spin(); and write the file afterwards. Ctrl-C should stop the spinning. (You might want to test that before doing something critical).