Processing bag file with ROS node
I have a large bag file with sensor messages captured at 100 FPS. I also have a third-party ROS node that listens to the topic in the bag file, transforms the sensor messages, and publishes the result in another topic. The processing takes around 0.1s per message.
I would like to process the bag file with the node writing the results directly in a new bag file. I tried doing this by running:
roslaunch third-party-node third-party-node.launch &
rosbag record -O large_output_bag_file.bag output_topic &
rosbag play large_bag_file.bag
While this works, some messages seem to be skipped, probably due to the slow processing speed of the node. Also, I feel like there must be a more direct way using a single command.
Is there a standard direct way to wrap a ROS node to e.g. an executable that has a bag file as input and another one as output, guaranteeing to process all input messages?