Replay at given rate
tocttou opened this issue · comments
Hi! thanks for the amazing library.
Since bag.readMessages
reads through the entire bag in a go, I was wondering how to implement replay at a given rate.
One way I could think of is pushing the messages into an event-queue like structure and then picking them up at appropriate intervals using setTimeout
- but that would mean that the browser's memory will get full.
Is there a recommended approach? Pardon if the question is stupid.
Thanks!
Not a stupid question at all, it might not be super clear in the readme. You can specify start/end times to readMessages
. See here for all the options that we accept: https://github.com/cruise-automation/rosbag.js#bagoptions
See here for an example of how we use readMessages
in Webviz: https://github.robot.car/cruise/webviz/blob/b9ced4993242685bf80e557ec3b570e90975e705/webviz-core/src/dataProviders/BagDataProvider.js#L143
Hope this helps!
Oh and for how to approach a given rate, see this example here: https://github.robot.car/cruise/webviz/blob/b9ced4993242685bf80e557ec3b570e90975e705/webviz-core/src/players/RandomAccessPlayer.js#L259-L272
This helps. Thanks!