Something like rosbag but it keeps a rolling buffer and saves a file only when you want to
Is there any existing tool that will record a bag file but instead of continuing to record would instead discard any data past some set time threshold (so if the threshold is 1 hour, at any given point it has the data up to one hour before the current time). Ideally this would allow one to call a service to save this data into a proper bagfile which can be then used for deeper investigation.
The usecase in mind is situations where some extraordinary event has happened to a robot (e.g. massive localization failure) and a bag file of data leading up to the event would be useful for fixing whatever bug may have caused the problem. I have thoughts about how something like this could be made but want to check if maybe something already exists.