rules_ros2 — Build ROS 2 with Bazel
github.com/mvukov/rules_ros2 · Bazel Central Registry
ROS 2 normally assumes you install it system-wide with apt and build your code with colcon.
That works for a lab. It gets painful when you have a monorepo, a fleet of robots,
cross-compilation, a CI farm and a need for builds that give the same result every time.
rules_ros2 lets you build ROS 2 itself, from source, as ordinary Bazel targets next to your own
code. Nothing ROS-related has to be installed on the host. With a hermetic C++ toolchain
(e.g. toolchains_llvm) and a recent rules_python, Bazel is the only prerequisite.
I started the project in May 2021, a few months after its predecessor rules_ros for ROS 1. Since then it has grown into one of the main ways people build ROS 2 with Bazel.
What it does
rules_ros2 covers the whole path from a .msg file to a deployed, observable robot application,
all in one Bazel build graph:
- Define interfaces. Messages, services and actions are declared with
ros2_interface_library, and depend on each other like any other Bazel target. - Generate code for every language. C, C++, Python and Rust bindings are generated on demand, and only for the interfaces a target actually uses.
- Write nodes.
ros2_cpp_binary,ros2_py_binaryand Rust binaries are ordinary Bazel targets, andros2_pluginhandles pluginlib plugins. - Define deployments.
ros2_launchbundles nodes, launch files and parameters into a single runnable target that you canbazel runlocally or package for a robot. - Test the system.
ros2_testruns launch-based integration tests hermetically, so they can run in parallel and be cached in CI. - Visualize and record.
foxglove_bridgeprovides live visualization, andros2_bagrecords and replays data (including MCAP).
The pieces you need to run in production are built in too:
- Zero-copy transport through CycloneDDS with the iceoryx shared-memory backend.
- Pluggable logging backends: spdlog, syslog and noop.
Who uses it
The rules are open source and don’t phone home, so there’s no complete list. These are the public signals I could find.
Contributors
Engineers from the following organizations have contributed code (affiliations taken from public GitHub profiles):
Organizations that keep their own forks include Wayve, Fetch Robotics, ReSim, the Institute for Autonomous Systems Technology (TAS) at Universität der Bundeswehr München, and Oasis Robotics.
Talks
- FOSDEM 2026: Productionising ROS when you have no choice (with Bazel) by Ricardo Delfin covers using rules_ros2 to produce real ROS build artifacts and ship them to robots in production with OTA updates.
Why Bazel for robotics?
Robotics stacks mix C++, Python, Rust, CUDA, generated code and firmware. They often target several architectures and have to be reproducible for safety and certification. Bazel handles that well: hermetic toolchains, remote caching and execution, precise incremental builds, and one dependency graph from message definitions to deployable images. ROS 2 was the missing piece. rules_ros2 lets you keep the ROS ecosystem without giving up that build discipline.
Related
Found a bug or want a feature? Please open an issue. Using rules_ros2 at your company and happy to be listed here? Get in touch.