I'm trying to speed up a post-processing pipeline based on ROS and since the data is in a bag file I tried the following architecture:
A node opens the bag with
rosbag_py. There's a worker thread that reads the next entry, publishes a msg and waits athreading.event()to be set to true.A subscriber waits for the post-processing pipeline to finish publishing the results, which releases the wait event from the worker
The idea is go through the bag as fast as possible, being the limiting factor the time that the pipeline takes to process a sample. When testing the implementation, it looks like the way the worker thread interacts with the underlying ROS2 threads end up slowing down the pipeline instead of speeding it up.
How do Python threads interact with ROS? What would be the correct approach to solve this issue?