replay_testing
A testing library and CLI for replaying ROS nodes.
README
Replay Testing
A ROS2-based framework for configuring, authoring and running replay tests.
Features include:
MCAP replay and automatic recording of assets for offline review
Baked-in Unittest support for MCAP asserts
Parametric sweeps
Easy-to-use CMake for running in CI
Lightweight CLI for running quickly
What is Replay Tesing?
Replay testing is simply a way to replay previously recorded data into your own set of ROS nodes. When you are iterating on a piece of code, it is typically much easier to develop it on your local machine rather than on robot. Therefore, if you are able to record that data on-robot first, and then replay locally, you get the best of both worlds!
All robotics developers use replay testing in one form or another. This package just wraps many of the conventions into an easy executable.
Usage
CLI
ros2 run replay_testing replay_test [REPLAY_TEST_PATH]
For other args:
ros2 run replay_testing replay_test --help
colcon test
and CMake
This package exposes CMake you can use for running replay tests as part of your own package’s testing pipeline.
To use:
find_package(replay_testing REQUIRED)
..
if(BUILD_TESTING)
add_replay_test([REPLAY_TEST_PATH])
endif()
If you’ve set up your CI to persist artifact paths under test_results
, you should see a *.xunit.xml
file be produced based on the REPLAY_TEST_PATH
you provided.
Reviewing MCAP from Replay Tests
If you’d like to directly view the resulting replay results in tools like Foxglove, replay_testing
will produce and print the result directory under /tmp/replay_testing
. Example:
/tmp/replay_testing/a00a98aa-7f24-45c6-9299-b6232dcd842d/cmd_vel_only/runs/default
The guide here is dynamically generated, and within that directory you can find all of your run results under the runs
subdirectory.
Developing
Activating Code Standard Hooks
Pre-commit hooks are provided to maintain code standards for this repository.
If you do not have pre-commit installed, run
python3 -m pip install pre-commit
For preexisting repositories, you must run
pre-commit install
in that repositoryYou can automatically install pre-commit for newly cloned repositories by running
$ git config –global init.templateDir ~/.git-template $ pre-commit init-templatedir ~/.git-template pre-commit installed at /home/asottile/.git-template/hooks/pre-commit ```
Now all git commits will be automatically gated by the configured checks.
FAQ
Why MCAP?
We’ve built most of our internal tooling around Foxglove, which supports MCAP best. The Foxglove team has published a robust set of libraries for writing and reading MCAP that we’ve used successfully here.
Can this package support other forms of recorded data? E.g. *.db3
Certainly open to it!