What is the easiest way to dump messages of all topics in a rosbag which may be started and stopped by a trigger in c++?
Actually, I want to record a rosbag in a smooth way using a node, which may be triggered to start or stop the recordings.
My first attempt was to run the rosbag::Recorder
in a first node to record all topics and then set up another node which kills the first one when receiving a trigger signal. (I have a program which has to decide the start and stop time of a recording.)
I wonder, is there a more smooth way to do this in a single node and without having to terminate the node? I know that a rosbag::Bag
can be closed at runtime, but I would have to dump all messages by myself. I have about one hundred different topics with various standard and custom message types, so implementing some sort of callback would only be acceptable if it was a generic, message-type independent one. Is there a way to do this?
So I know, there may be different ways to approach this. Any help is appreciated!
Asked by Marcel Usai on 2019-08-09 04:06:54 UTC
Comments
I was also surprised to find that rosbag Recorder didn't have a couple methods to stop and close, but I'm sure that would be capability that if you added they would merge.
Alternatively, you could make a derived class of Recorder with your additional methods so you can reuse that code and build on top of it.
Asked by stevemacenski on 2019-08-09 10:54:57 UTC
Snapshotting seems to be a thing, but sometimes the Recorder misses a trigger, which makes it worthless. Automatic splits only work when the situations to be recorded are of exact equal duration... And for some reason, all the stuff in Recorder is private, making it ugly to just derive from it. So I decided to re-implement it.
Asked by Marcel Usai on 2019-08-21 03:09:20 UTC