Logging and how it works in the NUbots codebase.
Alex Biddulph GitHub avatar
Updated 1 Oct 2023

Data Playback

The DataPlayback module will allow you to play back .nbs files as if they were happening in realtime. This can be very useful when you are trying to diagnose a problem for which you have a recording since you can continuously play back the same data.

The module will buffer up packets from the future and emit them at the same rate that they were emitted originally.


Add support::logging::DataPlayback to your role file and comment out the roles that you want the nbs files to replace. For example, if you are playing back message.input.Sensors you need to comment out input::SensorFilter from your role otherwise you will have two different modules emitting conflicting Sensors messages. You must recompile your role for these changes to take effect.

In order to play back the messages you need to enable the message types that are the input to the modules that you wish to test by setting them to true in the configuration (e.g. message.input.Sensors: true). Make sure the .nbs file contains the messages you are trying to emit (you can check with ./b nbs stats <nbs-file>).

nbs files can be provided to the module via the configuration file or via the command line. If the configuration file has arguments those are used. If there are no files provided in the configuration file, the arguments from the command line are used instead. This is so that if you have another module in your role that relies on command line arguments you have an alternate way to provide these files.

If you provide files in the configuration file and files on the command line, only the files in the configuration will be played.

You can provide multiple .nbs files and they will be played in sequence. For example, the following command will run a role and play back <nbs-file-a> followed by <nbs-file-b>

./b run <role> recordings/<nbs-file-a> recordings/<nbs-file-b>


There is some weird behaviour that will occur when using this module that won't happen in a real system. Take note of these if they influence your usage

  • If there are any timestamp fields in the messages, these will not be updated. If you are comparing the timestamps in the messages to the current time they will be wrong.
  • When you are providing paths to .nbs files via a ./b run command they are relative to the build directory in docker. There is a symlink to recordings that is placed there to make any nbs file in recordings easier to use. Outside of this path you will need to provide the full path from docker's perspective.

recordings is a directory in the root folder of the NUbots repository.

NUbots acknowledges the traditional custodians of the lands within our footprint areas: Awabakal, Darkinjung, Biripai, Worimi, Wonnarua, and Eora Nations. We acknowledge that our laboratory is situated on unceded Pambalong land. We pay respect to the wisdom of our Elders past and present.
Copyright © 2023 NUbots - CC-BY-4.0
Deploys by Netlify