Welcome
nano-ros runs ROS 2 nodes on microcontrollers and real-time operating
systems, and those nodes talk to an ordinary ROS 2 system on your computer.
In your first hour you install the nros command, scaffold a talker for an
Arm Cortex-M3 board, run it in an emulator, and watch its messages arrive in
ros2 topic echo. You need no board and you write no code to get there.
The talker you will run
The first Tutorial chapter scaffolds a workspace with one node package. Its code is a ROS 2 talker. This excerpt is the part that does the work:
#![allow(unused)]
fn main() {
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
let mut node = ctx.create_node(nros::NodeOptions::new("talker"))?;
node.create_publisher_for_topic::<StringMsg>("/chatter")?;
node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(1000),
)?;
Ok(())
}
fn on_callback(
state: &mut i32,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_tick" {
*state = state.wrapping_add(1);
let mut msg = StringMsg::default();
let _ = write!(msg.data, "Hello World: {}", *state);
if ctx.publish_to_topic::<StringMsg, 64>("/chatter", &msg).is_ok() {
log::info!("Publishing: '{}'", msg.data);
}
}
}
}
The node creates a publisher on /chatter and a one-second timer. Each tick
publishes a std_msgs/String. You run it with nros run sensor_node, which
builds the firmware, boots it in QEMU, and prints the board’s console:
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
Publishing: 'Hello World: 3'
In a second terminal, the ROS 2 command line sees the same messages:
data: 'Hello World: 2'
---
data: 'Hello World: 3'
---
Nothing on the ROS 2 side knows that the talker is firmware on an emulated microcontroller. It is a ROS 2 node publishing a ROS 2 message type, and the ROS 2 tools you already use receive it. The same chapter also runs the talker as a process on your Linux host, for when you have no emulator set up.
Who nano-ros is for
nano-ros serves three kinds of work. Each has a budget that the book is written and tested against:
- Education. Courses and labs on robotics and embedded systems. The install takes 15 minutes, a lab fits a two-hour session, and every seat gets the same result.
- Field solutions. Engineers and technicians who build a system for each
customer, often on a board they were handed. The target is 30 minutes from
an unopened box to
ros2 topic echoshowing the board’s data. - Industrial. Teams who build products where safety and robustness matter. The same inputs give the same image, every fact about a board is on a page, and a build runs with no network.
Two more readers use the book: ROS 2 developers moving existing nodes onto a microcontroller, and porters who add a board or a platform. Choose your path gives each of the five a route through the book, in order, with its budget.
What you get
- One node, any supported board. You write a node once. Moving it to another board is one line in the workspace’s configuration, the board’s name. The cross-compiler, linker flags, middleware and memory sizes follow from that line, so neither your code nor your build files change.
- Your ROS 2 graph as it is. Your nodes join a stock ROS 2 system over
Zenoh, through
rmw_zenoh_cpp, or over DDS, throughrmw_cyclonedds_cpp. Topics, services and actions work in both directions. - The middleware you choose, with the same code. Zenoh needs no agent. XRCE-DDS works with the micro-ROS agent. Cyclone DDS speaks plain RTPS. Switching between them is a one-line change and a rebuild.
- A fit for a small microcontroller. The core runs with no operating system, and the heap is optional: whether an image needs one depends on the middleware you choose. Memory for nodes, topics and messages is sized when you build, in fixed pools.
- Rust, C or C++. The core is Rust, with C and C++ APIs over it. The C
API follows
rclcconventions, and the C++ API usesrclcpp’s names. One workspace can mix all three. - Messages that match your peers. Message bindings are generated from the ROS 2 install you build against, so the types and their hashes are the ones your ROS 2 nodes use.
- Claims you can check. Each board’s support level, where it runs, and
how often it is tested come from one registry. The book prints them on
generated pages, and
nros board show <board>prints the same facts from thenrosyou installed.
Where nano-ros differs from ROS 2
nano-ros keeps ROS 2’s vocabulary (nodes, publishers, subscriptions,
services, actions, timers, parameters, QoS) and its wire format. It is not a
port of rclcpp, and some things you rely on in ROS 2 work differently:
- Choices happen at build time. The middleware, the board and the memory sizes are fixed when you build. A running image cannot load a different middleware or create more topics than it was built for.
- The executor comes first. An executor opens the middleware session and
owns the nodes, instead of a global
initfollowed by nodes. - A node is code you build into an image. On a microcontroller there is
no process to start with
ros2 run. The workspace says which board each image runs on, andnros runbuilds and boots it. - Parameters are smaller. Each node keeps its own parameter store, with no descriptors or change callbacks yet.
- Some ROS 2 tools need the host.
ros2 topic echoandros2 node listrun on your computer and see the board’s nodes. Runtime introspection on the board itself is limited.
How nano-ros differs from ROS 2 and micro-ROS gives each difference and its reason, and compares nano-ros with micro-ROS, the other ROS 2 stack for microcontrollers.
Does it run on my board?
Each row below is a starter in this book, with the languages its tabs cover today:
| Board | Runs | RMW | Rust | C | C++ |
|---|---|---|---|---|---|
| Nucleo-F767ZI | Boots, manual | Zenoh | yes | yes | yes |
| mps2-an385 in QEMU (bare-metal) | Verified in emulator | Zenoh | yes | yes | yes |
| mps2-an385 in QEMU (FreeRTOS) | Verified in emulator | Zenoh | yes | yes | yes |
| mps2-an385 in QEMU (Zephyr) | Verified in emulator | Zenoh | yes | yes | yes |
| NuttX in QEMU (Arm) | Verified in emulator | Zenoh | yes | yes | yes |
| NuttX in QEMU (RISC-V) | Verified in emulator | Zenoh | yes | yes | yes |
| ThreadX in QEMU (RISC-V 64) | Verified in emulator | Zenoh | yes | yes | yes |
| Linux host | Verified on host | Cyclone DDS | yes | yes | yes |
| Zephyr native_sim | Verified on host | Zenoh | yes | yes | yes |
| ThreadX Linux simulator | Verified on host | Zenoh | yes | yes | yes |
| FreeRTOS POSIX | Verified on host | Cyclone DDS, Zenoh | yes | yes | yes |
yes: the starter’s tab for that language is replayed in CI from a clean install and passes. not yet: the tab is in the book and its replay waits on a fix. —: the starter has no tab for that language.
Supported Boards lists every board the release knows, with its support level and where it runs: on your host, in an emulator, or on hardware. Board support levels says what each level means. These pages are generated from the board registry, so they always match the release.
Every board in this book has a way to run without its hardware: on your host, in an emulator, or in an emulated twin of the board. The first chapter uses QEMU’s model of the MPS2-AN385, an Arm Cortex-M3 board, because it boots in seconds and needs nothing but your computer. Boards with a hardware twin, such as the Nucleo-F767ZI, run the same firmware in an emulator first and then on the board.
A board that is not in the registry can still run nano-ros. You add it from your own tree, without changing nano-ros: Add a board shows how.
How this book is organized
The sidebar follows what you are doing:
- Start here: this page, Choose your path and Install.
- Get started on your board: one page per board, from install to
ros2 topic echo. - Tutorial: one project, built up chapter by chapter, starting with the talker above.
- User guide: task pages, grouped by area: communication, contracts and sizing, build and configuration, platforms, real-time, deployment, and porting from ROS 2.
- Background: why nano-ros works the way it does.
- Reference: the CLI, the APIs, configuration keys and the boards, generated from their sources where possible.
- Extending nano-ros: adding a board, a platform, a transport or a middleware backend.
- Releases: moving from an older release.
Each page shows its kind and level under its title. Level 1 pages assume nothing beyond this section. A page at a higher level assumes the levels below it:
| Level | What it covers |
|---|---|
| 1. First contact | install, a board’s first run, the first Tutorial chapters |
| 2. Building real applications | your own messages, services, launch files, ROS 2 interop |
| 3. Production and tuning | configuration, offline builds, deployment, timing and memory |
| 4. Extending nano-ros | new boards, platforms, transports and middleware |
Changing nano-ros itself is a different job, with its own book: nano-ros Internals.
Next
Go to Choose your path to find the route for your work, or go straight to Install.
Design background
The three purposes and their budgets are RFC-0116 D1. The book’s sections, page types and topic levels are RFC-0124.
Choose your path
Pick the card that matches your work and follow its route in order. Each step needs only the steps above it, so you never read a page that assumes one you skipped. Each card also states its budget: the time or the property the route is written and tested to meet.
Every route starts with Install. If you are not sure which card fits, start with Education: its first chapters are the common start of every other route.
Education
For: instructors and students in a course or lab on robotics or embedded systems.
Budget: a 15-minute install on each seat, labs that fit a two-hour session, and the same result on every seat.
Route: the Tutorial, one project carried through ten chapters, each a lab of its own, every step in Rust, C and C++ tabs. Chapters 1 to 7 fit the education budget.
- Install on each seat.
- 1. Run a talker on an emulated board. The output it prints is the result to check on every seat.
- 2. What you just built: the node package, the bringup and the image.
- 3. Add a second node: the workspace.
- 4. Pick and configure the RMW: zenoh, Cyclone DDS and XRCE-DDS, and the board moved onto its network.
- 5. Your own message: a message package of the project’s own.
- 6. Services and actions.
- 7. Parameters and launch files.
- 8. Tell the build what your system creates: the contract, and the static RAM it saves.
- 9. Same project, another target.
- 10. Talk to ROS 2.
- The lab’s own board: its starter in the list of starters, such as Nucleo-F767ZI, or its entry in Supported Boards.
Field solutions
For: engineers and technicians who build a system for each customer, often on a board they were handed.
Budget: 30 minutes from an unopened box to ros2 topic echo showing the
board’s data.
Route:
- Install.
- Your board’s starter, from the list of starters. The boards with an emulated twin come first, such as the Nucleo-F767ZI: the starter runs the twin first, then flashes the board itself. A board with no starter has a page in Supported Boards that says what nano-ros can show for it.
- Talk to ROS 2: the board’s topics in your ROS 2 graph, in both directions.
Industrial
For: teams who build products where safety and robustness matter.
Budget: reproducible, auditable and offline. The same inputs give the same image, every fact about a board is on a page, and the build runs with no network.
Route:
- Install.
- Background: the execution model, static memory and pools and safety.
- User guide: pin a release and work offline, build inside a vendor tree for air-gapped CI, and deploy to production.
- Reference: board support levels
and the configuration keys.
nros doctor --reportprints the support level of every board your images name, as a report you can file with a review.
ROS 2 developer porting nodes
For: developers with existing rclcpp nodes who want them on a
microcontroller.
Budget: Install’s 15 minutes, then the first chapter’s run. The port itself depends on your node, so this route sets no time for it.
Route:
- Install.
- Run a talker on an emulated board, to see the toolchain work before your own code is in it.
- How nano-ros differs from ROS 2.
- Port a C++ node.
- Move a ROS 2 project over.
Board porter
For: developers who bring nano-ros to a board, a platform or a transport it does not support yet.
Budget: Install’s 15 minutes, then the first chapter’s run. Porting is development work, so this route sets no time for it.
Route:
- Install.
- Run a talker on an emulated board and What you just built.
- How a build becomes an image.
- Extending nano-ros: Add a board. A board of yours lives in your own tree.
- nano-ros Internals, when the port needs a change inside nano-ros itself, such as a new platform.
If none of these fit
Read Welcome for what nano-ros is and what it is not, then follow the Education route as far as you need. Its first two chapters are the shortest way to see nano-ros run. If a step fails, Troubleshooting lists the problems readers meet in their first ten minutes.
Design background
The three purposes and their budgets are RFC-0116 D1. The five cards are RFC-0124 D10.
Install
This page takes a Linux machine to one that builds nano-ros, in about 15
minutes. You install a few host packages, install the nros command, and let
nros setup fetch the toolchains for your board. There is no nano-ros
checkout and no system-wide install: everything lands under ~/.nros.
Before you start
- A Linux host. The book’s steps are tested on Ubuntu 22.04 and 24.04, and the host packages below also cover Fedora and Arch. macOS is not supported.
- ROS 2 with its Zenoh middleware, installed before step 1, as Install ROS 2 first shows.
- A network connection for this install. To install on a machine with no network, see Install options.
Install ROS 2 first
The edition follows your Ubuntu release: Humble on 22.04, Jazzy on 24.04 (Humble has no 24.04 packages). If ROS 2 is already installed, skip to Add the Zenoh middleware.
Follow the official ROS 2 guide for your edition: Humble or Jazzy. Where it offers a choice, take these two:
- The desktop install (
ros-<distro>-desktop). It has everything else this book uses: the message packages nano-ros generates your bindings from, theros2command the Tutorial watches your nodes with, the Cyclone DDS middleware,example_interfacesfor the services chapter, anddemo_nodes_cpp, a ROS 2 talker and listener to test a board against. - The development tools (
ros-dev-tools). They bringcolcon, which the Tutorial uses to build a message package for the ROS 2 side.
Do this before step 1 on Ubuntu, so that step 1’s python3-catkin-pkg
comes from the ROS 2 repository. Taken from Ubuntu’s own archive first, it
blocks ROS’s catkin package, and the ROS install fails with
trying to overwrite '/usr/lib/python3/dist-packages/catkin_pkg/__init__.py'.
If that already happened, sudo apt remove python3-catkin-pkg and run the
ROS 2 install again.
Add the Zenoh middleware
Neither ROS 2 install includes the Zenoh middleware, which nano-ros uses by default. Add it:
# Ubuntu 24.04 (Jazzy); on 22.04, write humble for jazzy
sudo apt-get install -y ros-jazzy-rmw-zenoh-cpp
You source ROS 2 before your first build; the Tutorial shows where.
If adding the ROS 2 repository fails
The official guide looks up the newest ros2-apt-source release through
GitHub’s API. On a network where many machines share one address, such as a
lab, that lookup can answer API rate limit exceeded, and its dpkg -i then
fails on an empty file. These lines add the same repository from a pinned
release, 1.3.0, and ask GitHub for nothing but the file:
sudo apt-get update
sudo apt-get install -y curl ca-certificates software-properties-common
sudo add-apt-repository -y universe
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
base=https://github.com/ros-infrastructure/ros-apt-source/releases/download
curl -fL -o /tmp/ros2-apt-source.deb \
"$base/1.3.0/ros2-apt-source_1.3.0.${codename}_all.deb"
sudo dpkg -i /tmp/ros2-apt-source.deb
sudo apt-get update
A newer release works the same way: replace both 1.3.0s with its number.
Then go back to the official guide’s install step.
Optional: a minimal install
For a headless machine, a container or a lab image, the smaller ros-base
install is enough, with two packages it lacks: the Zenoh middleware and
example_interfaces. It has no rviz2, no rqt and no demo nodes.
# Ubuntu 24.04 (Jazzy); on 22.04, write humble for jazzy
sudo apt-get install -y \
ros-jazzy-ros-base \
ros-jazzy-rmw-zenoh-cpp \
ros-jazzy-example-interfaces \
ros-dev-tools
For a lab of many seats, prepare one machine or image with this page and
the first board’s nros setup done, then copy it to each seat. Thirty seats
then download nothing in class, and none of them depends on the network that
day.
Steps
1. Install the host packages
The host needs git, curl, a C toolchain, CMake, Python 3, zstd, and the
Python packages that ROS message generation uses. Run the line for your
distribution.
Debian or Ubuntu:
sudo apt-get update
sudo apt-get install -y git curl ca-certificates build-essential \
cmake clang pkg-config python3 python3-dev zstd \
python3-catkin-pkg python3-empy python3-lark python3-yaml
clang lets each build check a C image’s stack against the size it was
measured to need. Without it the build still succeeds, and says the check
could not run.
Fedora:
sudo dnf install -y git curl ca-certificates gcc gcc-c++ make \
cmake pkgconf-pkg-config python3 python3-devel python3-pip zstd
pip install --user catkin_pkg 'empy==3.3.4' lark PyYAML
Arch:
sudo pacman -S --needed git curl base-devel cmake python python-pip zstd
pip install --user --break-system-packages catkin_pkg 'empy==3.3.4' lark PyYAML
Fedora and Arch ship no packages for the Python side, so the last line installs it with pip, into your home directory. The command finishes with no error, and a package that is already installed is left as it is. Host packages says what each package is for, and how to use a virtual environment instead.
2. Install the nros command
curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh | sh
export PATH="$HOME/.nros/bin:$PATH" # install.sh prints this line too
The installer downloads the newest release for your host, checks its checksum, and ends with lines like these:
nros-install: installed 0.6.0-nros8
nros-install: /home/you/.nros/sdk/nros/0.6.0-nros8
nros-install: /home/you/.nros/bin/nros -> /home/you/.nros/sdk/nros/0.6.0-nros8/bin/nros
nros-install: next → nros setup <board> (e.g. `nros setup linux`)
Add the export PATH=… line to your shell’s startup file, such as
~/.bashrc, so that nros is on your PATH in every new terminal.
3. Check the install
nros version
It prints the version of the command, of the code it generates, and of the libraries it was built with:
nros 0.6.0-nros8
codegen version 18
play_launch d9b79f2bf4505a04b5351c83e916aefaadaf805e
ros-launch-manifest v0.2.0
Your numbers are those of the release you installed. The first line is the
release, suffix included: the same 0.6.0-nros8 the installer printed and a
project’s pin names. A nros built from a source checkout has no release, so
it prints 0.6.0 (checkout build, no release version; …) instead.
4. Provision your board
nros setup fetches what a board needs: the cross-compiler, the emulator,
the middleware’s host tools and the board’s sources, plus a Rust toolchain if
the host has none. You do not install a cross-compiler yourself.
nros setup <board> --rmw <zenoh|xrce|cyclonedds>
Replace <board> and the middleware with the ones you run first:
- For the first Tutorial chapter, the emulated Cortex-M3 board:
mps2-an385-freertoswithzenoh. The chapter runs this step for you. - For a talker on this machine:
linuxwithcyclonedds. Cyclone DDS runs inside your process, so it needs no router and no agent. - For any other board, its name from
nros board list.
When the board is ready, the last line names it:
nros setup: linux ready; locked in /home/you/.nros/nros-sdk.lock
A board whose packages are already present prints
nros setup: linux — all packages already present instead.
nros-sdk.lock records which version of each tool and source the store
holds, so another machine can install the same set. Run outside a project,
as here, nros setup writes the store’s own lock, ~/.nros/nros-sdk.lock.
Run inside a project (a directory with a system.toml, a workspace, or a
pinned nros-toolchain.toml), it writes the project’s lock beside them
instead, and that is the one to commit. The nearest project up the path wins.
To move a version a project’s lock records, run nros update.
5. Turn on completion
With completion on, <Tab> completes nros verbs and flags, and the names
they take: nros board show <Tab> lists the board keys, and nros rmw show <Tab> the RMWs. Ask nros for the line your shell needs, naming the shell:
nros completions bash
It prints the line, and the file to add it to:
# Turn on `nros` completion: add this line to ~/.bashrc
source <(COMPLETE=bash nros)
Add that line to the file it names, then open a new terminal. For another
shell, name it instead: nros completions zsh, fish or powershell. With
no name, nros completions uses the shell $SHELL names. In zsh, the line
goes after compinit. The installer and the first nros setup print the
same line.
If it doesn’t work
nros: command not found. This shell does not have~/.nros/binon itsPATH. Run theexport PATH=…line from step 2, and add it to your shell’s startup file.- The installer stops with a checksum error. The download was cut short
or changed. Run the
curlline again. The installer never installs a release whose checksum it cannot check. nros setupsays it is building from source. The release has no prebuilt package for your host, sonros setupbuilds it. That is normal and takes several minutes.nros setup <board> --dry-runshows the plan before anything is fetched.- Something else.
nros doctorchecks the install: the command, the store under~/.nros, and the version a project pins. It names what is wrong and the command that fixes it.
Troubleshooting covers what goes wrong in the first build and run, such as an unsourced ROS 2 shell.
Next
- Choose your path: the route through the book for your work.
- Run a talker on an emulated board: the first Tutorial chapter.
- Nucleo-F767ZI: a board’s first run, in its emulated twin and then on the board.
- Install options: a specific release, pinning a project, working offline, what each package is for, and ROS 2’s role in detail.
Use the starter image
Not published yet. Until the image is made public,
docker pullbelow fails withdenied. Installnroson your own machine meanwhile, as Install describes.
The starter image is a container with nano-ros already installed: the nros
command, ROS 2 Humble with its Zenoh router, the toolchains for the Linux host
and the emulated mps2-an385 boards (bare-metal and FreeRTOS), Rust, and the
crates the first projects build from. Pulling it is the whole install, and a
project builds in it with no network. It suits a first look, a lab with many
seats, a machine behind a firewall, and a team that wants its own image on
top.
The image is ghcr.io/newslabntu/nano-ros-starter. Each release of nros
publishes a tag of the same version, and that tag never changes.
Before you start
- Docker, or another engine that runs Docker images, on a Linux x86_64 host. The image is built for amd64 only.
- About 1.7 GB to download and 4.5 GB of disk once unpacked.
Try it
Pull the image and start a shell in it:
docker pull ghcr.io/newslabntu/nano-ros-starter:latest
docker run --rm -it ghcr.io/newslabntu/nano-ros-starter:latest
You are now the user nros in /work, the directory your projects go in.
Scaffold a talker for the Linux host, then build and run it:
source /opt/ros/humble/setup.bash
nros new my_ws --board linux --template talker --lang rust --rmw zenoh
cd my_ws
nros run my_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run starts ROS’s Zenoh router, builds the talker and runs it. None of
it reaches the network: the crates it needs are already in the image. It
keeps running until you press Ctrl-C.
Cargo runs offline in the image (CARGO_NET_OFFLINE=true), so a seat with no
network builds without being told to. When your project adds a dependency
from crates.io, start the container with -e CARGO_NET_OFFLINE=false so
cargo can fetch it.
The Tutorial runs from here unchanged, and so
do the Linux host,
mps2-an385 bare-metal and
mps2-an385 FreeRTOS starters, minus
their install steps. To keep your work when the container stops, mount a
directory of your own at /work:
docker run --rm -it -v "$PWD:/work" ghcr.io/newslabntu/nano-ros-starter:latest
Use latest to try things out. Anything you want to rebuild later should
name a version instead, as the next sections do.
Run a course on it
Every seat should open the same image for the whole semester. Pin it by digest, which names exact bytes; a tag is only a name. Read the digest of the version you chose:
docker pull ghcr.io/newslabntu/nano-ros-starter:<version>
docker image inspect --format '{{index .RepoDigests 0}}' \
ghcr.io/newslabntu/nano-ros-starter:<version>
Then commit a .devcontainer/devcontainer.json to the course repository that
names it, so an editor with Dev Containers support opens every seat in it:
{
"name": "nano-ros course",
"image": "ghcr.io/newslabntu/nano-ros-starter@sha256:<digest>",
"workspaceMount": "source=${localWorkspaceFolder},target=/work,type=bind",
"workspaceFolder": "/work",
"remoteUser": "nros"
}
A seat that behaves differently from the others first checks it opened the
same bytes: nros doctor prints the image’s version on its container
line, and the host reads the digest with the docker image inspect command
above. If the two disagree, the seat pulled something else; pull the digest
again.
Pull before the session, not in it. A lab link is the limit: on a 100 Mbit/s link shared by 30 seats, every seat pulling the 1.7 GB image at once takes about 70 minutes. Pull the pinned digest on each seat the day before, or load it from a mirror on the lab network.
Use it with no network
On a machine with network access, save a version to a file:
docker pull ghcr.io/newslabntu/nano-ros-starter:<version>
docker save ghcr.io/newslabntu/nano-ros-starter:<version> \
| gzip > nano-ros-starter.tar.gz
Move the file across, then load and run it:
docker load < nano-ros-starter.tar.gz
docker run --rm -it --network none ghcr.io/newslabntu/nano-ros-starter:<version>
The image builds the first projects with --network none; that is checked
every time it is built. A board or package the image does not carry needs
network access once, in a derived image (below), before it moves across.
When you ask for help, include the nros doctor output: its container line
names the version you ran.
Build your team’s image on top
When your team needs a board or a ROS 2 package the starter does not carry,
derive an image from it rather than installing into a running container.
docker/starter-recipe/Dockerfile in the nano-ros repository is a working
example: it starts FROM the starter, adds the mps3-an536-freertos board
with nros setup, and installs ros-humble-nav-msgs. Copy it and change the
two marked lines.
Name a version in FROM, never latest, and the starter promises four
things your image can rely on:
- A version tag never changes.
FROMa version gives the same bytes every time you build. - The image matches its release. What it has installed is what
nros setupof that release would install, sonros setupin your image only adds what you ask for. - The paths stay put.
NROS_HOMEis/opt/nrosand the working directory is/workfor the whole of a major version. - The recipe is tested. Each release builds the example recipe on the new image.
Get started on your board
Needs first: Install
Pick the board you have, or the one you want to try, and follow its starter.
Each starter takes you from a finished install to a talker on that board whose
messages you read with ros2 topic echo. It needs nothing from the Tutorial,
and it takes about half an hour, most of it the first build.
Every starter has the same steps:
- What you need: the board or emulator, a cable if there is a board, and the host packages.
- Provision:
nros setup <board>fetches the board’s cross-compiler, emulator and sources into~/.nros. - Scaffold the project:
nros new <workspace> --board <board> --template talkerwrites a workspace with one talker node. - Run it:
nros run <node>builds the image and runs it in the emulator, in the board’s twin, or on this machine. - Flash the board, for a board you can hold:
nros flash --monitor. - See it in ROS 2, with
ros2 topic echo.
How the list is ordered
The list below is generated from the board support registry, and each entry shows the board’s status as the registry states it.
- Twin and hardware come first. Each of these boards has an emulator twin that boots the very image you later flash to the board, so you can run the starter today and buy the board when you are ready.
- Emulated boards run in QEMU on your machine. Nothing needs to be bought, and an automated lane runs each of them.
- Host boards run as ordinary programs on your Linux machine, with no emulator at all. They are the fastest way to try nano-ros.
A board that is not listed has no starter yet. Its page under Supported Boards says what nano-ros can show for it.
Twin and hardware
- Nucleo-F767ZI: Boots, manual (2026-11-01); reads Builds from 2027-03-02
Verified in emulator
- mps2-an385 in QEMU (bare-metal): Verified in emulator (daily)
- mps2-an385 in QEMU (FreeRTOS): Verified in emulator (daily)
- mps2-an385 in QEMU (Zephyr): Verified in emulator (daily)
- NuttX in QEMU (Arm): Verified in emulator (daily)
- NuttX in QEMU (RISC-V): Verified in emulator (daily)
- ThreadX in QEMU (RISC-V 64): Verified in emulator (daily)
Verified on host
- Linux host: Verified on host (daily)
- Zephyr native_sim: Verified on host (daily)
- ThreadX Linux simulator: Verified on host (daily)
- FreeRTOS POSIX: Verified on host (daily)
Next
Once your board publishes, the Tutorial grows the same kind of project: what the scaffold wrote, a second node, and the middleware choice. The platform pages in the User guide cover each board’s configuration.
Get started on the Nucleo-F767ZI
Needs first: Install
Status: Boots, manual (2026-11-01); reads Builds from 2027-03-02. From the board support registry:
nros-board-nucleo-f767zi-zephyr; Board Support Levels explains the words. The image runs in the board’s twin,renode:nucleo_f767zi, and on the board,nucleo-f767zi.
This starter puts a talker on an ST Nucleo-F767ZI (STM32F767ZI, Cortex-M7) running Zephyr 3.7, talking to ROS 2 over the board’s USB serial port. You do not need the board to start: Renode emulates it on your machine, and wires USART3, the UART the Nucleo’s ST-LINK carries to your USB port, to your host the way the cable would. The image you run in Renode is the image you later flash to the board. You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux x86_64 host with the install done, so
nrosis on yourPATH, and ROS 2 withros-<distro>-rmw-zenoh-cpp(Humble on Ubuntu 22.04, Jazzy on 24.04; which edition). - For the last step only: a Nucleo-F767ZI and a USB cable for its ST-LINK port. Everything before it runs in the twin.
- Zephyr’s host tools:
westand the build tools Zephyr’s Getting Started lists.nros setupinstalls no system packages, so install them yourself. On Debian or Ubuntu:
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
device-tree-compiler python3-pip python3-venv xz-utils file wget clang
pip3 install --user west
export PATH="$HOME/.local/bin:$PATH"
The serial link comes first and is the only link this starter opens. Ethernet is covered under Next. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
Provision the board:
nros setup nucleo-f767zi-zephyr --rmw zenoh
export ZEPHYR_SDK_INSTALL_DIR="$(nros locate tool zephyr-sdk)"
That fetches what the board needs into a shared store under ~/.nros: the
Zephyr SDK, the zenoh-pico sources, the Rust target, and Renode. It installs
no router: the router is ROS’s rmw_zenohd, from your ROS 2 install.
Zephyr’s sources live in a west workspace of your own. This one pins Zephyr
3.7 and fetches only the modules the board builds with, hal_stm32 among them
(import: true would fetch every vendor’s HAL), plus Zephyr’s Rust support,
which only a Rust talker builds with:
mkdir -p nucleo_ws/manifest && cd nucleo_ws
manifest/west.ymlmanifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v3.7.2
import:
name-allowlist: [cmsis, picolibc, mbedtls, tinycrypt, mcuboot, net-tools, hal_stm32]
# Rust support: only a Rust app builds with it. Pinned to the revision
# nano-ros's own west.yml pins for the 3.7 line (it has no release tags).
- name: zephyr-lang-rust
remote: zephyrproject-rtos
revision: 404fcefdbab0f2711cd342a1fab9d2eda52a1ba9
path: modules/lang/rust
self:
path: manifest
west init -l manifest
west update --narrow -o=--depth=1
pip3 install --user -r zephyr/scripts/requirements-base.txt
export ZEPHYR_BASE="$PWD/zephyr"
Last, give the west workspace the patches nano-ros carries for Zephyr 3.7.
The same command installs the Rust toolchain the talker’s runtime is
compiled with: a pinned nightly, with rust-src and the board’s
thumbv7em-none-eabi target (the board’s Zephyr configuration builds
soft-float):
nros setup board nucleo-f767zi-zephyr --zephyr-workspace "$PWD"
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
. "$HOME/.cargo/env"
nros new nucleo_ws --board nucleo-f767zi-zephyr --template talker --lang rust
cd nucleo_ws
nros setup --sudo
A Rust application on Zephyr also needs the Rust target the board
implies (thumbv7em-none-eabihf), rustup’s clippy, and clang with
libclang. nros setup in the workspace installs the target and clippy,
and with --sudo the two packages.
nros new nucleo_ws --board nucleo-f767zi-zephyr --template talker --lang c
cd nucleo_ws
nros new nucleo_ws --board nucleo-f767zi-zephyr --template talker --lang cpp
cd nucleo_ws
That wrote a workspace with two packages: src/nucleo_node/, the talker,
and src/nucleo_node_bringup/, which says what the talker runs on. The board
reaches the router on your host through USART3, which Zephyr calls
serial@40004800, at 115200 baud. The scaffold already said so, with a
locator line in the bringup’s system.toml:
grep '^locator' src/nucleo_node_bringup/system.toml
locator = "serial/serial@40004800#baudrate=115200"
The line sits in the [image.zephyr] block, under the
board = "nucleo-f767zi-zephyr" line. Do not add a second one: TOML refuses
a duplicate key, and nros build stops with duplicate key `locator` .
The board’s own configuration already turns Zephyr’s IP stack off and gives
USART3 to zenoh. Its console is USART6.
Run it in the Renode twin
Source ROS 2, then build and run. ROS 2 provides the router, and its message
definitions are what the build generates the talker’s std_msgs code from.
This first run records the ROS 2 prefix in the workspace, so later runs of it
need no sourced shell:
source /opt/ros/humble/setup.bash
nros run nucleo_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the firmware through west (the first build takes a few
minutes; later ones take seconds), boots it in Renode’s nucleo_f767zi
machine with USART3 on a terminal device of your host, starts rmw_zenohd on
that device, and prints the board’s console, USART6. It keeps running until
you press Ctrl-C.
Flash the board
On the bench, plug the Nucleo’s ST-LINK port into your host and flash the same image:
nros flash --monitor
Not replayed. No probe runs this flash line (a CI runner has no board), so it is written from the board’s runner, not measured (tracking issue).
nros flash builds the image if it is stale and programs it through
Zephyr’s own runner for the board, OpenOCD over the ST-LINK. With
--monitor it then serves the board’s link on your host: on the real board
USART3 is the ST-LINK’s virtual COM port, so the zenoh link arrives as a USB
serial device (/dev/ttyACM0, say), and the router listens there instead of
on Renode’s terminal device. Name the device with --port when more than one
is attached. The console, USART6, is on the board’s pins, not on the USB
cable.
See it in ROS 2
With the talker running, in the twin or on the board, ask ROS 2 for the topic
from a second terminal. The router nros run started
also listens where a ROS 2 node on this machine looks for one, so nothing
needs to be configured:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable; asking for best-effort receives from a publisher of either kind. Ctrl-C in the first terminal stops Renode and the router together.
If it doesn’t work
nros runnamesno runner package drivesorthe plan's tools name no renode: run thenros setup nucleo-f767zi-zephyrstep again, which installs Renode.- A router that does not start:
rmw_zenohdwas not found (source ROS 2 in that terminal), or another router already holds port 7447 on this machine. - A build that cannot find
hal_stm32: the west workspace predates thehal_stm32line in its allowlist. Add it and runwest updateagain. - Everything else: Troubleshooting - First 10 Minutes.
Next
- Ethernet. The Nucleo’s on-chip ethernet MAC works in Renode: the talker
reached a router over
tcp/with Zephyr’seth_stm32_haldriver in an early spike. That run needed a host tap device bridged to Renode’s virtual switch, which takesCAP_NET_ADMIN, andnros rundoes not set one up yet, so this starter stops at serial. - The board’s link, RAM budget and notes: Nucleo-F767ZI.
- The same kind of project, grown: the Tutorial.
- Talk to a larger ROS 2 system: Talk to ROS 2.
Get started on mps2-an385 in QEMU (bare-metal)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-mps2-an385; Board Support Levels explains the words.
This starter puts a talker on an Arm Cortex-M3 board with no operating system at all, emulated by QEMU, and shows its messages arriving in ROS 2. The board is Arm’s MPS2-AN385, which QEMU models closely. No one buys one: it is the board this book teaches nano-ros on, because it costs nothing and behaves like a real microcontroller. The talker runs as one loop with no scheduler under it, which is what “bare-metal” means. You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from.
Nothing else: no board, no cable, no root access. The board talks to your machine over its emulated serial port, the way a real board’s first program does. Its network comes later, under Next. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup mps2-an385-baremetal --rmw zenoh
That fetches the Arm cross-compiler, the QEMU that emulates the board, and,
for a Rust talker, the thumbv7m-none-eabi target into a shared store under
~/.nros. Nothing
is installed system-wide. It installs no router: the router is ROS’s
rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new bm_ws --board mps2-an385-baremetal --template talker --lang rust --rmw zenoh
cd bm_ws
nros new bm_ws --board mps2-an385-baremetal --template talker --lang c --rmw zenoh
cd bm_ws
nros new bm_ws --board mps2-an385-baremetal --template talker --lang cpp --rmw zenoh
cd bm_ws
That wrote a workspace with two packages:
bm_ws/
└── src/
├── bm_node/ # the talker: manifest, build file, source
└── bm_node_bringup/ # what it runs on: board, RMW
bm_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. bm_node_bringup
says what the talker runs on. You do not need to open it for this starter.
Run it in QEMU
Source ROS 2, then build and run. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell (the router still comes from ROS 2):
source /opt/ros/humble/setup.bash
nros run bm_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the firmware (the first build compiles nano-ros for the
Cortex-M3 and takes about five minutes; later builds take seconds), boots it
in QEMU with the board’s serial port connected to a terminal device on your
host, and starts the router on that device. What it prints is the board’s
console. It keeps running until you press Ctrl-C.
See it in ROS 2
Leave nros run going. In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
The router nros run started also listens where a ROS 2 node on this machine
looks for one, so nothing else needs to be configured.
If it doesn’t work
nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it. Source it and run again.nros runstops at once and names the router: it could not findrmw_zenohd. Source ROS 2 in that shell, and installros-<distro>-rmw-zenoh-cppif it is missing.- No
Publishing:line within a minute of boot: the router started but the board did not reach it.nros runnames the router’s log underbuild/nros/run/when it stops. A router you started yourself on the same port is the usual cause. - The talker stalls after you change it: bare-metal has no preemption, so a callback that runs long stops every other callback until it returns.
- Everything else: Troubleshooting - First 10 Minutes.
Next
- The same board over its network, and its configuration: Bare-metal Cortex-M3.
- The same board with an RTOS: mps2-an385 in QEMU (FreeRTOS).
- The project, grown: the Tutorial starts from this same talker, on this board with FreeRTOS under it.
Get started on mps2-an385 in QEMU (FreeRTOS)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-mps2-an385-freertos; Board Support Levels explains the words.
This starter puts a talker on FreeRTOS, on an emulated Arm Cortex-M3 board, and shows its messages arriving in ROS 2. The board is Arm’s MPS2-AN385 in QEMU, the board this book teaches nano-ros on: it costs nothing and behaves like a real microcontroller. FreeRTOS runs the talker as a task, with lwIP as its network stack on the board’s emulated LAN9118 ethernet. You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from.
No board, no cable and no root access: QEMU’s user-mode network carries the board’s ethernet to your machine, with no TAP device to create. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup mps2-an385-freertos --rmw zenoh
That fetches the Arm cross-compiler, the QEMU that emulates the board, and
the FreeRTOS kernel and lwIP sources into a shared store under ~/.nros.
Nothing is installed system-wide. It installs no router: the router is ROS’s
rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new fr_ws --board mps2-an385-freertos --template talker --lang rust
cd fr_ws
nros new fr_ws --board mps2-an385-freertos --template talker --lang c
cd fr_ws
nros new fr_ws --board mps2-an385-freertos --template talker --lang cpp
cd fr_ws
That wrote a workspace with two packages:
fr_ws/
└── src/
├── fr_node/ # the talker: manifest, build file, source
└── fr_node_bringup/ # what it runs on: board, RMW
fr_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. fr_node_bringup
says what the talker runs on. The FreeRTOS startup task that runs your node is
generated from it when you build, so you do not need to open it for this
starter.
Run it in QEMU
The image dials a zenoh router on your host through QEMU’s user-mode
network: the guest reaches your host as 10.0.2.2, on port 7447. nros run
starts that router itself, listening on every interface so the guest’s
connection arrives, and stops it when the run ends. If a router already runs
on that port, nros run --router auto uses it instead.
In the workspace, source ROS 2 and build and run the talker. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
source /opt/ros/humble/setup.bash
nros run fr_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the firmware (the first build cross-compiles nano-ros, the
FreeRTOS kernel and lwIP, about three minutes for C and five for Rust; later
builds take seconds), then boots it in QEMU with the board’s LAN9118 on the
user-mode network. What it prints is the board’s console. It keeps running
until you press Ctrl-C.
See it in ROS 2
Leave nros run going; its router stays up while it runs. In a second
terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
It prints a data: line per message:
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter
shows. Asking for best-effort receives from a publisher of either kind, so
the command works whatever QoS a publisher offers.
If it doesn’t work
- No
Publishing:line within 30 seconds of boot: the board did not reach the router. A cold boot through FreeRTOS, lwIP and the zenoh session takes 10 to 15 seconds. If you run your own router with--router auto, check that it listens on0.0.0.0:7447: one on127.0.0.1is out of the guest’s reach. Failed to open sessionon the console: the talker tried once, found no router, and stopped. With--router auto, start your router beforenros run.nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The board’s configuration, its own locator and address, and real hardware: FreeRTOS on mps2-an385.
- The same FreeRTOS on this machine, with no QEMU: FreeRTOS POSIX.
- The project, grown: the Tutorial starts from this same talker on this same board.
Get started on mps2-an385 in QEMU (Zephyr)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-mps2-an385-zephyr; Board Support Levels explains the words.
This starter puts a talker on Zephyr 3.7, on an emulated Arm Cortex-M3
board, and shows its messages arriving in ROS 2. The board is Arm’s
MPS2-AN385 in QEMU, the board this book teaches nano-ros on: it costs nothing
and behaves like a real microcontroller. Zephyr runs the talker with its own
IP stack on the board’s emulated SMSC911x ethernet. nano-ros is a Zephyr
module here: nros run writes the Zephyr application for your image and
builds it with Zephyr’s west.
You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from. - Zephyr’s host tools:
westand the build tools Zephyr’s Getting Started lists.nros setupinstalls no system packages, so install them yourself. On Debian or Ubuntu:
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
device-tree-compiler python3-pip python3-venv xz-utils file wget clang
pip3 install --user west
export PATH="$HOME/.local/bin:$PATH"
No board, no cable and no root access: QEMU’s user-mode network carries the board’s ethernet to your machine. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
Provision the board:
nros setup mps2-an385-zephyr --rmw zenoh
export ZEPHYR_SDK_INSTALL_DIR="$(nros locate tool zephyr-sdk)"
That fetches the Zephyr SDK, whose QEMU boots the board, and the zenoh-pico
sources into a shared store under ~/.nros. It installs no router: the
router is ROS’s rmw_zenohd.
Zephyr’s sources live in a west workspace of your own. This one pins Zephyr
3.7 and fetches only the modules the board builds with (import: true would
fetch every vendor’s HAL), plus Zephyr’s Rust support:
mkdir -p zephyr_ws/manifest && cd zephyr_ws
manifest/west.ymlmanifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v3.7.2
import:
name-allowlist: [cmsis, picolibc, mbedtls, tinycrypt, mcuboot, net-tools]
# Zephyr's Rust support. Pinned to the revision nano-ros builds with on
# the 3.7 line (it has no release tags).
- name: zephyr-lang-rust
remote: zephyrproject-rtos
revision: 404fcefdbab0f2711cd342a1fab9d2eda52a1ba9
path: modules/lang/rust
self:
path: manifest
west init -l manifest
west update --narrow -o=--depth=1
pip3 install --user -r zephyr/scripts/requirements-base.txt
export ZEPHYR_BASE="$PWD/zephyr"
Last, give the west workspace the patches nano-ros carries for Zephyr 3.7, and the board’s Rust target:
nros setup board mps2-an385-zephyr --zephyr-workspace "$PWD"
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
. "$HOME/.cargo/env"
nros new zm_ws --board mps2-an385-zephyr --template talker --lang rust
cd zm_ws
nros setup --sudo
A Rust application on Zephyr needs three things a C one does not: the Rust
target the board implies (thumbv7m-none-eabi), rustup’s clippy (Zephyr’s
Rust support lints every Rust app as it builds), and clang with libclang, for
the bindings it generates from Zephyr’s headers. nros setup in the
workspace installs the target and clippy, and with --sudo the two
packages. Without --sudo it prints the install command instead.
nros new zm_ws --board mps2-an385-zephyr --template talker --lang c
cd zm_ws
nros new zm_ws --board mps2-an385-zephyr --template talker --lang cpp
cd zm_ws
That wrote a workspace with two packages: src/zm_node/, the talker, a
library with no main() that names no board, and src/zm_node_bringup/,
which says what the talker runs on. The Zephyr application itself is
generated under build/ when you build, so you write no CMakeLists.txt and
no prj.conf.
Run it in QEMU
The board’s own configuration puts the image on QEMU’s user-mode network, at
10.0.2.15, and points it at the router on 10.0.2.2:7447, which is your
host. nros run reads that address from the image’s build and starts the
router on your host’s port 7447 itself, or reuses a zenoh router already
listening there.
In the workspace, source ROS 2 and build the firmware first. The build
writes the image’s network configuration, which nros run reads to start the
router, so build before the first run. It goes through west, and the first
build takes several minutes; later ones take seconds:
source /opt/ros/humble/setup.bash
nros build
Then run the talker:
nros run zm_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run rebuilds the firmware if a source changed, then boots it in the
QEMU that the Zephyr SDK ships. What it prints is the board’s console:
Zephyr’s boot banner, then the talker. It keeps running until you press
Ctrl-C.
See it in ROS 2
Leave nros run going. In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
If it doesn’t work
nros runrefuses the image and namesclang,clippyor the Rust target: runnros setup --sudoin the workspace again, or the install command it prints.- No
Publishing:line within 30 seconds of boot: the board did not reach the router. QEMU’s boot and Zephyr’s start take about 15 seconds. Check whatnros runsaid about the router: it starts one on port 7447, reuses a zenoh router already there, and refuses to run when something else holds the port. - A build that names zephyr-lang-rust: the west workspace has no
modules/lang/rust. Add thezephyr-lang-rustproject towest.ymland runwest updateagain. - Everything else: Troubleshooting - First 10 Minutes.
Next
- Each Zephyr piece, the image’s configuration, and other boards: Zephyr on mps2-an385.
- Zephyr with no emulator, as a program on this machine: Zephyr native_sim.
- A Zephyr board you can hold: the Nucleo-F767ZI.
Get started on NuttX in QEMU (Arm)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-nuttx-qemu; Board Support Levels explains the words.
This starter puts a talker on Apache NuttX, on QEMU’s Arm virt machine (a
Cortex-A7), and shows its messages arriving in ROS 2. NuttX is a POSIX-style
RTOS, so the talker runs as an ordinary NuttX task, with NuttX’s own network
stack on a virtio-net device. You need no NuttX checkout of your own:
nros setup fetches the kernel and its apps tree, and nros run links your
node into a bootable kernel. You write the talker in Rust, C or C++; pick a tab
and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from. - Two host packages the NuttX kernel build uses: the kconfig-frontends
tools, which configure the kernel, and
unzip. The provision step installs them for you when you allow it.
No board, no cable: QEMU’s user-mode network carries the guest’s ethernet to your machine, with no TAP device to create. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup qemu-armv7a-nuttx --rmw zenoh --sudo
That fetches the NuttX cross-compiler, the QEMU that emulates the machine, and
the NuttX kernel and apps sources into a shared store under ~/.nros. Before
it downloads anything it names the host packages that are missing, and
--sudo lets it run the one install command it composed for your package
manager (sudo apt-get install -y kconfig-frontends-nox unzip on Debian or Ubuntu).
Leave --sudo off and it only prints that command. It installs no router:
the router is ROS’s rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new nx_ws --board qemu-armv7a-nuttx --template talker --lang rust
cd nx_ws
nros new nx_ws --board qemu-armv7a-nuttx --template talker --lang c
cd nx_ws
nros new nx_ws --board qemu-armv7a-nuttx --template talker --lang cpp
cd nx_ws
That wrote a workspace with two packages: src/nx_node/, the talker, a
library with no main() that names no board, and src/nx_node_bringup/,
which says what the talker runs on. The NuttX task that runs your node is
generated from the bringup when you build, so you do not need to open it for
this starter.
Run it in QEMU
The image dials a zenoh router on your host through QEMU’s user-mode
network: the guest reaches your host as 10.0.2.2, on port 7447. nros run
starts that router itself, listening on every interface so the guest’s
connection arrives, and stops it when the run ends. If a router already runs
on that port, nros run --router auto uses it instead.
In the workspace, source ROS 2 and build and run the talker. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
source /opt/ros/humble/setup.bash
nros run nx_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the kernel with your node linked in (the first build
configures NuttX from the board’s defconfig and takes several minutes; later
builds take seconds), then boots it on QEMU’s virt machine with virtio-net
on the user-mode network. The image starts its application itself, so what you
see is the talker on the NuttX console. It keeps running until you press
Ctrl-C.
See it in ROS 2
Leave nros run going; its router stays up while it runs. In a second
terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
If it doesn’t work
nros setupstops and nameskconfig-frontends-noxorunzip: you left--sudooff. Run the command it printed, or run the step again with--sudo.- No
Publishing:line within a minute of boot: the talker did not reach the router. Its first line usually appears within about six seconds of boot. If you run your own router with--router auto, check that it listens on0.0.0.0:7447: one on127.0.0.1is out of the guest’s reach. nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration, a NuttX tree of your own, and real hardware: NuttX Arm and RISC-V.
- The same NuttX on a RISC-V machine: NuttX in QEMU (RISC-V).
- The project, grown: the Tutorial.
Get started on NuttX in QEMU (RISC-V)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-nuttx-qemu; Board Support Levels explains the words.
This starter puts a talker on Apache NuttX, on QEMU’s 32-bit RISC-V virt
machine (rv32imac), and shows its messages arriving in ROS 2. NuttX is a
POSIX-style RTOS, so the talker runs as an ordinary NuttX task, with NuttX’s
own network stack on a virtio-net device. You need no NuttX checkout of your
own: nros setup fetches the kernel and its apps tree, and nros run links
your node into a bootable kernel. You write the talker in Rust, C or C++; pick
a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from. - Two host packages the NuttX kernel build uses: the kconfig-frontends
tools, which configure the kernel, and
unzip. The provision step installs them for you when you allow it. - A
qemu-system-riscv32from your distribution. The QEMU in nano-ros’s store is built for Arm and 64-bit RISC-V only, so this board takes yours. On Debian or Ubuntu it is inqemu-system-misc.
No board, no cable: QEMU’s user-mode network carries the guest’s ethernet to your machine, with no TAP device to create. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup rv-virt-nuttx --rmw zenoh --sudo
sudo apt-get install -y qemu-system-misc
The first line fetches the RISC-V cross-compiler and the NuttX kernel and apps
sources into a shared store under ~/.nros. Before it downloads anything it
names the host packages that are missing, and --sudo lets it run the one
install command it composed for your package manager
(sudo apt-get install -y kconfig-frontends-nox unzip on Debian or Ubuntu).
Leave --sudo off and it only prints that command. The second line installs the emulator. Neither
installs a router: the router is ROS’s rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
QEMU_SYSTEM_RISCV32 names the emulator nros run boots the board with, so
set it in the shell you build and run from:
export QEMU_SYSTEM_RISCV32="$(command -v qemu-system-riscv32)"
nros new nx_ws --board rv-virt-nuttx --template talker --lang rust
cd nx_ws
export QEMU_SYSTEM_RISCV32="$(command -v qemu-system-riscv32)"
nros new nx_ws --board rv-virt-nuttx --template talker --lang c
cd nx_ws
export QEMU_SYSTEM_RISCV32="$(command -v qemu-system-riscv32)"
nros new nx_ws --board rv-virt-nuttx --template talker --lang cpp
cd nx_ws
That wrote a workspace with two packages: src/nx_node/, the talker, a
library with no main() that names no board, and src/nx_node_bringup/,
which says what the talker runs on. The NuttX task that runs your node is
generated from the bringup when you build. A Rust talker builds for the
board’s riscv32imac-unknown-nuttx-elf target, which the build compiles the
Rust standard library for itself.
Run it in QEMU
The image dials a zenoh router on your host through QEMU’s user-mode
network: the guest reaches your host as 10.0.2.2, on port 7447. nros run
starts that router itself, listening on every interface so the guest’s
connection arrives, and stops it when the run ends. If a router already runs
on that port, nros run --router auto uses it instead.
In the workspace, source ROS 2 and build and run the talker. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
source /opt/ros/humble/setup.bash
nros run nx_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the kernel with your node linked in (the first build
configures NuttX from the board’s defconfig and takes several minutes; later
builds take seconds), then boots it with the qemu-system-riscv32 that
QEMU_SYSTEM_RISCV32 names. The image starts its application itself, so what
you see is the talker on the NuttX console. It keeps running until you press
Ctrl-C.
See it in ROS 2
Leave nros run going; its router stays up while it runs. In a second
terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
If it doesn’t work
nros runasksnros locate tool qemu-system-riscv32, or names no emulator: this shell has noQEMU_SYSTEM_RISCV32. Run theexportline again, after installingqemu-system-misc.- No
Publishing:line within a minute of boot: the talker did not reach the router. If you run your own router with--router auto, check that it listens on0.0.0.0:7447: one on127.0.0.1is out of the guest’s reach. nros setupstops and nameskconfig-frontends-noxorunzip: you left--sudooff. Run the command it printed.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration, a NuttX tree of your own, and real hardware: NuttX Arm and RISC-V.
- The same NuttX on Arm: NuttX in QEMU (Arm).
- The project, grown: the Tutorial.
Get started on ThreadX in QEMU (RISC-V 64)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-threadx-qemu-riscv64; Board Support Levels explains the words.
This starter puts a talker on Eclipse ThreadX (formerly Azure RTOS
ThreadX), on QEMU’s 64-bit RISC-V virt machine, and shows its messages
arriving in ROS 2. ThreadX runs the talker as a thread, with NetX Duo as its
TCP/IP stack on a virtio-net device. You install no RISC-V cross-compiler and
no QEMU of your own: nros setup fetches both.
You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from.
No board, no cable and no root access: QEMU’s user-mode network carries the guest’s ethernet to your machine, with no TAP device to create. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup rv-virt-threadx --rmw zenoh
That fetches the RISC-V 64 cross-compiler, the qemu-system-riscv64 that
emulates the machine, and the ThreadX and NetX Duo sources into a shared store
under ~/.nros. Most of it is prebuilt for your host; what is not is built
from source the first time, and nros setup --dry-run shows which. It
installs no router: the router is ROS’s rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new tx_ws --board rv-virt-threadx --template talker --lang rust
cd tx_ws
nros new tx_ws --board rv-virt-threadx --template talker --lang c
cd tx_ws
nros new tx_ws --board rv-virt-threadx --template talker --lang cpp
cd tx_ws
That wrote a workspace with two packages:
tx_ws/
└── src/
├── tx_node/ # the talker: manifest, build file, source
└── tx_node_bringup/ # what it runs on: board, RMW
tx_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. tx_node_bringup
says what the talker runs on. The ThreadX startup that runs your node is
generated from it when you build, so you do not need to open it for this
starter.
Run it in QEMU
The image dials a zenoh router on your host through QEMU’s user-mode
network: the guest reaches your host as 10.0.2.2, on port 7447. nros run
starts that router itself, listening on every interface so the guest’s
connection arrives, and stops it when the run ends. If a router already runs
on that port, nros run --router auto uses it instead.
In the workspace, source ROS 2 and build and run the talker. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
source /opt/ros/humble/setup.bash
nros run tx_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the firmware (the first build compiles ThreadX, NetX Duo and
nano-ros, a few minutes; later builds take seconds), then boots it with the
store’s qemu-system-riscv64 on the virt machine, the UART on your terminal
and virtio-net on the user-mode network. What it prints is the board’s
console. It keeps running until you press Ctrl-C.
See it in ROS 2
Leave nros run going; its router stays up while it runs. In a second
terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
If it doesn’t work
- No
Publishing:line within 30 seconds of boot: the talker did not reach the router. QEMU’s boot and NetX Duo’s start take about 15 seconds. If you run your own router with--router auto, check that it listens on0.0.0.0:7447: one on127.0.0.1is out of the guest’s reach. nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it.nros runnames noqemu-system-riscv64: run thenros setup rv-virt-threadxstep again, which installs it.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration, sched tasks, and real hardware: ThreadX RISC-V 64.
- The same ThreadX as a program on this machine: ThreadX Linux simulator.
- The project, grown: the Tutorial.
Get started on the Linux host
Needs first: Install
Status: Verified on host (daily). From the board support registry:
nros-board-linux; Board Support Levels explains the words.
This starter builds a talker as an ordinary program on your Linux machine, runs it, and shows its messages arriving in ROS 2. It is the fastest way to try nano-ros: no emulator, no cross-compiler, and no router. The talker uses Cyclone DDS, which runs inside the talker’s own process and finds its peers on the network the way any ROS 2 node does. The project has the same shape as every board’s: change the board in the scaffold line and the same steps target an embedded board. You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. Only Linux is supported as a host board: macOS, Windows and FreeBSD are not. - ROS 2 (Humble on Ubuntu 22.04, Jazzy on 24.04; which edition),
with its Cyclone DDS middleware, so that
ros2 topic echocan read what the talker publishes. Both installs on the Install page include it; for any other ROS 2 install, add it on Debian or Ubuntu:
sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp
Nothing else: no board, no cable, and nothing to keep running beside the talker.
Provision
nros setup linux --rmw cyclonedds
That installs the Cyclone DDS runtime and its IDL compiler, prebuilt for your
host, into a shared store under ~/.nros. Nothing is installed system-wide.
There is no cross-compiler to fetch: a host build uses your own C and C++
compilers.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new host_ws --board linux --template talker --lang rust --rmw cyclonedds
cd host_ws
nros new host_ws --board linux --template talker --lang c --rmw cyclonedds
cd host_ws
nros new host_ws --board linux --template talker --lang cpp --rmw cyclonedds
cd host_ws
That wrote a workspace with two packages:
host_ws/
└── src/
├── host_node/ # the talker: manifest, build file, source
└── host_node_bringup/ # what it runs on: board, RMW
host_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. host_node_bringup
says what the talker runs on: its system.toml holds one image,
[image.linux], whose board = "linux" line is what makes it a host program.
Run it on this machine
The build generates the message bindings from your ROS 2 install, so source it
before the first run. That run records the ROS 2 prefix in the workspace, so
later runs of host_ws need no sourced shell:
source /opt/ros/humble/setup.bash
nros run host_node
nros run builds the talker (the first build compiles nano-ros, a minute or
two; later builds take seconds) and runs it. It keeps running until you press
Ctrl-C. It prints:
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
See it in ROS 2
Leave nros run going. In a second terminal, ask ROS 2 for the topic over
Cyclone DDS:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
Both sides use domain 0, the ROS 2 default, so they find each other with no configuration. Asking for best-effort receives from a best-effort or a reliable publisher alike.
If it doesn’t work
nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it. Source it and run again.ros2 topic echoprints nothing: check theRMW_IMPLEMENTATIONline, and that neither shell sets aROS_DOMAIN_IDother than 0. A firewall that drops multicast also stops DDS discovery.nros setuprefusesnativeorposix: the host board is namedlinux. The other two names are retired.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The host board with zenoh, its configuration and deployment: Linux host.
- The same project on an emulated microcontroller: mps2-an385 in QEMU (bare-metal).
- The project, grown: the Tutorial.
Get started on Zephyr native_sim
Needs first: Install
Status: Verified on host (daily). From the board support registry:
nros-board-zephyr; Board Support Levels explains the words.
This starter puts a talker on Zephyr 3.7’s native_sim board, which builds a
Zephyr application as an ordinary program for your Linux machine, and shows
its messages arriving in ROS 2. There is no emulator: the Zephyr kernel runs
inside one host process, and its sockets are your host’s, so the talker
reaches a router on this machine with no network setup. nano-ros is a Zephyr
module here: nros run writes the Zephyr application for your image and
builds it with Zephyr’s west. You write the talker in Rust, C or C++; pick a
tab and every tab on the page follows.
What you need
- A Linux x86_64 host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the talker talks to, and the message definitions the build generates the talker’s code from. - Zephyr’s host tools:
westand the build tools Zephyr’s Getting Started lists.nros setupinstalls no system packages, so install them yourself. On Debian or Ubuntu:
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
device-tree-compiler python3-pip python3-venv xz-utils file wget clang
pip3 install --user west
export PATH="$HOME/.local/bin:$PATH"
No board, no cable and no root access: the board’s own configuration routes the application’s sockets to the host’s, so no TAP interface is created.
Provision
Provision the board:
nros setup zephyr --rmw zenoh
export ZEPHYR_SDK_INSTALL_DIR="$(nros locate tool zephyr-sdk)"
That fetches the Zephyr SDK and the zenoh-pico and mbedtls sources into a
shared store under ~/.nros. It installs no router: the router is ROS’s
rmw_zenohd.
Zephyr’s sources live in a west workspace of your own. This one pins Zephyr
3.7 and fetches only the modules nano-ros’s boards build with (import: true
would fetch every vendor’s HAL, about 2.5 GB more), plus Zephyr’s Rust
support, which only a Rust talker builds with:
mkdir -p my_zephyr_ws/manifest && cd my_zephyr_ws
manifest/west.ymlmanifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v3.7.2
import:
name-allowlist: [cmsis, picolibc, mbedtls, tinycrypt, mcuboot, net-tools]
# Rust support: only a Rust app builds with it. Pinned to the revision
# nano-ros's own west.yml pins for the 3.7 line (it has no release tags).
- name: zephyr-lang-rust
remote: zephyrproject-rtos
revision: 404fcefdbab0f2711cd342a1fab9d2eda52a1ba9
path: modules/lang/rust
self:
path: manifest
west init -l manifest
west update --narrow -o=--depth=1
pip3 install --user -r zephyr/scripts/requirements-base.txt
export ZEPHYR_BASE="$PWD/zephyr"
Last, give the west workspace the patches nano-ros carries for Zephyr 3.7, among them the one that passes the board’s settings to a Rust app’s cargo build:
nros setup board zephyr --zephyr-workspace "$PWD"
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
Scaffold the workspace beside the west workspace, and tell nros where the
west workspace is with NROS_ZEPHYR_WORKSPACE:
. "$HOME/.cargo/env"
export NROS_ZEPHYR_WORKSPACE="$PWD"
cd ..
nros new zs_ws --board zephyr --template talker --lang rust --rmw zenoh
cd zs_ws
nros setup --sudo
A Rust application on Zephyr needs three things a C one does not: the Rust
target the board implies (x86_64-unknown-none for native_sim/64 on an
x86_64 host), rustup’s clippy (Zephyr’s Rust support lints every Rust app
as it builds), and clang with libclang, for the bindings it generates from
Zephyr’s headers. nros setup in the workspace installs the target and
clippy, and with --sudo the two packages. Without --sudo it prints the
install command instead.
export NROS_ZEPHYR_WORKSPACE="$PWD"
cd ..
nros new zs_ws --board zephyr --template talker --lang c --rmw zenoh
cd zs_ws
export NROS_ZEPHYR_WORKSPACE="$PWD"
cd ..
nros new zs_ws --board zephyr --template talker --lang cpp --rmw zenoh
cd zs_ws
That wrote a workspace with two packages: src/zs_node/, the talker, a
library with no main() that names no board, and src/zs_node_bringup/,
whose system.toml holds one image, [image.zephyr], with
board = "zephyr": Zephyr’s native_sim/native/64. The Zephyr application
itself is generated under build/ when you build, so you write no
CMakeLists.txt and no prj.conf.
Run it on this machine
Source ROS 2, then build and run. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell (the router still comes from ROS 2):
source /opt/ros/humble/setup.bash
nros run zs_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
The image dials a router on this machine’s port 7447, so nros run starts
that router, ROS’s rmw_zenohd, then builds the application through west
(the first build takes several minutes; later ones take seconds) and runs
zephyr.exe. Don’t start a router of your own on the same port. It keeps
running until you press Ctrl-C.
See it in ROS 2
Leave nros run going. In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
If it doesn’t work
eth_posix: Cannot create zethon the console: the application tried to create a TAP interface instead of using the host’s sockets. The board’s configuration prevents that; an application you configured yourself needs nano-ros’snros-nsossnippet.nros runrefuses a Rust image and namesclang,clippyor the Rust target: runnros setup --sudoin the workspace again, or the install command it prints.nros runstops at once and names the router: it could not findrmw_zenohd, or another router already holds port 7447.- Everything else: Troubleshooting - First 10 Minutes.
Next
- Each Zephyr piece, the image’s configuration, and other boards: Zephyr native_sim.
- A Zephyr application you build with west yourself: A Zephyr app you build with west.
- The same Zephyr on an emulated microcontroller: mps2-an385 in QEMU (Zephyr).
Get started on the ThreadX Linux simulator
Needs first: Install
Status: Verified on host (daily). From the board support registry:
nros-board-threadx-linux; Board Support Levels explains the words.
This starter puts a talker on Eclipse ThreadX (formerly Azure RTOS ThreadX) running as an ordinary program on your Linux machine, and shows its messages arriving in ROS 2. ThreadX’s Linux port runs the kernel’s threads inside one host process, and NetX Duo’s BSD socket layer sits on your host’s own TCP stack, so there is no emulator and no network to set up. The build is fast, which makes this the quickest way to try nano-ros on ThreadX. You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the talker talks to, and the message definitions the build generates the talker’s code from.
Nothing else: no board, no cable, no root access. The talker reaches the router on this machine’s loopback interface.
Provision
nros setup threadx-linux --rmw zenoh
That fetches the ThreadX and NetX Duo sources, with the Linux port, into a
shared store under ~/.nros. There is no cross-compiler to fetch: the
simulator builds for your host. It installs no router: the router is ROS’s
rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new tx_ws --board threadx-linux --template talker --lang rust
cd tx_ws
nros new tx_ws --board threadx-linux --template talker --lang c
cd tx_ws
nros new tx_ws --board threadx-linux --template talker --lang cpp
cd tx_ws
That wrote a workspace with two packages:
tx_ws/
└── src/
├── tx_node/ # the talker: manifest, build file, source
└── tx_node_bringup/ # what it runs on: board, RMW
tx_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. tx_node_bringup
says what the talker runs on. The ThreadX startup that runs your node is
generated from it when you build, so you do not need to open it for this
starter.
Run it on this machine
Source ROS 2, then build and run. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell (the router still comes from ROS 2):
source /opt/ros/humble/setup.bash
nros run tx_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
The talker dials a router on this machine’s port 7447, so nros run starts
that router, ROS’s rmw_zenohd, then the talker, and stops both together.
Don’t start a router of your own on the same port. The first build compiles
ThreadX, NetX Duo and nano-ros, a minute or two; later builds take seconds. It
keeps running until you press Ctrl-C.
See it in ROS 2
Leave nros run going. In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
The router nros run started listens where a ROS 2 node on this machine
looks for one, so nothing else needs to be configured.
If it doesn’t work
nros runstops at once and names the router: it could not findrmw_zenohd, or another router already holds port 7447. Source ROS 2 in that shell, or stop the other router. To use a router you already run, pass--router <its locator>.nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it.- No
Publishing:line: a cold first build takes about 80 seconds before the first publish. If it still prints nothing,nros runnames the router’s log when it stops. - Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration and sched tasks: ThreadX Linux simulator.
- The same ThreadX on an emulated RISC-V machine: ThreadX in QEMU (RISC-V 64).
- The project, grown: the Tutorial.
Get started on FreeRTOS POSIX
Needs first: Install
Status: Verified on host (daily). From the board support registry:
nros-board-freertos-posix; Board Support Levels explains the words.
This starter puts a talker on the FreeRTOS kernel running as an ordinary program on your Linux machine, and shows its messages arriving in ROS 2. FreeRTOS’s POSIX port runs the kernel’s tasks as threads of one host process, and the talker uses your host’s own sockets, so there is no emulator and no network to set up. It is the quickest way to see a FreeRTOS application talk to ROS 2. You write the talker in Rust, C or C++; pick a tab and every tab on the page follows.
The talker uses Cyclone DDS, which runs inside the talker’s own process and finds its peers on the network the way any ROS 2 node does, so there is no router to start. The board runs zenoh too, through a router on this machine: Zenoh on this board shows how.
What you need
- A Linux host with the install done, so
nrosis on yourPATH, and the C toolchain and CMake the install’s host packages bring. - ROS 2 (Humble on Ubuntu 22.04, Jazzy on 24.04;
which edition), with its Cyclone
DDS middleware, so that
ros2 topic echocan read what the talker publishes. The build also generates the talker’s message code from ROS 2’s message definitions. Both installs on the Install page include Cyclone DDS; for any other ROS 2 install, add it on Debian or Ubuntu:
sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp
Nothing else: no board, no cable, and nothing to keep running beside the talker.
Provision
nros setup freertos-posix --rmw cyclonedds
That fetches the FreeRTOS kernel sources, with its POSIX port, and what
Cyclone DDS needs, into a shared store under ~/.nros. Nothing is installed
system-wide. There is no cross-compiler to fetch: the simulator builds with
your host’s compilers.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new fp_ws --board freertos-posix --template talker --lang rust --rmw cyclonedds
cd fp_ws
nros new fp_ws --board freertos-posix --template talker --lang c --rmw cyclonedds
cd fp_ws
nros new fp_ws --board freertos-posix --template talker --lang cpp --rmw cyclonedds
cd fp_ws
That wrote a workspace with two packages:
fp_ws/
└── src/
├── fp_node/ # the talker: manifest, build file, source
└── fp_node_bringup/ # what it runs on: board, RMW
fp_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. fp_node_bringup
says what the talker runs on: its system.toml holds one image,
[image.freertos], with board = "freertos-posix", and names Cyclone DDS as
the RMW. The FreeRTOS startup task that runs your node is generated from it
when you build.
Run it on this machine
Build and run from the same shell, where ROS 2 is sourced. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
nros run fp_node
nros run builds the talker with CMake (the first build compiles the FreeRTOS
kernel, Cyclone DDS and nano-ros, a few minutes; later builds take seconds)
and runs it. It keeps running until you press Ctrl-C. It prints:
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
See it in ROS 2
Leave nros run going. In a second terminal, ask ROS 2 for the topic over
Cyclone DDS:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
Both sides use domain 0, the ROS 2 default, so they find each other with no configuration. Asking for best-effort receives from a best-effort or a reliable publisher alike.
Zenoh on this board
To talk over zenoh instead, the talker dials a zenoh router on this machine,
at tcp/127.0.0.1:7447. ROS 2’s zenoh middleware brings the router
nros run starts. Install
added it; the first line below is there for a host that skipped it. Then
provision the board for zenoh:
sudo apt-get install -y ros-humble-rmw-zenoh-cpp
nros setup freertos-posix
Scaffold a second workspace beside the first, this time naming zenoh:
cd ..
nros new fpz_ws --board freertos-posix --template talker --lang rust --rmw zenoh
cd fpz_ws
cd ..
nros new fpz_ws --board freertos-posix --template talker --lang c --rmw zenoh
cd fpz_ws
cd ..
nros new fpz_ws --board freertos-posix --template talker --lang cpp --rmw zenoh
cd fpz_ws
Build and run the talker. nros run starts a zenoh router on
tcp/127.0.0.1:7447 for the run and stops it after, so there is nothing to
start beside it:
source /opt/ros/humble/setup.bash
nros run fpz_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
Leave it going. In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
If it doesn’t work
nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it. Source it and run again.nros runsays the router exited: another zenoh router already holds port 7447 on this machine. Stop it;nros runstarts its own.ros2 topic echoprints nothing: check theRMW_IMPLEMENTATIONline, and that neither shell sets aROS_DOMAIN_IDother than 0. A firewall that drops multicast also stops DDS discovery.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration, and moving it to the emulated board: FreeRTOS POSIX.
- The same talker on an emulated Cortex-M3: mps2-an385 in QEMU (FreeRTOS).
- The project, grown: the Tutorial.
Run a talker on an emulated board
Needs first: Install
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
By the end of this chapter, an Arm Cortex-M3 board emulated by QEMU is
printing Publishing: 'Hello World: 1', 'Hello World: 2' and onward, once a
second, and ros2 topic echo on your machine prints the same messages as they
arrive. You write no code and edit no configuration to get there: you
provision the board, scaffold a project, and run it.
This chapter starts the one project the whole Tutorial grows. Each later chapter adds to the workspace you create here, so keep it.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with its zenoh middleware,
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 gives you the router the board talks to, theros2command that shows its messages, and the message definitions the build generates the talker’s code from. If you have no ROS 2 install, the container in Install options has one. The commands here source Humble; on Jazzy, writejazzywhere they sayhumble.
You need no board, no cable and no root access. The emulated board reaches your machine over QEMU’s user network, with no network device to create. WiFi is deferred: no chapter uses it yet.
The board is Arm’s MPS2-AN385, which QEMU models closely. No one buys one: it
is the board this book teaches nano-ros on, because it costs nothing and
behaves like a real microcontroller. FreeRTOS runs on it, the talker runs as
one of its tasks, and lwIP is its network stack. Rust, C and C++ projects all
run on this one board, mps2-an385-freertos, so the commands and the output
are the same whichever language you pick; only the code differs.
Provision the board
nros setup mps2-an385-freertos --rmw zenoh
This fetches the Arm cross-compiler, a QEMU that emulates the MPS2-AN385, the
Rust target for the Cortex-M3, and the FreeRTOS kernel and lwIP sources, into
a shared store under ~/.nros.
Nothing is installed system-wide, and a second project for the same board
reuses what this step fetched. Running it again is quick: it checks what is
there and fetches only what is missing.
--rmw zenoh names the middleware the talker uses to reach ROS 2. nano-ros
offers three, and zenoh is the one the board support registry verifies on
this board, so it is the one this Tutorial uses. nros setup fetches only
what that middleware needs on this board. Chapter 4 compares the three and shows what
each one needs beside your program.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
Pick the language you will write the project in. Every later chapter shows its code in the same three languages, and the project keeps the language you pick here.
nros new sensor_ws --board mps2-an385-freertos --template talker --lang rust
cd sensor_ws
nros new sensor_ws --board mps2-an385-freertos --template talker --lang c
cd sensor_ws
nros new sensor_ws --board mps2-an385-freertos --template talker --lang cpp
cd sensor_ws
nros new prints what it wrote and the command that runs it. The workspace
holds two packages:
sensor_ws/
└── src/
├── sensor_node/ (new) # your node
└── sensor_node_bringup/ (new) # what it runs on
sensor_node is the code: a talker that publishes std_msgs/String on
/chatter once a second. Its build file is a Cargo.toml in Rust and a
CMakeLists.txt in C and C++. sensor_node_bringup says what that code runs
on. The scaffold filled it in, and this chapter never needs you to open it.
The next chapter opens both.
To keep an untouched copy to read beside the one you change, run the same
nros new line again with another workspace name.
Run it
Run it from the same shell, where ROS 2 is sourced. ROS 2 provides the
router the board talks to, and its message definitions are what nros run
generates the talker’s std_msgs code from. This first run records the ROS 2
prefix in the workspace, so a later build of it needs no sourced shell. The
router still does, because it is a ROS 2 program.
nros run sensor_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
The first run compiles nano-ros, the FreeRTOS kernel and lwIP for the Cortex-M3 and takes a few minutes; later runs rebuild only what changed and take seconds. Then QEMU boots the program, and the output looks like this (trimmed):
nros run: starting the zenoh router on tcp/127.0.0.1:7447
========================================
nros FreeRTOS Platform
========================================
Initializing LAN9118 + lwIP...
MAC: 02:00:00:00:00:00
IP: 10.0.2.15
Network ready.
Application setup complete — entering spin loop.
[INFO] sensor_node: [ 3.122351] Publishing: 'Hello World: 1'
[INFO] sensor_node: [ 4.122350] Publishing: 'Hello World: 2'
nros run: starting the zenoh router on tcp/127.0.0.1:7447
Network ready
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run: starting the zenoh router on tcp/127.0.0.1:7447
Network ready
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
Everything after the router line is the board’s console: FreeRTOS brings up
the board’s Ethernet controller and takes the address 10.0.2.15, then the
talker publishes once a second. In Rust, the number in brackets is the
board’s own clock, in seconds since it booted; a C or C++ talker prints its
Publishing: line without the [INFO] prefix.
nros run keeps streaming until you press Ctrl-C, which stops QEMU and the
router together. Leave it running for the next step.
See it in ROS 2
Leave nros run going. In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
ros2 topic echo prints one data: line per message, followed by ---:
data: 'Hello World: 7'
---
data: 'Hello World: 8'
---
The command asks for best-effort delivery, which receives from a publisher
of either kind, so it works whatever QoS a publisher offers. This talker’s
publisher happens to be reliable, as ros2 topic info -v /chatter shows, and
a plain ros2 topic echo /chatter hears it too. Chapter 10 explains the QoS
rules that decide what a subscriber hears, and where nano-ros differs from
ROS 2 on the wire.
Press Ctrl-C in both terminals when you have seen enough.
Change it
Open the talker’s source, change the "Hello World" text, and run
nros run sensor_node again. It rebuilds what changed and boots the new
program.
The text is in src/sensor_node/src/lib.rs, in the line that formats the
message:
#![allow(unused)]
fn main() {
let _ = write!(msg.data, "Hello World: {}", *state);
}
The text is in src/sensor_node/src/Talker.c, in on_tick:
snprintf(self->msg.data.data, self->msg.data.capacity, "Hello World: %d",
(int)self->count);
The text is in src/sensor_node/src/Talker.cpp, in on_tick:
std::snprintf(payload, sizeof(payload), "Hello World: %d", count_);
Keep the message under 64 bytes: the talker formats it into a fixed buffer, because each message is built in a buffer whose size is fixed when the program is built.
What just happened
You ran a ROS 2 talker on a microcontroller without writing any of the program around it. Four things worked together, and each later chapter changes one of them:
- The build.
nros runcompiled your talker, nano-ros and FreeRTOS for the Cortex-M3, a 32-bit Arm core with no memory protection. The program it built contains the talker, the FreeRTOS kernel and the task that runs your node, lwIP, and the zenoh client that carries messages. - The board. QEMU booted that program as the MPS2-AN385 would. QEMU’s
user network connects the board’s emulated Ethernet controller, a LAN9118,
to your host: on that network the board is
10.0.2.15and your host is10.0.2.2. What the program prints reaches your terminal separately, through QEMU itself, which is why the console and the messages do not mix. - The router.
nros runstarted ROS 2’s zenoh router,rmw_zenohd, on TCP port 7447 of your host. The board dials it at10.0.2.2:7447, and every ROS 2 program on your machine reaches it the same way. nano-ros ships no router of its own: the one ROS 2 already uses is the one the board reaches. - ROS 2.
ros2 topic echowithRMW_IMPLEMENTATION=rmw_zenoh_cppconnected to the same router and subscribed to/chatter. To ROS 2, the board is one more node on the graph.
The talker itself is the same kind of node you would write for ROS 2: a publisher, a timer, and a callback that publishes on every tick. What differs is around it. The program is built for one board, its messages are built in buffers of fixed size, and its memory is fixed when it is built. The next chapter opens the two packages and shows where each of those facts is stated.
No QEMU, no router: run it on this machine
The same flow runs on your Linux host, with Cyclone DDS, which needs no router. Only the board in the scaffold line changes; the node code has the same shape, and so does every command after it. Get started on the Linux host takes it step by step. Chapter 9 adds the host to this project as its second target.
If nothing appears
nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it. Runsource /opt/ros/humble/setup.bashand run again.nros runsays the router exited (code 127): the router is a ROS 2 program, and this shell has not sourced ROS 2, so it could not start. Source ROS 2 in that shell and run again.nros runstops at once and names the router: it could not find the zenoh router. Installros-<distro>-rmw-zenoh-cppif it is missing, or pointNROS_RMW_ZENOHDat anrmw_zenohdbinary.- No
Publishing:line within 30 seconds of boot: the router started but the board did not reach it. A cold boot through FreeRTOS, lwIP and the zenoh session takes 10 to 15 seconds.nros runnames the router’s log when it stops. ros2 topic echoprints nothing: check the--qos-reliability best_effortflag and theRMW_IMPLEMENTATIONline.
Troubleshooting index has the rest.
Next
- What you just built: what each of the two
packages is for, and what
nros runmade from them. - FreeRTOS on mps2-an385: the board’s configuration, its own locator and address, and real hardware.
- Bare-metal Cortex-M3: the same board with no operating system, in Rust.
Design background
The chapter follows RFC-0116 D5 and D6, RFC-0121 D4 and D5, and RFC-0124 D3: one Tutorial project on a Verified board.
What you just built
Needs first: Run a talker on an emulated board
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
In this chapter you open the two packages chapter 1 scaffolded and ask
nros what it built from them. At the end you can say which file holds the
talker’s code, which file chose the board and the middleware, and what an
image is: the one program nros run built and booted. You change nothing
yet; every step reads.
Run the steps from the root of sensor_ws, where chapter 1 left you.
List the packages
nros list
nros list prints each package of the workspace with its kind and its
directory. For a Rust project:
ws list (/home/you/sensor_ws):
rust sensor_node src/sensor_node
other sensor_node_bringup src/sensor_node_bringup
ws list: 0 msg, 1 rust consumer
A C or C++ project lists sensor_node as a CMake package instead. The
bringup’s kind is other in every language: it holds no code to compile.
Two packages, two roles. Everything you add to this project in the later chapters is another package with one of these roles, or a few more lines in the bringup. The shape of the workspace never changes; it only gains packages. If you come from ROS 2, both roles are familiar:
| Your workspace | Role | In ROS 2 terms |
|---|---|---|
src/sensor_node/ | node package | a package holding one composable node (rclcpp_components) |
src/sensor_node_bringup/ | bringup package | a <pkg>_bringup package: configuration and launch, no code |
Read the node package
A node package is one node, built as a library. It has no main() and names
no board and no middleware. Its files, in the language you picked:
src/sensor_node/
├── Cargo.toml # a library crate and its dependencies
├── package.xml # ROS 2 manifest: <depend>std_msgs</depend>
└── src/lib.rs # the talker
src/lib.rs declares the node in two parts. register runs once at startup
and states what the node creates: one publisher on /chatter and one timer
that fires every 1,000 ms. on_callback is what runs each time the timer
fires:
#![allow(unused)]
fn main() {
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
let mut node = ctx.create_node(NodeOptions::new("sensor_node"))?;
let pub_chatter = node.create_publisher_for_topic::<StringMsg>("/chatter")?;
let _timer = node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(1000),
)?;
node.callback_for_name("on_tick")
.publishes_entity(&pub_chatter)?;
Ok(())
}
}
The file’s last line, nros::node!(Talker);, exports the node so a program
can run it. Cargo.toml names the class the package exports,
sensor_node::Talker, and lists nros as a dependency with
version = "*". Nothing of nano-ros comes from crates.io: the build points
that dependency at the nano-ros your nros installed.
src/sensor_node/
├── CMakeLists.txt # the library and the class it registers
├── nros-codegen.toml # the longest string a message holds
├── package.xml # ROS 2 manifest: <depend>std_msgs</depend>
└── src/Talker.c # the talker
src/Talker.c is a state struct, a timer callback and a configure
function. configure runs once at startup, on a node and an executor the
program hands it, and creates one publisher on /chatter and one timer that
fires every second. The file’s last line exports the pair:
RCLC_C_COMPONENT(talker_t, talker_configure)
CMakeLists.txt finds the message package and registers the class the
bringup names (comments trimmed):
find_package(nano_ros REQUIRED)
find_package(std_msgs REQUIRED)
nano_ros_add_node(sensor_node CLASS sensor_node::Talker TYPED
SOURCES src/Talker.c)
Nothing in it chooses the board the project builds for; the bringup does that.
src/sensor_node/
├── CMakeLists.txt # the library and the class it registers
├── include/sensor_node/Talker.hpp # the Talker class
├── nros-codegen.toml # the longest string a message holds
├── package.xml # ROS 2 manifest: <depend>std_msgs</depend>
└── src/Talker.cpp # its two members
The node is a class with a configure(rclcpp::Node&) member, the shape of a
composable node. configure runs once at startup, creates one publisher on
/chatter, and binds on_tick as a timer that fires every second:
class Talker {
::rclcpp::Publisher<std_msgs::msg::String> pub_;
::rclcpp::Timer timer_;
int count_ = 0;
void on_tick();
public:
::rclcpp::Result configure(::rclcpp::Node& node);
};
CMakeLists.txt finds the message package and registers the class the
bringup names (comments trimmed):
find_package(nano_ros REQUIRED)
find_package(std_msgs REQUIRED)
nano_ros_add_node(sensor_node CLASS sensor_node::Talker
SOURCES src/Talker.cpp)
target_link_libraries(sensor_node_sensor_node_component
PUBLIC std_msgs__nano_ros_cpp)
The last line links the generated C++ code of std_msgs. Nothing in the
file chooses the board the project builds for; the bringup does that.
In every language, package.xml is a standard ROS 2 manifest, and its
<depend>std_msgs</depend> line is the only place the message package is
named. The build generates the std_msgs code from your ROS 2 install, which
is why chapter 1 sourced ROS 2 before the first run. You never write message
code by hand, and you never commit it.
The same node package builds for any board, because nothing in it says
mps2-an385, freertos or zenoh. Those words belong to the bringup.
Read the bringup
cat src/sensor_node_bringup/system.toml
Comments trimmed, the file is:
[system]
name = "sensor_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
[[component]]
pkg = "sensor_node"
class = "sensor_node::Talker"
name = "sensor_node"
[image.freertos]
board = "mps2-an385-freertos"
stack_floor_image = "talker/rust/zenoh@mps2-an385-freertos"
A C or C++ project’s file is the same, but for c or cpp in place of
rust on the last line. The bringup holds package.xml, this
system.toml and a contract file that chapter 3 looks at, and no code. Its
three tables answer three questions:
[system]: how the nodes reach ROS 2.rmwis the middleware, the--rmw zenohyou passed tonros setup.ros_editionis the ROS 2 release your peers run, anddomain_idis the ROS 2 domain.[[component]]: which nodes run. One row per node: the package, the class it registers, and the node’s name at run time. Chapter 3 adds a second row.[image.freertos]: what program is built, for which board. Theboardline chose the MPS2-AN385 with FreeRTOS under the program. The table has nolocatorline, so the image reaches its zenoh router the way the board states: TCP to10.0.2.2:7447, over the board’s emulated Ethernet.stack_floor_imagenames the template the image was made from, whose measured stack use the build checks this image against; remove it once the image is no longer that template.
Every configuration choice of the project lives in this file, never in a
node package. Moving the talker to another board is another [image.*]
table; switching the middleware is the rmw line. Neither touches
src/sensor_node/.
Ask what nros run runs
nros run sensor_node worked in chapter 1, but you never said which board.
Ask nros how it decided, without building or booting anything:
nros run sensor_node --dry-run --why
--dry-run prints the run plan instead of carrying it out, and --why adds
where each part of the plan came from. The parts that matter here, trimmed:
image = "sensor_node_bringup:freertos"
verb = "run"
[runner]
package = "nros_runner_qemu"
name = "qemu"
[target]
emulator = "qemu:mps2-an385"
[console]
kind = "semihosting"
[link]
kind = "tcp"
locator = "tcp/10.0.2.2:7447"
rmw = "zenoh"
host_peer = "zenoh-router"
[provenance]
image = "rung 3, `<node>`: `sensor_node` is the only component of `sensor_node_bringup`, whose only image this is"
link = "board"
"link.host_peer" = "rmw `zenoh` (.../nros-rmw-zenoh/nros-rmw.toml)"
"target.emulator" = "board"
Read it from the top:
imageissensor_node_bringup:freertos: the bringup, a colon, and the name of its[image.freertos]table. That is the full name of what you ran.[provenance] imageexplains the shortcut. You typed the name of a node;sensor_nodeis the only node ofsensor_node_bringup, and that bringup has only one image, so the name picked exactly one image.[target]and[runner]say the image runs in QEMU’s MPS2-AN385, booted by theqemurunner. Their provenance isboard: the board’s own description states how it runs, so the bringup does not.[link]is how the image reaches its router, TCP to the host, and it is whynros runstarted a zenoh router on TCP port 7447. Its provenance isboard: the image states no locator, so the board’s applies. Itshost_peeris what the zenoh backend’s own descriptor says it needs on this side of the link; that, not the backend’s name, is what decides to start a router.[console]says the program’s printed output comes through QEMU’s semihosting, apart from the network the messages use.
See what the build left behind
Chapter 1’s run left more in the workspace than the two packages:
ls
build generated nros-sdk.lock src
src/holds the two packages, and nothing else. It is the only directory you write in.generated/holds the message code the build generated from your ROS 2 install:std_msgs, andbuiltin_interfaces, whichstd_msgsdepends on. Adding a<depend>to a node’spackage.xmladds a directory here on the next build. Chapter 5 adds your own message package and finds its code here too.build/holds the image’s build tree, the program’s generatedmain(), and each run’s logs. The board’s console from chapter 1 is inbuild/nros/run/sensor_node_bringup_freertos/console.log, which is the first file to read when a run goes wrong.nros-sdk.lockrecords what the build was made from: the versions of the ROS 2 message packages it generated code from, and the source of the zenoh client it compiled. The scaffold’s.gitignoreleaves it in, so it is committed with your sources and a teammate’s build uses the same inputs.
The scaffold’s .gitignore leaves out build/ and generated/. You can
delete both at any time: the next nros run makes them again, which takes as
long as chapter 1’s first run did.
What just happened
You met the three nano-ros ideas every later chapter builds on.
A node package is code that runs anywhere. It is a library holding one
node. It has no main() and names no board, no middleware and no ROS 2
release, so the same package goes into an image for this emulated board, an
image for your Linux host, or an image for a board with an RTOS, without a
second copy.
A bringup package says what runs where. It holds no code: only
system.toml, which lists the nodes ([[component]]), how they reach ROS 2
([system]), and the programs to build ([image.*]). Where a ROS 2 project
spreads that across launch files, parameter files and environment variables,
nano-ros keeps it in one file, because on a microcontroller it must be known
when the program is built: there is no shell, file system or environment to
read it from at run time.
An image is one program for one board. Each [image.*] table is one
image: the bringup’s nodes, built with one middleware for one board, into one
file you can boot or flash. nros run built sensor_node_bringup:freertos
in chapter 1 and booted it in QEMU. Nothing in src/ contains that program’s
main(): nros generated it under build/ from the image table, together
with the generated message code and the build settings the board needs.
This is where nano-ros differs most from a ROS 2 workspace. In ROS 2, a
package builds executables, and you start each one with ros2 run or a
launch file, as its own process, on a machine that already runs an operating
system. In nano-ros there is no separate step that starts nodes: the image
is the whole system for its board. Every node of the bringup is compiled
into it, they share one executor, and booting the image starts all of them.
Running two images means two programs, on one board each. A bare-metal board
has no processes at all, so one program per board is the only shape that fits
it, and nano-ros uses the same shape on every board, Linux included, so a
project does not change shape when it changes board.
Everything under src/ is yours to edit and commit. Everything under
build/ is derived from src/ and your ROS 2 install, so none of it is
committed and none of it is edited; the scaffold’s .gitignore already
leaves it out. How a build becomes an image
explains the layers inside an image and why the program is generated rather
than written.
Next
- Add a second node: a listener in the same image, and the workspace that holds both.
- Organize a larger workspace: every field of the two roles, for when you need them.
Design background
The two roles and the generated program follow RFC-0121 D1 to D3. The run plan
--dry-run prints is RFC-0118’s.
Add a second node
Needs first: What you just built
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
In this chapter you add a listener to the project: a second node package,
monitor_node, that subscribes to /chatter. At the end, one run of the
board prints both sides of the conversation:
[INFO] sensor_node: [ 3.122528] Publishing: 'Hello World: 1'
[INFO] monitor_node: [ 3.123277] I heard: [Hello World: 1]
Along the way you see what makes sensor_ws a workspace, and why adding a
node is one package and one line in the bringup. This is the part of the
workspace the chapter adds to:
sensor_ws/
└── src/
├── monitor_node/ (new)
├── sensor_node/
└── sensor_node_bringup/
├── package.xml (changed)
├── system.contract.yaml (changed)
└── system.toml (changed)
Run every step from the root of sensor_ws.
Add the listener package
nros new monitor_node --template listener --lang rust --to sensor_node_bringup
nros new monitor_node --template listener --lang c --to sensor_node_bringup
nros new monitor_node --template listener --lang cpp --to sensor_node_bringup
nros new: added the node package src/monitor_node/ (listener, rust) to /home/you/sensor_ws
declared it in /home/you/sensor_ws/src/sensor_node_bringup: a [[component]] row and an <exec_depend>
Inside a workspace, nros new adds a package under src/ instead of writing
a new workspace. --template listener picks the node it holds: a
subscription on /chatter that prints each message it receives. --to sensor_node_bringup also tells the bringup to run it, which the next step
looks at. Without --to, no bringup is touched, and the package sits in the
workspace until a bringup names it.
Use the language of the rest of your project. A workspace can mix languages, and Mix languages shows how, but this Tutorial keeps to one.
Read the listener
The new package has the shape of sensor_node: a library holding one node,
with no main() and no board.
src/monitor_node/
├── Cargo.toml # a [lib] crate; registers monitor_node::Listener
├── package.xml # <depend>std_msgs</depend>
└── src/lib.rs # the listener; its last line is nros::node!(Listener);
register creates one subscription and binds it to the callback named
on_chatter. on_callback reads the message when that callback fires:
#![allow(unused)]
fn main() {
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
nros_log::register_logger(&LOGGER);
let mut node = ctx.create_node(NodeOptions::new("monitor_node"))?;
let _sub = node.create_subscription_for_callback_name::<StringMsg>(
"on_chatter",
"/chatter",
)?;
log_info!(&LOGGER, "Subscriber created for topic: /chatter");
Ok(())
}
fn on_callback(
state: &mut Self::State,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_chatter"
&& let Ok(msg) = ctx.message::<StringMsg>()
{
*state = state.wrapping_add(1);
log_info!(&LOGGER, "I heard: [{}]", msg.data);
}
}
}
register declares what the node creates; it does not run the node. It runs
once, at startup, and no message flows during it. on_callback is the body,
which the executor calls each time one of the node’s callbacks fires;
state is the node’s own storage, here a count of the messages it has seen.
The constant at the top of the impl Component block, ENTITY_BOUNDS,
says how many publishers, service servers, service clients, action clients
and action servers the node creates. The talker’s is exact(1, 0, 0, 0, 0):
one publisher. The listener’s is all zeros, because a subscription needs no
slot there. The numbers size static memory, so they are exact rather than
generous; a node that creates more than it declares stops at boot, naming
the node, rather than dropping one silently.
Cargo.toml registers the class the package exports:
[package.metadata.nros.node]
class = "monitor_node::Listener"
name = "monitor_node"
src/monitor_node/
├── CMakeLists.txt # registers monitor_node::Listener
├── nros-codegen.toml # the longest string a message holds
├── package.xml # <depend>std_msgs</depend>
└── src/Listener.c # the listener
listener_configure creates one subscription and adds it to the executor
with a callback and a context pointer, the way rclc does. The message is
owned by the node’s state struct, so nothing allocates when one arrives:
static void on_msg(const void* msgin, void* ctx) {
listener_t* self = (listener_t*)ctx;
const std_msgs__msg__String* msg = (const std_msgs__msg__String*)msgin;
printf("I heard: [%.*s]\n", (int)msg->data.size, msg->data.data);
self->recv++;
}
static rcl_ret_t listener_configure(rcl_node_t* node, rclc_executor_t* executor,
listener_t* self) {
self->recv = 0;
std_msgs__msg__String__init_in(&self->msg, &self->msg_storage);
self->sub = rcl_get_zero_initialized_subscription();
rcl_ret_t rc = rclc_subscription_init_default(
&self->sub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String),
"/chatter");
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_subscription_with_context(
executor, &self->sub, &self->msg, on_msg, self, ON_NEW_DATA);
}
RCLC_C_COMPONENT(listener_t, listener_configure)
std_msgs__msg__String__init_in points the message’s string at
msg_storage, memory the node owns. Generated messages take rosidl’s C
names and member shape, and their strings and sequences always point at
memory you own: nothing on this path allocates, so rosidl’s allocating
__init and __fini are not declared.
src/monitor_node/
├── CMakeLists.txt # registers monitor_node::Listener
├── include/monitor_node/Listener.hpp # the Listener class
├── nros-codegen.toml # the longest string a message holds
├── package.xml # <depend>std_msgs</depend>
└── src/Listener.cpp # its two members
configure binds the member on_msg as the subscription’s callback, by
identity rather than through a std::function:
void Listener::on_msg(const ::std_msgs::msg::String& msg) {
std::printf("I heard: [%s]\n", msg.data.c_str());
++recv_;
}
::rclcpp::Result Listener::configure(::rclcpp::Node& node) {
return ::rclcpp::bind_subscription<::std_msgs::msg::String, Listener,
&Listener::on_msg>(node, "/chatter", this);
}
Every call returns a Result rather than throwing, because every nano-ros
build compiles with -fno-exceptions. configure returns the first
failure, and the program stops at boot naming the node that failed.
Port a C++ node shows the
rclcpp-shaped constructors a ported node can keep.
Where its messages come from
In every language, the listener’s package.xml is a standard ROS 2 manifest,
and its one <depend> names the message package the node uses:
<depend>std_msgs</depend>
That line is all you write for a message package. The build generates the
message code from your ROS 2 install and links it into the node: in Rust it
adds a dependency row to Cargo.toml, tagged # nros-managed, pointing at
the crate it generated under generated/; in C and C++, find_package finds
the generated code during the CMake configure. Removing the <depend> removes
the generated code from the node’s build. A row in Cargo.toml without the
# nros-managed tag is yours and is never touched, so to override a
generated row, delete its tag.
Both nodes depend on std_msgs, and the build generates it once for the
workspace, not once per package. Chapter 5 adds a message package of your
own, which every node in the workspace can depend on the same way.
See the bringup run both
cat src/sensor_node_bringup/system.toml
--to sensor_node_bringup added a second [[component]] row, after the
talker’s:
[[component]]
pkg = "sensor_node"
class = "sensor_node::Talker"
name = "sensor_node"
[[component]]
pkg = "monitor_node"
class = "monitor_node::Listener"
name = "monitor_node"
| Field | Meaning |
|---|---|
pkg | the node package: its <name> in package.xml |
class | the class the package registers |
name | the node’s name at run time; chapter 7 renames one |
It also added <exec_depend>monitor_node</exec_depend> to the bringup’s
package.xml, beside the talker’s, so the bringup states every package it
runs, the way a ROS 2 bringup package does. To run a node package you
copied in from elsewhere, write both lines by hand.
It also gave monitor_node a row in the bringup’s contract,
system.contract.yaml, beside the talker’s: one subscription to chatter
and no parameters. The contract states what each node creates, so the build
can size the image from it, and it must name every node the image runs.
Chapter 8 writes a contract of your own.
The image table did not change. [image.freertos] still names one board,
and it now builds both rows into its one program.
nros graph shows the same facts as an order: each package after the
packages it depends on, with the bringup last because it runs both nodes:
nros graph
monitor_node
sensor_node
sensor_node_bringup <- monitor_node, sensor_node
The two node packages depend on nothing in the workspace. Neither one names
the other: the only thing they share is the topic name /chatter and its
type, std_msgs/String, which is all a ROS 2 publisher and subscriber ever
share.
Before you build, nros check catches the common mistakes in a workspace: a
row naming a package or class that does not exist, or a build file left in
the bringup:
nros check --workspace .
nros check: ok (workspace ., 3 pkg(s), 0 warning(s))
Run both nodes
source /opt/ros/humble/setup.bash
nros run
Publishing: 'Hello World: 1'
I heard: [Hello World: 1]
The run builds the new package, then boots the board. A Rust project’s console, trimmed:
[INFO] monitor_node: [ 2.128731] Subscriber created for topic: /chatter
Application setup complete — entering spin loop.
[INFO] sensor_node: [ 3.122528] Publishing: 'Hello World: 1'
[INFO] monitor_node: [ 3.123277] I heard: [Hello World: 1]
[INFO] sensor_node: [ 4.130612] Publishing: 'Hello World: 2'
[INFO] monitor_node: [ 4.144289] I heard: [Hello World: 2]
A C or C++ project prints the same lines without the [INFO] prefix. Press
Ctrl-C when you have seen both nodes.
This time the command names nothing to run. With nothing named, nros run
runs the workspace’s only image, and sensor_node_bringup:freertos is
still the only one.
nros run sensor_node, the spelling from chapter 1, no longer works. It
meant “the bringup whose only node is sensor_node”, and the bringup now has
two, so it refuses and prints the full name that would work:
nros run: `sensor_node` is a component of `sensor_node_bringup`, but never the only one, so it names no one image; name one:
sensor_node_bringup:freertos
nros run sensor_node_bringup:freertos always works: it is the bringup and
the image, the name chapter 2’s --dry-run printed. nros run never guesses
between several images; when a short name matches more than one, it lists the
full names instead.
To see which rule picked the image when nothing is named, add --dry-run --why as in chapter 2. The [provenance] table’s image line now says the
image was the workspace’s only one, rather than the only image of the only
bringup that runs sensor_node. The same four spellings work for nros build
too, and chapter 9, which gives the project a second image, lists them in
the order they are tried.
The console also shows a warning from the listener’s subscription: it asked for a history of 10 messages, and this board’s receive buffer holds 4. The image granted 4 and told the ROS 2 graph so. Chapter 8 shows where that number comes from and how to state the one you need.
How two nodes share one board
Both nodes now run in one program, on a processor with one core, in one FreeRTOS task. One executor runs every callback of both nodes, one at a time: the talker’s timer callback, then the listener’s subscription callback when the message arrives, then whatever is ready next. Nothing runs two callbacks at once, so neither node needs a lock around its state.
The cost is that callbacks share the processor’s time. A callback that waits, spins or blocks holds up every other callback in the image, the other node’s included. Keep each callback short: read the message, update the state, publish, return. Work that takes longer belongs in a task of its own, which Pick a scheduling model covers, and The execution model explains how the executor decides what runs next.
For the same reason, a node cannot make a blocking service call from inside a callback: the executor is in the middle of running that callback, and the reply could never be delivered. Chapter 6 shows where such calls go instead.
What just happened
You turned a project of one node into a workspace of two, and the shape did not change.
A nano-ros workspace is a directory of packages under src/, like a colcon
workspace. It has no root Cargo.toml or CMakeLists.txt, and no file that
lists its packages: nros finds each package by its package.xml. nros list and nros graph show what it found. Each package keeps one role. A
node package holds one node and no board; a bringup holds the board, the
middleware and the list of nodes, and no code. Adding a node is therefore
always two edits: a package under src/, and a row in the bringup that runs
it. nros new --to makes both.
What differs from a colcon workspace is what a build produces. colcon build
builds each package into its own executables. nros run built the bringup’s
one image, and both node packages went into it: one program for the board,
with one executor running both nodes’ callbacks. Neither node package knows
the other is there. The talker would publish with no listener, and the
listener would wait with no talker, in this image or in two images on two
boards.
| ROS 2 | nano-ros |
|---|---|
ros2 pkg create | nros new <pkg> inside the workspace; --to <bringup> adds its component row |
colcon build | nros build (every image) or nros build <image> |
ros2 run <pkg> <exe> | nros run <node>, when one bringup runs only that node |
ros2 launch <pkg> <file> | nros run <bringup>:<image> |
Organize a larger workspace covers what a workspace grows into: several bringups, shared packages, and every field of the two roles.
Next
- Pick and configure the RMW: the three middlewares, and the link the image uses to reach its router.
- Mix languages: a C++ node beside a Rust one in the same image.
Design background
The workspace layout and nros new --to follow RFC-0121; one page for the
three languages follows RFC-0124 D9.
Pick and configure the RMW
Needs first: Add a second node
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
Every nano-ros image talks to ROS 2 through one RMW, the ROS middleware
layer: zenoh, Cyclone DDS or XRCE-DDS. In this chapter you find which one the
project uses and the link it reaches ROS 2 over, compare what each backend
needs beside the board, and write the image’s link into the bringup, where
you would change it. At the end, nros run --dry-run --why says the link
comes from your image rather than the board, and ros2 topic echo still
receives every message.
This is the part of the workspace the chapter changes:
sensor_ws/
└── src/
└── sensor_node_bringup/
└── system.toml (changed)
Run every step from the root of sensor_ws.
Find the project’s RMW
Open src/sensor_node_bringup/system.toml. Two places in it decide how the
project reaches ROS 2 (trimmed):
[system]
name = "sensor_node"
rmw = "zenoh"
[image.freertos]
board = "mps2-an385-freertos"
rmw = "zenoh" in [system] picks the middleware for every image of the
bringup. The [image.freertos] table would say where the image finds its
zenoh router, in a locator line, but it has none, so the board’s own
applies: TCP to 10.0.2.2:7447, your host as QEMU’s user network sees it.
Chapter 2’s --dry-run --why showed that link with the provenance board.
The RMW is chosen when the image is built, not when it starts. ROS 2 reads
RMW_IMPLEMENTATION when a process starts and loads that middleware’s shared
library; a microcontroller has no shared libraries to load and no environment
to read. So the build links the chosen backend into the image, and only that
one: an image built for zenoh contains no DDS code at all. Changing the RMW
means editing the rmw line and building again.
Compare the three backends
All three carry topics, services and actions between a nano-ros image and ROS 2. They differ in what has to run beside your image, and in what the image needs from its board:
| zenoh | Cyclone DDS | XRCE-DDS | |
|---|---|---|---|
| Runs beside the image | ROS 2’s zenoh router, rmw_zenohd | nothing | the Micro XRCE-DDS Agent, MicroXRCEAgent |
| ROS 2 side | rmw_zenoh_cpp | rmw_cyclonedds_cpp, directly | any DDS RMW, through the agent |
| Links | serial, TCP, UDP | UDP, multicast discovery | serial, UDP, TCP |
| Board needs (planning numbers) | about 16 KB RAM, 100 KB flash | a heap, about 32 KB RAM, 150 KB flash, an IP stack with IGMP | about 3 KB RAM, 75 KB flash |
rmw = | "zenoh" | "cyclonedds" | "xrce" |
The RAM and flash figures are order-of-magnitude planning numbers, not measurements of your image; chapter 8 measures this project’s. The RMW feature matrix lists what each backend supports, generated from the backends’ sources: in short, all three do publish and subscribe, services and status events, and they differ in the less common features, such as graph introspection and zero-copy loans.
How to choose:
- zenoh when the board is small, when its only link to the host is a
serial port, or when the ROS 2 side already runs
rmw_zenoh_cpp. It needs the router, and the router comes from ROS 2, so a machine with ROS 2 installed already has it. - Cyclone DDS when the target has an operating system with a network
stack, such as the Linux host or an RTOS board with Ethernet, and you want
nothing running beside it. A stock ROS 2 node using
rmw_cyclonedds_cppsees it directly, with the same wire protocol and the same discovery. - XRCE-DDS when RAM is the tightest constraint, or when the device joins a
micro-ROS or DDS deployment that already runs an agent. It is
not heap-free: each allocation goes through
nros_platform_alloc, once per session or entity, never per message. The device does no discovery of its own; while the agent is down, the device has no connectivity, and an agent that restarts makes the device open its session again.
On this board the choice is made for you: the board support registry
verifies the MPS2-AN385 images with zenoh, which is why chapter 1
provisioned --rmw zenoh. Chapter 9 runs the same project on the Linux host,
where Cyclone DDS runs too.
How nano-ros differs from ROS 2 explains how each backend reaches the ROS 2 graph, and what happens when the router, the agent or a peer goes away.
State the image’s link
A board’s locator is a default. Write it into the image when the image
should not depend on it: a router on another machine, another port, or a
link the board does not default to. Add the board’s own locator to
[image.freertos], so the image states it:
src/sensor_node_bringup/system.toml, change the marked lines [image.freertos]
board = "mps2-an385-freertos"
+locator = "tcp/10.0.2.2:7447"
A zenoh locator is <link>/<address>: tcp/10.0.2.2:7447 is TCP to port
7447 of the host, the zenoh router’s usual port. A router on another machine
of your network would be tcp/<its address>:7447; a board whose only link is
a UART names its serial port, as in
Use a serial link. Nothing else
changes: the node packages do not name a link, and the board’s description
already says which network devices it has and how its network stack is
built.
Ask nros where the link comes from now:
nros run --dry-run --why
[link]
kind = "tcp"
locator = "tcp/10.0.2.2:7447"
rmw = "zenoh"
host_peer = "zenoh-router"
[provenance]
image = "rung 4, no target named: the workspace's only image"
link = "image"
The plan is the same as chapter 2’s, but its provenance is image: the
locator now comes from your bringup, and a change to that line changes the
run.
Run it
source /opt/ros/humble/setup.bash
nros run
nros run: starting the zenoh router on tcp/127.0.0.1:7447
I heard: [Hello World: 1]
The image is rebuilt with the new line, then boots. A Rust project’s output, trimmed:
nros run: starting the zenoh router on tcp/127.0.0.1:7447
Initializing LAN9118 + lwIP...
MAC: 02:00:00:00:00:00
IP: 10.0.2.15
Network ready.
[INFO] sensor_node: [ 3.127668] Publishing: 'Hello World: 1'
[INFO] monitor_node: [ 3.133778] I heard: [Hello World: 1]
nros run read the locator and started the router listening on TCP port
7447 of your host’s loopback address, because QEMU’s user network delivers
10.0.2.2 to your host’s loopback. It starts the router only when the image
needs one and the address is this host’s. With --router none it starts
nothing, and with --router tcp/<host>:<port> it uses a router you already
run elsewhere.
See it in ROS 2
Leave nros run going. The ROS 2 side has not changed: it reaches the same
router. In a second terminal, the same command as in chapter 1:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
Press Ctrl-C in both terminals when you have seen enough.
What switching the RMW takes
On a board that supports more than one backend, switching is two edits and a provisioning step. This board’s image stays on zenoh, so read this section rather than run it; Switch the RMW per image is the full procedure.
-
Provision the backend for the board:
nros setup <board> --rmw cyclonedds(or--rmw xrce) fetches what that backend needs, as chapter 1’s--rmw zenohdid for zenoh. -
Change the
rmwline. In[system], it changes every image of the bringup. Set inside one[image.*]table, it changes that image only, so one bringup can build its board image with zenoh and its host image with Cyclone DDS:[image.linux] board = "linux" rmw = "cyclonedds" -
Change the link to the backend’s. Cyclone DDS needs no locator: it finds its peers by multicast on the network, and its domain is
[system] domain_id. XRCE-DDS dials its agent, so itslocatornames the agent’s address and port, such asudp/10.0.2.2:2018, andnros runstartsMicroXRCEAgenton that port the way it starts the zenoh router.
Then nros run again. The node packages do not change for any of the three:
the same code publishes over each, because the backend sits below the client
library the nodes call.
What just happened
You configured the project’s RMW in use: the backend linked into the image, and the link it uses to reach whatever runs beside it.
Three facts carry over to every board and every later chapter:
- The RMW is a build-time choice, per image. The
rmwline picks it, in[system]for every image or in one[image.*]for that image. The build links that backend alone. There is noRMW_IMPLEMENTATIONswitch on an embedded target, and the image cannot change its backend after it is built. - Each backend has its own peer beside the image. zenoh needs a router,
XRCE-DDS an agent, and Cyclone DDS nothing but a network that carries
multicast.
nros runstarts the router or the agent when the image’s link points at your host, which is why the project has never needed you to start one by hand. - The link is configuration, not code. The board states a default
link, and one
locatorline in an image overrides it: another address, another port, or a serial port on a board whose only link is a UART. A network needs addresses, which the board’s description and the image supply; a serial link needs a port and a baud rate. WiFi is deferred: no chapter of this book uses it yet.
Next
- Your own message: a message type of your own,
generated like
std_msgs. - Configure zenoh: locators, client mode and the router’s options.
- Use Cyclone DDS and Use XRCE-DDS: what each backend needs on its boards.
- Use a serial link: serial links in depth, including XRCE-DDS over a UART.
Design background
Choosing the backend at build time follows RFC-0031; using ROS 2’s own router
follows RFC-0075; nros run starting it follows RFC-0118 D8. RMW use before
RMW implementation is RFC-0124 D5.
Your own message
Needs first: Pick and configure the RMW
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
So far the project has sent text: std_msgs/String, a message package that
comes with ROS 2. A sensor sends numbers, with names and units. In this
chapter you write a message package of your own, tutorial_msgs, with one
message, Reading, and change both nodes to use it. At the end the board
prints
[INFO] sensor_node: [ 3.143246] Publishing: reading 1 (21100 mC)
[INFO] monitor_node: [ 3.167941] I heard: reading 1 (21100 mC)
and the package you wrote is an ordinary ROS 2 message package, which a ROS 2 machine builds unchanged.
Run every step from the root of sensor_ws. The chapter adds one package
and changes both nodes, in the language you picked:
sensor_ws/
└── src/
├── monitor_node/
│ ├── package.xml (changed)
│ └── src/lib.rs (changed)
├── sensor_node/
│ ├── package.xml (changed)
│ └── src/lib.rs (changed)
└── tutorial_msgs/ (new)
├── CMakeLists.txt (new)
├── package.xml (new)
└── msg/Reading.msg (new)
sensor_ws/
└── src/
├── monitor_node/
│ ├── CMakeLists.txt (changed)
│ ├── package.xml (changed)
│ └── src/Listener.c (changed)
├── sensor_node/
│ ├── CMakeLists.txt (changed)
│ ├── package.xml (changed)
│ └── src/Talker.c (changed)
└── tutorial_msgs/ (new)
├── CMakeLists.txt (new)
├── package.xml (new)
└── msg/Reading.msg (new)
sensor_ws/
└── src/
├── monitor_node/
│ ├── CMakeLists.txt (changed)
│ ├── package.xml (changed)
│ ├── include/monitor_node/Listener.hpp (changed)
│ └── src/Listener.cpp (changed)
├── sensor_node/
│ ├── CMakeLists.txt (changed)
│ ├── package.xml (changed)
│ ├── include/sensor_node/Talker.hpp (changed)
│ └── src/Talker.cpp (changed)
└── tutorial_msgs/ (new)
├── CMakeLists.txt (new)
├── package.xml (new)
└── msg/Reading.msg (new)
Write the message package
A message package is a directory under src/ with a package.xml, a
CMakeLists.txt and one file per message. nano-ros reads the stock ROS 2
shape, so these three files are exactly what the ROS 2 documentation’s
custom interfaces tutorial
has you write. Create them in an editor.
The manifest declares the package an interface package:
src/tutorial_msgs/package.xml<?xml version="1.0"?>
<package format="3">
<name>tutorial_msgs</name>
<version>0.1.0</version>
<description>The Tutorial project's messages</description>
<maintainer email="you@example.com">you</maintainer>
<license>Apache-2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rosidl_default_generators</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
The build file asks rosidl to generate the interfaces. nano-ros never runs
this file: its build reads the package’s msg/ directory itself. It is
there so the same package builds with colcon on a ROS 2 machine, which
chapter 10 does.
src/tutorial_msgs/CMakeLists.txtcmake_minimum_required(VERSION 3.20)
project(tutorial_msgs)
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
msg/Reading.msg
)
ament_export_dependencies(rosidl_default_runtime)
ament_package()
And the message, in the ROS 2 .msg format, one field per line:
src/tutorial_msgs/msg/Reading.msg# One sample from the sensor node.
int32 sequence # counts up from 1
int32 temperature_mc # milli-degrees Celsius
Each line is a type and a name. The types are ROS 2’s, and each maps to the same type in every language the project can use:
.msg type | Rust | C | C++ |
|---|---|---|---|
int32 | i32 | int32_t | int32_t |
float64 | f64 | double | double |
bool | bool | bool | bool |
string | a fixed-capacity string | a pointer, size and capacity into memory you own | a fixed-capacity string |
T[] | a fixed-capacity sequence | a pointer, size and capacity into memory you own | a fixed-capacity sequence |
The last two rows are where a microcontroller shows: a string or a sequence cannot grow at run time, because nothing allocates. What that costs is in “What just happened” below.
Both fields are integers. The temperature is in thousandths of a degree,
21100 for 21.1 °C, a common choice on a microcontroller: it keeps the
message small and exact, and printing it needs no floating-point formatting,
which costs flash on a board this size.
Ask nros whether it found the message:
nros interface show tutorial_msgs/msg/Reading
# One sample from the sensor node.
int32 sequence # counts up from 1
int32 temperature_mc # milli-degrees Celsius
nros interface show searches the workspace’s src/ first, then your ROS 2
install, so it prints any message a node in this workspace can use.
nros interface list prints all of them.
Depend on it
Each node declares the message packages it uses in its package.xml.
Replace std_msgs with tutorial_msgs in both nodes:
src/sensor_node/package.xml, change the marked lines <license>Apache-2.0</license>
- <depend>std_msgs</depend>
+ <depend>tutorial_msgs</depend>
<export>
src/monitor_node/package.xml, change the marked lines <license>Apache-2.0</license>
- <depend>std_msgs</depend>
+ <depend>tutorial_msgs</depend>
<export>
In Rust, that is the whole change to the build: the next build rewrites the
# nros-managed row in each Cargo.toml to the generated tutorial_msgs
crate. A C or C++ build finds message packages with find_package, so
change that line in each node’s CMakeLists.txt too:
Nothing more to change: Cargo.toml follows package.xml.
src/sensor_node/CMakeLists.txt, change the marked lines set(CMAKE_C_STANDARD_REQUIRED ON)
find_package(nano_ros REQUIRED)
-find_package(std_msgs REQUIRED)
+find_package(tutorial_msgs REQUIRED)
src/monitor_node/CMakeLists.txt, change the marked lines set(CMAKE_C_STANDARD_REQUIRED ON)
find_package(nano_ros REQUIRED)
-find_package(std_msgs REQUIRED)
+find_package(tutorial_msgs REQUIRED)
src/sensor_node/CMakeLists.txt, change the marked lines set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(nano_ros REQUIRED)
-find_package(std_msgs REQUIRED)
+find_package(tutorial_msgs REQUIRED)
src/sensor_node/CMakeLists.txt, change the marked lines target_link_libraries(sensor_node_sensor_node_component
- PUBLIC std_msgs__nano_ros_cpp)
+ PUBLIC tutorial_msgs__nano_ros_cpp)
src/monitor_node/CMakeLists.txt, change the marked lines set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(nano_ros REQUIRED)
-find_package(std_msgs REQUIRED)
+find_package(tutorial_msgs REQUIRED)
src/monitor_node/CMakeLists.txt, change the marked lines target_link_libraries(monitor_node_monitor_node_component
- PUBLIC std_msgs__nano_ros_cpp)
+ PUBLIC tutorial_msgs__nano_ros_cpp)
The C++ node also links the generated C++ message library by name, in its
target_link_libraries line.
Publish a reading
Replace the talker’s code. It publishes a Reading on /reading once a
second, with a sequence number and a temperature that steps through ten
values:
src/sensor_node/src/lib.rs#![allow(unused)]
fn main() {
//! `sensor_node`: publishes a `tutorial_msgs/Reading` on `/reading` once a second.
#![no_std]
use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode,
NodeContext, NodeOptions, NodeResult, TimerDuration,
};
use nros_log::{Logger, log_info};
use tutorial_msgs::msg::Reading;
static LOGGER: Logger = Logger::new("sensor_node");
pub struct Talker;
impl Component for Talker {
const NAME: &'static str = "sensor_node";
const ENTITY_BOUNDS: nros::EntityBounds =
nros::EntityBounds::exact(1, 0, 0, 0, 0);
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
nros_log::register_logger(&LOGGER);
let mut node = ctx.create_node(NodeOptions::new("sensor_node"))?;
let pub_reading = node.create_publisher_for_topic::<Reading>("/reading")?;
let _timer = node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(1000),
)?;
node.callback_for_name("on_tick")
.publishes_entity(&pub_reading)?;
Ok(())
}
}
impl ExecutableNode for Talker {
/// The sequence number of the last reading published.
type State = i32;
const HAS_TICK: bool = false;
fn init() -> Self::State {
0
}
fn on_callback(
state: &mut Self::State,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_tick" {
*state = state.wrapping_add(1);
let msg = Reading {
sequence: *state,
temperature_mc: 21_000 + (*state % 10) * 100,
};
let _ = ctx.publish_to_topic::<Reading, 32>("/reading", &msg);
log_info!(
&LOGGER,
"Publishing: reading {} ({} mC)",
msg.sequence,
msg.temperature_mc
);
}
}
}
nros::node!(Talker);
}
tutorial_msgs::msg::Reading is a plain Rust struct with one field per line
of the .msg file, generated under generated/tutorial_msgs. The 32 in
publish_to_topic::<Reading, 32> is the size of the buffer the message is
serialized into, in bytes; a Reading needs 12.
src/sensor_node/src/Talker.c// sensor_node: publishes a tutorial_msgs/Reading on /reading once a second.
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <rcl/rcl.h>
#include <rclc/executor.h>
#include <rclc/rclc.h>
#include <tutorial_msgs/tutorial_msgs.h>
typedef struct {
rcl_publisher_t pub;
rcl_timer_t timer;
int32_t count;
} talker_t;
static void on_tick(rcl_timer_t* timer, int64_t last_call_time) {
talker_t* self = RCLC_CONTAINER_OF(timer, talker_t, timer);
(void)last_call_time;
self->count++;
tutorial_msgs__msg__Reading msg;
memset(&msg, 0, sizeof msg);
msg.sequence = self->count;
msg.temperature_mc = 21000 + (self->count % 10) * 100;
if (rcl_publish(&self->pub, &msg, NULL) == RCL_RET_OK) {
printf("Publishing: reading %d (%d mC)\n", (int)msg.sequence,
(int)msg.temperature_mc);
}
}
static rcl_ret_t talker_configure(rcl_node_t* node, rclc_executor_t* executor,
talker_t* self) {
setvbuf(stdout, NULL, _IOLBF, 0);
self->count = 0;
self->pub = rcl_get_zero_initialized_publisher();
rcl_ret_t rc = rclc_publisher_init_default(
&self->pub, node,
ROSIDL_GET_MSG_TYPE_SUPPORT(tutorial_msgs, msg, Reading), "/reading");
if (rc != RCL_RET_OK) {
return rc;
}
self->timer = rcl_get_zero_initialized_timer();
rc = rclc_timer_init_default(&self->timer, NULL, 1000000000ULL, on_tick);
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_timer(executor, &self->timer);
}
RCLC_C_COMPONENT(talker_t, talker_configure)
The generated header, <tutorial_msgs/tutorial_msgs.h>, declares
tutorial_msgs__msg__Reading with rosidl’s C names, and
ROSIDL_GET_MSG_TYPE_SUPPORT(tutorial_msgs, msg, Reading) names its type
support, as in rclc.
src/sensor_node/include/sensor_node/Talker.hpp#pragma once
#include <rclcpp/rclcpp.hpp>
#include "tutorial_msgs.hpp"
namespace sensor_node {
class Talker {
::rclcpp::Publisher<::tutorial_msgs::msg::Reading> pub_;
::rclcpp::Timer timer_;
int32_t count_ = 0;
void on_tick();
public:
::rclcpp::Result configure(::rclcpp::Node& node);
};
} // namespace sensor_node
src/sensor_node/src/Talker.cpp#include "sensor_node/Talker.hpp"
#include <cstdio>
namespace sensor_node {
void Talker::on_tick() {
++count_;
::tutorial_msgs::msg::Reading msg;
msg.sequence = count_;
msg.temperature_mc = 21000 + (count_ % 10) * 100;
if (pub_.publish(msg).ok()) {
std::printf("Publishing: reading %d (%d mC)\n",
static_cast<int>(msg.sequence),
static_cast<int>(msg.temperature_mc));
}
}
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
::setvbuf(stdout, nullptr, _IOLBF, 0);
::rclcpp::Result r = node.create_publisher(pub_, "/reading");
if (!r.ok()) return r;
return node.create_wall_timer<Talker, &Talker::on_tick>(timer_, 1000, this);
}
} // namespace sensor_node
The generated header, tutorial_msgs.hpp, declares
tutorial_msgs::msg::Reading with the member names of the .msg file, as
rclcpp’s generated headers do.
Hear a reading
Replace the listener’s code to match. It subscribes to /reading and
prints both fields:
src/monitor_node/src/lib.rs#![allow(unused)]
fn main() {
//! `monitor_node`: subscribes to `/reading` and logs each reading.
#![no_std]
use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode,
NodeContext, NodeOptions, NodeResult,
};
use nros_log::{Logger, log_info};
use tutorial_msgs::msg::Reading;
static LOGGER: Logger = Logger::new("monitor_node");
pub struct Listener;
impl Component for Listener {
const NAME: &'static str = "monitor_node";
const ENTITY_BOUNDS: nros::EntityBounds =
nros::EntityBounds::exact(0, 0, 0, 0, 0);
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
nros_log::register_logger(&LOGGER);
let mut node = ctx.create_node(NodeOptions::new("monitor_node"))?;
let _sub = node.create_subscription_for_callback_name::<Reading>(
"on_reading",
"/reading",
)?;
Ok(())
}
}
impl ExecutableNode for Listener {
/// Number of readings seen.
type State = i32;
const HAS_TICK: bool = false;
fn init() -> Self::State {
0
}
fn on_callback(
state: &mut Self::State,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_reading"
&& let Ok(msg) = ctx.message::<Reading>()
{
*state = state.wrapping_add(1);
log_info!(
&LOGGER,
"I heard: reading {} ({} mC)",
msg.sequence,
msg.temperature_mc
);
}
}
}
nros::node!(Listener);
}
src/monitor_node/src/Listener.c// monitor_node: subscribes to /reading and prints each reading.
#include <stdint.h>
#include <stdio.h>
#include <rcl/rcl.h>
#include <rclc/executor.h>
#include <rclc/rclc.h>
#include <tutorial_msgs/tutorial_msgs.h>
typedef struct {
rcl_subscription_t sub;
tutorial_msgs__msg__Reading msg;
int recv;
} listener_t;
static void on_msg(const void* msgin, void* ctx) {
listener_t* self = (listener_t*)ctx;
const tutorial_msgs__msg__Reading* msg =
(const tutorial_msgs__msg__Reading*)msgin;
printf("I heard: reading %d (%d mC)\n", (int)msg->sequence,
(int)msg->temperature_mc);
self->recv++;
}
static rcl_ret_t listener_configure(rcl_node_t* node, rclc_executor_t* executor,
listener_t* self) {
setvbuf(stdout, NULL, _IOLBF, 0);
self->recv = 0;
self->sub = rcl_get_zero_initialized_subscription();
rcl_ret_t rc = rclc_subscription_init_default(
&self->sub, node,
ROSIDL_GET_MSG_TYPE_SUPPORT(tutorial_msgs, msg, Reading), "/reading");
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_subscription_with_context(
executor, &self->sub, &self->msg, on_msg, self, ON_NEW_DATA);
}
RCLC_C_COMPONENT(listener_t, listener_configure)
The message lives in the node’s state struct, so nothing allocates when a
reading arrives. A Reading holds no string or sequence, so it needs no
storage beyond the struct.
src/monitor_node/include/monitor_node/Listener.hpp#pragma once
#include <rclcpp/rclcpp.hpp>
#include "tutorial_msgs.hpp"
namespace monitor_node {
class Listener {
int recv_ = 0;
void on_reading(const ::tutorial_msgs::msg::Reading& msg);
public:
::rclcpp::Result configure(::rclcpp::Node& node);
};
} // namespace monitor_node
src/monitor_node/src/Listener.cpp#include "monitor_node/Listener.hpp"
#include <cstdio>
namespace monitor_node {
void Listener::on_reading(const ::tutorial_msgs::msg::Reading& msg) {
std::printf("I heard: reading %d (%d mC)\n",
static_cast<int>(msg.sequence),
static_cast<int>(msg.temperature_mc));
++recv_;
}
::rclcpp::Result Listener::configure(::rclcpp::Node& node) {
::setvbuf(stdout, nullptr, _IOLBF, 0);
return ::rclcpp::bind_subscription<::tutorial_msgs::msg::Reading, Listener,
&Listener::on_reading>(node, "/reading", this);
}
} // namespace monitor_node
Run it
source /opt/ros/humble/setup.bash
nros run
Publishing: reading 1 (21100 mC)
I heard: reading 1 (21100 mC)
The first lines of the build show the new package being generated before anything compiles (a Rust project’s output, trimmed):
sync: codegen tutorial_msgs
sync: message dependencies → /home/you/sensor_ws/src/sensor_node/Cargo.toml
sync: message dependencies → /home/you/sensor_ws/src/monitor_node/Cargo.toml
and the console then shows the readings:
[INFO] sensor_node: [ 3.143246] Publishing: reading 1 (21100 mC)
[INFO] monitor_node: [ 3.167941] I heard: reading 1 (21100 mC)
[INFO] sensor_node: [ 4.169282] Publishing: reading 2 (21200 mC)
[INFO] monitor_node: [ 4.225809] I heard: reading 2 (21200 mC)
A C or C++ project prints the same lines without the [INFO] prefix. Press
Ctrl-C to stop it.
generated/ now holds tutorial_msgs beside the packages generated before
it. A package no node depends on any more stays there until you delete
generated/; it is never linked into the image, so it costs nothing on the
board.
The topic changed with the type: both nodes now use /reading, and nothing
publishes on /chatter any more. A topic’s name and its type travel
together, so a subscriber on /reading with another type would match
nothing, on the board or in ROS 2.
Your own, or one from ROS 2
ROS 2 already ships a temperature message, sensor_msgs/msg/Temperature.
A node uses it exactly as it used std_msgs: <depend>sensor_msgs</depend>
in its package.xml, and the build generates it from your ROS 2 install. Use
an installed message when the machines you talk to expect it: a ROS 2 tool
that plots temperatures reads sensor_msgs/msg/Temperature, not yours.
Write your own when no standard message fits, or when the standard one costs
more than the board can spend. Temperature carries a std_msgs/Header,
whose frame_id is an unbounded string, and two float64 fields, so every
sample needs a string capacity and floating-point formatting to print.
Reading is 8 bytes of payload. The choice is per message, and a workspace
can mix both: one node can depend on tutorial_msgs and sensor_msgs at
once. Whichever you pick, a peer that receives it needs the same definition:
for a ROS 2 machine, an installed package or the same .msg source built
there.
Change it
Add a field and follow it through. Append a line to Reading.msg:
src/tutorial_msgs/msg/Reading.msgint32 humidity_pct # relative humidity, percent
then set humidity_pct in the talker and print it in the listener. The next
nros run regenerates tutorial_msgs before it compiles anything, and a node
that sets or reads a field the message lacks fails to compile, naming the
field. Nothing else in the workspace needs to know the message changed: the
two nodes share it through package.xml, never through each other.
If it doesn’t work
nros interface showsays the type is not found: the package is not where the search starts. It must sit directly undersrc/, with itspackage.xmland amsg/directory beside it.- Rust:
unresolved import tutorial_msgs: the node’spackage.xmlstill depends onstd_msgsonly. Check the<depend>line, then run again; the build writes theCargo.tomlrow. - C or C++: CMake cannot find
tutorial_msgs: the node’sCMakeLists.txtstill saysfind_package(std_msgs REQUIRED). Change it, and for C++ thetarget_link_librariesline too. - The build stops naming
AMENT_PREFIX_PATH: the generator readsrosidl_default_generatorsand the base types from ROS 2. Source ROS 2 in this shell, as in chapter 1.
What just happened
You wrote a message package, and the build turned it into code for every node that depends on it.
A message package holds definitions and no code. Its msg/ directory is the
whole interface; package.xml names it and marks it an interface package
with <member_of_group>rosidl_interface_packages</member_of_group>. On each
build, nros finds every message package a node depends on, in this order,
and generates code for it under generated/:
- a package under the workspace’s
src/, such astutorial_msgs; - a package in your ROS 2 install, such as
std_msgs, throughAMENT_PREFIX_PATHor the prefix the workspace’s first build recorded; - a few standard packages the nano-ros release carries, which only fill gaps under a ROS 2 install and never stand in for one.
A workspace package shadows an installed one of the same name, whole: it replaces all of that package’s messages, not one of them.
What the build generates is where nano-ros differs from ROS 2. ROS 2
generates code that allocates: a std::string, a std::vector, rosidl’s
__init and __fini in C. nano-ros generates code whose every string and
sequence has a capacity fixed when the image is built.
A Rust message is a no_std struct built on fixed-capacity types. A C
message’s strings and sequences point at memory the node owns. Because
nothing grows at run time, an unbounded string or [] sequence in a
.msg file needs a capacity stated at build time. A C or C++ node states it
in nros-codegen.toml beside its package.xml: the scaffold wrote one for
std_msgs/String, "std_msgs/String.data" = 256. Reading holds two
integers, so it needs none.
On the wire nothing differs. The generated types serialize to the same CDR
bytes and carry the same type name, tutorial_msgs/msg/Reading, as the code
ROS 2 generates from the same .msg file. That is why chapter 10 can build
the same package with colcon and hear the board with ros2 topic echo.
Message generation lists what the
build generates and the CMake functions behind it.
Next
- Services and actions: request and reply, and long-running goals, between nodes of the same project.
- Build inside an existing CMake or vendor tree: message packages in a tree that is not a nano-ros workspace.
Design background
Generating message code from the stock ROS 2 package shape, with the workspace first on the search path, follows RFC-0094 and RFC-0098.
Services and actions
Needs first: Your own message
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
Topics carry a stream with no reply. ROS 2 has two other ways for nodes to talk: a service answers one request with one reply, and an action runs a long goal, sends feedback while it works, and ends with a result. nano-ros carries both, with the same names, types and wire format as ROS 2.
In this chapter you add four nodes to the project from the scaffold’s
templates: an AddTwoInts service server and its client, and a Fibonacci
action server and its client, the roles of the ROS 2 demos. At the end one
run of the board prints a service reply and an action result, and a ROS 2
shell on your host calls the board’s service and sends its action server a
goal:
response:
example_interfaces.srv.AddTwoInts_Response(sum=9)
This chapter introduces no new nano-ros idea. It shows the one rule services and actions add to chapter 3’s: where a node may wait for a reply.
Run every step from the root of sensor_ws. The chapter adds four node
packages and a row for each to the bringup:
sensor_ws/
└── src/
├── action_client_node/ (new)
├── action_server_node/ (new)
├── client_node/ (new)
├── server_node/ (new)
└── sensor_node_bringup/
├── package.xml (changed)
├── system.contract.yaml (changed)
└── system.toml (changed)
Add a service server and its client
nros new server_node --template server --lang rust --to sensor_node_bringup
nros new client_node --template client --lang rust --to sensor_node_bringup
nros new server_node --template server --lang c --to sensor_node_bringup
nros new client_node --template client --lang c --to sensor_node_bringup
nros new server_node --template server --lang cpp --to sensor_node_bringup
nros new client_node --template client --lang cpp --to sensor_node_bringup
Both templates use example_interfaces/srv/AddTwoInts, a standard ROS 2
interface package: two int64 fields in the request, a and b, and one in the reply,
sum. Each package’s package.xml depends on example_interfaces, and the
next build generates it from your ROS 2 install like any message package.
Both installs on Install include it. On any other
ROS 2 install, add it now:
sudo apt install ros-$ROS_DISTRO-example-interfaces. A service type is a pair
of messages, so a .srv file in a package of your own, beside chapter 5’s
.msg, works the same way. As in chapter 3, --to also gives each node a
row in the bringup’s contract, and the services: section names who serves
/add_two_ints and who calls it.
The server answers each request in its callback:
#![allow(unused)]
fn main() {
fn on_callback(
_state: &mut Self::State,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "handle_add" {
if let Ok(req) = ctx.message::<AddTwoIntsRequest>() {
log_info!(&LOGGER, "Incoming request");
log_info!(&LOGGER, "a: {} b: {}", req.a, req.b);
let reply = AddTwoIntsResponse { sum: req.a + req.b };
let _ = ctx.reply::<AddTwoIntsResponse, 64>(&reply);
}
}
}
}
register created the server with
create_service_server_for_name_with_callback::<AddTwoInts>("/add_two_ints", "handle_add"), which binds requests on /add_two_ints to the callback named
handle_add. The server’s ENTITY_BOUNDS is exact(0, 1, 0, 0, 0): one
service server.
static void on_request(const example_interfaces__srv__AddTwoInts_Request* req,
example_interfaces__srv__AddTwoInts_Response* resp,
void* ctx) {
add_server_t* self = (add_server_t*)ctx;
self->request_count++;
resp->sum = req->a + req->b;
printf("[server_node] %lld + %lld = %lld\n", (long long)req->a,
(long long)req->b, (long long)resp->sum);
}
The handler fills the reply the executor sends. configure creates the
service and adds it to the executor through the functions generated for the
service type, example_interfaces__srv__AddTwoInts__service_init and
..._executor_add_service.
example_interfaces::srv::AddTwoInts::Response
AddTwoIntsServer::on_request(
const example_interfaces::srv::AddTwoInts::Request& req) {
example_interfaces::srv::AddTwoInts::Response resp;
resp.sum = req.a + req.b;
std::printf("[server_node] %lld + %lld = %lld\n",
static_cast<long long>(req.a), static_cast<long long>(req.b),
static_cast<long long>(resp.sum));
return resp;
}
configure binds the member as the handler of /add_two_ints with
rclcpp::bind_service<Svc, AddTwoIntsServer, &AddTwoIntsServer::on_request>,
by identity, as chapter 3’s listener bound its subscription. The member takes
the request and returns the reply.
The client is where services differ from topics. A ROS 2 client often calls the service and waits for the reply. A nano-ros node cannot wait inside a callback: the executor is in the middle of running that callback, and the reply it waits for can only be delivered by the same executor, so the image would stop. The client splits the call in two:
#![allow(unused)]
fn main() {
fn on_callback(
state: &mut Self::State,
callback: Callback<'_>,
_ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "issue_call" && !state.done {
state.pending = true; // decide; do not call here
}
}
fn tick(state: &mut Self::State, ctx: &mut TickCtx<'_>) {
if !state.pending || state.done {
return;
}
state.pending = false;
let req = AddTwoIntsRequest { a: 2, b: 3 };
match ctx.call_for_name::<AddTwoIntsRequest, AddTwoIntsResponse, 64, 64>(
"/add_two_ints",
&req,
) {
Ok(reply) => {
log_info!(&LOGGER, "Result of add_two_ints: {}", reply.sum);
state.done = true;
}
Err(e) => log_info!(&LOGGER, "Service call failed, retrying: {:?}", e),
}
}
}
The timer callback only decides that a call is due. tick runs once per
spin of the executor, between callbacks, where a call may wait for its reply.
The scaffold’s client calls once, with a: 2 and b: 3, and then stops.
The C client sends a request from its timer callback every 500 ms and takes
the reply on a later tick, so the callback never waits. Each request adds 1
to a counter: a counts up, b is 1.
The C++ client sends a request from its timer callback every 500 ms and
takes the reply on a later tick, so the callback never waits. Each request
adds 1 to a counter: a counts up, b is 1.
Add an action server and its client
nros new action_server_node --template action-server --lang rust \
--to sensor_node_bringup
nros new action_client_node --template action-client --lang rust \
--to sensor_node_bringup
nros new action_server_node --template action-server --lang c \
--to sensor_node_bringup
nros new action_client_node --template action-client --lang c \
--to sensor_node_bringup
nros new action_server_node --template action-server --lang cpp \
--to sensor_node_bringup
nros new action_client_node --template action-client --lang cpp \
--to sensor_node_bringup
Both use example_interfaces/action/Fibonacci: the goal is an order, the
feedback is the sequence so far, and the result is the whole sequence. The
client sends one goal, order: 10. The server accepts it, computes one term
at a time, publishes feedback as it goes, and completes the goal with the
result.
The server follows the same rule as the client. Its callbacks only decide:
on_goal accepts or rejects a goal, and on_cancel accepts a cancel. The
work happens in tick, which visits every active goal on each spin, adds a
term, and publishes feedback or completes the goal. Spreading the work over
spins is what lets the six nodes share one processor: no callback runs for
long, so the talker still publishes every second while a goal is in
progress. A goal’s result has a fixed capacity too: the Rust template keeps
the sequence in a heapless::Vec<i32, 64> and caps order at 50.
The bringup’s system.toml now has six [[component]] rows, one per node
package, and nros check --workspace . still passes. Six nodes in one image
is not a limit of the board: each node’s slots are counted when the image is
built, so an image too large for the board fails to build rather than failing
at boot.
Run all six nodes
Leave this run going: the next section calls the board from ROS 2.
source /opt/ros/humble/setup.bash
nros run
The service reply and the action result come from different nodes, and either may print first. The run prints both:
Result of add_two_ints: 5
Result received: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
[client_node] sum:
[action_client_node] result last=
[client_node] sum:
[action_client_node] result last=
A Rust project’s console, trimmed to the four new nodes:
[INFO] server_node: [ 2.143647] Waiting for service requests
[INFO] action_server_node: [ 2.181442] Waiting for action goals
[INFO] action_client_node: [ 2.249390] Sending goal
[INFO] action_client_node: [ 2.252703] Goal sent, waiting for result
[INFO] action_server_node: [ 2.254812] Received goal request with order 10
[INFO] action_server_node: [ 2.258269] Publish feedback
[INFO] action_client_node: [ 2.261516] Next number in sequence received: [0]
[INFO] server_node: [ 3.240558] Incoming request
[INFO] server_node: [ 3.244643] a: 2 b: 3
[INFO] client_node: [ 3.268359] Result of add_two_ints: 5
[INFO] action_server_node: [ 4.484253] Publish feedback
...
[INFO] action_server_node: [ 26.009786] Goal succeeded
[INFO] action_client_node: [ 26.125114] Result received: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
Between those lines, the talker and the listener keep exchanging a reading every second. The goal takes about 25 seconds because the template’s server paces itself, one term every few spins, so a cancel has time to arrive.
Call them from ROS 2
The service and the action are on the ROS 2 graph like any other. The ros2 command needs the example_interfaces package on the host to call
the board. Both installs on Install include it. With nros run still
going, this line in a second terminal makes sure:
sudo apt-get install -y ros-humble-example-interfaces
Then call the board’s service:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts '{a: 4, b: 5}'
response:
example_interfaces.srv.AddTwoInts_Response(sum=9)
and send its action server a goal of your own:
ros2 action send_goal /fibonacci example_interfaces/action/Fibonacci '{order: 5}'
Result:
sequence:
- 0
- 1
- 1
- 2
- 3
- 5
Goal finished with status: SUCCEEDED
The board’s server printed Incoming request and a: 4 b: 5 in the first
terminal, then worked through your goal while its own nodes kept running.
Press Ctrl-C in the first terminal when you are done.
Change it
Make the client ask a question of your own. In the Rust client, change the
request in tick to AddTwoIntsRequest { a: 20, b: 22 } and run again: the
console prints Result of add_two_ints: 42. In the C and C++ clients, the
request is built in the timer callback from the counter a and the constant
b; set b to 41 and the first reply is sum: 41. Either way only the
client package rebuilds, and the server neither knows nor cares who asked.
If it doesn’t work
- The Rust client logs
service not available, waiting again...: the client asked before the server’s service was on the graph. It asks again on its next timer tick, so a few of these lines at boot are normal. If they never stop, check thatserver_nodeis a[[component]]row of the same bringup, or running in another image on the same router. ros2 service callprintswaiting for service to become available...and stops there: that shell is not on zenoh, or the board is not running. CheckRMW_IMPLEMENTATION=rmw_zenoh_cppin that shell and thatnros runis still going in the other.ros2 action send_goalreports the goal rejected: the Rust template’s server rejects a negativeorder. It accepts a large one but computes only 50 terms, because its result has a fixed capacity: a sequence that could grow without bound would need a heap the board does not have. Raise the capacity in the server’s code, and the build sizes the image for it.- The action goal never finishes: the server works through one goal at a time. A goal sent while the in-image client’s goal is running waits its turn; the template paces each term, so a goal of order 10 takes about 25 seconds.
What just happened
You added the two remaining ROS 2 communication patterns, and they work as
they do in ROS 2: the same types from example_interfaces, the same names on
the graph, and a ROS 2 command line on the other end that cannot tell it is
talking to a microcontroller.
What nano-ros adds is one rule, which follows from chapter 3’s one executor
per image: a node never waits inside a callback. A callback decides; it
records what is due in the node’s state and returns. Work that waits for a
reply, or that takes many steps, goes in tick, which the executor runs on
each spin, between callbacks. The client calls there, and the action server
advances its goals there. That is also why nothing here needs a thread: one
loop runs six nodes, and none of them holds the processor for long.
The other half of the rule is that a reply must have somewhere to go. Every
request, reply, goal, feedback message and result is serialized into a buffer
of a size fixed at build time: the 64 and 256 in the templates’ calls are
those sizes, in bytes. Too small a buffer fails the call with an error you can
log; it never writes past the end.
Each server and client also took a slot in its node’s ENTITY_BOUNDS, the
second to fifth numbers of exact(...): service servers, service clients,
action clients and action servers. Those slots are static memory, fixed when
the image is built. Chapter 8 shows how the build sizes them, and the rest of
the image, from a statement of what the system creates.
If you write ROS 2 nodes in C++, the mapping is direct:
| rclcpp | nano-ros |
|---|---|
create_service<Srv>(name, handler) | a server bound to a callback by name (Rust) or to a member by identity (C++) |
create_client<Srv>(name), then async_send_request and spin_until_future_complete | a client that sends in a callback or tick and takes the reply in tick |
rclcpp_action::create_server with goal, cancel and accepted handlers | on_goal, on_cancel and on_accepted, with the work in tick |
| a multi-threaded executor so a handler can block | one executor; nothing blocks inside a callback |
Port a C++ node shows the C++ spellings a ported node keeps.
Next
- Parameters and launch files: configure a node without changing its code.
- The execution model: the executor,
tick, and how a board with an RTOS runs callbacks in tasks. - Pick a scheduling model: when one loop is not enough.
Design background
The templates follow the ROS 2 demos’ roles and interfaces (RFC-0121 D4); one Tutorial path that adds services and actions to the same project is RFC-0124 D3.
Parameters and launch files
Needs first: Services and actions
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
Until now the bringup’s [[component]] rows were the whole description of
the system, and nros generated a launch file from them. In this chapter the
bringup gets a launch file of its own. Through it you set a parameter that the
talker reads, so it publishes twice a second with no change to its code
afterwards, and you move both nodes to another topic name with a remap. At the
end the board prints
[INFO] sensor_node: [ 3.041841] Publishing every 500 ms
and ros2 topic list on your host shows /sensor/reading, a name that
appears in no node’s code.
Run every step from the root of sensor_ws. The chapter adds a launch file
to the bringup and changes the talker, in the language you picked:
sensor_ws/
└── src/
├── sensor_node/
│ └── src/lib.rs (changed)
└── sensor_node_bringup/
└── launch/
└── system.launch.xml (new)
sensor_ws/
└── src/
├── sensor_node/
│ └── src/Talker.c (changed)
└── sensor_node_bringup/
├── system.toml (changed)
└── launch/
└── system.launch.xml (new)
sensor_ws/
└── src/
├── sensor_node/
│ └── src/Talker.cpp (changed)
└── sensor_node_bringup/
├── system.toml (changed)
└── launch/
└── system.launch.xml (new)
Start from the generated launch file
A bringup with no launch/ directory gets a launch file generated from its
[[component]] rows on every build. Start from that file, so that adding
launch/ changes nothing until you edit it:
mkdir -p src/sensor_node_bringup/launch
cp build/nros/launch/sensor_node_bringup/launch/system.launch.xml \
src/sensor_node_bringup/launch/system.launch.xml
cat src/sensor_node_bringup/launch/system.launch.xml
<?xml version="1.0"?>
<!-- Generated by nros from this bringup's system.toml [[component]] rows.
Add launch/system.launch.xml to the bringup to replace it. -->
<launch>
<node pkg="sensor_node" exec="sensor_node" name="sensor_node"/>
<node pkg="monitor_node" exec="monitor_node" name="monitor_node"/>
<node pkg="server_node" exec="server_node" name="server_node"/>
<node pkg="client_node" exec="client_node" name="client_node"/>
<node pkg="action_server_node" exec="action_server_node" name="action_server_node"/>
<node pkg="action_client_node" exec="action_client_node" name="action_client_node"/>
</launch>
From now on launch/system.launch.xml is used instead of the generated one.
Deleting the launch/ directory goes back to generation, and the
[[component]] rows stay the list of packages the bringup runs. The file is the
ROS 2 launch XML format,
read with the same parser, so a launch file from another ROS 2 project pastes
in. Keep each <node>’s pkg and exec as the generated file wrote them:
they name the package and the class it registers.
Read a parameter in the talker
A parameter is a value a launch file gives a node. Make the talker’s period
one: read period_ms when the node starts, and keep 1,000 ms when the
launch file sets none.
src/sensor_node/src/lib.rs#![allow(unused)]
fn main() {
//! `sensor_node`: publishes a `tutorial_msgs/Reading` on `/reading` once a second.
#![no_std]
use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode,
NodeContext, NodeOptions, NodeResult, ParameterDefault, TimerDuration,
};
use nros_log::{Logger, log_info};
use tutorial_msgs::msg::Reading;
static LOGGER: Logger = Logger::new("sensor_node");
pub struct Talker;
impl Component for Talker {
const NAME: &'static str = "sensor_node";
const ENTITY_BOUNDS: nros::EntityBounds =
nros::EntityBounds::exact(1, 0, 0, 0, 0);
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
nros_log::register_logger(&LOGGER);
// The launch file's `<param name="period_ms" .../>`, baked in at build
// time; 1000 ms when the launch file sets none.
let period_ms: u64 = ctx
.param("period_ms")
.and_then(|v| v.parse().ok())
.unwrap_or(1000);
let mut node = ctx.create_node(NodeOptions::new("sensor_node"))?;
// State the parameter and its default, so the build sees it.
node.declare_parameter_for_name_with_default(
"period_ms",
ParameterDefault::Integer(1000),
)?;
let pub_reading = node.create_publisher_for_topic::<Reading>("/reading")?;
let _timer = node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(period_ms),
)?;
log_info!(&LOGGER, "Publishing every {} ms", period_ms);
node.callback_for_name("on_tick")
.publishes_entity(&pub_reading)?;
Ok(())
}
}
impl ExecutableNode for Talker {
/// The sequence number of the last reading published.
type State = i32;
const HAS_TICK: bool = false;
fn init() -> Self::State {
0
}
fn on_callback(
state: &mut Self::State,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_tick" {
*state = state.wrapping_add(1);
let msg = Reading {
sequence: *state,
temperature_mc: 21_000 + (*state % 10) * 100,
};
let _ = ctx.publish_to_topic::<Reading, 32>("/reading", &msg);
log_info!(
&LOGGER,
"Publishing: reading {} ({} mC)",
msg.sequence,
msg.temperature_mc
);
}
}
}
nros::node!(Talker);
}
ctx.param("period_ms") returns the value the launch file gives, as text,
or None. The value is baked into the image when it is built, so reading it
costs no lookup at run time and needs no parameter store.
declare_parameter_for_name_with_default states that the node has the
parameter, as a ROS 2 node declares one; chapter 9’s host image checks the
contract against such declarations.
src/sensor_node/src/Talker.c// sensor_node: publishes a tutorial_msgs/Reading on /reading once a second.
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <rcl/rcl.h>
#include <rclc/executor.h>
#include <rclc/rclc.h>
#include <rclc_parameter/rclc_parameter.h>
#include <tutorial_msgs/tutorial_msgs.h>
typedef struct {
rcl_publisher_t pub;
rcl_timer_t timer;
rclc_parameter_server_t params;
int32_t count;
} talker_t;
static void on_tick(rcl_timer_t* timer, int64_t last_call_time) {
talker_t* self = RCLC_CONTAINER_OF(timer, talker_t, timer);
(void)last_call_time;
self->count++;
tutorial_msgs__msg__Reading msg;
memset(&msg, 0, sizeof msg);
msg.sequence = self->count;
msg.temperature_mc = 21000 + (self->count % 10) * 100;
if (rcl_publish(&self->pub, &msg, NULL) == RCL_RET_OK) {
printf("Publishing: reading %d (%d mC)\n", (int)msg.sequence,
(int)msg.temperature_mc);
}
}
static rcl_ret_t talker_configure(rcl_node_t* node, rclc_executor_t* executor,
talker_t* self) {
setvbuf(stdout, NULL, _IOLBF, 0);
self->count = 0;
// The launch file's <param name="period_ms" .../>; 1000 ms when it sets none.
rcl_ret_t rc = rclc_parameter_server_init_default(&self->params, node);
if (rc != RCL_RET_OK) {
return rc;
}
int64_t period_ms = 1000;
(void)rclc_parameter_get_int(&self->params, "period_ms", &period_ms);
printf("Publishing every %d ms\n", (int)period_ms);
self->pub = rcl_get_zero_initialized_publisher();
rc = rclc_publisher_init_default(
&self->pub, node,
ROSIDL_GET_MSG_TYPE_SUPPORT(tutorial_msgs, msg, Reading), "/reading");
if (rc != RCL_RET_OK) {
return rc;
}
self->timer = rcl_get_zero_initialized_timer();
rc = rclc_timer_init_default(&self->timer, NULL,
(uint64_t)period_ms * 1000000ULL, on_tick);
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_timer(executor, &self->timer);
}
RCLC_C_COMPONENT(talker_t, talker_configure)
The C node reads parameters through rclc’s parameter server, which needs the image’s parameter services. Every image serves them unless it opts out, so there is nothing to declare.
src/sensor_node/src/Talker.cpp#include "sensor_node/Talker.hpp"
#include <cstdio>
namespace sensor_node {
void Talker::on_tick() {
++count_;
::tutorial_msgs::msg::Reading msg;
msg.sequence = count_;
msg.temperature_mc = 21000 + (count_ % 10) * 100;
if (pub_.publish(msg).ok()) {
std::printf("Publishing: reading %d (%d mC)\n",
static_cast<int>(msg.sequence),
static_cast<int>(msg.temperature_mc));
}
}
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
::setvbuf(stdout, nullptr, _IOLBF, 0);
::rclcpp::Result r = node.create_publisher(pub_, "/reading");
if (!r.ok()) return r;
// The launch file's <param name="period_ms" .../>; 1000 ms when it sets none.
int64_t period_ms = 1000;
(void)node.get_parameter<int64_t>("period_ms", period_ms);
std::printf("Publishing every %d ms\n", static_cast<int>(period_ms));
return node.create_wall_timer<Talker, &Talker::on_tick>(
timer_, static_cast<uint32_t>(period_ms), this);
}
} // namespace sensor_node
node.get_parameter reads from the image’s parameter store, which comes
with the parameter services every image has unless it opts out.
Set it in the launch file
Now give the talker a period, and move the reading topic to a name of your choosing. Replace the launch file:
src/sensor_node_bringup/launch/system.launch.xml<?xml version="1.0"?>
<launch>
<arg name="topic" default="/sensor/reading"/>
<node pkg="sensor_node" exec="sensor_node" name="sensor_node">
<param name="period_ms" value="500"/>
<remap from="/reading" to="$(var topic)"/>
</node>
<node pkg="monitor_node" exec="monitor_node" name="monitor_node">
<remap from="/reading" to="$(var topic)"/>
</node>
<node pkg="server_node" exec="server_node" name="server_node"/>
<node pkg="client_node" exec="client_node" name="client_node"/>
<node pkg="action_server_node" exec="action_server_node" name="action_server_node"/>
<node pkg="action_client_node" exec="action_client_node" name="action_client_node"/>
</launch>
Three things changed:
<arg name="topic" default="/sensor/reading"/>declares a launch argument with a default.$(var topic)expands it anywhere below.<param name="period_ms" value="500"/>inside the talker’s<node>sets the parameter the code reads.<remap from="/reading" to="$(var topic)"/>inside both nodes renames the topic they create as/reading, so both now publish and subscribe on/sensor/reading. Remap both or neither: a remap applies to the node it is in, and two nodes on different names do not hear each other.
Run it
Leave this run going for the next section:
source /opt/ros/humble/setup.bash
nros run
Publishing every 500 ms
I heard: reading 4
A Rust project’s console, trimmed to the talker and listener:
[INFO] sensor_node: [ 3.041841] Publishing every 500 ms
[INFO] sensor_node: [ 3.485234] Publishing: reading 1 (21100 mC)
[INFO] monitor_node: [ 3.487297] I heard: reading 1 (21100 mC)
[INFO] sensor_node: [ 3.975575] Publishing: reading 2 (21200 mC)
[INFO] monitor_node: [ 3.991086] I heard: reading 2 (21200 mC)
[INFO] sensor_node: [ 4.423176] Publishing: reading 3 (21300 mC)
[INFO] monitor_node: [ 4.431667] I heard: reading 3 (21300 mC)
[INFO] sensor_node: [ 5.038481] Publishing: reading 4 (21400 mC)
[INFO] monitor_node: [ 5.073491] I heard: reading 4 (21400 mC)
Readings now arrive every half second. Change value="500" to another
period and run again: only the image rebuilds, and the talker’s package
does not change.
The same mechanism serves a second board or a second deployment of the same board. Two launch files in one bringup, each with its own parameters and remaps, can run the same node packages as two different systems; chapter 9 gives the project a second image, and an image can name the launch file it builds. A node package that reads its configuration from parameters, rather than from constants in its code, is a node package you never fork.
See the new name in ROS 2
In a second terminal, list the topics and the nodes the router knows.
--no-daemon asks the router directly: a ros2 daemon left over from an
earlier chapter still holds a session to the router that nros run has
since replaced, and it answers with an error.
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic list --no-daemon --spin-time 3
ros2 node list --no-daemon --spin-time 3
/parameter_events
/rosout
/sensor/reading
/action_client_node
/action_server_node
/client_node
/monitor_node
/sensor_node
/server_node
/sensor/reading is the remapped topic, and the six nodes of the image are
six nodes on the ROS 2 graph. Press Ctrl-C in the first terminal when you
are done.
Compare this with what ROS 2 shows for nodes on your own machine: the same two commands, the same names. The board’s launch file decided those names when it was built, and the graph sees the result. Nothing on the ROS 2 side can tell that the remap happened at build time rather than at launch.
Parameters from a file
For more than a few values, a node loads a standard ROS 2 parameter file.
Start its path with $(dirname), the launch file’s own directory. A bare
relative path is resolved against the working directory, not the launch
file, exactly as ros2 launch resolves it, so it breaks as soon as the
command runs from another directory:
# launch/sensor.param.yaml
/**: # every node
ros__parameters:
use_sim_time: false
sensor_node: # this node only
ros__parameters:
period_ms: 250
<node pkg="sensor_node" exec="sensor_node" name="sensor_node">
<param from="$(dirname)/sensor.param.yaml"/>
<param name="period_ms" value="500"/> <!-- wins over the file -->
</node>
The file is the same YAML a ROS 2 node loads with --params-file, so a
parameter file written for the same node on a ROS 2 machine works here
unchanged, and the build reads it as it reads the launch file: once, when the
image is built.
Precedence is ROS 2’s: the /** block, then the node’s own block (keyed
sensor_node, /ns/sensor_node or /**/sensor_node), then an inline
<param name= value=>. A from= naming a missing file is a build error.
What the image does with parameters at run time is decided in system.toml.
Every image gets the parameter services, as a ROS 2 node does, unless it opts
out with node_interfaces = "none":
system.toml states | Parameter store (get_parameter, launch values) | ros2 param services |
|---|---|---|
| nothing (the default) | yes | six per node: get, set, list, describe, and two more |
node_interfaces = "none" and features = ["params"] | yes | none |
node_interfaces = "none" | Rust’s ctx.param reads the baked value | none |
The store alone suits a small board whose nodes only read their
configuration: each of the six services costs memory per node. What it gives
up is ros2 param get, set, list, describe and dump, and the
use_sim_time switch. node_interfaces = "none" also turns off each node’s
/rosout publisher.
Read once, or read live
The talker reads period_ms once, in register or configure, and builds
its timer from it. That is the right shape for a value that sizes or shapes
the node: a period, a buffer length, a frame name. It is also why the launch
file is the place to set it: the value is decided when the image is built,
and every boot of the image starts with it.
A value the node should follow while it runs is read in the callback
instead, from the parameter store, on every call. With the parameter
services on (the default), ros2 param set /sensor_node <name> <value> from a ROS 2 shell
changes that live value on the board. It changes nothing a node read once:
setting period_ms that way would leave the timer at the period it was built
with. A value set at run time is also volatile. The next boot starts from the
launch file again, because the board has nowhere to store the change.
If it doesn’t work
- The talker prints
Publishing every 1000 ms: the parameter did not reach it. Check that the<param>is inside the talker’s own<node>, and that itsnameis exactly the one the code reads. - The listener stops hearing readings: only one of the two nodes is remapped. Remap both, or neither.
- A C build stops with
#error "<rclc_parameter/rclc_parameter.h> needs the param_services capability": the bringup opts out withnode_interfaces = "none", which removes the parameter services even wherefeaturesdeclares them. Remove it from the image whose node reads parameters. - The build names a package that does not exist: a
<node>’spkgnames no package in the workspace.nros check --workspace .lists every such mistake before a build. - A C++ node stops at boot with
parameter "…" is declared double but the launch value is the integer 1; write 1.0 in the YAML: the launch file or YAML gives the parameter a value of another type thandeclare_parameter<T>asks for. Write the value in the declared type, as the line says.
The launch file, briefly
| Tag | Purpose |
|---|---|
<arg name="…" default="…"/> | declare a launch argument |
<node pkg="…" exec="…" name="…"/> | start a node |
<param name="…" value="…"/> | set one parameter (inside <node>) |
<param from="$(dirname)/….yaml"/> | load a ROS 2 parameter file (inside <node>), named from the launch file’s directory |
<remap from="…" to="…"/> | rename a topic or service (inside <node>) |
<group ns="…"> | put a group of nodes in a namespace |
<include file="…"/> | include another launch file |
Substitutions: $(var <arg>) expands a launch argument, $(find <pkg>) a
package’s path, and $(env <name>) an environment variable.
What just happened
The bringup’s launch file became the system’s description: which nodes run, under which names, on which topics, with which parameters. The node packages say what a node can do; the launch file says what this system does with them.
Where ROS 2 reads a launch file when you run ros2 launch, nano-ros reads it
when it builds the image. There is no ros2 launch step and no launch
process on the board. The build resolves the file, arguments, remaps,
parameter files and all, into a fixed system: the nodes to construct, the
names to give them, and the parameter values to bake in. The image starts
exactly that system, every time, on a board that has no file system to read a
launch file from. Editing the launch file or a parameter file rebuilds the
image, and nothing in src/sensor_node/ changes.
The same resolved system is what the next chapter builds on. Because the build knows, before it compiles anything, every node the image will run and every topic, service and action they use, it can size the image’s memory for exactly that system, if you tell it what the nodes create.
Next
- Tell the build what your system creates: the contract beside this launch file, and what it sizes in the image.
- Use simulated time: the
use_sim_timeparameter and a clock from ROS 2. - Organize a larger workspace: several bringups and several launch files.
Design background
Resolving the launch file at build time, with the ROS 2 launch parser, follows RFC-0121 D2 and D3.
Tell the build what your system creates
Needs first: Parameters and launch files
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
Every node in the project creates publishers, subscriptions, timers, servers and clients when it starts. On this board, the memory for all of them is set aside when the image is built, so the build must size it before any node has run. Until now it has not known what the nodes create, so it sized every pool for a generous default. In this chapter you write the contract: a file beside the launch file that states what the system creates. You measure the image’s static RAM before and after, and see what the contract decides that the build could not guess, such as how many samples a subscription keeps:
text data bss dec hex filename
646932 12648 1331684 1991264 1e6260 .../freertos_entry (before)
651004 10872 1334020 1995896 1e7478 .../freertos_entry (after)
Then you break the contract on purpose and read the refusal, which shows what the build does when a statement and the system disagree.
Run every step from the root of sensor_ws. The chapter writes a contract
beside the launch file and adds a table to system.toml:
sensor_ws/
└── src/
└── sensor_node_bringup/
├── system.toml (changed)
└── launch/
└── system.contract.yaml (new)
Measure the image as it is
Build the image:
nros build
Its last lines name the image it built, after artifact: (a Rust project’s,
trimmed):
nros build: next for `sensor_node_bringup:freertos`:
artifact: /home/you/sensor_ws/build/freertos-zenoh/freertos_entry/target/thumbv7m-none-eabi/release/freertos_entry
Read the image’s sizes with the size tool of the Arm toolchain
nros setup installed, on that path:
"$(nros locate tool arm-none-eabi-gcc)/bin/arm-none-eabi-size" \
build/freertos-zenoh/freertos_entry/target/thumbv7m-none-eabi/release/freertos_entry
"$(nros locate tool arm-none-eabi-gcc)/bin/arm-none-eabi-size" \
build/freertos-zenoh-mps2-an385-freertos-sensor_node_bringup-freertos/cmake/freertos_entry
"$(nros locate tool arm-none-eabi-gcc)/bin/arm-none-eabi-size" \
build/freertos-zenoh-mps2-an385-freertos-sensor_node_bringup-freertos/cmake/freertos_entry
text data bss dec hex filename
646932 12648 1331684 1991264 1e6260 build/freertos-zenoh/freertos_entry/target/thumbv7m-none-eabi/release/freertos_entry
Those are the numbers of a Rust project; a C or C++ project’s differ.
text is flash: the code and its constants. data and bss are RAM that
exists from the moment the board boots, data with initial values and bss
zeroed. This image claims 1,331,684 bytes of zeroed RAM before its first
instruction. FreeRTOS’s heap is 966,656 bytes of it; the rest is what
nano-ros sizes.
Where does it go? Each node’s slots, the executor’s storage for every callback, the middleware’s sessions and receive buffers, and a parameter store. The parameter store is sized from the parameters the code declares. The rest is sized for the most the system might create: four samples per subscription, a copy of each topic’s last sample kept for late joiners, and so on. The build warned about some of it on every run, in lines like this one:
warning: nros-rmw-zenoh@0.6.0: the parameter family's requests are not priced: the image declares no `params:`. Its inbox slot keeps 1024 B; a larger `set_parameters` is dropped with no reply. Declaring the parameters in the contract derives it ...
Write the contract
A contract is a YAML file with the launch file’s name and .contract.yaml,
in the same directory. Write launch/system.contract.yaml:
src/sensor_node_bringup/launch/system.contract.yaml# What the system in system.launch.xml creates, so the build can size the
# image for exactly that. Names are the names the code and the launch file
# give: local endpoint names under nodes:, resolved names under topics:.
version: 1
nodes:
sensor_node:
params:
period_ms: { type: integer }
paths:
on_tick:
trigger: { timer: { rate: 2Hz } }
output: [reading]
pub:
reading: { qos: { depth: 1, durability: volatile } }
monitor_node:
params: {}
sub:
reading: { qos: { depth: 1, durability: volatile } }
server_node:
params: {}
srv:
add_two_ints: {}
client_node:
params: {}
paths:
issue_call:
trigger: { timer: { rate: 1Hz } }
output: []
cli:
add_two_ints: {}
action_server_node:
params: {}
action_client_node:
params: {}
topics:
/sensor/reading:
type: tutorial_msgs/msg/Reading
pub: [sensor_node/reading]
sub: [monitor_node/reading]
services:
/add_two_ints:
type: example_interfaces/srv/AddTwoInts
server: [server_node/add_two_ints]
client: [client_node/add_two_ints]
actions:
/fibonacci:
type: example_interfaces/action/Fibonacci
server: [action_server_node/fibonacci]
client: [action_client_node/fibonacci]
Read it from the top:
nodes:has one entry per node, under the name the launch file gives it. Under each, the endpoints the node creates are keyed by their LOCAL name:reading, not/sensor/reading.pub:,sub:,srv:andcli:are publishers, subscriptions, service servers and service clients.params:lists the parameters a node declares. The talker declaresperiod_ms, the one chapter 7’s launch file sets; every other node declares none,params: {}. That is not the same as leavingparams:out, which says nothing.paths:is where timers live. A path with atimertrigger and no input is a periodic callback: the talker’son_tickat 2 Hz (the 500 ms of chapter 7) and the client’sissue_callat 1 Hz.qos:states the quality of service an endpoint uses.depth: 1keeps one sample, anddurability: volatilekeeps none for late joiners.topics:,services:andactions:wire the endpoints together under their RESOLVED names, and carry their types./sensor/readingis the name after chapter 7’s remap, which is the name the board uses.
The build reads this file every time it builds the image, folds it into the
system it resolved from the launch file, and sizes every pool from it.
Nothing in a node package changes. The contract describes this launch file’s
system, so a second launch file in the bringup gets its own contract, with
its own name before .contract.yaml.
Mark the contract as unchecked
A contract is a statement beside the code, and the build can check it against the code by building the same launch file for your host, running that host program once in a recording mode, and comparing what the nodes created with what the contract says. That check is the census. It needs a host image of the same launch file in the bringup, and this one has only the board’s, so tell the build to warn rather than refuse when no census exists:
src/sensor_node_bringup/system.toml
[census]
on_missing = "warn"
Every build of the image now says, in its output, that its pools come from a contract nothing has compared with the code. Treat that line as a reminder: the contract is yours to keep right until a census checks it.
Measure it again
Build, and read the sizes on the same path:
nros build
"$(nros locate tool arm-none-eabi-gcc)/bin/arm-none-eabi-size" \
build/freertos-zenoh/freertos_entry/target/thumbv7m-none-eabi/release/freertos_entry
"$(nros locate tool arm-none-eabi-gcc)/bin/arm-none-eabi-size" \
build/freertos-zenoh-mps2-an385-freertos-sensor_node_bringup-freertos/cmake/freertos_entry
"$(nros locate tool arm-none-eabi-gcc)/bin/arm-none-eabi-size" \
build/freertos-zenoh-mps2-an385-freertos-sensor_node_bringup-freertos/cmake/freertos_entry
text data bss dec hex filename
651004 10872 1334020 1995896 1e7478 build/freertos-zenoh/freertos_entry/target/thumbv7m-none-eabi/release/freertos_entry
The totals barely moved: data fell by 1,776 bytes and bss grew by
2,336. What changed is what the image keeps. /sensor/reading’s receive
buffers hold one sample instead of four, and no copy is kept for late
joiners, because the contract says so. The parameter store was already
sized from the code, contract or not. On a C or C++ image bss grows by more
today, because the build reserves executor capacity the image does not use.
Run it
The image runs as before:
source /opt/ros/humble/setup.bash
nros run
I heard: reading 3
The console says where the depth now comes from, and Ctrl-C stops it:
[WARN] nros: [ 2.125169] declared depth: taking KEEP_LAST(1) on publisher `/sensor/reading`; the call site asked 10 and the build reserved 1. Raise the contract row to keep more (type `tutorial_msgs::msg::dds_::Reading_`).
[INFO] sensor_node: [ 2.132168] Publishing every 500 ms
The talker’s code asks for a history of 10, the ROS 2 default; the image reserved 1, because the contract says the system keeps 1, and the board takes what was reserved. The talker publishes every 500 ms and the listener reads each sample before the next arrives, so one is enough. A node that needs to keep more says so in the contract, and the build reserves it.
Break it on purpose
Rename the talker’s parameter in the contract, from period_ms to period:
src/sensor_node_bringup/launch/system.contract.yaml, change the marked lines sensor_node:
params:
- period_ms: { type: integer }
+ period: { type: integer }
and build:
nros build
The build refuses, before it compiles anything:
Error: 1 launch parameter value(s) disagree with the contract's declarations:
node `/sensor_node`: parameter `period_ms`, set by launch file system.launch.xml, is not declared in its contract (…); it declares: period
The launch file sets period_ms, and the contract says the talker declares
only period. The build does not guess which one is right, and it does not
size the parameter store for the names that matched and ignore the rest. It
stops, naming the node, the parameter and both files. The model it resolved
is set aside as refused, so nothing builds from it until a resolve succeeds.
Put the name back, and the build succeeds again:
src/sensor_node_bringup/launch/system.contract.yaml, change the marked lines sensor_node:
params:
- period: { type: integer }
+ period_ms: { type: integer }
nros build
What just happened
You gave the build the contract, and it used it for static sizing: every pool of the image sized from what the system states it creates, rather than from a default large enough for any system.
A contract states, ahead of the build, what only exists after the program
runs. A node creates its publishers and timers in register or configure,
at boot, but the pools they live in are static arrays whose sizes are
compiled in before any node’s code is. Somebody must state those numbers
before the build, and the contract is where the whole system states them
once, under the same names the launch file and the ROS 2 graph use.
Three rules make it safe to size from a statement:
- Names are resolved names. A contract row matches an endpoint, a parameter or a node by the name the system actually uses, after remaps and namespaces. A row that matches nothing is not used, and a value the launch file sets that the contract does not declare is refused, as you saw.
- All or nothing, per image. If one node of an image is missing from the contract, that image derives nothing and keeps its configured defaults. A count taken over only the nodes the contract describes would be smaller than the image needs, and a pool one slot short fails at boot, so the build refuses to guess “some of them”.
- Checked against the code when it can be. The census compares the
contract with what the nodes actually create. An endpoint the code creates
and the contract omits is refused, because it is the pool that would be
short; one the contract declares and the code never creates is refused
too, unless the bringup waives it under
[census.waive]. A census is fresh by content: touching a file changes nothing, adding a subscription does. This Tutorial’s bringup has no host image to take a census with, so it warns instead;[census] on_stale = "warn"does the same for a census that no longer matches the code.
The same contract works for every language. A C or C++ node package has no
ENTITY_BOUNDS: its counts come only from the contract, which is why a
contract matters most for a C or C++ image. A bringup with no launch/
directory writes the same file as system.contract.yaml beside its
system.toml, and the build carries it to where the launch file is
generated.
Static memory and pools explains what each pool holds and why the sizes derived from messages are upper bounds.
Next
- Same project, another target: the same nodes, the same contract, on a second board.
- Contract format: every key a contract accepts, generated from the format’s own definition.
- Measure static memory: RAM broken down by symbol and by owner.
Design background
The contract and the sizing it drives follow RFC-0124 D6 for this walkthrough;
the census follows the contract’s retirement of the per-component ENTITIES
list, which declared counts beside the code with nothing comparing the two.
Same project, another target
Needs first: Tell the build what your system creates
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily);nros-board-linux: Verified on host (daily). From the board support registry; Board Support Levels explains the words.
The project has run on one target since chapter 1: the MPS2-AN385 with FreeRTOS, in QEMU. In this chapter you build the same six nodes, with the same launch file and the same contract, for a second target: your Linux host, as an ordinary program on your machine. You add one table to the bringup and change nothing else. At the end the bringup has two images, and the host one prints the same lines the board does:
[INFO] client_node: [8345474.073235] Result of add_two_ints: 5
...
[INFO] action_client_node: [8345482.703991] Result received: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
The board’s image keeps working beside it, and you choose which one runs by its name.
Run every step from the root of sensor_ws. The chapter changes one file:
sensor_ws/
└── src/
└── sensor_node_bringup/
└── system.toml (changed)
Provision the second target
nros setup linux --rmw zenoh
For the Linux host, nros setup checks the host toolchain and the zenoh
sources it builds against, and usually finds everything already present:
the host needs no cross-compiler and no emulator.
On the host, the image is a Linux program. Where the board’s image runs nano-ros in a FreeRTOS task, with lwIP under it, the host image runs it in a process, on the host’s own network stack. Nothing in the nodes changes: they were written against nano-ros, not against FreeRTOS.
Add an image row
An image is one [image.<id>] table in the bringup’s system.toml. Add a
second one, named linux, at the end of the file:
src/sensor_node_bringup/system.toml
[image.linux]
board = "linux"
board names the target by its nano-ros board name;
Supported boards lists them. The image
needs no locator: it runs on your host, and the host board’s own default
dials the router on tcp/127.0.0.1:7447.
The image’s name, linux, is yours to choose. It appears in the full name
of the image, sensor_node_bringup:linux, in the directory its build lands
in under build/, and on the command line, so pick a short name that says
which target it is.
Everything else the image needs, it inherits: the [[component]] rows, the
launch file, the contract, rmw = "zenoh" from [system]. Nothing in
src/ outside the bringup changes. The board’s own description supplies
the rest: the Rust target or the C toolchain, the linker script, the RTOS
configuration and the memory the board has.
Name the image you run
With two images, a command that names nothing no longer picks one. Plain
nros run configures the images, then refuses, and its last lines list what
would work:
nros run: this workspace declares 2 images and no default.
sensor_node_bringup:freertos
sensor_node_bringup:linux
build one: nros build freertos
build all: nros build --all
or declare: [system] default_images = ["freertos"]
nros run, nros build and nros flash all accept the same spellings,
tried in this order:
| You type | It means |
|---|---|
sensor_node_bringup:linux | that bringup’s image; always works |
linux | the image named linux, when only one bringup declares it |
sensor_node | the bringup whose only node is sensor_node, with its only image |
| nothing | the workspace’s only image |
The third spelling stopped working in chapter 3, and the fourth stops now.
Anything that does not resolve refuses and lists the full spellings; a
shortcut never picks one of several. --why names the rule that resolved:
nros run linux --dry-run --why
The plan is chapter 2’s, for another target. Its image lines, near the
top and in [provenance], say which rule picked it:
image = "sensor_node_bringup:linux"
image = "rung 2, `<image>`: declared by one bringup, `sensor_node_bringup`"
To make a bare nros build or nros run choose for you, declare the images
it means in [system]:
[system]
default_images = ["freertos"]
Run it on the second target
source /opt/ros/humble/setup.bash
nros run linux
I heard: reading 1
Result of add_two_ints: 5
Result received: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
I heard: reading 1
[action_client_node] result last=
I heard: reading 1
[action_client_node] result last=
The first build of the image compiles nano-ros for your host, which takes a minute or two. Then the program starts, and its output (a Rust project’s, trimmed) is the board’s without the board:
nros run: starting the zenoh router on tcp/127.0.0.1:7447
[INFO] nros: session open
[INFO] sensor_node: [8345473.073004] Publishing every 500 ms
[INFO] server_node: [8345473.073180] Waiting for service requests
[INFO] action_server_node: [8345473.073438] Waiting for action goals
[INFO] action_client_node: [8345473.083724] Sending goal
[INFO] sensor_node: [8345473.572971] Publishing: reading 1 (21100 mC)
[INFO] monitor_node: [8345473.573009] I heard: reading 1 (21100 mC)
[INFO] client_node: [8345474.073235] Result of add_two_ints: 5
...
[INFO] action_client_node: [8345482.703991] Result received: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
There is no banner and no network to bring up: the program is a process on a machine that already has both. The number in brackets is your host’s monotonic clock, where the board’s counts from its own boot. Every node line is the same as on the board, because they are the same nodes, and the in-image goal finishes in about ten seconds instead of twenty-five, because a host processor is faster than an emulated Cortex-M3. Press Ctrl-C when the action result has printed.
The contract from chapter 8 sized this image too, because a contract belongs to the launch file, and every image built from that launch file is sized from it. The numbers it derives differ per board, since each board’s pools have their own sizes, but the statement is written once.
The first image still runs, unchanged. Press Ctrl-C when the listener has heard a few readings:
nros run freertos
I heard: reading 3
This build of the board image did one thing it never did before. Its output says so:
entity-census take sensor_node_bringup:freertos: taking the census with `sensor_node_bringup:linux` (linux_entry)
With a host image of the same launch file in the bringup, nros build takes
the census that chapter 8 marked as missing: it runs the host program
once, records what every node creates, and compares that with the contract
before it builds the board’s image. A contract row the code does not match
now stops the build, naming the node, the entry and the file to change. That
is why chapter 7’s talker declares period_ms as well as reading it: a
parameter the contract states and no node declares is refused here.
Change it
Make the board the image a bare command means. Add
default_images = ["freertos"] to the [system] table, and plain
nros run and nros build stop refusing: they run and build the FreeRTOS
image, and nros run linux still names the host. Remove the line to go back
to naming one every time. A list of several images makes a bare
nros build build each of them.
If it doesn’t work
- The build stops because the host toolchain is missing: this machine
has not provisioned the host target. Run
nros setup linux --rmw zenoh, as above. nros runrefuses and lists two images: name one, as in the table above.nros run linuxandnros run sensor_node_bringup:linuxare the same image.- The host program starts and never prints
I heard:: it did not reach the router. Check that nothing else holds port 7447, or run your own router and pass--router tcp/127.0.0.1:7447.
What an image row can say
The two image tables differ in their board line. An image can also say
anything else that is a fact about that program and not about its nodes:
| Key | Meaning |
|---|---|
board | the target, by its nano-ros board name |
rmw | this image’s RMW, when it differs from [system] rmw |
locator | where this image’s router or agent is |
launch | a launch file in the bringup other than the default one |
features | capabilities added to [system] features for this image |
os_config | RTOS configuration files: Zephyr prj-*.conf fragments or a board network file |
system.toml keys lists them all. Values every
image shares go in [image_defaults], so eight images do not repeat their
RMW eight times; a key in a specific image replaces the default.
On the host, Cyclone DDS runs as well as zenoh, which
Get started on the Linux host shows on a project
of its own. A host image of the same launch file is also what the census of
chapter 8 runs: with one in the bringup, nros build takes the census and
compares it with the contract before it builds the board image.
What just happened
You added an image row: a second program built from the same bringup. The bringup now describes one system, six nodes with their names, parameters and contract, deployed two ways, and each image is one table that says how.
That is the shape every nano-ros project grows into. The nodes say what the
system does, the launch file and the contract say how the system is put
together, and each image says where it runs and through what. A new board is
a new image row; a new middleware for one board is an rmw line in its row;
a second variant of the system for the same board is a second row naming
another launch file. Each row builds and runs on its own, with its own name,
and nros never chooses between them for you.
In ROS 2 a launch file starts processes on machines that already run an operating system, so where a node runs is decided when it starts. In nano-ros that is decided when the image is built, because on a microcontroller the program and its target are one thing: there is no loader that could put the same binary on another board. One bringup with several image rows is how one system reaches several targets without being written twice.
Next
- Talk to ROS 2: what crosses the wire between the board and ROS 2, and where the two differ.
- Linux host: the host target’s configuration, and Cyclone DDS on it.
- Switch the RMW per image: one bringup, a different backend per image.
Design background
Images as rows of the bringup, and the target names nros run accepts, follow
RFC-0121; the board descriptor that supplies an image’s target facts follows
RFC-0098.
Talk to ROS 2
Needs first: Same project, another target
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
Every chapter so far ended with a ROS 2 command reaching the board. This one
looks at what crosses the wire, in both directions, with the project’s own
message type. You build tutorial_msgs for ROS 2 with colcon, read the
board’s readings with ros2 topic echo, ask the ROS 2 graph what QoS the
board offers, and publish a reading from ROS 2 that the board’s listener
hears:
[INFO] monitor_node: [ 9.159741] I heard: reading 1000 (25000 mC)
At the end you know which parts of ROS 2 a nano-ros image matches exactly, and the few places it does not, each of them a choice made for a microcontroller, whose memory is fixed when its image is built.
Run every step from the root of sensor_ws.
Build the message package for ROS 2
A ROS 2 program can only read a message whose type it knows. std_msgs
came with ROS 2; tutorial_msgs is yours, so the ROS 2 side needs it built.
It is a stock ROS 2 package, which is why chapter 5 gave it a
CMakeLists.txt that nano-ros never runs. Build it with colcon, into a
directory under build/, so it stays out of your sources. The ROS 2
development tools from Install
include colcon; without them, this line adds it:
sudo apt-get install -y python3-colcon-common-extensions
source /opt/ros/humble/setup.bash
colcon build --base-paths src/tutorial_msgs \
--build-base build/colcon --install-base build/colcon/install
Starting >>> tutorial_msgs
Finished <<< tutorial_msgs [3.80s]
Summary: 1 package finished [7.31s]
The same .msg file now has two builds: the one nros generates for the
board, and the one rosidl generated for ROS 2. They agree on the type’s
name, tutorial_msgs/msg/Reading, and on its bytes on the wire.
Read the board from ROS 2
Start the board’s image in one terminal, and leave it running:
source /opt/ros/humble/setup.bash
nros run freertos
I heard: reading 2
In a second terminal, source ROS 2 and the overlay colcon built, select
the zenoh RMW, and read one message. --no-daemon asks the router directly,
as in chapter 7: a ros2 daemon left over from an earlier chapter still holds
a session to a router that nros run has since replaced, and it answers with
!rclpy.ok().
source /opt/ros/humble/setup.bash
source build/colcon/install/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo --no-daemon /sensor/reading tutorial_msgs/msg/Reading --once
sequence: 11
temperature_mc: 21100
---
The board publishes on the name chapter 7’s remap gave it, with the type chapter 5 defined, and ROS 2 reads both fields by name. Without the overlay, the same command refuses the type, because ROS 2 has no code for a message it has never built.
Ask the graph what the board offers
The same shell can ask what the board’s endpoints look like from the ROS 2 side:
ros2 topic info -v --no-daemon /sensor/reading
Type: tutorial_msgs/msg/Reading
Publisher count: 1
Node name: sensor_node
Node namespace: /
Topic type: tutorial_msgs/msg/Reading
Endpoint type: PUBLISHER
QoS profile:
Reliability: RELIABLE
History (Depth): KEEP_LAST (1)
Durability: VOLATILE
...
Subscription count: 1
Node name: monitor_node
Node namespace: /
Topic type: tutorial_msgs/msg/Reading
Endpoint type: SUBSCRIPTION
QoS profile:
Reliability: RELIABLE
History (Depth): KEEP_LAST (1)
Durability: VOLATILE
...
Both endpoints are on the graph with their node names, in the root namespace, exactly as two ROS 2 nodes on your machine would be. Their QoS is the one the board actually granted, not the one the code asked for: the code asked for a history of 10, the contract of chapter 8 reserved 1, and the board advertises 1. A ROS 2 tool that sizes its own queue from what a publisher offers sees the truth about the board.
Compare the plan with the graph
nros can say which nodes and topics an image will create before it runs.
Ask it about the image that is running now, then ask ROS 2 what it sees:
nros image show freertos --nodes --topics
freertos
image `freertos` of bringup `sensor_node_bringup`
...
PLANNED NODE PACKAGE RUNS
/sensor_node sensor_node sensor_node
/monitor_node monitor_node monitor_node
/server_node server_node server_node
/client_node client_node client_node
/action_server_node action_server_node action_server_node
/action_client_node action_client_node action_client_node
PLANNED KIND TYPE FROM TO
/sensor/reading topic tutorial_msgs/msg/Reading /sensor_node /monitor_node
/add_two_ints service example_interfaces/srv/AddTwoInts /server_node /client_node
/fibonacci action example_interfaces/action/Fibonacci /action_server_node /action_client_node
FROM is the publisher or server side, TO the subscriber or client side.
freertos
image `freertos` of bringup `sensor_node_bringup`
...
PLANNED NODE PACKAGE RUNS
/sensor_node sensor_node sensor_node
/monitor_node monitor_node monitor_node
/server_node server_node server_node
/client_node client_node client_node
/action_server_node action_server_node action_server_node
/action_client_node action_client_node action_client_node
PLANNED KIND TYPE FROM TO
/parameter_events topic rcl_interfaces/msg/ParameterEvent image freertos -
/sensor/reading topic tutorial_msgs/msg/Reading /sensor_node /monitor_node
/add_two_ints service example_interfaces/srv/AddTwoInts /server_node /client_node
/fibonacci action example_interfaces/action/Fibonacci /action_server_node /action_client_node
FROM is the publisher or server side, TO the subscriber or client side.
`image <name>` marks an endpoint the image's sizing descriptor records without naming its node.
freertos
image `freertos` of bringup `sensor_node_bringup`
...
PLANNED NODE PACKAGE RUNS
/sensor_node sensor_node sensor_node
/monitor_node monitor_node monitor_node
/server_node server_node server_node
/client_node client_node client_node
/action_server_node action_server_node action_server_node
/action_client_node action_client_node action_client_node
PLANNED KIND TYPE FROM TO
/sensor/reading topic tutorial_msgs/msg/Reading /sensor_node /monitor_node
/add_two_ints service example_interfaces/srv/AddTwoInts /server_node /client_node
/fibonacci action example_interfaces/action/Fibonacci /action_server_node /action_client_node
FROM is the publisher or server side, TO the subscriber or client side.
ros2 node list --no-daemon
ros2 topic list --no-daemon
/action_client_node
/action_server_node
/client_node
/monitor_node
/sensor_node
/server_node
/parameter_events
/rosout
/sensor/reading
The six planned nodes are the six on the graph, and the planned topic
/sensor/reading is there too. ROS 2 also lists /parameter_events and
/rosout, which nodes create for themselves. The launch plan names
neither. A C image’s sizing descriptor records /parameter_events, so its
table shows it, with image freertos where the node would be: the
descriptor records what the image creates, not which node creates it.
Publish to the board from ROS 2
Messages go the other way just as well. From the second terminal:
ros2 topic pub --times 3 /sensor/reading tutorial_msgs/msg/Reading \
'{sequence: 1000, temperature_mc: 25000}'
publisher: beginning loop
publishing #1: tutorial_msgs.msg.Reading(sequence=1000, temperature_mc=25000)
The board’s console, in the first terminal, prints the readings beside its own:
[INFO] monitor_node: [ 9.159741] I heard: reading 1000 (25000 mC)
[INFO] monitor_node: [ 10.632566] I heard: reading 1000 (25000 mC)
[INFO] monitor_node: [ 11.626410] I heard: reading 1000 (25000 mC)
The listener does not know, and cannot tell, whether a reading came from the talker in its own image or from a ROS 2 machine. Press Ctrl-C in the first terminal when you are done.
Change it
Move the project to another ROS 2 domain and watch the two sides lose each
other. Set domain_id = 42 in the bringup’s [system] table and run the
board again: ros2 topic list in a shell with no ROS_DOMAIN_ID no longer
shows /sensor/reading, because zenoh keeps each domain’s names apart. Run
export ROS_DOMAIN_ID=42 in that shell, and the topic is back. Set the
bringup’s domain_id back to 0 when you are done, so the commands of this
book keep working. Nothing in a node package changed in either direction:
the domain is a fact about the deployment, so it lives in the bringup.
What must match
A nano-ros image and a ROS 2 program reach each other when four things match:
- The RMW. The board uses zenoh, so the ROS 2 side sets
RMW_IMPLEMENTATION=rmw_zenoh_cpp, and both reach the same router, whichnros runstarted. Theros-<distro>-rmw-zenoh-cpppackage, which chapter 1 and every zenoh starter ask for, provides both the RMW and the router. With Cyclone DDS on both sides there is no router at all, as the Linux host starter shows. - The domain. ROS 2 reads
ROS_DOMAIN_IDfrom its environment, and defaults to 0. A board has no environment: its domain is[system] domain_idin the bringup, fixed when the image is built. The project’s is 0. A board on domain 42 needsdomain_id = 42and a rebuild, and the ROS 2 shell needsROS_DOMAIN_ID=42. - The ROS 2 edition.
[system] ros_edition = "humble"builds the image for Humble’s wire format. Iron and Jazzy add type hashes to every name on the wire, so a Humble image and a Jazzy graph discover nothing of each other. A bringup that serves both declares one image per edition, each with its ownros_editionline, and builds the one it needs:nros new <ws> --ros-edition jazzyscaffolds a Jazzy project from the start. - The QoS. As in ROS 2, a subscriber that asks for more than a publisher
offers receives nothing: a reliable subscriber hears nothing from a
best-effort publisher. A best-effort subscriber hears a publisher of
either kind, which is why chapter 1’s
ros2 topic echoasked for it.
Where nano-ros differs from ROS 2
On the wire, a nano-ros image speaks what rmw_zenoh_cpp speaks: the same
key expressions, the same liveliness tokens for discovery, CDR-encoded
messages and the same attachment on each one. You configure none of it.
What differs is what the image can afford, and the differences are
deliberate:
| ROS 2 | nano-ros |
|---|---|
| a history depth is whatever the code asks for | the board grants what was reserved at build time, and advertises what it granted |
| an incompatible QoS pair is reported as an event | it fails when the publisher or subscription is created, so you see it at boot |
RMW_IMPLEMENTATION and ROS_DOMAIN_ID are read at start-up | the RMW and the domain are built into the image |
| zenoh nodes may run in peer mode, with no router | every nano-ros session is a client of a router; peer mode is refused |
| every node keeps a full graph cache | an image on a serial-only link leaves its own graph cache out to save RAM; ROS 2 still sees the image |
| status events are polled from a waitset | an event callback runs on the executor, like a message callback |
None of these change what a ROS 2 program sees of the board, apart from the QoS it offers, which is the truth. Use QoS, status events and discovery shows the status events a node can register for, and How nano-ros differs from ROS 2 and micro-ROS explains each difference in full.
Troubleshooting
ros2 topic echosays the message type is invalid: the shell has not sourcedbuild/colcon/install/setup.bash, orcolcondid not buildtutorial_msgs. Source it after/opt/ros/humble/setup.bash.- The topic is not in
ros2 topic list: the ROS 2 shell is on another RMW or another domain. CheckRMW_IMPLEMENTATION=rmw_zenoh_cpp, and thatROS_DOMAIN_IDis unset or equals the bringup’sdomain_id. Check the edition too: a Humble image on a Jazzy graph is invisible. - The topic is listed but no messages arrive: the QoS does not match.
Ask for best-effort on the ROS 2 side,
--qos-reliability best_effort, which hears any publisher. ros2warns that it is unable to connect to a zenoh router: the board is not running, so no router is either. Startnros runfirst; a router you run yourself,ros2 run rmw_zenoh_cpp rmw_zenohd, works as well, withnros run --router tcp/127.0.0.1:7447on the board’s side.
What just happened
You used the boundary between nano-ros and ROS 2 from both sides, with a message type of your own, and saw where nano-ros differs from ROS 2 on the wire: almost nowhere. Names, types, bytes, discovery and the commands you use are ROS 2’s. What differs is decided when the image is built rather than when it starts (the RMW, the domain, the edition, the depth each endpoint keeps), and the image tells the graph the truth about each of them.
That is the end of the Tutorial. The project you started in chapter 1 is a workspace of six node packages and a message package, with one bringup that holds the system’s launch file and contract, built for two targets, and reachable from any ROS 2 machine on the same router. Everything else in this book builds on that shape.
Next
- Get started on your board: the same first chapter on every other supported board.
- Use a serial link and Configure zenoh: the board’s links in depth.
- Move a ROS 2 project over: bring an existing ROS 2 project to nano-ros.
Design background
Speaking rmw_zenoh_cpp’s wire format, with ROS 2’s own router, follows
RFC-0075; saying plainly where nano-ros differs is RFC-0124 Principle 13.
Lab: QoS is checked twice
Needs first: Add a second node
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
A ROS 2 publisher and subscription agree on QoS when they meet, at run time,
and a mismatch shows up as messages that never arrive. On a microcontroller
there is no one watching at run time, so nano-ros checks the agreement
earlier, and twice: when the image is built, against the other nodes of the
system, and when the image boots, against what your code asked for. In this
lab you break each check on purpose, read what it says, and then make the
two nodes of chapter 3 agree on a non-default QoS: the talker keeps its last
message for a subscriber that joins late (transient_local durability), and
the listener asks for it.
At the end, nros run prints I heard: again, from a pair that agrees on
transient_local in its code and in its contract.
The lab starts from the workspace of chapter 3: sensor_node publishes on
/chatter and monitor_node subscribes to it. Run every step from the root
of sensor_ws, in a shell where ROS 2 is sourced. It takes about an hour,
most of it reading.
The lab changes the contract and both nodes’ code:
sensor_ws/
└── src/
├── monitor_node/
│ └── src/lib.rs (changed)
├── sensor_node/
│ └── src/lib.rs (changed)
└── sensor_node_bringup/
└── system.contract.yaml (changed)
sensor_ws/
└── src/
├── monitor_node/
│ └── src/Listener.c (changed)
├── sensor_node/
│ └── src/Talker.c (changed)
└── sensor_node_bringup/
└── system.contract.yaml (changed)
sensor_ws/
└── src/
├── monitor_node/
│ └── src/Listener.cpp (changed)
├── sensor_node/
│ └── src/Talker.cpp (changed)
└── sensor_node_bringup/
└── system.contract.yaml (changed)
What transient_local buys, and costs
A volatile publisher sends each message to the subscribers that exist when
it publishes, and forgets it. A subscriber that starts a second later has
missed it for good. A transient_local publisher keeps its last messages and
hands them to a subscriber that joins later, which is what a topic that
changes rarely needs: a map, a configuration, a robot’s mode. A node that
boots late, or restarts, still learns the current value without waiting for
the next change.
On a workstation the kept messages live in a heap the middleware grows as it likes. On a microcontroller every kept message is a buffer fixed when the image is built, so the build must know which publishers keep messages and how many. That is why the choice belongs in the contract as well as in the code: the contract is what the build sizes from, and the code is what runs.
The contract the scaffold wrote
The bringup holds a contract beside system.toml. The scaffold wrote the
talker’s row when it made the workspace, and nros new --to added the
listener’s in chapter 3:
cat src/sensor_node_bringup/system.contract.yaml
The part that matters (comments trimmed):
nodes:
sensor_node:
params: {}
paths:
on_tick:
trigger: { timer: { rate: 1Hz } }
output: [chatter]
pub:
chatter:
qos:
durability: volatile
monitor_node:
params: {}
sub:
chatter:
qos:
durability: volatile
A contract row states what a node creates and with which QoS. The build
sizes the image from it (chapter 8 shows what that
changes), and, which is this lab’s subject, checks it. Both rows say volatile, which is what the scaffolded code
asks for, so the two checks have nothing to say yet. Every node has a
params: line, even an empty one: the build sizes the parameter store from
every node’s declaration or from none, and a contract that states some nodes
and not others is refused.
Check one: the build compares the nodes
Change monitor_node’s row to ask for more than the talker offers: a
transient_local subscription, against a volatile publisher. Replace the
contract with:
src/sensor_node_bringup/system.contract.yamlversion: 1
nodes:
sensor_node:
params: {}
paths:
on_tick:
trigger: { timer: { rate: 1Hz } }
output: [chatter]
pub:
chatter:
qos:
durability: volatile
monitor_node:
params: {}
sub:
chatter:
qos:
durability: transient_local
topics:
/chatter:
type: std_msgs/msg/String
pub: [sensor_node/chatter]
sub: [monitor_node/chatter]
# Read outside this workspace, by `ros2 topic echo` or a ROS 2 node.
external: sub
params: {} says the node declares no parameters. A C or C++ bringup needs
the key on every row or on none, so write it on both.
Build:
nros build
The build stops before it compiles anything. The lines that matter, at the end of its output:
error: [qos-match] error: incompatible QoS on topic '/chatter' field 'durability': pub '/sensor_node/chatter' offers 'volatile', sub '/monitor_node/chatter' requests 'transient_local' (at topics./chatter.qos.durability)
Error: refusing to emit a SystemModel: 2 contract error(s) (run `check` on the same launch file for source excerpts)
This is the rule ROS 2 applies when the two endpoints meet, “requested
versus offered”: a subscription may ask for less than the publisher offers,
never more. A transient_local subscription wants the samples published
before it joined, and a volatile publisher keeps none. ROS 2 would connect
nothing and report an incompatible-QoS event at run time, if anyone listened
for it. Here both rows are in one file, so the build compares them first and
names the topic, the field and both endpoints.
Check two: the boot compares the contract with the code
Make the talker offer what the listener asks for, in the contract only. Change the publisher’s row:
src/sensor_node_bringup/system.contract.yaml, change the marked lines pub:
chatter:
qos:
- durability: volatile
+ durability: transient_local
The two rows agree now, and the build accepts them. Run it:
nros run
The image builds and boots, then stops on its own. The lines that matter,
each trimmed of its [WARN] nros: or [ERROR] nros: prefix and the board’s
clock:
declared QoS: taking durability transient_local on publisher `/chatter`; the call site asked volatile. Change the contract row to keep the call site's.
declared QoS: subscription `/chatter` registers volatile and the contract declares durability transient_local; taking it would widen what the code narrowed. Fix the contract row or the call site.
nros run: the target exited with code 1 after …
When a node creates an endpoint, nano-ros compares the QoS the code passed with the contract’s row for it, and the two lines are the two directions of that rule:
- A publisher’s row may strengthen the call site. The code asked for
volatile; keeping one sample for a late subscriber costs the image a buffer the build already reserved from the row, and every subscriber the publisher served before is still served. So the image takes the row’s value and warns, naming both. - A subscription’s row may not widen what the call site narrowed. The
code subscribed
volatile, which is the narrower request; the row claimstransient_local. Taking the row would hand the callback samples published before it joined, which the code never asked for and may not handle. So the image refuses to create the subscription, and the boot fails withDeclaredQosMismatch.
The contract describes the code; it does not replace it. Where they disagree, the safe direction is taken with a warning, and the unsafe one is refused.
Make the code say it
Change both call sites to transient_local, so the code and the contract
say the same thing.
The talker’s create_publisher_for_topic has a _with_qos form that takes
a QoSProfile:
src/sensor_node/src/lib.rs, change the marked lines use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode, NodeContext, NodeOptions,
- NodeResult, TimerDuration,
+ NodeResult, QoSProfile, TimerDuration,
};
src/sensor_node/src/lib.rs, change the marked lines let mut node = ctx.create_node(NodeOptions::new("sensor_node"))?;
- let pub_chatter = node.create_publisher_for_topic::<StringMsg>("/chatter")?;
+ let pub_chatter = node.create_publisher_for_topic_with_qos::<StringMsg>(
+ "/chatter",
+ QoSProfile::default().transient_local(),
+ )?;
let _timer =
The listener’s create_subscription_for_callback_name has no QoS form; the
one that does, create_subscription_for_topic_with_qos, names the callback
after the topic, so on_callback matches "/chatter" instead of
"on_chatter":
src/monitor_node/src/lib.rs, change the marked lines use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode, NodeContext, NodeOptions,
- NodeResult,
+ NodeResult, QoSProfile,
};
src/monitor_node/src/lib.rs, change the marked lines let mut node = ctx.create_node(NodeOptions::new("monitor_node"))?;
- let _sub =
- node.create_subscription_for_callback_name::<StringMsg>("on_chatter", "/chatter")?;
+ let _sub = node.create_subscription_for_topic_with_qos::<StringMsg>(
+ "/chatter",
+ QoSProfile::default().transient_local(),
+ )?;
log_info!(&LOGGER, "Subscriber created for topic: /chatter");
src/monitor_node/src/lib.rs, change the marked lines- if callback.as_str() == "on_chatter"
+ if callback.as_str() == "/chatter"
&& let Ok(msg) = ctx.message::<StringMsg>()
rclc_publisher_init_default and rclc_subscription_init_default have
_with_qos forms that take an rclc_qos_t. Start from the default profile
and change one field, in the talker:
src/sensor_node/src/Talker.c, change the marked lines self->pub = rcl_get_zero_initialized_publisher();
- rcl_ret_t rc = rclc_publisher_init_default(
- &self->pub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), "/chatter");
+ rclc_qos_t qos = RCLC_QOS_DEFAULT;
+ qos.durability = RCLC_QOS_DURABILITY_TRANSIENT_LOCAL;
+ rcl_ret_t rc = rclc_publisher_init_with_qos(
+ &self->pub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), "/chatter",
+ &qos);
if (rc != RCL_RET_OK) {
and in the listener:
src/monitor_node/src/Listener.c, change the marked lines self->sub = rcl_get_zero_initialized_subscription();
- rcl_ret_t rc = rclc_subscription_init_default(
- &self->sub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), "/chatter");
+ rclc_qos_t qos = RCLC_QOS_DEFAULT;
+ qos.durability = RCLC_QOS_DURABILITY_TRANSIENT_LOCAL;
+ rcl_ret_t rc = rclc_subscription_init_with_qos(
+ &self->sub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), "/chatter",
+ &qos);
if (rc != RCL_RET_OK) {
Both calls take a QoS after the topic name, the way rclcpp does. In the
talker:
src/sensor_node/src/Talker.cpp, change the marked lines ::setvbuf(stdout, nullptr, _IONBF, 0);
- ::rclcpp::Result r = node.create_publisher(pub_, "/chatter");
+ ::rclcpp::Result r = node.create_publisher(
+ pub_, "/chatter", ::rclcpp::QoS::default_profile().transient_local());
if (!r.ok()) return r;
and in the listener:
src/monitor_node/src/Listener.cpp, change the marked lines ::rclcpp::Result r =
::rclcpp::bind_subscription<::std_msgs::msg::String, Listener, &Listener::on_msg>(
- node, "/chatter", this);
+ node, "/chatter", this, ::rclcpp::QoS::default_profile().transient_local());
if (r.ok()) {
Run the pair
nros run
I heard: [Hello World: …]
The image boots, and the listener hears the talker. The console still carries warnings, of a different kind (trimmed):
[WARN] nros: [ 2.122472] qos: publisher '/chatter' asked for TRANSIENT_LOCAL KEEP_LAST(10); this image retains 1 sample(s) per transient-local publisher and replays them on a late joiner's query. Granting 1 and advertising it to the graph. Declare the publisher's…
[WARN] nros: [ 2.127589] qos: subscription '/chatter' asked for KEEP_LAST(10); this image's receive ring holds 4. Granting 4 and advertising it to the graph. Raise NROS_ZENOH_SUBSCRIBER_RING_DEPTH to keep more.
[INFO] monitor_node: [ 3.123307] I heard: [Hello World: 1]
Press Ctrl-C when you have read them.
These are not mismatches between the code and the contract. They are the
image granting less depth than the code asked for: QoSProfile::default(),
RCLC_QOS_DEFAULT and QoS::default_profile() all ask for KEEP_LAST(10),
and this image keeps one sample per transient-local publisher and four per
subscription. The image grants what it has, advertises the granted value to
the ROS 2 graph (so ros2 topic info -v /chatter shows the truth), and names
the knob that would raise it.
Change it
Silence the depth warnings by asking for what the image grants. Add
depth: 1 beside durability in both contract rows, and ask for depth 1 at
both call sites: .keep_last(1) on the Rust QoSProfile, qos.depth = 1;
in C, .keep_last(1) on the C++ QoS. Run again: the qos: lines are gone,
and the image reserves one sample per endpoint instead of the default ring.
Then try the other direction of check two: put the talker’s contract row back
to volatile while its code keeps transient_local. The build refuses it
first (check one, since the listener still asks for transient_local); make
the listener volatile in both places too, and read what the boot says about
a publisher whose row is weaker than its call site.
If it doesn’t work
- Step one builds instead of refusing: compare the file with the one
above. The listener’s row must sit under
nodes:with the namemonitor_node, and/chatterundertopics:must listmonitor_node/chatterin itssub:, so the build knows the two rows meet on one topic. - Step two fails without a
declared QoSline: the build itself failed, before the image booted. Read the firsterrorin its output; a C or C++ bringup refuses a contract where some rows carryparams:and others do not. - The last run prints
declared QoSerrors again: one call site still asks forvolatile. Each line names the endpoint (publisherorsubscription) and its topic. - The listener prints nothing in the last run: in a Rust project,
on_callbackstill matches"on_chatter". The_with_qossubscription names its callback after the topic.
What just happened
You met the two places a nano-ros system’s QoS is checked, and the rule each applies:
| When | Compares | Rule | On a mismatch |
|---|---|---|---|
build (qos-match) | a subscription’s row with its publisher’s row | the subscription may request no more than the publisher offers | the build refuses and names topic, field and both endpoints |
| boot, publisher | the call site with the row | the row may strengthen the call site, never weaken it | stronger: taken, with a warning; weaker: refused |
| boot, subscription | the call site with the row | the row may not widen what the call site narrowed | refused (DeclaredQosMismatch) |
| boot, any endpoint | the asked depth with the image’s pools | the image grants what it has | granted and advertised, with a warning naming the knob |
In ROS 2, all of this happens when two endpoints meet on the network, and a
mismatch is a topic that stays silent. nano-ros states the system in one
contract, so the comparison between nodes moves to the build, and the
comparison between the contract and the code happens once, at boot, before
any message flows. What remains at run time is the same “requested versus
offered” check with peers outside the image, such as ros2 topic echo.
Next
- Tell the build what your system creates: the contract as a whole, and what it does to the image’s memory.
- Talk to ROS 2:
ros2 topic info -vshows the QoS the board granted, from the ROS 2 side.
Design background
The contract and what the build derives from it follow RFC-0100. The lab grows the Tutorial’s one project, as RFC-0124 D3 lays out.
Lab: two sched tasks keep a promise
Needs first: Run a talker
Status: this chapter runs on
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
A control loop makes a promise: it runs every period, and it is never so late that the thing it controls notices. On a microcontroller that promise is broken most often not by the loop itself but by something else on the same processor that runs too long. In this lab you build that situation on purpose: a 100 Hz control loop and a 10 Hz telemetry job whose every run takes 60 ms. You put both on one sched task and watch the loop miss its periods, then give the loop a sched task of its own, at a higher priority, and watch it keep its period while the telemetry job does exactly the same work.
The loop grades itself. Every 100 ticks it prints the longest gap between two
of its ticks, and after 1,000 ticks it prints how many of those ten windows
broke a 50 ms budget. At the end, nros run prints 10 windows, 0 late.
The lab runs on the emulated MPS2-AN385 with FreeRTOS, in Rust, C or C++. It
uses a workspace of its own, beside the Tutorial’s sensor_ws, and takes
about an hour, most of it reading.
What a sched task is
An executor runs callbacks one at a time. When a timer is due, the executor calls its callback, and it calls the next one only when that callback returns. That is what makes a callback simple to write, since nothing else in the same executor touches its state while it runs. It is also the problem this lab is about: a callback that is due cannot start while another one is still running.
A sched task is an RTOS task that runs part of the image’s callbacks, with a priority of its own. You decide which callbacks run where in two steps:
- In the node’s code, put the callbacks in a named callback group.
- In the bringup’s
system.toml, bind each group to a sched task withgroup_tasks, and give each sched task a[tasks.<name>]table, with its FreeRTOS priority in[tasks.<name>.freertos].
The code never names a sched task or a priority, so the same node runs on one task or on two, and on another RTOS, without a change. On FreeRTOS a bigger number is more urgent, and a more urgent task that becomes ready takes the processor from a less urgent one at once, in the middle of its callback.
Make the workspace
Start beside sensor_ws, not inside it: nros new inside a workspace adds
a package to that workspace. Chapter 1 already provisioned the board:
cd ..
Make a workspace whose first node is the control loop, and add the
telemetry job beside it. Both start from the talker template; the next
two steps replace their code.
nros new control_ws --board mps2-an385-freertos --template talker --lang rust
cd control_ws
nros new telemetry_node --template talker --lang rust --to control_node_bringup
nros new control_ws --board mps2-an385-freertos --template talker --lang c
cd control_ws
nros new telemetry_node --template talker --lang c --to control_node_bringup
nros new control_ws --board mps2-an385-freertos --template talker --lang cpp
cd control_ws
nros new telemetry_node --template talker --lang cpp --to control_node_bringup
nros new control_ws named the node package control_node and the bringup
control_node_bringup, as chapter 1’s did for sensor_ws. Run every step
from here on in control_ws. The steps below then rewrite both nodes’ code
and the bringup’s contract, and add to its system.toml:
control_ws/ (new)
└── src/
├── control_node/ (new)
├── telemetry_node/ (new)
└── control_node_bringup/ (new)
Write the control loop
The loop runs every 10 ms. It does no control work; it only measures itself. On each tick it reads a steady clock, keeps the longest gap since the previous tick, and every 100 ticks prints that gap and whether it broke the budget of 50 ms, five periods. Replace the talker’s code:
src/control_node/src/lib.rs#![allow(unused)]
fn main() {
//! A 100 Hz control loop that measures itself: the longest gap between
//! two of its ticks, judged against a 50 ms budget.
#![no_std]
use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode,
NodeContext, NodeOptions, NodeResult, TimerDuration,
};
use nros_log::{Logger, log_info};
static LOGGER: Logger = Logger::new("control_node");
/// Five periods: a tick later than this is late.
const BUDGET_US: u64 = 50_000;
pub struct Talker;
impl Component for Talker {
const NAME: &'static str = "control_node";
const ENTITY_BOUNDS: nros::EntityBounds =
nros::EntityBounds::exact(0, 0, 0, 0, 0);
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
nros_log::register_logger(&LOGGER);
let mut node = ctx.create_node(NodeOptions::new("control_node"))?;
// Everything created after this line belongs to the group `ctrl`.
node.callback_group("ctrl")?;
let _timer = node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(10),
)?;
Ok(())
}
}
/// Ticks so far, the last tick's time, the window's longest gap, late windows.
pub struct Loop {
ticks: u32,
last_us: u64,
worst_us: u64,
late: u32,
}
impl ExecutableNode for Talker {
type State = Loop;
const HAS_TICK: bool = false;
fn init() -> Self::State {
Loop { ticks: 0, last_us: 0, worst_us: 0, late: 0 }
}
fn on_callback(
s: &mut Self::State,
callback: Callback<'_>,
_ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() != "on_tick" {
return;
}
let now = nros::time::now_us();
if s.ticks > 0 {
s.worst_us = s.worst_us.max(now.saturating_sub(s.last_us));
}
s.last_us = now;
s.ticks += 1;
if s.ticks % 100 == 0 {
let late = s.worst_us > BUDGET_US;
if late {
s.late += 1;
}
log_info!(
&LOGGER,
"ticks {}-{}: longest gap {} us ({})",
s.ticks - 99,
s.ticks,
s.worst_us,
if late { "late" } else { "on time" }
);
s.worst_us = 0;
if s.ticks == 1000 {
log_info!(&LOGGER, "10 windows, {} late", s.late);
}
}
}
}
nros::node!(Talker);
}
src/control_node/src/Talker.c// A 100 Hz control loop that measures itself: the longest gap between two
// of its ticks, judged against a 50 ms budget.
#include <stdint.h>
#include <stdio.h>
#include <rcl/rcl.h>
#include <rclc/executor.h>
#include <rclc/rclc.h>
// Five periods: a tick later than this is late.
#define BUDGET_NS (50LL * 1000000LL)
typedef struct {
rcl_timer_t timer;
int32_t ticks;
int64_t worst_ns;
int32_t late;
} control_t;
// `since_last` is rcl's `last_call_time`: nanoseconds since the previous call.
static void on_tick(rcl_timer_t* timer, int64_t since_last) {
control_t* self = RCLC_CONTAINER_OF(timer, control_t, timer);
if (self->ticks > 0 && since_last > self->worst_ns) {
self->worst_ns = since_last;
}
self->ticks++;
if (self->ticks % 100 == 0) {
int late = self->worst_ns > BUDGET_NS;
if (late) {
self->late++;
}
printf("[control_node] ticks %d-%d: longest gap %lld us (%s)\n",
(int)self->ticks - 99, (int)self->ticks,
(long long)(self->worst_ns / 1000), late ? "late" : "on time");
self->worst_ns = 0;
if (self->ticks == 1000) {
printf("[control_node] 10 windows, %d late\n", (int)self->late);
}
}
}
static rcl_ret_t control_configure(rcl_node_t* node, rclc_executor_t* executor,
control_t* self) {
(void)node;
setvbuf(stdout, NULL, _IOLBF, 0);
self->ticks = 0;
self->worst_ns = 0;
self->late = 0;
self->timer = rcl_get_zero_initialized_timer();
rcl_ret_t rc = rclc_timer_init_default(&self->timer, NULL,
10ULL * 1000000ULL, on_tick);
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_timer(executor, &self->timer);
}
RCLC_C_COMPONENT(control_t, control_configure)
src/control_node/include/control_node/Talker.hpp#pragma once
#include <rclcpp/rclcpp.hpp>
namespace control_node {
/// A 100 Hz control loop that measures itself: the longest gap between two
/// of its ticks, judged against a 50 ms budget.
class Talker {
::rclcpp::Timer timer_;
::rclcpp::Clock clock_{RCL_STEADY_TIME};
int ticks_ = 0;
int64_t last_ns_ = 0;
int64_t worst_ns_ = 0;
int late_ = 0;
void on_tick();
public:
::rclcpp::Result configure(::rclcpp::Node& node);
};
} // namespace control_node
src/control_node/src/Talker.cpp#include "control_node/Talker.hpp"
#include <cstdio>
namespace control_node {
// Five periods: a tick later than this is late.
static const int64_t kBudgetNs = 50LL * 1000000LL;
void Talker::on_tick() {
const int64_t now = clock_.now().nanoseconds();
if (ticks_ > 0 && now - last_ns_ > worst_ns_) worst_ns_ = now - last_ns_;
last_ns_ = now;
++ticks_;
if (ticks_ % 100 == 0) {
const bool late = worst_ns_ > kBudgetNs;
if (late) ++late_;
std::printf("[control_node] ticks %d-%d: longest gap %lld us (%s)\n",
ticks_ - 99, ticks_, (long long)(worst_ns_ / 1000),
late ? "late" : "on time");
worst_ns_ = 0;
if (ticks_ == 1000) {
std::printf("[control_node] 10 windows, %d late\n", late_);
}
}
}
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
::setvbuf(stdout, nullptr, _IONBF, 0);
return node.create_wall_timer<Talker, &Talker::on_tick>(timer_, 10, this);
}
} // namespace control_node
Three things to notice:
- The callback group. In Rust,
node.callback_group("ctrl")puts everything the node creates after it, here the timer, in the groupctrl. In C and C++ the group is the package’s, named in itsCMakeLists.txtbelow. - The clock. A gap is measured on a steady clock, one that never jumps
when the wall time is set. Rust reads
nros::time::now_us(); C gets the time since the previous call as the timer callback’s second argument, rcl’slast_call_time; C++ reads anrclcpp::Clockbuilt onRCL_STEADY_TIME. - No publisher. The loop prints to the console and publishes nothing, so the lab measures scheduling and nothing else.
Write the telemetry job
The telemetry job runs every 100 ms and spends 60 ms of processor time each time, standing in for real work such as compressing a log. Its callback does not sleep or wait: it keeps the processor busy until 60 ms have passed, which is what a long computation does.
src/telemetry_node/src/lib.rs#![allow(unused)]
fn main() {
//! A 10 Hz telemetry job whose every run takes 60 ms of processor time.
#![no_std]
use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode,
NodeContext, NodeOptions, NodeResult, TimerDuration,
};
pub struct Talker;
impl Component for Talker {
const NAME: &'static str = "telemetry_node";
const ENTITY_BOUNDS: nros::EntityBounds =
nros::EntityBounds::exact(0, 0, 0, 0, 0);
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
let mut node = ctx.create_node(NodeOptions::new("telemetry_node"))?;
node.callback_group("telem")?;
let _timer = node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(100),
)?;
Ok(())
}
}
impl ExecutableNode for Talker {
type State = ();
const HAS_TICK: bool = false;
fn init() -> Self::State {}
fn on_callback(
_s: &mut Self::State,
callback: Callback<'_>,
_ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_tick" {
// Stand-in for real work: compress a log, format a report.
let t0 = nros::time::now_us();
while nros::time::now_us().saturating_sub(t0) < 60_000 {
core::hint::spin_loop();
}
}
}
}
nros::node!(Talker);
}
src/telemetry_node/src/Talker.c// A 10 Hz telemetry job whose every run takes 60 ms of processor time.
#include <stdint.h>
#include <rcl/rcl.h>
#include <rclc/executor.h>
#include <rclc/rclc.h>
typedef struct {
rcl_timer_t timer;
rcl_clock_t clock;
} telemetry_t;
static void on_tick(rcl_timer_t* timer, int64_t since_last) {
telemetry_t* self = RCLC_CONTAINER_OF(timer, telemetry_t, timer);
(void)since_last;
// Stand-in for real work: compress a log, format a report.
int64_t t0 = 0;
int64_t t = 0;
rcl_clock_get_now(&self->clock, &t0);
do {
rcl_clock_get_now(&self->clock, &t);
} while (t - t0 < 60LL * 1000000LL);
}
static rcl_ret_t telemetry_configure(rcl_node_t* node, rclc_executor_t* executor,
telemetry_t* self) {
(void)node;
rcl_ret_t rc = rcl_clock_init(RCL_STEADY_TIME, &self->clock, NULL);
if (rc != RCL_RET_OK) {
return rc;
}
self->timer = rcl_get_zero_initialized_timer();
rc = rclc_timer_init_default(&self->timer, NULL, 100ULL * 1000000ULL,
on_tick);
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_timer(executor, &self->timer);
}
RCLC_C_COMPONENT(telemetry_t, telemetry_configure)
src/telemetry_node/include/telemetry_node/Talker.hpp#pragma once
#include <rclcpp/rclcpp.hpp>
namespace telemetry_node {
/// A 10 Hz telemetry job whose every run takes 60 ms of processor time.
class Talker {
::rclcpp::Timer timer_;
::rclcpp::Clock clock_{RCL_STEADY_TIME};
void on_tick();
public:
::rclcpp::Result configure(::rclcpp::Node& node);
};
} // namespace telemetry_node
src/telemetry_node/src/Talker.cpp#include "telemetry_node/Talker.hpp"
namespace telemetry_node {
void Talker::on_tick() {
// Stand-in for real work: compress a log, format a report.
const int64_t t0 = clock_.now().nanoseconds();
while (clock_.now().nanoseconds() - t0 < 60LL * 1000000LL) {
}
}
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
return node.create_wall_timer<Talker, &Talker::on_tick>(timer_, 100, this);
}
} // namespace telemetry_node
In C and C++ the callback group is declared in each package’s
CMakeLists.txt, on the nano_ros_add_node call. Name ctrl for the loop
and telem for the job. A Rust project has nothing to do here: its groups
are in the code.
Nothing to change.
src/control_node/CMakeLists.txt, change the marked lines nano_ros_add_node(control_node CLASS control_node::Talker TYPED
+ CALLBACK_GROUPS ctrl
SOURCES src/Talker.c)
src/telemetry_node/CMakeLists.txt, change the marked lines nano_ros_add_node(telemetry_node CLASS telemetry_node::Talker TYPED
+ CALLBACK_GROUPS telem
SOURCES src/Talker.c)
src/control_node/CMakeLists.txt, change the marked lines nano_ros_add_node(control_node CLASS control_node::Talker
+ CALLBACK_GROUPS ctrl
SOURCES src/Talker.cpp)
src/telemetry_node/CMakeLists.txt, change the marked lines nano_ros_add_node(telemetry_node CLASS telemetry_node::Talker
+ CALLBACK_GROUPS telem
SOURCES src/Talker.cpp)
State what the nodes create
The scaffold wrote a contract for two talkers that publish on /chatter
once a second. The nodes now publish nothing and tick at 100 Hz and 10 Hz,
so replace it with one that says so:
src/control_node_bringup/system.contract.yamlversion: 1
nodes:
control_node:
params: {}
paths:
on_tick:
trigger: { timer: { rate: 100Hz } }
output: []
telemetry_node:
params: {}
paths:
on_tick:
trigger: { timer: { rate: 10Hz } }
output: []
Each node has a timer path with its rate and no output, and an empty
params:. The build sizes the image’s callback table from these rows, so a
timer missing from the contract is a timer the image has no room for.
One sched task
First put both groups on one sched task, main. Add the task to the
bringup’s system.toml, and bind each node’s group to it on its
[[component]] row:
src/control_node_bringup/system.toml
[tasks.main]
spin_period = "10000us"
[tasks.main.freertos]
priority = 2
src/control_node_bringup/system.toml, change the marked lines [[component]]
pkg = "control_node"
+group_tasks = { ctrl = "main" }
class = "control_node::Talker"
src/control_node_bringup/system.toml, change the marked lines [[component]]
pkg = "telemetry_node"
+group_tasks = { telem = "main" }
class = "telemetry_node::Talker"
spin_period is how long the sched task’s executor may sleep when nothing
is due. Priority 2 is below the network stack’s tasks, which this board runs
at 4; a sched task that outranked them would starve the transport it
depends on, and the build refuses one unless it says so.
Run it, and wait for the tenth window, about 40 seconds after boot; then press Ctrl-C:
nros run
10 windows, 10 late
Every window is late. The console shows why in its numbers:
[WARN] nros: [ 2.282421] contract violation: timer-overrun-runtime timer measured=5 declared=0
...
[INFO] control_node: [ 5.287820] ticks 1-100: longest gap 189036 us (late)
[INFO] control_node: [ 9.295950] ticks 101-200: longest gap 147774 us (late)
...
[INFO] control_node: [ 40.610821] ticks 901-1000: longest gap 152845 us (late)
[INFO] control_node: [ 40.613991] 10 windows, 10 late
That is a Rust project’s console; a C or C++ project’s gaps are about half
as long, 70 to 80 ms, and late all the same. Once every 100 ms the telemetry
callback takes the executor for 60 ms, and the loop’s ticks that fall due in
that time cannot start until it returns. The loop’s timer then fires once
and counts the periods it missed, rather than replaying them, which is what
the timer-overrun-runtime warnings report: activations the image dropped.
A thousand ticks at 10 ms should take ten seconds; they took four times as
long, because most of them never happened.
Two sched tasks
Now give the loop a sched task of its own, high, at priority 3, above
main and still below the network stack. Only the loop’s binding changes;
the telemetry job stays on main:
src/control_node_bringup/system.toml
[tasks.high]
spin_period = "1000us"
[tasks.high.freertos]
priority = 3
src/control_node_bringup/system.toml, change the marked lines pkg = "control_node"
-group_tasks = { ctrl = "main" }
+group_tasks = { ctrl = "high" }
class = "control_node::Talker"
Run it again, and press Ctrl-C after the tenth window:
nros run
10 windows, 0 late
[INFO] control_node: [ 3.136740] ticks 1-100: longest gap 12420 us (on time)
...
[INFO] control_node: [ 12.759645] ticks 901-1000: longest gap 21469 us (on time)
[INFO] control_node: [ 12.766466] 10 windows, 0 late
The telemetry job still spends 60 ms of every 100. What changed is who waits.
When the loop’s timer falls due, the high task becomes ready, FreeRTOS
takes the processor from the main task in the middle of the telemetry
callback, the loop runs its tick, and the telemetry callback resumes where
it was. A thousand ticks now take ten seconds of the board’s time. A C or
C++ build prints the two tasks it made:
codegen entry: sched task high: priority 3 (authored)
codegen entry: sched task main: priority 2 (authored)
What the numbers do not say
The loop’s longest gap, between 12 and 26 ms in these runs, is longer than its 10 ms period even with a task of its own. That is the emulator’s floor, and it is the same with the telemetry job doing no work at all: the network stack’s tasks run above both sched tasks, and an emulated processor’s time advances in steps of its own. The lab’s budget of five periods is set above that floor so that the comparison is between the two schedules, not between the emulator and a perfect clock.
On a real board the floor is lower, and its height is a property of that board, measured there. What carries over is the shape of the result: on its own sched task, the loop’s worst case does not depend on how long the telemetry job runs. On a shared one it does, and no budget holds once the job grows.
Change it
Predict each result before you run it, then check it against the console.
- Make the job lighter, then heavier. Change the telemetry job’s 60 ms to 0, then to 90, and run the two-task setup each time. Does the loop’s longest gap follow the job’s length? Run the one-task setup at 90 ms: what does the loop’s gap follow there?
- Swap the priorities. Give
highpriority 1, belowmain. The loop is alone on its task; is that enough? - Move the job instead. Put
telemon a new task at priority 1 and leavectrlonmain. Which property of the setup kept the loop on time: that it had a task to itself, or that its task outranked the job’s?
If it doesn’t work
- The build refuses a priority: a sched task’s priority must stay below the board’s network stack (4 on this board). The refusal names the band.
- Both runs print
0 late: check that the twogroup_taskslines sit in the[[component]]rows ofsystem.toml, as above. A group that no row binds is not onmain. - No
tickslines at all: the loop’s timer never ran. In C or C++, theCALLBACK_GROUPSline must sit insidenano_ros_add_node(...), beforeSOURCES; in Rust,callback_groupmust come before the timer is created. - The one-task run seems stuck before the tenth window: it takes four times as long as the other, about 40 seconds of the board’s time; wait for it before pressing Ctrl-C.
What just happened
| Setup | Who waits | Loop’s longest gap | Verdict |
|---|---|---|---|
one sched task, main | the loop, behind every 60 ms telemetry run | 70 to 190 ms | 10 windows, 10 late |
ctrl on high (3), telem on main (2) | the telemetry job, preempted mid-callback | 12 to 26 ms | 10 windows, 0 late |
A callback group says which callbacks belong together, in the code. A sched
task says how urgent they are, in the bringup. Keeping the two apart is what
lets the same nodes run under either schedule: you changed one line of
system.toml between the runs, and no code.
Next
- Pick a scheduling model:
every key of
[tasks], and each RTOS’s own mechanisms, such as Zephyr’s deadline scheduling and NuttX’s sporadic server. - Analyze timing: find the code that makes a callback’s worst case unbounded before you measure it.
Design background
Sched tasks and their mapping onto RTOS tasks follow RFC-0015. How a sched task’s priority is checked against the board’s own tasks follows RFC-0079.
Configure zenoh
Needs first: Pick and configure the RMW
Use this page when an image runs on the zenoh backend and you need to say where its router is: on this machine, on another host, or at the other end of a serial link.
A nano-ros zenoh image is a zenoh-pico client. It dials one router and
reaches every other node, nano-ros or ROS 2, through it. The router is the one
ROS 2 ships, rmw_zenohd from rmw_zenoh_cpp; nano-ros ships none of its
own. The image’s locator is the address it dials, and it is the only thing
a board needs to find the router.
Before you start
- A workspace with a zenoh image, such as the one from Run a talker.
- ROS 2 with
ros-<distro>-rmw-zenoh-cpp(which edition), sourced in each terminal (source /opt/ros/humble/setup.bash). It providesrmw_zenohd.
Steps
-
See which locator the image dials.
--dry-runprints the run plan without running anything:nros run sensor_node --dry-runThe
[link]table is the image’s locator. The scaffold’s first image reaches the router over the board’s serial port:[link] kind = "serial" locator = "serial/UART_0#baudrate=115200" rmw = "zenoh" host_peer = "zenoh-router"A host image (
board = "linux") that states no locator dials the zenoh default,tcp/127.0.0.1:7447. -
Point the image at a router over the network. Set
locatorin the image’s block ofsrc/sensor_node_bringup/system.toml. Inside QEMU’s user network, the host is10.0.2.2:[image.baremetal] board = "mps2-an385-baremetal" locator = "tcp/10.0.2.2:7447"Run it.
nros runsees that10.0.2.2is this host as the emulator reaches it, and startsrmw_zenohdon the matching local port first:nros run sensor_nodenros run: starting the zenoh router on tcp/127.0.0.1:7447 Publishing: 'Hello World: 1' Publishing: 'Hello World: 2' -
Use a router on another host instead. Name its address in the locator:
[image.baremetal] board = "mps2-an385-baremetal" locator = "tcp/192.168.50.1:7447"nros runstarts no router for an address that is not this machine’s, and says so:nros run: starting no router (tcp/192.168.50.1:7447 is not an address of this host, so its router runs elsewhere)On the other host, start the router. It reads no command-line arguments; its default configuration listens on port 7447:
source /opt/ros/humble/setup.bash ros2 run rmw_zenoh_cpp rmw_zenohd -
Reuse a router that is already running on this machine. Pass its locator to
--router, andnros runstarts nothing:nros run sensor_node --router tcp/127.0.0.1:7447nros run: starting no router (the router at tcp/127.0.0.1:7447) -
On a host image, change the locator at run time. A host image reads
NROS_LOCATORwhen it starts, and the variable wins over the locator baked fromsystem.toml. Its first log line says which one it used:NROS_LOCATOR=tcp/192.168.50.1:7447 nros run host_nodeboot config: domain 0 (baked), locator tcp/192.168.50.1:7447 (env), …An embedded image has no environment: its locator is fixed when it is built.
-
For more than one endpoint, TLS, or a user name and password, write the session’s own configuration file instead of a locator. Create
rmw/zenoh.json5besidesystem.toml. It is the same documentrmw_zenohreads fromZENOH_SESSION_CONFIG_URIon a ROS 2 host:// src/sensor_node_bringup/rmw/zenoh.json5 { mode: "client", connect: { endpoints: ["tcp/192.168.50.1:7447", "tcp/192.168.50.2:7447"] }, }Then delete the image’s
locatorline: the file is now the session’s wiring, andnros buildrefuses an image that states both. It also refuses a key zenoh-pico cannot take, and names the key, rather than dropping it. Because the file names routers elsewhere, run with--router none.
Client, not peer
zenoh defines a peer mode in which two devices talk with no router. nano-ros
does not build it: zenoh-pico is compiled without the multicast transport and
scouting that peer mode needs, to save flash. A session asked for peer mode,
by mode: "peer" in the file or NROS_SESSION_MODE=peer, refuses to open
and logs:
peer mode unsupported: shim built without multicast transport/scouting
Two nano-ros boards therefore talk through a router, as two rmw_zenoh_cpp
nodes do. This differs from the ROS 2 DDS backends, where nodes discover each
other directly; for that, use Cyclone DDS.
Downsample at the router
When a subscriber’s contract declares an arrival curve, nros configure
writes a router downsampling rule beside the resolved model.
nros router config --model <model> prints it as the
ZENOH_CONFIG_OVERRIDE entry rmw_zenohd reads (--format json5 prints the
rule file itself):
ZENOH_CONFIG_OVERRIDE="$(nros router config --model build/nros/models/<bringup>/<stem>.yaml)" rmw_zenohd
It fails when there is no rule: no subscriber declares an arrival curve, no
image links zenoh, or the model was never configured. nros router is a
command package (nros_zenoh_tools), not a built-in verb, so
nros help --all lists it and nros router config --help prints its flags.
Example
A talker in QEMU and a ROS 2 listener on the host, sharing one router that
nros run starts. The whole bringup:
# src/sensor_node_bringup/system.toml
[system]
name = "sensor_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
[[component]]
pkg = "sensor_node"
class = "sensor_node::Talker"
name = "sensor_node"
[image.baremetal]
board = "mps2-an385-baremetal"
locator = "tcp/10.0.2.2:7447"
In one terminal:
source /opt/ros/humble/setup.bash
nros run sensor_node
In a second terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: 3'
If it doesn’t work
nros runstops withno zenoh router: rmw_zenoh_cpp/rmw_zenohd was not found. Source ROS 2 in that terminal, installros-<distro>-rmw-zenoh-cpp, or setNROS_RMW_ZENOHDto thermw_zenohdbinary.nros run: something that is not a zenoh router listens on tcp/127.0.0.1:7447. Another program holds the port. Free it, name your own router with--router tcp/<address>:<port>, or start none with--router none. A zenoh router already on the port needs nothing:nros runreuses it and says so.- The board boots but nothing arrives. Check the locator with
--dry-run.10.0.2.2means the host only from inside QEMU’s user network; a board on a real network needs the router host’s real address. Both sides must use the samedomain_id, andros2 topic echoneeds--qos-reliability best_effortfor a best-effort talker. - A host image stops at start-up naming
NROS_LOCATOR.ZENOH_LOCATORandZENOH_MODEare retired names. UseNROS_LOCATORandNROS_SESSION_MODE.
See also
- Use a serial link: the
serial/locator and a router on a serial device. - Configure an image: the session file, per-image files and the keys it takes.
- Environment variables:
NROS_LOCATOR,NROS_SESSION_MODEand the retired names. - CLI reference: every
nros runflag. - Tune throughput and latency: zenoh-pico’s transmit path and buffers.
- How nano-ros differs from ROS 2.
Design background
Use Cyclone DDS
Needs first: Pick and configure the RMW
Use Cyclone DDS when an image should talk to ROS 2 nodes directly, with no router or agent running beside it.
The Cyclone DDS backend is Eclipse Cyclone DDS, the same DDS implementation
ROS 2 uses through rmw_cyclonedds_cpp, pinned to the version ROS 2 ships.
An image on it speaks RTPS and discovers its peers itself, so a stock
rmw_cyclonedds_cpp node sees it with nothing in between.
Where it runs
Which boards build and run a Cyclone DDS image is generated from the board registry, not written here:
- Supported boards: each board’s evidence page lists, under Breadth, the RMWs its tests run.
- Per-RMW feature matrix: what the backend implements (services, status events, QoS policies) next to zenoh and XRCE-DDS.
- Support status: the pinned Cyclone version and the ROS 2 release it pairs with.
Before you start
- A workspace, such as the host one from Run a talker.
- ROS 2 with
ros-<distro>-rmw-cyclonedds-cpp(which edition) on the same network, to see the image from ROS 2.
Steps
-
Provision the backend for your board.
--rmw cycloneddsadds Cyclone’s sources and the message tools its type support needs;nros buildthen builds Cyclone itself, with no separate step:nros setup linux --rmw cyclonedds -
Select it. Set
rmwin the bringup’ssystem.toml, for every image:[system] rmw = "cyclonedds"Check what the bringup resolved:
nros config show[system] rmw = cyclonedds # system.toml [system]To change one image only, put
rmw = "cyclonedds"in its[image.<id>]block instead; see Switch the RMW per image. -
Run it. No router starts, because Cyclone DDS needs none:
nros run host_nodePublishing: 'Hello World: 1' Publishing: 'Hello World: 2' -
See it from ROS 2, in a second terminal:
source /opt/ros/humble/setup.bash export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effortdata: 'Hello World: 4' -
Pick the DDS domain. The image runs on
[system] domain_id, and Cyclone’s own domain follows it. A ROS 2 peer must use the same number:[system] domain_id = 5ROS_DOMAIN_ID=5 ros2 topic echo /chatter std_msgs/msg/String \ --qos-reliability best_effort -
Configure Cyclone itself, if the defaults do not fit your network: which interface to use, whether to multicast, tracing. Write Cyclone’s own XML, the document
CYCLONEDDS_URInames on a ROS 2 host, asrmw/cyclonedds.xmlbesidesystem.toml:<CycloneDDS xmlns="https://cdds.io/config"> <Domain id="any"> <General> <Interfaces> <NetworkInterface autodetermine="true" priority="default" multicast="default" /> </Interfaces> <AllowMulticast>default</AllowMulticast> </General> </Domain> </CycloneDDS>The build copies the file into the image and hands it to Cyclone’s own parser, so it reaches a target that has no file system. Use
<Domain id="any">, or the image’sdomain_id:nros buildrefuses any other id. On a host image,CYCLONEDDS_URIstill replaces the file at run time. -
On an RTOS image, give the network stack what RTPS discovery needs: multicast (IGMP), enough network buffers for the burst of discovery traffic, and a heap, since Cyclone allocates with
malloc. On Zephyr, start from the fragment the shipped examples use and name it in the image:[image.zephyr_cyclonedds] board = "zephyr" rmw = "cyclonedds" os_config = ["prj-cyclonedds.conf"]Copy
examples/zephyr/rust/talker/src/zephyr_talker_node_bringup/prj-cyclonedds.confbesidesystem.toml. Its lines that matter for Cyclone areCONFIG_NET_IPV4_IGMP=y, theCONFIG_NET_PKT_*andCONFIG_NET_BUF_*counts, andCONFIG_HEAP_MEM_POOL_SIZE, withCONFIG_NET_SOCKETS_POLL_MAX=8for the receive thread’s socket set.On the other RTOS platforms the board package already carries the network settings Cyclone DDS needs, so an image adds none: the FreeRTOS boards’
lwipopts.henablesLWIP_IGMP,IP_REASSEMBLY(for fragmented RTPS samples) andLWIP_SO_RCVTIMEO; the NuttX boards’ defconfig setsCONFIG_NET_IGMPandCONFIG_NET_BROADCAST; the ThreadX boards’nx_user.hdefinesNX_ENABLE_IGMPV2. On a POSIX host the kernel handles multicast and needs nothing. A board you add yourself needs the same settings in its own package (Add a board).
Example
A host talker on DDS domain 5 with its own Cyclone configuration. This is
the bringup nros new host_ws --board linux --template talker --rmw cyclonedds
writes, with domain_id changed:
# src/host_node_bringup/system.toml
[system]
name = "host_node"
rmw = "cyclonedds"
ros_edition = "humble"
domain_id = 5
[[component]]
pkg = "host_node"
class = "host_node::Talker"
name = "host_node"
[image.posix]
board = "linux"
with src/host_node_bringup/rmw/cyclonedds.xml as in step 6. Run the image
and the listener:
nros run host_node
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ROS_DOMAIN_ID=5
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
If it doesn’t work
- The build stops on
<Domain id>. The XML names a domain other thananyor the image’sdomain_id. Change it toany. ros2 topic echoshows nothing. Check that both sides use the sameROS_DOMAIN_IDand that the ROS 2 side runsrmw_cyclonedds_cpp. On a network without multicast, list the peers in the XML instead.- Two Zephyr
native_simimages never discover each other. Its offloaded sockets do not pass multicast to the host; see Troubleshoot. - An RTOS image stalls during discovery. The network buffer counts or the heap are too small for the discovery burst. Raise them in the image’s fragment.
See also
- Configure an image: the middleware’s own file, and one file per image.
- Configuration surface: where
rmwanddomain_idare set and what they become on Zephyr. - Bridge between backends: Cyclone DDS beside zenoh or XRCE-DDS in one image.
- How nano-ros differs from ROS 2.
Design background
Use XRCE-DDS
Needs first: Pick and configure the RMW
Use XRCE-DDS when the image must be as small as possible, or must join an existing micro-ROS or DDS system through an agent.
The XRCE-DDS backend is the Micro-XRCE-DDS client, the one micro-ROS uses. The client does no discovery of its own: it asks a Micro-XRCE-DDS Agent on a host to create DDS entities for it, and the agent carries the data between the client and the DDS network. ROS 2 nodes on any DDS-based RMW see those entities. The agent is required: while the node cannot reach its agent it has no connectivity, and it carries on once the same agent answers again. An agent that restarts forgets the node’s session, and the node has to open again (When the Agent restarts).
Before you start
- A workspace, such as the host one from Run a talker.
- ROS 2 (which edition), to see the image from ROS 2.
Steps
-
Provision the backend.
--rmw xrceinstalls the client sources and the agent at the version nano-ros pins:nros setup linux --rmw xrce -
Add an XRCE-DDS image and tell it where the agent listens. XRCE-DDS has no configuration file; its whole wiring is the image’s
locator. Port 2018 is the client’s default agent port:[image.posix_xrce] board = "linux" rmw = "xrce" locator = "udp/127.0.0.1:2018" -
Run it. For a UDP locator on this machine,
nros runstarts the agent on that port first:nros run posix_xrcenros run: starting the XRCE agent (udp4 -p 2018) Publishing: 'Hello World: 1' Publishing: 'Hello World: 2' -
See it from ROS 2. The agent creates ordinary DDS entities, so the default ROS 2 RMW receives them:
source /opt/ros/humble/setup.bash ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effortdata: 'Hello World: 5' -
Run the agent yourself instead, for example on another host or with your own options. Start the pinned agent, and tell
nros runto start nothing:"$(nros locate tool xrce-agent)/bin/MicroXRCEAgent" udp4 -p 2018nros run posix_xrce --router noneFor an agent on another host, put that host’s address in the
locator. -
Use a serial link. With a
serial/locator,nros runwaits for the runner to report the serial device and then starts the agent on it with the locator’s baud rate (serial --dev <device> -b 115200). For a board on your desk, start the agent on the board’s USB serial device yourself:"$(nros locate tool xrce-agent)/bin/MicroXRCEAgent" serial \ --dev /dev/ttyACM0 -b 115200How a bare-metal board carries XRCE-DDS over its UART is the board’s: the mps2-an385 image
baremetal_talker_xrce_serialstateslocator = "custom://uart", and its build then leaves out the IP transports. -
Size the session for a small target. The client’s buffers and entity counts are build-time knobs, stated per image:
[image.posix_xrce.knobs.xrce] buffer_bytes = 256 stream_history = 4stream_historymust be at least 4. A received sample larger thanbuffer_bytesis refused on take.
Example
The host scaffold with a zenoh image and an XRCE-DDS image side by side. The bringup:
# src/host_node_bringup/system.toml
[system]
name = "host_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
[[component]]
pkg = "host_node"
class = "host_node::Talker"
name = "host_node"
[image.posix]
board = "linux"
[image.posix_xrce]
board = "linux"
rmw = "xrce"
locator = "udp/127.0.0.1:2018"
nros run posix_xrce
source /opt/ros/humble/setup.bash
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
If it doesn’t work
no XRCE agent at …. The agent is not provisioned. Runnros setup linux --rmw xrce, or start an agent of your own and pass--router none.the agent exited (…) … so the target cannot work. Another agent or program already holds the port. Stop it, or change the port in the locator.- Entity creation times out. The agent is not running or not reachable
at the locator’s address, or
stream_historyis below 4. ros2 topic echoshows nothing. Both sides must use the samedomain_id; the agent joins the domain the client asks for.XRCE session lost: … (it restarted). The agent restarted and forgot the node’s session. Open the executor again and create the entities again, as in When the Agent restarts.
See also
- Environment variables: every XRCE-DDS knob, its default and its minimum.
- Per-RMW feature matrix: what XRCE-DDS implements compared with zenoh and Cyclone DDS.
- Support status: the pinned client and agent versions.
- Use a serial link and Bridge between backends.
Design background
Switch the RMW per image
Needs first: Pick and configure the RMW
Use this page to build one bringup on more than one RMW backend, or to move an image from one backend to another.
nano-ros picks the backend when it builds an image. There is no
RMW_IMPLEMENTATION to change at run time, as there is in ROS 2: an image is
built for one backend, and a second backend is a second image. The backend
names are zenoh, cyclonedds and xrce, everywhere. A bringup that names
none builds zenoh.
Before you start
- A workspace whose bringup builds, such as the one from Run a talker.
- Each backend you add provisioned for the board:
nros setup <board> --rmw <backend>.
Steps
-
Choose the backend every image gets by default, in the bringup’s
system.toml:[system] rmw = "zenoh" -
Add an image on another backend. An image’s own
rmwwins over[system] rmw:[image.posix] board = "linux" [image.posix_cyclonedds] board = "linux" rmw = "cyclonedds" -
Build the image by name. Each image builds into a directory of its own, so nothing from the other backend’s build is reused:
nros build posix_cyclonedds -
Run it. A host image logs the backend it was built for in its first line:
nros run posix_cycloneddsboot config: … rmw cyclonedds (baked) Publishing: 'Hello World: 1' Publishing: 'Hello World: 2' -
To move every image instead, change
[system] rmwand drop the per-image lines. Then provision the new backend and build again:nros setup linux --rmw cyclonedds nros build posix
Node packages need no edit for any of this. A Rust node package names no
backend feature and calls no backend register(); the entry nros build
generates for the image links the backend and registers it.
On an RTOS image
The same rmw line selects the backend on every platform; the build turns
it into the platform’s own setting. On Zephyr it becomes exactly one of
CONFIG_NROS_RMW_ZENOH, CONFIG_NROS_RMW_XRCE or
CONFIG_NROS_RMW_CYCLONEDDS, which you do not write in a .conf file
yourself. Give each backend’s image the Zephyr fragment that backend needs:
[image.zephyr_zenoh]
board = "zephyr"
rmw = "zenoh"
os_config = ["prj-zenoh.conf"]
[image.zephyr_cyclonedds]
board = "zephyr"
rmw = "cyclonedds"
os_config = ["prj-cyclonedds.conf"]
A Cyclone DDS image also needs multicast networking on the target; see Use Cyclone DDS.
In a CMake project that is not a workspace
A CMake project with no system.toml that uses nano-ros through
find_package(nano_ros) or add_subdirectory picks its backend on the
configure line with NROS_RMW. nros setup presets writes the project a
CMakePresets.json that already carries the SDK root and the board’s
toolchain:
nros setup presets
cmake --preset linux -DNROS_RMW=cyclonedds # zenoh | xrce | cyclonedds
cmake --build build/linux
Clear the build directory, or use one per backend, when you switch back and forth.
Example
One bringup, three images on the Linux host, one per backend:
# src/host_node_bringup/system.toml
[system]
name = "host_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
default_images = ["posix"]
[[component]]
pkg = "host_node"
class = "host_node::Talker"
name = "host_node"
[image.posix]
board = "linux"
[image.posix_cyclonedds]
board = "linux"
rmw = "cyclonedds"
[image.posix_xrce]
board = "linux"
rmw = "xrce"
locator = "udp/127.0.0.1:2018"
nros setup linux --rmw zenoh
nros setup linux --rmw cyclonedds
nros setup linux --rmw xrce
nros build posix_cyclonedds
nros run posix_xrce
A bare nros build builds the default_images; with several images and no
default_images, it lists them and stops rather than guess.
If it doesn’t work
nros buildlists the images and stops. The bringup has several images and nodefault_images. Name the image, or adddefault_images.- The build cannot find the backend’s sources. That backend is not
provisioned for the board; run
nros setup <board> --rmw <backend>. - The image still talks the old backend. You ran a different image than
you built.
nros run <image> --dry-runprints the plan; itsimageline names the image it runs.
See also
- Configure zenoh, Use Cyclone DDS and Use XRCE-DDS: what each backend needs after you select it.
- Configuration surface: where
rmwis set and what it becomes on each build road. - CLI reference:
nros buildand its image argument. - How a build becomes an image.
Design background
- RFC-0031: RMW selection and lowering
- RFC-0130: one ROS 2 CMake build (supersedes RFC-0048)
- RFC-0098: generated leaf build config
Use a serial link
Needs first: Run a talker
Use a serial link when a board has a UART but no network, or when a point-to-point cable to one host is all the network you want. It is the link the board starters use first, because it needs no IP stack, no address and no switch.
The image’s locator makes the link. A locator that starts with serial/
tells the build to leave the IP stack out, and tells zenoh-pico to send its
frames over that UART. On the host, rmw_zenohd listens on the serial
device and connects the board to every other node. For XRCE-DDS over a UART,
see Use XRCE-DDS; WiFi is not covered yet.
Before you start
- The board provisioned for zenoh, for example
nros setup mps2-an385-baremetal --rmw zenoh. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp(which edition), sourced in each terminal. It provides the router.
Steps
-
Scaffold a project. A board that brings a UART out to the host gets a serial image from
nros new:nros new serial_ws --board mps2-an385-baremetal --template talker cd serial_wsThe image block in
src/serial_node_bringup/system.tomlnames the board’s UART and its rate:[image.baremetal] board = "mps2-an385-baremetal" locator = "serial/UART_0#baudrate=115200" -
Run it in the emulator.
nros runboots QEMU with the UART on a terminal device of your host, then starts the router on that device:nros run serial_nodenros run: starting the zenoh router on serial//dev/pts/4#baudrate=115200 Publishing: 'Hello World: 1' Publishing: 'Hello World: 2'The device number differs from run to run. The router also listens on
tcp/127.0.0.1:7447, so ROS 2 nodes on this host can reach the board. -
Hear it from ROS 2. Leave
nros run serial_noderunning in one terminal, and in another:export RMW_IMPLEMENTATION=rmw_zenoh_cpp ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effortdata: 'Hello World: 2' -
Change the rate, for a board on a real cable. Edit the
baudratein the locator;nros rungives the router the same options. QEMU ignores the rate, so it matters only on hardware:locator = "serial/UART_0#baudrate=921600"115200 works on any adapter. Many USB serial adapters take 460800, and 921600 is the top rate of many MCU UARTs. A long or noisy cable gives framing errors at high rates.
-
Run the router yourself for a real board. Flash the board as its starter shows. Its UART then appears as a USB serial device,
/dev/ttyACM0for example.rmw_zenohdreads no command-line arguments, so give it the endpoints inZENOH_CONFIG_OVERRIDE: the serial device for the board, and a TCP port for ROS 2 nodes on this host:source /opt/ros/humble/setup.bash ZENOH_CONFIG_OVERRIDE='listen/endpoints=["serial//dev/ttyACM0#baudrate=115200","tcp/127.0.0.1:7447"]' \ ros2 run rmw_zenoh_cpp rmw_zenohdThe router listens and the board dials it. Reset the board, then run the
ros2 topic echoof step 3. -
On a Zephyr board, set the main thread below the zenoh read task. With Zephyr’s default main priority, 0, the main thread outranks the read task while it creates entities, the UART receive ring overflows, and a board joining a busy domain misses the router’s replies. Put this in the image’s Zephyr fragment, the file its
os_confignames:CONFIG_MAIN_THREAD_PRIORITY=5nros buildrefuses a serial image whose main thread is not below the read task, and its message names the value to use. If joins into a busy domain still fail, raiseCONFIG_NROS_ZENOH_SERIAL_RX_RING_BYTESfrom its default of 1024; the ring is static RAM.
Example
The scaffold’s whole bringup, which runs as is in QEMU:
# src/serial_node_bringup/system.toml
[system]
name = "serial_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
[[component]]
pkg = "serial_node"
class = "serial_node::Talker"
name = "serial_node"
[image.baremetal]
board = "mps2-an385-baremetal"
locator = "serial/UART_0#baudrate=115200"
source /opt/ros/humble/setup.bash
nros run serial_node
If it doesn’t work
- The session never opens, or times out. The router listens on a
different device than the board’s UART, or the two use different rates.
Check the device in the router’s endpoint and the
baudrateon both sides. - The board runs but ROS 2 hears nothing. The router has no TCP endpoint
for host nodes (add
tcp/127.0.0.1:7447as in step 5), the two sides use differentdomain_idvalues, orros2 topic echois missing--qos-reliability best_effort. - Nothing arrives on hardware, but QEMU works. The UART may also carry the board’s debug console. Give zenoh a UART of its own, or turn the console off.
nros runstops and names the router. It could not findrmw_zenohd. Source ROS 2, or setNROS_RMW_ZENOHDto the binary.
See also
- Configure zenoh: network locators, a router on another host, and the session file.
- Tune throughput and latency: the buffers a serial image gets and how to change them.
- Environment variables:
the locator forms
NROS_LOCATORtakes. - Troubleshoot: failures that are not specific to serial.
Design background
Bridge between backends
Needs first: Configure zenoh, Use Cyclone DDS
Use a bridge when one image must forward topics from one RMW backend to another: a field gateway that takes zenoh traffic from sensor boards and republishes it on a DDS network, or a flight controller on XRCE-DDS whose telemetry a DDS ground station reads.
A bridge is declared, not written. In the bringup’s system.toml, each
backend session is a [[domain]] row and each forwarding is a [[bridge]]
row between two of them. The build resolves every topic name to its ROS type
and generates the forwarder; you write no bridge code. Most images use one
backend; a bridge image links two and drains both in each executor spin.
Before you start
- A workspace with a Rust node package that publishes what you want to
forward. The shipped
examples/workspaces/bridge-cycloneddsis this page’s example. - Both backends provisioned for the board, for example
nros setup linux --rmw zenohandnros setup linux --rmw cyclonedds. - ROS 2 with
rmw_zenoh_cppandrmw_cyclonedds_cpp(which edition), sourced.
Steps
-
Declare what the node publishes, in its
Cargo.toml, so the build can resolve a topic name to its type before anything is compiled:# src/talker_pkg/Cargo.toml [[package.metadata.nros.node.publishes]] topic = "/chatter" type = "std_msgs/msg/Int32" -
Declare the two sessions.
nameis yours,rmwis the backend andidthe domain. The node runs on the image’s own backend,[system] rmw:# src/demo_bringup/system.toml [[domain]] name = "zen" rmw = "zenoh" id = 0 [[domain]] name = "dds" rmw = "cyclonedds" id = 5 -
Declare the bridge.
fromandtoare<rmw>:<domain name>. Leave outtopicsto forward every declared topic, or list some; setbidirectional = trueto forward both ways without echoing a sample back:[[bridge]] name = "gw" from = "zenoh:zen" to = "cyclonedds:dds" topics = ["/chatter"] -
Give a session its middleware file when it needs more than its defaults. A
[[domain]]names it withconfig, in the backend’s own language:[[domain]] name = "zen" rmw = "zenoh" id = 0 config = "rmw/zenoh-zen.json5"// src/demo_bringup/rmw/zenoh-zen.json5 { mode: "client", connect: { endpoints: ["tcp/127.0.0.1:7447"] }, }A domain with a
configstates nolocator: the file is its wiring. -
Build the image. The build writes the bridge’s configuration,
nros-bridge.toml, beside the bringup and links both backends:nros build linux ls src/demo_bringup/nros-bridge.tomlsrc/demo_bringup/nros-bridge.toml -
Run it. The image’s own backend is zenoh, so
nros runstarts the router for it first:nros run linuxnros run: starting the zenoh router on tcp/127.0.0.1:7447 -
Read the forwarded topic on the Cyclone DDS side, on domain 5, in a second terminal:
source /opt/ros/humble/setup.bash export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ROS_DOMAIN_ID=5 ros2 topic echo /chatter std_msgs/msg/Int32data: 7 -
Forward to XRCE-DDS instead. An XRCE-DDS session has no configuration file, so its domain names the agent’s address as
locator:[[domain]] name = "agent" rmw = "xrce" id = 0 locator = "udp/127.0.0.1:8888" [[bridge]] name = "gw" from = "zenoh:zen" to = "xrce:agent"Start the agent on that port, as in Use XRCE-DDS; the shipped
examples/workspaces/bridge-xrceis this form. -
Change a session’s endpoint at run time on a host image, without a rebuild. For each
[[node]]in the generatednros-bridge.toml,NROS_BRIDGE_<NODE>_LOCATORreplaces its locator andNROS_BRIDGE_<NODE>_DOMAINits domain, with<NODE>the node’s name in upper case.
Example
The bringup of examples/workspaces/bridge-cyclonedds, which forwards
/chatter from zenoh to Cyclone DDS domain 5:
# src/demo_bringup/system.toml
[system]
name = "bridge_demo"
rmw = "zenoh"
domain_id = 0
default_launch = "system.launch.xml"
[[component]]
pkg = "talker_pkg"
class = "talker_pkg::Talker"
name = "talker"
[[domain]]
name = "zen"
rmw = "zenoh"
id = 0
config = "rmw/zenoh-zen.json5"
[[domain]]
name = "dds"
rmw = "cyclonedds"
id = 5
config = "rmw/cyclonedds-dds.xml"
[[bridge]]
name = "gw"
from = "zenoh:zen"
to = "cyclonedds:dds"
[image.linux]
board = "linux"
The two rmw/ files are in the example. Build and run it with steps 5 to 7.
A bridge you write yourself
When the forwarding needs logic of its own, open the second session in code
instead. Register each backend before the executor opens, open the primary
session with Executor::open_with_rmw, and give each node its backend with
node_builder(name).rmw(backend). A node whose backend is the primary’s
shares the primary session; any other opens a session of its own. Set
NROS_RMW to the primary’s name when the image links several backends, so
the primary does not depend on link order:
NROS_RMW=zenoh ./my_bridge
Each extra session adds its backend’s poll and dispatch time to every spin, because one executor drains the sessions in turn. For a bridge with a deadline, put the fast side’s node in a higher-priority sched task; see Pick a scheduling model.
If it doesn’t work
- The build cannot resolve a topic. The node package does not declare
it under
[[package.metadata.nros.node.publishes]], or thetopicslist names a topic no node publishes. - The build refuses a domain’s
config. A domain with a file also states alocator, or no[[bridge]]uses the domain. Drop the locator, or the unused domain. - Nothing arrives on the far side. The reader is on another domain than
the egress
[[domain]]’sid, or, for XRCE-DDS, the agent is not running at the domain’slocator. - A hand-written bridge fails to open its second session. Both nodes
asked for the primary’s backend while the primary opened on another one.
Set
NROS_RMWto the primary’s backend.
See also
nros-bridge.tomlreference: the generated file, its keys and its errors.- Configure an image: one middleware file per domain, and per-image overrides.
- Use XRCE-DDS: the agent an XRCE-DDS egress needs.
- The execution model: how one executor drains several sessions.
Design background
Tune throughput and latency
Needs first: Configure zenoh
Use this page when a zenoh image publishes more than its transport sends, a latency-critical topic arrives late, or large messages and service replies do not arrive at all.
Every language front end, Rust, C and C++, publishes through the same zenoh-pico transmit path, so these settings apply to all three. They matter most on Zephyr, whose socket layer serializes sends and receives on one socket: the zenoh-pico read task holds the session socket for a whole receive window, 100 ms by default, so an untuned image sends about once per window, about 9 messages a second, however many publishers it has. All of these are build-time settings; an embedded image has no run-time configuration.
Before you start
- A zenoh image that builds, and a measure of its publish rate and the latency each topic can take.
- The platform’s defaults. Zephyr builds with batching and split locking on; every other platform builds with both off.
Steps
-
Read the values your platform resolves, and the rung that set each one (
builtin,platform,boardorenv):nros config explain --platform zephyrknob value set by ---- ----- ------ zenoh.tx_batch true platform zenoh.tx_split_lock true platform zenoh.tx_batch_flush_ms 50 platform -
Turn on transmit batching for an image that publishes many small or medium messages and can wait one flush period. Publishes then collect in the transport’s write buffer and leave as one socket send per flush:
[image.posix.knobs.zenoh] tx_batch = trueA flush thread sends the batch every
tx_batch_flush_ms; ThreadX has no background tasks, so there the executor’s spin sends it. Service requests and replies never wait in the batch. Do not batch a timer-paced image that publishes less than once per flush period: there is nothing to combine, and the flushes make it slower. -
Add split locking if a tight-loop or bursty publisher is still limited by the transport. The flush then sends one batch while publishers fill the next, and a full batch no longer blocks the publishing thread. It needs
tx_batch:[image.posix.knobs.zenoh] tx_batch = true tx_split_lock = trueOn Zephyr
native_sim, 64-byte messages from a tight loop went from about 9 a second untuned to about 136 with batching and about 181 with both. Those are single runs on one development host; the ratios hold, the absolute numbers move with the host. -
Bound the latency batching adds. A non-express sample waits up to
tx_batch_flush_ms; lower it toward 10 to 20 ms when your budget needs fresher samples, at the cost of more, smaller sends:[image.posix.knobs.zenoh] tx_batch = true tx_batch_flush_ms = 20 -
Mark a low-rate, latency-critical publisher express, such as a control setpoint or an emergency stop. Its samples skip the batch and leave at once, while the rest of the image stays batched. Express is a transport hint, not a DDS QoS policy: subscriptions and backends that do not batch ignore it.
#![allow(unused)]
fn main() {
let pub_ = node.publisher("/cmd_vel").typed::<Twist>().tx_express(true).build()?;
}
rclc_qos_t qos = RCLC_QOS_DEFAULT;
qos.tx_express = 1;
rclc_publisher_init_with_qos(&pub, &node, type_info, "/cmd_vel", &qos);
auto pub = node.create_publisher<Twist>("/cmd_vel", rclcpp::QoS().tx_express(true));
Do not mark a stream express on Zephyr: each express sample waits for the socket window on its own.
Set the wire buffers
The wire buffers decide the largest message an image can send and receive. They depend on your network and your largest message, so the build does not derive them. Set them per image:
[image.posix.knobs.zenoh]
frag_max_bytes = 1400
batch_unicast_bytes = 1024
get_reply_buffer_bytes = 1024
or for one build, in its environment, where an exported value wins:
NROS_ZENOH_FRAG_MAX_BYTES=1400 NROS_ZENOH_BATCH_UNICAST_BYTES=1024 nros build
or in the board descriptor’s [knobs], when the budget belongs to the
hardware. frag_max_bytes is the largest message the image can receive; a
larger one is dropped. batch_unicast_bytes is the largest it sends without
fragmenting. On a network with a 1500-byte MTU, or Zephyr’s default of about
1400, keep the batch sizes below the MTU. A serial image gets a 1500-byte
unicast batch by default.
Example
A Linux host image that streams telemetry batched every 20 ms and sends its command topic express:
# src/host_node_bringup/system.toml
[system]
name = "host_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
[[component]]
pkg = "host_node"
class = "host_node::Talker"
name = "host_node"
[image.posix]
board = "linux"
[image.posix.knobs.zenoh]
tx_batch = true
tx_split_lock = true
tx_batch_flush_ms = 20
with the command publisher built tx_express(true) as in step 5. Build it
with nros build posix.
If it doesn’t work
| What you see | What to change |
|---|---|
| Large messages never arrive | raise frag_max_bytes: the message exceeds the reassembly limit |
| A subscription receives truncated data, or a large-type subscription fails to create | the receive slot is too small; see Size an image from its contract |
| Service calls with large replies time out | raise get_reply_buffer_bytes |
| Several concurrent service calls fail | raise NROS_ZENOH_MAX_PENDING_GETS |
| An entity create fails at run time | a pool is full; the Static pool inventory names the knob that sizes it |
| A benchmark listener counts far fewer messages than were sent | its receive ring is too shallow for a batch arriving at once; build the listener with NROS_ZENOH_SUBSCRIBER_RING_DEPTH=1024 |
| Batching made a timer-paced image slower | turn tx_batch off: at one message per flush there is nothing to combine |
Do not flush from your own timers or executor threads. Flushing from a sched-task thread stalls the timers that produce the samples, and measured slower than no batching.
See also
- Environment variables: every transmit knob and its Zephyr, cargo and CMake spelling, and the buffer knobs of zenoh-pico, smoltcp and XRCE-DDS.
- CLI reference:
nros config explain. - Use XRCE-DDS: sizing an XRCE-DDS session.
- Static memory and pools: why these buffers are fixed at build time.
Design background
Use QoS, status events and discovery
Needs first: Talk to ROS 2
Use status events when a node must react to what its middleware sees: a publisher it depends on going silent, a periodic topic missing its deadline, samples lost to a slow consumer, or the first subscriber appearing.
The events are the ones ROS 2 defines, with the
QoS
policies behind them. Two things differ in nano-ros. A callback you register
runs from inside spin_once, on the executor thread, like a message
callback; there is no waitset to poll. And an incompatible QoS pair is not an
event: it fails at create_publisher or create_subscription with
NROS_RMW_RET_INCOMPATIBLE_QOS, so you see it at start-up.
| Event | Side | Fires when |
|---|---|---|
LivelinessChanged | subscription | a matched publisher starts or stops asserting liveliness |
RequestedDeadlineMissed | subscription | no sample arrived within the deadline |
MessageLost | subscription | the backend dropped samples |
LivelinessLost | publisher | this publisher missed its own liveliness deadline |
OfferedDeadlineMissed | publisher | this publisher fell behind its offered rate |
PublicationMatched, SubscriptionMatched | either | an endpoint on the other side appears or leaves |
PublisherIncompatibleType, SubscriptionIncompatibleType | either | the same topic name appears with another type |
Before you start
- A node package whose subscription or publisher you want to watch.
- Its backend. Not every backend generates every event; the Per-RMW feature matrix lists which ones each backend implements.
Steps
-
Ask the backend first, if the node must run on more than one. A registration the backend cannot serve answers
Unsupported:#![allow(unused)] fn main() { if sub.supports_event(EventKind::RequestedDeadlineMissed) { sub.on_requested_deadline_missed(Duration::from_millis(15), on_late)?; } else { // fall back to a timeout of your own } } -
Register a subscription callback. The callback runs from
spin_once, counts as one callback against the executor’s per-spin limit, and never runs after the subscription is finalized.
#![allow(unused)]
fn main() {
let mut sub = node.create_polling_subscription::<SensorReading>("/sensor")?;
sub.on_liveliness_changed(|status| {
if status.alive_count == 0 {
log::warn!("sensor publisher went silent");
}
})?;
sub.on_message_lost(|status| {
log::warn!("dropped {} samples", status.total_count_change);
})?;
}
static void on_liveliness_changed(rcl_subscription_t *sub,
rclc_liveliness_changed_status_t status,
void *user_context) {
if (status.alive_count == 0) {
trigger_failover();
}
}
/* After rclc_executor_add_subscription(): */
rcl_ret_t rc = rclc_subscription_set_liveliness_changed_callback(
&sub, on_liveliness_changed, NULL);
The C setters return RCL_RET_OK, or RCL_RET_UNSUPPORTED when the backend
does not generate the event.
static void on_liveliness_changed(void* storage,
nros_cpp_liveliness_changed_status_t status,
void* user_context) {
if (status.alive_count == 0) trigger_failover();
}
// On an rclcpp::PollingSubscription:
sub.on_liveliness_changed(on_liveliness_changed, nullptr);
sub.on_requested_deadline_missed(15 /* ms */, on_deadline_missed, nullptr);
The C++ setters take a function pointer and a user_context, not a lambda,
and the subscription setters exist on PollingSubscription only.
ErrorCode::Unsupported means the backend does not generate the event.
-
Start publishing once someone listens. A matched callback on the publisher reports the subscribers it matches; publisher-side events are noticed when the publisher publishes or asserts liveliness, so a publisher that is not publishing yet asserts liveliness while it waits:
#![allow(unused)] fn main() { pub_.on_matched(|s| { if s.current_count > 0 { LISTENER_PRESENT.store(true, Ordering::Release); } })?; while !LISTENER_PRESENT.load(Ordering::Acquire) { let _ = pub_.assert_liveliness(); executor.spin_once(Duration::from_millis(50)); } }When the subscriber goes away,
current_count_changeis-1. -
Watch a periodic topic’s deadline. Set the deadline to the period plus the jitter you accept; for a 100 Hz topic, 15 ms:
#![allow(unused)] fn main() { let mut sub = node.create_polling_subscription::<SensorReading>("/imu")?; sub.on_requested_deadline_missed(Duration::from_millis(15), |status| { if status.total_count_change > 0 { log::error!("IMU late: {} missed deadlines", status.total_count_change); } })?; }On zenoh the argument is the deadline unless the subscription’s QoS states one. On Cyclone DDS the deadline comes from the QoS profile and the argument is ignored.
What each backend generates
- zenoh generates the five core events and both matched and
incompatible-type pairs. Liveliness is per publisher (
alive_countis 0 or 1), and there is noLivelinessChangedon bare metal. Matched counts come from the graph cache, as inrmw_zenoh_cpp. - Cyclone DDS generates the same set by polling: the runtime asks Cyclone
on the entity’s own data path. A publisher that stops publishing stops
being asked, so its events arrive with its next publish or
assert_liveliness. - XRCE-DDS generates the two deadline events only, by a clock check on the client. The agent’s DDS entity keeps an infinite deadline, so a DDS peer matching on deadline sees none.
A subscription with any status callback is asked on every spin, not only when data arrives, so a publisher leaving is noticed at the next spin after the backend sees it. A subscription with no status callback costs an idle executor nothing.
Example
A subscription that fails over when its publisher goes silent and counts late samples, on any backend:
#![allow(unused)]
fn main() {
use core::time::Duration;
let mut sub = node
.create_polling_subscription::<VehicleAttitude>("/vehicle_attitude")?;
sub.on_liveliness_changed(|status| {
if status.alive_count == 0 {
request_minimum_risk_manoeuvre();
} else if status.alive_count_change > 0 {
clear_failover();
}
})?;
if sub.supports_event(EventKind::RequestedDeadlineMissed) {
sub.on_requested_deadline_missed(Duration::from_millis(15), |status| {
LATE.fetch_add(status.total_count_change as u32, Ordering::Relaxed);
})?;
}
}
If it doesn’t work
- A C subscription setter returns
RCL_RET_NOT_INIT. The subscription is not in an executor yet. Register afterrclc_executor_add_subscription. - A C or C++ setter returns
RCLC_RET_FULLorErrorCode::Full. The process-wide table holds 16 registrations across every C and C++ entity. One publisher with all four of its kinds and one subscription with all five take nine. - A registration answers
Unsupported. The backend does not generate that event; see the list above. Usesupports_eventand a fallback. - A publisher-side event never fires. The publisher is not publishing.
Call
assert_livelinessfrom its loop.
See also
- Per-RMW feature matrix: the generated list of events and QoS policies per backend.
- Talk to ROS 2: QoS on the wire between nano-ros and ROS 2.
- The execution model: the per-spin callback limit that event callbacks share.
- How nano-ros differs from ROS 2.
Declare QoS in a contract
Needs first: the contract walkthrough · Project layout
Declare an endpoint’s QoS in its contract when you want the image to reserve memory for the history it keeps, rather than for the backend’s default.
QoS itself is the ROS 2 idea you already know: see About Quality of Service settings. What differs in nano-ros is that every queue is static. The build sizes the receive rings, the executor arena and the transient-local retention from what the contract declares, before any of your code is compiled. A QoS you pass in code and never declare is a QoS the image did not reserve for.
Before you start
- A bringup that builds and runs, with a contract beside its launch file
(
<bringup>/launch/<stem>.contract.yaml), or besidesystem.tomlfor a bringup with nolaunch/directory (Contracts for a bringup with no launch file). - The endpoint is already declared under
nodes:and wired undertopics:. - The call site registers the endpoint on an absolute name (
"/chatter", not"chatter"). A contract states resolved names, and the build will not match a relative one.
Steps
-
Add a
qos:block to the endpoint. Edit the endpoint’s row undernodes.<node>.pubornodes.<node>.sub. The keys are those of the contract format’sqossection:reliability,durability,history,depth,lifespan,liveliness,deadline,lease_duration.nodes: qos_listener: sub: qos_chatter: qos: history: keep_last depth: 5 durability: transient_localUse
history: keep_lastwith thedepth:you mean.keep_allhas no static bound, so the build cannot size a buffer from it.A
qos:block undertopics.<name>sets the topic’s QoS for every endpoint on it; an endpoint’s own block overrides it. -
Make the call site state the same QoS. The contract says what the build reserved; the code says what the endpoint asks for. Each language holds the two together differently.
Pass the profile to the _with_qos registration. Rust checks at registration:
where the code asks for a deeper queue than the contract reserved, it takes the
contract’s depth and logs a warning; where the code asks for a shallower one, it
refuses the registration. From
rust_qos_talker_pkg/src/lib.rs:
#![allow(unused)]
fn main() {
pub fn qos_profile() -> QoSProfile {
QoSProfile::default().reliable().transient_local().depth(5)
}
let pub_chatter =
node.create_publisher_for_topic_with_qos::<Int32>("/qos_chatter", qos_profile())?;
}
Build an rclc_qos_t and pass it to rclc_subscription_init_with_qos (or
rclc_publisher_init_with_qos). At registration, a C subscription whose depth,
reliability or durability differs from the contract is refused. From
c_qos_listener_pkg/src/QosListener.c, whose contract row would state
depth: 1:
static rclc_qos_t qos_profile(void) {
rclc_qos_t q = RCLC_QOS_DEFAULT;
q.reliability = RCLC_QOS_RELIABILITY_RELIABLE;
q.durability = RCLC_QOS_DURABILITY_TRANSIENT_LOCAL;
q.history = RCLC_QOS_HISTORY_KEEP_LAST;
q.depth = 1;
return q;
}
const rclc_qos_t qos = qos_profile();
self->sub = rcl_get_zero_initialized_subscription();
rcl_ret_t rc = rclc_subscription_init_with_qos(
&self->sub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
"/chatter", &qos);
Make the QoS a constexpr and assert it against the contract beside the call.
A disagreement then fails to compile, naming the topic and both values.
NROS_ASSERT_DECLARED_PUB_QOS does the same for a publisher. From
examples/workspaces/cpp/src/listener_pkg/src/Listener.cpp, whose contract row
is chatter: { qos: { depth: 1 } }:
constexpr ::rclcpp::QoS kChatterQos = ::rclcpp::QoS(1);
NROS_ASSERT_DECLARED_QOS(::std_msgs::msg::String::TYPE_NAME, "/chatter", kChatterQos,
"\"/chatter\"");
::rclcpp::Result r =
::rclcpp::bind_subscription<::std_msgs::msg::String, Listener, &Listener::on_msg>(
node, "/chatter", this, kChatterQos);
-
Rebuild the image.
nros build linux_rust_qosAmong the stage lines, the resolve line names the file the build sized the image from:
nros build: resolved → <workspace>/build/demo_bringup__linux_rust_qos/resolved.toml (max_cbs <n>, nodes <n>, digest <digest>)If it ends
(entity counts not derived; configured defaults kept)instead, the contract did not describe the whole image: see Fix a contract refusal.
Example
The features workspace’s QoS pair, in
examples/workspaces/features.
A Rust talker publishes /qos_chatter as transient-local with KEEP_LAST(5),
and the zenoh backend sizes its retention ring from the deepest transient-local
depth the contract declares, so a late joiner receives the last five samples.
This is src/demo_bringup/launch/rust_qos.contract.yaml, beside
rust_qos.launch.xml:
version: 1
nodes:
reliable_talker:
paths:
on_tick:
trigger: { timer: { rate: 1Hz } }
output: [qos_chatter]
pub:
qos_chatter:
qos:
history: keep_last
depth: 5
durability: transient_local
reliability: best_effort
qos_listener:
sub:
qos_chatter:
qos:
history: keep_last
depth: 5
durability: transient_local
pub:
qos_ok:
qos:
history: keep_last
depth: 10
durability: volatile
topics:
/qos_chatter:
type: std_msgs/msg/Int32
pub: [reliable_talker/qos_chatter]
sub: [qos_listener/qos_chatter]
/qos_ok:
type: std_msgs/msg/Int32
external: sub
pub: [qos_listener/qos_ok]
The talker’s code asks for reliable; the publisher row says best_effort
because the bringup’s system.toml overrides it with a
qos_overrides./qos_chatter.publisher.reliability parameter, and the contract
has to state the same fact as the override.
If it doesn’t work
- The build refuses with “QoS statement(s) disagree between the launch
contract and the
qos_overrides.*parameters”. A launch orsystem.tomlqos_overrides.*parameter and the contract state one policy two ways, or the parameter states one the contract omits. Make the contract state the same value; the message names the topic, the parameter and the contract row. - A C++ build fails with “nros: the QoS depth passed for topic … disagrees
with the depth declared for that topic in the contract sidecar”. The call
site and the row differ. The
declared_depth_agrees<declared, passed>diagnostic beside it carries both numbers. Change whichever is wrong. - A Rust image logs
declared depth: taking KEEP_LAST(…)at boot. The code asked for more than the contract reserved, and the registration took the contract’s depth. Raise the contract row to keep more. - A registration fails at boot and the log says the contract declares a deeper queue, or a stronger policy, than the code. Taking it would widen what the code narrowed. Lower the contract row or change the call site.
See also
- Size an image from its contract: what the declared depths size, and how to see it.
- Contract format reference:
every
qoskey, generated from the grammar this release pins. - QoS, status events, and discovery: the QoS policies at run time.
Size an image from its contract
Needs first: the contract walkthrough · Project layout
Write a contract that describes every node of an image when you want the build to size that image’s static pools from what it creates, instead of from the backend’s defaults.
Every pool in a nano-ros image is a fixed array: a slot costs its bytes whether an entity uses it or not. The build cannot count your entities from the code, because the crates that hold the pools compile before your components do. So it reads the count from the contract, once per image, before anything is compiled, and writes the answers where those crates read them. The steps are the same for Rust, C and C++ images.
Before you start
- An image that builds and runs with no contract, so you have a baseline.
- Every node the image launches, and every publisher, subscription, service, client, action and timer each one creates. A count over only some of them is refused, not guessed at (see step 3).
Steps
-
Build without a contract and note the resolve line.
nros build linuxWith nothing to count from, the build keeps the configured defaults:
nros build: resolved → <workspace>/build/<bringup>__linux/resolved.toml (entity counts not derived; configured defaults kept)If you can, measure this image’s static RAM now (Measure static memory), so you can show the saving afterwards.
-
Write the contract. Put it beside the launch file, as
<bringup>/launch/<stem>.contract.yamlfor<stem>.launch.xml, or besidesystem.tomlfor a bringup with nolaunch/(Contracts for a bringup with no launch file). Declare each node’s endpoints undernodes:, keyed by their local names; a timer is apaths:entry whose trigger is{ timer: { rate: NHz } }. Wire each endpoint to its absolute name undertopics:,services:oractions:, with its type. To size the receive queues too, declare each endpoint’s depth (Declare QoS in a contract). -
Rebuild and read the resolve line.
nros build linuxnros build: resolved → <workspace>/build/<bringup>__linux/resolved.toml (max_cbs <n>, nodes <n>, digest <digest>)max_cbsis the executor’s callback table. A publisher claims no callback slot, so it is smaller than the number of entities you declared; that is expected. If the line still saysentity counts not derived, the contract does not describe some component: see Fix a contract refusal. -
Read what was derived. Open the
resolved.tomlthe line names.[executor]holds the callback, node and action counts,[pools]the RMW session’s publisher, subscriber, queryable and liveliness counts, and[provenance]says where each number came from. -
Measure again. Rebuild with the memory report, as in step 1, and compare the two images symbol by symbol (Showing a saving).
Example
The Rust listener in
examples/linux/rust/listener
runs one subscription. Its system.contract.yaml declares that subscription
with KEEP_LAST(1):
version: 1
nodes:
listener:
sub:
chatter:
qos:
history: keep_last
depth: 1
topics:
/chatter:
type: std_msgs/msg/String
sub: [listener/chatter]
With it, the zenoh backend sizes the subscriber’s payload pools for the one sample the image keeps instead of the four its ring would hold by default. The image’s static RAM falls from 273,802 to 172,298 bytes on Linux.
Which knobs the build derives
The pools that dominate static RAM are derived per image from what the
contract declares. The build writes the answers into its generated cargo
[env] table (on Zephyr, into the Kconfig defaults). Stating one of them by
hand is an override, not a requirement.
| Knob | Derived from |
|---|---|
NROS_ZENOH_MAX_PUBLISHERS, NROS_ZENOH_MAX_SUBSCRIBERS | the declared entity inventory, floored at 1: each sizes a fixed C array, where zero is not a smaller pool |
NROS_ZENOH_MAX_QUERYABLES | the declared service servers, plus the parameter and lifecycle services the image’s nodes register; with no readable declaration it stays at its undeclared budget (8 embedded, 32 hosted) |
NROS_ZENOH_MAX_LIVELINESS | one per node name plus the session’s own, one per publisher, subscriber, service server and client, and the parameter and lifecycle families’ entities |
NROS_EXECUTOR_MAX_CBS, NROS_EXECUTOR_ACTION_CLIENTS, NROS_RMW_SUBSCRIBER_SLOTS | the declared entity inventory |
NROS_SUBSCRIBER_BUFFER_BYTES | the largest small-class message type the image subscribes to |
NROS_ZENOH_SUBSCRIBER_LARGE_BYTES | the largest large-class type; stated only when the large count is non-zero |
NROS_ZENOH_MAX_LARGE_SUBSCRIBERS | how many subscribed types fall in the large class. Zero is an answer, not a floor: the pool becomes zero bytes |
NROS_EXECUTOR_SUBSCRIPTION_BUFFER_BYTES | the executor’s take buffer, from the same message bounds |
NROS_EXECUTOR_ARENA_BYTES | the same inventory, in the executor’s own build; the variable is the override |
The transport’s wire buffers (NROS_ZENOH_FRAG_MAX_BYTES, the batch sizes,
NROS_ZENOH_SERVICE_BUFFER_BYTES, NROS_ZENOH_GET_REPLY_BUFFER_BYTES,
NROS_ZENOH_MAX_PENDING_GETS), the smoltcp socket pools and the parameter
store limits are not derived: they are yours. They are covered in
Tune throughput and latency.
Precedence. A value you state wins over a derived one: an exported
environment variable first, then the image’s [image.<id>.knobs], then the
board descriptor’s [knobs]. The derived value comes next, and the crate’s
own default applies only when nothing is stated and nothing can be derived.
If it doesn’t work
- The derived buffer size is larger than any message you send. The
message-bound sizes (
NROS_SUBSCRIBER_BUFFER_BYTES, the large class,NROS_EXECUTOR_SUBSCRIPTION_BUFFER_BYTES) come from every type in the interface closure the image links, not only the types it subscribes to, so they are an upper bound: never too small, sometimes larger than you need. The build names the type that set the size. When that type is not one of yours, state your own value or trim the package’s<depend>list. - Nothing message-bound is derived, and the build names an unbounded type.
One unbounded type refuses the whole message-bound derivation, and the stated
or default values stand. Bound the field in the
.msg(string<=64) or cap itinlineinnros-codegen.toml; one cap on a declaring type such as"std_msgs/Header.frame_id"reaches every message that nests it. - Entity creation fails at boot after you trimmed the contract. Each slot is exactly what the contract declares, with no headroom, so a contract that leaves out an endpoint the code creates makes a pool one short. On an image for a board other than the host, the census check catches this before the build: see Fix a contract refusal.
See also
- Static pool inventory: every sizing knob, its default and what it costs at that default.
- Measure static memory: what your image actually reserved.
- Contract format reference: every contract key, generated from the grammar this release pins.
- Static memory and pools: why nano-ros pools are fixed-size.
Contracts for a bringup with no launch file
Needs first: Project layout · the contract walkthrough
Write a contract for a bringup that has no launch/ directory when you want
its image sized from what it creates, or its QoS declared, without adding a
launch file.
A bringup with no launch/ runs the nodes its system.toml lists in
[[component]] rows, and the build generates its launch file from those rows.
A contract normally sits beside the launch file it describes, but a generated
launch file lives under build/, where you cannot author anything. So you
write the contract beside system.toml instead, as system.contract.yaml, and
the build carries it to the generated launch file.
Before you start
- A bringup with
system.toml, at least one[[component]]row, and nolaunch/directory, that builds. If the bringup has alaunch/directory, this page does not apply: writelaunch/<stem>.contract.yamlbeside the launch file instead. - The name each node registers its endpoints on, written as an absolute name at the call site.
Steps
- Find each node’s name. In the generated launch file, a node’s name is
its
[[component]]row’sname, so that is the key you use undernodes:.
[[component]]
pkg = "native_listener"
class = "native_listener::Listener"
name = "listener"
[[component]]
pkg = "native_c_listener"
class = "native_c_listener::Listener"
name = "listener"
[[component]]
pkg = "cpp_listener"
class = "cpp_listener::Listener"
name = "listener"
-
Write
system.contract.yamlbesidesystem.toml. Keynodes:by thenamefrom step 1 and each endpoint by its local name; wire it undertopics:to the absolute name the code registers:version: 1 nodes: listener: sub: chatter: qos: history: keep_last depth: 1 topics: /chatter: type: std_msgs/msg/String sub: [listener/chatter]For a C or C++ node, state the depth its call site passes: a C or C++ registration whose depth differs from the contract’s is refused (Declare QoS in a contract).
-
Build the image.
nros build linuxThe build generates the launch file and copies your contract beside it. In a workspace, both are under
build/nros/launch/<bringup>/launch/:ls build/nros/launch/<bringup>/launch/system.contract.yaml system.launch.xmlFor a single package that holds its own
system.toml, the directory is<package>/build/nros/launch/<package>/. The copy is rewritten only when your file changes, and deleted when you delete yours. -
Check the resolve line. It reports the counts the contract produced:
nros build: resolved → <workspace>/build/<bringup>__linux/resolved.toml (max_cbs <n>, nodes <n>, digest <digest>)(entity counts not derived; configured defaults kept)means some component is not described: see Fix a contract refusal.
Example
examples/linux/rust/listener
is a single-node Rust workspace whose bringup, src/native_listener_bringup,
has no launch/. Its system.toml holds the [[component]] row from the
Rust tab above and an [image.linux], and its system.contract.yaml is the
file from step 2. The code registers the
subscription on /chatter, the absolute name the contract states:
#![allow(unused)]
fn main() {
node.create_subscription_for_callback_name::<StringMsg>("on_chatter", "/chatter")?;
}
The contract’s one line of QoS takes the image’s static RAM on Linux from 273,802 to 172,298 bytes, because the zenoh backend then sizes its payload pools for one sample instead of four. The listener still receives every message a 1 Hz talker publishes.
If it doesn’t work
-
The build ignores
system.contract.yaml. The bringup has alaunch/directory, so its own launch files are used and nothing is generated or carried. Move the contract tolaunch/<stem>.contract.yaml, beside the launch file it describes. -
The build warns that the bringup has no
launch/directory and no[[component]]row. The warning reads:nros: warning: <bringup>/system.toml: this bringup has no `launch/` directory and no `[[component]]` row, so nothing says what it runs and no system model is resolved for it. Add a `[[component]]` row (pkg, class, name) to system.toml, or add `launch/system.launch.xml`.With no row, there is no launch file to carry the contract to. Add the row.
-
A node’s endpoints are refused, or never matched. The
nodes:key is not the row’sname, or the code registers a relative name. Use the row’sname, and an absolute name at the call site. See Fix a contract refusal for the messages.
See also
- Size an image from its contract: what the counts size, and how to measure the result.
- Declare QoS in a contract.
- Contract format reference: every contract key, generated from the grammar this release pins.
Fix a contract refusal
Needs first: the contract walkthrough · Size an image from its contract
Use this page when nros build refuses a contract, or builds the image without
sizing it from the contract, and you need to know which statement is wrong.
The contract is a statement about the code, made beside it. The build checks it at several points, and each check refuses rather than guesses, because a pool sized from a wrong statement fails at boot on a board that may have no console. Find the message you have below; each section names the fix. In the messages, angle brackets stand for your own names.
Before you start
- The full output of the
nros build <image>that failed. - The contract it read:
<bringup>/launch/<stem>.contract.yaml, or<bringup>/system.contract.yamlfor a bringup with nolaunch/.
Steps
-
Rebuild the image and keep the output.
nros build <image> -
Find the first refusal in the output and match it to a section below. Fix the contract or the code, then rebuild.
The contract does not parse
The contract grammar refuses any key it does not list:
at '<path>': unknown key in `qos` — did you mean `depth`? An unrecognised key used to be discarded in silence, which deleted whatever it was meant to declare
Correct the spelling; the contract format reference
lists every key. An endpoint key holding a / is refused the same way:
endpoint key `/chatter` contains `/`: an endpoint key is a local name, and the node's FQN is prefixed to it (`/chatter` would become `<node>//chatter`). Use the endpoint's local name; remap the topic in the launch file or wire it under `topics:`
Key the endpoint by its local name (chatter) and put the absolute name under
topics:. Once a contract has been refused, later commands refuse the model it
left behind until a resolve succeeds:
SystemModel `<model>` was refused by its producer and cannot be trusted (marker `<marker>`):
check: <check>
input: <input>
Fix the input and run `nros configure`; the next successful resolve removes the marker.
Fix the contract and run nros configure (or nros build) again.
The contract and a qos_overrides parameter disagree
<n> QoS statement(s) disagree between the launch contract and the `qos_overrides.*` parameters.
Each disagreement that follows names the topic, the parameter and its node,
and the contract row, or says the row states no such policy. Make the
contract state the value the parameter sets. The parameter configures the
runtime and the contract sizes the buffers, so the two must agree.
The image was built with its configured defaults
The resolve line says the contract sized nothing:
nros build: resolved → <workspace>/build/<bringup>__<image>/resolved.toml (entity counts not derived; configured defaults kept)
The reason is the refused line under [provenance] in that resolved.toml.
The most common one:
<n> of <m> components in this image declare no entities:
<pkg>::<component> (<class>)
Deriving over only the components that did would publish a slot count smaller than the image needs, and a short NROS_EXECUTOR_MAX_CBS fails entity creation at boot.
Sizing is all or nothing per image. Declare every listed component under
nodes:, keyed by its node name. If the reason begins the launch tree resolved, and it declares neither wiring nor parameters, the build found no
contract at all: check its file name and where it sits.
An endpoint is not matched
On a Rust image the build prints one line per endpoint it could not match to the contract, for example:
nros build: subscription `chatter`: this subscription registers on `chatter`, which is not an absolute name. A contract states RESOLVED names, and resolving `chatter` needs the node's namespace AND its remappings -- neither of which reaches this reader per endpoint. Write the name absolutely at the call site, or declare the endpoint the contract already names
Write the name absolutely at the call site ("/chatter"). A node the launch
file remaps is refused too (the launch description applies name REMAPPINGS to node): drop the remap, or accept that the endpoint keeps its worst-case
sizes. A line beginning no subscription in this image's contract carries type names what the contract does describe; correct the type
or the topic.
The census check refuses a cross image
Before it builds an image for a board other than the host, nros build runs
the host image generated from the same launch file once, records what every
component creates, and compares that census with the contract, row by row:
error missing-in-contract <node> sub /chatter
the code creates this subscription on `/chatter`; no `sub:` row of `nodes.<node>` is wired to it, so no `topics:` entry names it either
in <contract>, add under `nodes.<node>.sub` (the alias is the author's; `chatter` is this name's last segment):
chatter: { qos: { depth: <depth> } }
and wire it under `topics`:
/chatter:
type: <package>/msg/<Name>
sub: [<node>/chatter]
not waivable: every pool derives one short; the first catch is ExecutorFull on a board with no console
census check: <n> confirmed, <n> error(s), <n> warning(s), <n> waived
Each row gives the edit. The verdicts:
| Verdict | Means | Fix |
|---|---|---|
missing-in-contract | the code creates it, the contract does not declare it | add the row the message prints |
phantom | the contract declares and wires it, the code never creates it | remove the row, or waive it |
unwired | declared under nodes: but named by no topics:, services: or actions: entry | wire it or remove it |
depth-mismatch, qos-mismatch, type-mismatch | both sides name it and disagree | change one side |
period-mismatch | a timer’s period differs from its path’s timer rate | change one side |
param-missing-in-contract, param-phantom, param-type-mismatch | the same, for a node’s params: | as above |
Only phantom and param-phantom rows are waivable, one row at a time, in the
bringup’s system.toml. The message prints the key to copy:
[census.waive."<node>:sub:/chatter"]
reason = "..."
A refusal that begins census missing: or census stale: means the census is
absent or older than the code. Run nros build <image> for the cross image;
it takes the census first. To take the census without building the cross
image, run nros configure --census <bringup>:<image> in the workspace, with
the same cross image. Both build and run the host image, so they take longer
than a plain nros configure, which only reports that the census is stale.
If either reports that the bringup declares no HOST image resolved from the same launch and arguments, add one, such as
[image.linux] board = "linux" with the same launch and args.
Example
The C++ workspace in
examples/workspaces/cpp
declares both its nodes in src/demo_bringup/launch/system.contract.yaml.
Delete the listener from it:
version: 1
nodes:
talker:
paths:
on_timer:
trigger: { timer: { rate: 1Hz } }
output: [chatter]
pub:
chatter: { qos: { depth: 1 } }
topics:
/chatter:
type: std_msgs/msg/String
pub: [talker/chatter]
The listener’s code still subscribes to /chatter, so building the
freertos image (board mps2-an385-freertos) is refused by the census: one
missing-in-contract row for listener sub /chatter, whose remedy is the
listener: entry with chatter: { qos: { depth: 1 } } and the
sub: [listener/chatter] wiring. Put them back and the census confirms every
row.
If it doesn’t work
- A configure stops with
ENTITIES was retired. ACMakeLists.txtstill passesENTITIEStonano_ros_node_register. Delete the argument and state the component’s entities in the contract. [census] on_missing = "warn"oron_stale = "warn"is set. The bringup has opted out of the refusal, and the build prints acensus missing (WARNINGline instead. Remove the key to make it a refusal again.- A hand-written entry’s configure stops with
exited 0 in census mode but wrote no census. The entry’s program never reached a census writer. If it never initialises nano-ros at all (a test program that drives a device directly), say so withruns_nano_ros = falseunder its[image.<id>]: its census is recorded empty without running it, and the image is sized for zero entities. Otherwise the program returns before it creates its first node on the host; make itsmainreach that point.
See also
- Declare QoS in a contract: the compile-time and boot-time QoS checks for each language.
- Contract format reference: every contract key, generated from the grammar this release pins.
Measure static memory
Needs first: Size an image from its contract
The Static Pool Inventory tells you
which knobs exist and what each one costs: a byte figure at its default where
the pool is a plain product of knobs, and otherwise where its bytes go — a
named static, the executor’s storage, a heap — and why no figure can be stated
without building. It cannot tell you what your image costs — your knobs
differ, your backend differs, and several pools are sized by a sizeof that no
comment can see.
For that, measure the image you built. Two ways:
-
With the LLVM tools, read the ELF directly.
nros setupinstalls them with the Rust toolchain, so this works offline afterwards. They read an image for any target:bin="$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n 's/^host: //p')/bin" "$bin/llvm-size" -A build/.../your-image # RAM = .data + .bss (+ .uninit) "$bin/llvm-nm" --size-sort -S -C --radix=d build/.../your-image | tail -20llvm-size -Agives the section totals;llvm-nm --size-sortlists the largest statics last, each with its size in bytes. -
With the memory report, the attribution is done for you. It ships in every release, inside the toolchain:
python3 "$(nros locate nano-ros)/scripts/nros-mem-report.py" build/.../your-image--jsonwrites the same report as data, and--baseline before.jsonprints the change against an earlier one.
On the Tutorial’s board, mps2-an385-baremetal, two figures are worth
knowing before you read either output:
- The heap is a static.
nros_platform_mps2_an385::memory::HEAPis a 128 KiB allocator (NROS_HEAP_SIZEchanges it, in bytes), so it is already inside the RAM total. Its symbol reads a little over 128 KiB (132,816 B measured) because the allocator’s own state sits beside the arena. It starts all-zero, so it is in.bssand costs no flash. - The stack has no budget. The main stack starts at the top of the
board’s 4 MiB SRAM and grows down toward the end of
.bss, with no guard between them; nothing in the image reserves or checks a stack size. On this board that leaves about 3.8 MiB, so it is not the limit; on a board with less RAM, the stack is what is left after.dataand.bss.
You get RAM broken down by symbol, by owner, by storage role and by pool, plus the section totals, so you can see how much is not attributable to any symbol:
RAM (writable allocated sections): 518,234 bytes
RAM attributed to symbols: 489,771 bytes
unattributed (padding, linker reservations, symbol-less data): 28,463 bytes (5.5%)
That last line matters. Alignment padding and linker-script reservations are
real RAM that no symbol names, so a budget built only from a list of pools will
come up short. “Writable allocated sections” means every section the linker
marks allocated and writable, whatever it is called — on Zephyr that includes
the per-file .noinit.* sections holding thread stacks and the kernel heap.
Who owns the bytes
The RAM by owner table puts every byte under the owner you would name:
177,112 34.2% [executor storage]
206,358 39.8% nros_rmw_zenoh
88,280 17.0% (C / asm / no path)
8,064 1.6% [component storage]
[executor storage]— the executor’s backing, whichever language placed it: the C/C++ entry’s__nros_executor_storage/__nros_sched_task_executor_storage, the C++ boot storageNode::GlobalStorageHolder<0>::storage, and the RustEXECUTOR_BACKING/__NROS_SCHED_TASK_EXECUTOR_BACKING. In a sched-task image this is usually the largest single owner.[component storage]— the generated per-component storage (__nros_comp_buf_Nfor C++,__NROS_COMPONENT_<pkg>_SLOT_STOREfor Rust).- A Rust crate name,
C++ <namespace>, or(C / asm / no path)otherwise. The language comes from the symbol’s mangling, so a C++ namespace that happens to share a Rust crate’s name is never filed under that crate.
For the C and C++ executor storage, the report also reads the build’s own sizes header and tells you how many executors’ worth the image reserved:
95,904 executor storage __nros_sched_task_executor_storage
= 4 x 23,976 (NROS_CPP_EXECUTOR_STORAGE_SIZE = 23,976)
The header is found beside the image (the build’s nros-cpp-generated/ mirror);
pass --sizes-header <path> if your build keeps it elsewhere. If the header is
newer than the image, or two headers disagree, the report says so instead of
pricing.
Finding what to cut
The per-symbol list is sorted, so the first few lines are usually the whole story:
## top 5 RAM symbols
131,072 25.3% nros_rmw_zenoh::shim::subscriber::LARGE_PAYLOADS
88,560 17.1% linux_entry::__nros_entry_run::__NROS_SCHED_TASK_EXECUTOR_BACKING
88,552 17.1% nros_node::executor::backing::EXECUTOR_BACKING
87,072 16.8% g_sessions
33,536 6.5% nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX
The last two sections of the report join these symbols to their knobs for you:
declared pools lists the pools that carry a formula (and whether the image
agrees with it), and knob-sized pools lists every other static the inventory
knows a knob for, with its exact measured size:
87,072 g_sessions
pool sized by NROS_ZENOH_MAX_SESSIONS, NROS_ZENOH_MAX_PUBLISHERS, ...
Be aware that today these pools are sized by which backend you link, not by what your node actually does: a publisher-only node still reserves the service and large-payload pools in full. If your image looks far larger than the entities you created would suggest, that is expected rather than a misconfiguration on your side. Turning the corresponding knobs down is the current remedy (see Which knobs the build derives).
The zenoh service inboxes (USER_SERVICE_INBOX, ACTION_INBOX,
BUILTIN_INBOX) are one table per family, each sized for its own requests;
how their slots are sized is in
Static memory and pools.
Showing a saving
Take a baseline (the report’s --json output), change something, rebuild,
and compare against it (--baseline; the commands are on the
Internals page).
Every symbol row then carries an annotation: (+12,288) for a change, (=) for
a symbol that matched and did not move, (new) for one the baseline does not
have. A baseline join section lists what matched, what is new and what is
gone, and the owner table shows each owner’s delta — so a pool that disappears
entirely is reported, not silently absent.
Symbols are matched across builds by name with the compiler’s per-build
decorations removed (.llvm.<hash>, .0, .constprop.0, Rust crate hashes),
so a static the linker renamed between two builds still compares. A baseline
written by an older version of the tool lists only its top symbols; the report
marks it incomplete and will not call a symbol “new” on its evidence.
This is also how a change to nano-ros itself should report a memory saving: as a measured difference between two named images, not as an estimate.
Cross-compiled images
The tool prefers llvm-nm, which reads ELF files for any target; your host’s
GNU nm is built for one target family and refuses a cross-built image with
“File format not recognized”.
You probably already have llvm-nm without knowing it: rustup ships it as part
of the llvm-tools component, under the toolchain’s own bin directory rather
than on your PATH, and the tool looks there. If it reports that it found no
usable nm, run:
rustup component add llvm-tools
llvm-cxxfilt (from a system LLVM) is used when present to demangle; without
it the tool falls back to nm -C.
See also
- Size an image from its contract: the pools the build sizes for you, and how to override one.
- Static pool inventory: every sizing knob and its default.
- Static memory and pools: why nano-ros reserves its memory statically.
Organize a larger workspace
Needs first: Add a second node
Use this page when a workspace grows past one node and one board: several node packages, several images, and a bringup per behaviour.
A nano-ros workspace has two kinds of package you write, and one thing that is not a package:
- A node package is a library that says what a node does: its publishers,
subscriptions, timers and callbacks. It has no
main(), no board and no deployment settings, so one node package runs on every board. - A bringup package says what runs and where. It holds a
package.xmland asystem.toml, and optionallylaunch/andconfig/. It has noCargo.toml, noCMakeLists.txtand no code. Name it<system>_bringup, as nav2 and Autoware do. - An image is one row,
[image.<id>], in thatsystem.toml: a board, a launch topology and a backend.nros build <id>generates the program’s entry underbuild/and hands off to cargo, CMake or west.
The workspace root has no build file at all. Where ROS 2 has you write a
launch file and a main() per process, nano-ros generates the entry from the
image row, so adding a board is adding a row, never a package.
Before you start
- nano-ros installed and the board provisioned, for example
nros setup linux. - ROS 2 sourced for the first build, which generates message bindings from it.
Steps
-
Start from a one-node workspace:
nros new host_ws --board linux --template talker cd host_ws✓ Created the workspace host_ws src/host_node/ the node: a rust talker (library) src/host_node_bringup/ what it runs on: `linux`, image `linux`, zenoh -
Add a node package. Run
nros newfrom the workspace root;--toadds its[[component]]row to the bringup, and--langpicks its language:nros new listener_pkg --lang cpp --template listener --to host_node_bringupnros new: added the node package src/listener_pkg/ (listener, cpp) to …/host_ws declared it in …/host_ws/src/host_node_bringup: a [[component]] row and an <exec_depend>
Each language states the node in its own build file, and none of them names a board:
# src/host_node/Cargo.toml: a library; `nros::node!(Talker);` ends src/lib.rs
[lib]
path = "src/lib.rs"
# src/talker_pkg/CMakeLists.txt
find_package(nano_ros REQUIRED)
find_package(std_msgs REQUIRED)
nano_ros_auto_add_library(talker_lib STATIC src/Talker.cpp)
nros_components_register_node(talker_lib
PLUGIN talker_pkg::Talker
EXECUTABLE talker
SHAPE configure)
The class has a configure(::rclcpp::Node&) method that creates its
entities and binds member callbacks by identity, with no callback name and no
allocation; the generated entry constructs it and calls configure:
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
::rclcpp::Result r = node.create_publisher(pub_, "/chatter");
if (!r.ok()) return r;
// Member-fn-pointer-as-template-param → no-alloc trampoline; `this` is ctx.
return node.create_wall_timer<Talker, &Talker::on_tick>(timer_, 1000, this);
}
The C shape, and packages of several languages in one image, are in Mix languages.
-
Add an image for a second board:
nros new --image freertos --board mps2-an385-freertosnros new: added [image.freertos] to …/src/host_node_bringup/system.toml build it with `nros build freertos` -
Build. With two images and no default, a bare
nros buildlists them and stops:nros buildError: this workspace declares 2 images and no default. host_node_bringup:freertos host_node_bringup:linux build one: nros build freertos build all: nros build --all or declare: [system] default_images = ["freertos"]Name one image, build them all, or set
[system] default_imagesin the bringup.nros build linux --dry-runprints the handoff and runs nothing:nros build: host_node_bringup:linux -> board linux (platform posix), driver cmakeThe driver is CMake here because the image now holds a C++ package.
-
Run one image. Once a bringup has a second node, the node’s name no longer names one image, so name
<bringup>:<image>:nros run host_node_bringup:linux -
Select a machine with launch arguments. Several images can share one launch file and differ only in its arguments, which is how one launch tree describes several hosts:
[image.linux_robot1] board = "linux" launch = "multihost.launch.xml" args = { host = "robot1" } [image.linux_robot2] board = "linux" launch = "multihost.launch.xml" args = { host = "robot2" }[image.<id>]says what is built.[host.<name>]says which machine a node runs on, withlaunchandnodeskeys. An image needs no host, and a host needs no image. -
Give each behaviour its own bringup when one workspace holds several programs. The language workspaces in the examples keep
pubsub_bringup,service_bringupandaction_bringupside by side, with one image row per platform and role:nros run pubsub_bringup:linux_listenerA variant with different code is its own node package with its own image row. A variant that only changes a setting, such as a serial link, is an image row over the same packages.
-
Check what the workspace holds.
nros listprints each package and its kind, andnros graphprints the dependency order:nros graphhost_node listener_pkg host_node_bringup <- host_node, listener_pkg
Example
The bringup after the steps above:
# src/host_node_bringup/system.toml
[system]
name = "host_node"
rmw = "zenoh"
ros_edition = "humble"
domain_id = 0
[[component]]
pkg = "host_node"
class = "host_node::Talker"
name = "host_node"
[[component]]
pkg = "listener_pkg"
class = "listener_pkg::Listener"
name = "listener_pkg"
[image.linux]
board = "linux"
[image.freertos]
board = "mps2-an385-freertos"
nros build --all
nros run host_node_bringup:linux
The bringup has no launch/, so its launch file is generated from the
[[component]] rows. Add launch/system.launch.xml when you need a launch
argument, a remap or a parameter, as in
Parameters and launch files.
The workspaces under
examples/workspaces/
(rust, c, cpp and mixed) have this shape, Zephyr images included.
Support packages
A package that holds no node, such as a shared library the nodes link
against, is part of an image when a node package <depend>s on it, directly
or through other workspace packages. The generated build adds it, so its own
CMakeLists.txt runs. A package no node of the image depends on is left
out. On Zephyr a support package that defines Kconfig symbols is also a Zephyr
module; see
A workspace package that is a Zephyr module.
When the generated entry is not enough
Reach for these in order, smallest first:
- An image key:
panic,profile,os_configorfeatures. before_boot = "<pkg>::<fn>"on the image, for one step before the runtime starts. Rust images only.- The board’s own hardware setup, for what every image on that board needs.
nros materialize <bringup>:<image>, which copies the generated entry tosrc/<image>_entry/as a package you own.nros buildthen leaves it alone; delete the directory to go back to a generated one.
An owned Zephyr entry still gets from nros build what the generated one
wrote into its own CMakeLists.txt: the workspace’s Zephyr modules
(ZEPHYR_EXTRA_MODULES) and the workspace’s src/, first, on
NROS_INTERFACE_SEARCH_PATH, followed by any value you exported. Both ride
the west build line, so a find_package(<pkg>) of a workspace message
package resolves with no set(NROS_INTERFACE_SEARCH_PATH ...) in the
entry. A set() of your own in the entry still replaces it.
If it doesn’t work
nros buildrefuses asystem.toml. It sits beside aCargo.tomlorCMakeLists.txt, and asystem.tomllives only in a bringup package. Runnros configure --migratein the workspace; it moves the file into a bringup package, creatingsrc/<package>_bringupwhen there is none, and prints every file it moves.nros run <node>lists images instead of running. The bringup has more than one node or image. Name<bringup>:<image>.- An edit to the image row changes nothing. A hand-written
src/<image>_entry/with aCargo.tomlorCMakeLists.txttakes precedence. Move its settings to the[image.*]row and delete it. - Configure stops:
project(<a>)… does not match the package name<b>. A C or C++ node package’sproject()must be itspackage.xml<name>, as in ament. The build names the package’s entry symbols fromproject()and the generated entry names them frompackage.xml, so two names would link to nothing. Rename one to match; after renaming a package, change both.
See also
- system.toml keys: every
[image.<id>]key and how blocks fold over[image_defaults]. - Build outputs: what
nros buildgenerates underbuild/, and where each artifact lands. - Build inside an existing CMake or vendor tree:
projects that own their build and have no
system.toml. - How a build becomes an image: the model behind the generated entry.
Design background
- RFC-0121: workspace-first project layout
- RFC-0065: colcon-like workspace builder (images, hosts, generated entries)
- RFC-0057: ament-parity component registration
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI
Mix languages
Needs first: Organize a larger workspace
Mix languages when one image should run node packages written in C, C++ and Rust: C code you want to keep in C, beside new C++ or Rust nodes.
Languages mix per package, not per file. A bringup’s [[component]] row names
a package and a class whatever language implements it, and each node package
registers itself through a C ABI the generated entry calls. The workspace shape
does not change with the language, and neither does system.toml.
Before you start
- A workspace with a bringup, as in Organize a larger workspace.
- ROS 2 sourced for the first build. It generates the message bindings for every language.
Steps
-
Add a node package per language. From the workspace root,
--langpicks the language and--toadds the package’s row to the bringup:nros new c_talker_pkg --lang c --template talker --to host_node_bringup nros new listener_pkg --lang cpp --template listener --to host_node_bringupnros new: added the node package src/c_talker_pkg/ (talker, c) to …/host_ws declared it in …/host_ws/src/host_node_bringup: a [[component]] row and an <exec_depend> -
Write the C node as a typed component. It has no
main(): it defines a state struct and aconfigurefunction, and exports them withRCLC_C_COMPONENT.configurereceives the entry’s own node and executor, so a C and a C++ component in one image share both:#include <stdint.h> #include <rclc/rclc.h> #include <std_msgs/msg/int32.h> typedef struct { rcl_publisher_t pub; rcl_timer_t timer; int32_t count; } c_talker_pkg_t; static void on_tick(rcl_timer_t* timer, int64_t last_call_time) { c_talker_pkg_t* self = RCLC_CONTAINER_OF(timer, c_talker_pkg_t, timer); (void)last_call_time; std_msgs__msg__Int32 msg = {.data = self->count}; (void)rcl_publish(&self->pub, &msg, NULL); self->count++; } static rcl_ret_t talker_configure(rcl_node_t* node, rclc_executor_t* executor, c_talker_pkg_t* self) { self->count = 0; self->pub = rcl_get_zero_initialized_publisher(); rcl_ret_t rc = rclc_publisher_init_default( &self->pub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), "/chatter"); if (rc != RCL_RET_OK) return rc; self->timer = rcl_get_zero_initialized_timer(); rc = rclc_timer_init_default(&self->timer, NULL, 1000000000ULL, on_tick); if (rc != RCL_RET_OK) return rc; return rclc_executor_add_timer(executor, &self->timer); } RCLC_C_COMPONENT(c_talker_pkg_t, talker_configure)Its
CMakeLists.txtregisters the component the same way a C++ package does, withTYPED:# declared as <depend>std_msgs</depend> in package.xml find_package(std_msgs REQUIRED) nano_ros_auto_add_library(talker_lib STATIC src/Talker.c) nros_components_register_node(talker_lib PLUGIN c_talker_pkg::Talker EXECUTABLE talker SHAPE configure TYPED)A Rust node package in the same image needs no CMake file. An image that runs C or C++ nodes builds through CMake, and the build registers each Rust package from its
[[component]]row: the row names the package, the class and the instance, and the package’sCargo.tomlis the source. So the same Rust package builds unchanged in a Rust-only image and in a mixed one:[[component]] pkg = "rust_heartbeat_pkg" class = "rust_heartbeat_pkg::Heartbeat" name = "heartbeat"A Rust package that ships its own
CMakeLists.txtkeeps it: its ownnano_ros_node_register(… LANGUAGE RUST SOURCES Cargo.toml)call wins, and the build derives nothing for it. -
Name the packages in the launch file, if the bringup has one. Without
launch/, the build generates the launch file from the[[component]]rows. Either way, nothing names a language. The mixed example workspace’s launch file:<launch> <node pkg="c_talker_pkg" exec="talker" name="talker"/> <node pkg="cpp_listener_pkg" exec="listener" name="listener"/> <node pkg="rust_heartbeat_pkg" exec="heartbeat" name="heartbeat"/> </launch> -
Build. Once the image holds a C or C++ package, the build runs CMake, and the Rust packages build inside it through Corrosion.
--dry-runshows the handoff:nros build linux --dry-runnros build: host_node_bringup:linux -> board linux (platform posix), driver cmake cmake -S build/posix-zenoh-linux-host_node_bringup-linux -B build/posix-zenoh-linux-host_node_bringup-linux/cmake … cmake --build build/posix-zenoh-linux-host_node_bringup-linux/cmakeThe generated
build/posix-zenoh-linux-host_node_bringup-linux/CMakeLists.txtis the CMake root. You do not write it, and the workspace has no root build file. -
Run it:
nros run host_node_bringup:linux
Example
examples/workspaces/mixed/
runs a C talker, a C++ listener and a Rust heartbeat in one image, with C and
C++ service and action pairs beside them. Its bringup states the image the
same way a one-language workspace does:
# src/demo_bringup/system.toml (excerpt)
[system]
name = "mixed_demo"
rmw = "zenoh"
domain_id = 0
default_launch = "system.launch.xml"
[[component]]
pkg = "c_talker_pkg"
class = "c_talker_pkg::Talker"
name = "talker"
[[component]]
pkg = "cpp_listener_pkg"
class = "cpp_listener_pkg::Listener"
name = "listener"
[image_defaults]
rmw = "zenoh"
[image.linux]
board = "linux"
[image.freertos]
board = "mps2-an385-freertos"
source /opt/ros/humble/setup.bash
nros build linux
nros run demo_bringup:linux
The first build records the ROS 2 prefix in the workspace, so later shells need not source ROS 2.
Per-language notes
- Rust. A node package is a library crate ending in
nros::node!(YourNode). Its message crates and cargo settings are generated underbuild/. In a mixed image its compiler errors are still cargo’s. - C. Its message bindings are generated during the CMake configure.
- C++. The component has a
configure(::rclcpp::Node&)method, as in Organize a larger workspace. - The RMW is stated once, whatever the languages:
[system] rmw, orrmw =on one image block. See Switch the RMW per image.
If it doesn’t work
- A node is missing at run time. Its
[[component]]row or launch<node>names a package or class that does not match the package’s own registration (PLUGINin CMake, the class innros::node!). - The first build stops on
AMENT_PREFIX_PATH. ROS 2 was not sourced and the workspace has no recorded prefix yet. Source ROS 2 and build again.
See also
- Build outputs: where a CMake-driven image lands.
- C API and C++ API.
Design background
Configure an image
Needs first: Organize a larger workspace
Configure an image when it needs more than a board: an address on a network, a router to dial, a per-image build knob, a flash or console override, or a smaller binary for a constrained board.
Everything here goes in the image’s row of the bringup’s system.toml, or in
a file that row names. The toolchain bakes it in at build time: an embedded
image has no configuration file on the device and parses nothing at run time.
Cargo.toml and CMakeLists.txt carry language facts only, and nothing a
board implies is written anywhere: the build derives it from the board’s
descriptor.
Building and configuring
nros build prepares everything the build needs (generated messages, the
resolved system, the image’s build settings) and then runs the host build
tool. A project that stays in west, CMake, NuttX make or an IDE runs the
preparation step, nros configure, from that tool’s own configure step
instead.
Before you start
- A workspace with a bringup and at least one image, as in Organize a larger workspace.
Steps
See what the image resolves to
nros config show prints the resolved configuration of the bringup, with the
file and table each value came from:
nros config show
# Resolved config for system 'host_node' (bringup pkg: host_node_bringup)
# source: …/src/host_node_bringup/system.toml
[system]
rmw = zenoh # system.toml [system]
domain_id = 0 # system.toml [system]
Resolution is a fixed ladder, not a merge: a command-line or build flag, then
[image.<id>], then [system], then the board descriptor’s [knobs], then
the built-in default. nros config explain prints the build-time knob ladder
for a platform.
Retarget the image
board is the one key that has to change. The image’s id is the name you
pass to nros build:
[image.mps2-an385-baremetal]
board = "mps2-an385-baremetal"
locator = "tcp/10.0.2.2:7447"
locator is the router or agent the image dials. Without it, the image dials
[system] locator, then the board’s default.
Give the image an address
On a board where nano-ros owns the network (the reference FreeRTOS, ThreadX
and bare-metal boards), the address is in a board network file the image
names with os_config. On Linux, Zephyr and NuttX the operating system owns
the network, and you set the address in its own configuration.
-
Name the file on the image:
[image.talker] board = "mps2-an385-baremetal" os_config = ["board-net.toml"] -
Write one table per interface, beside
system.toml. On QEMU’s built-in network,hostis enough:# board-net.toml [eth0] network = "qemu" host = 10 # 10.0.2.10 -
For a network of your own, define it in the same file and state the router on the image:
# board-net-sensor.toml [eth0] network = "lab" address = "192.168.50.20" [network.lab] subnet = "192.168.50.0/24" gateway = "192.168.50.1"[image.sensor] board = "mps2-an385-baremetal" os_config = ["board-net-sensor.toml"] locator = "tcp/192.168.50.1:7447"Two images on one network each define it, and the definitions must agree. A mistake fails the build and names the image: an address outside the subnet, two images with one address, or a network no file defines.
-
To run that image under QEMU on a host bridge, say how it joins:
[image.sensor.run] nic = { bridge = "qemu-br" }nros runpasses the-nicvalue to QEMU. An image on a network other thanqemuwith nonicis physical only. -
Variants of one host may share its address. A bringup that builds one controller several ways (plain, with runtime statistics, with a trace) on one network boots only one of them at a time, so each variant can name the same board network file. Say so, or the build refuses the shared address:
[image_alternatives] fvp-tap = ["fvp-tap", "fvp-tap-stats", "fvp-tap-trace", "fvp-tap-trace-ring"]Only images of one group may share; any other image on that address is still refused. See system.toml keys.
The middleware’s own file
How a session finds its peers is the middleware’s own configuration, in its
own language: rmw/zenoh.json5 or rmw/cyclonedds.xml beside system.toml,
the same documents ROS 2 reads. To ship a different file for one image, name
it:
[image.qemu]
board = "mps2-an385-freertos"
rmw_config = "rmw/zenoh-qemu.json5"
Configure zenoh and Use Cyclone DDS show the files themselves.
Per-image build knobs
A build knob one image needs, and its board does not state, goes in
[image.<id>.knobs.<group>]:
[image.linux.knobs.log]
max_level = "warn" # NROS_LOG_MAX_LEVEL
[image.linux.knobs.executor]
max_cbs = 16 # NROS_EXECUTOR_MAX_CBS
An unknown key, a wrong type or an out-of-range value stops nros build,
naming the key. An application’s own build variable, one the knob registry
does not hold, goes in env = { NAME = "value" } instead.
On Zephyr, an application’s own Kconfig symbol is set by a .conf fragment
in the image’s os_config. The fragment only assigns the symbol. A workspace
package defines it, as a Zephyr module the image depends on; see
A workspace package that is a Zephyr module.
nros build <id> applies these rows, and so does a standalone CMake leaf.
A hand-written workspace root (nano_ros_workspace(SYSTEM <bringup> …))
builds one image only when it is told which one, so name it at configure time
with -DNROS_IMAGE=<id> (for this image, -DNROS_IMAGE=linux). A root that names no image while its bringup states per-image knob or env
rows stops the configure, rather than building with the defaults. The same
applies to the image’s domain_id. A hand-written
nano_ros_add_executable(… BRINGUP <dir> IMAGE <id>) takes the domain that
image states, and stops when a -DNROS_DOMAIN_ID names another.
Override how a board is flashed and watched
A board’s descriptor states its flasher and console. An image overrides any key of them:
[image.lab.flash]
command = "pyocd flash -t stm32f767zi {hex}"
prepare = [{ say = "Set BOOT0 to 1, then press RESET", wait_for = "usb:0483:df11" }]
[image.lab.console]
baud = 921600
Both tables are checked when system.toml is read, and nros flash and
nros monitor use them.
Shrink the image for a small board
-
Build with the size profile. Name it on the image, and
nros buildpasses it to whichever tool it drives:[image.mps2-an385-baremetal] board = "mps2-an385-baremetal" profile = "nros-minsizerel" -
Drop what a brokered client does not need. These are ordinary build environment variables, and a value you export wins over the generated one:
NROS_LINK_IP=0 NROS_ZENOH_NO_SMOLTCP=1 \ NROS_NET_MAX_SOCKETS=1 NROS_NET_MAX_UDP_SOCKETS=1 \ nros build mps2-an385-baremetalNROS_LINK_IP=0drops zenoh-pico’s TCP and UDP links on a serial-only image, andNROS_ZENOH_NO_SMOLTCP=1skips the smoltcp glue on bare metal. A knob you always want for a board belongs in that board’s descriptor[knobs], not on every command line. -
Keep the heap at the board default for a
nros::main!image. Its executor backing is one large allocation; shrinkNROS_HEAP_SIZEonly on a hand-written direct-mode image whose peak you measured.
Moving from ethernet to a serial link is the largest saving. The measured sizes are in Build outputs.
Example
A bare-metal image on a lab network, with its own router and a log ceiling:
# src/sensor_bringup/system.toml
[system]
name = "sensor"
rmw = "zenoh"
domain_id = 0
[[component]]
pkg = "sensor_node"
class = "sensor_node::Sensor"
name = "sensor"
[image.sensor]
board = "mps2-an385-baremetal"
os_config = ["board-net-sensor.toml"]
locator = "tcp/192.168.50.1:7447"
[image.sensor.run]
nic = { bridge = "qemu-br" }
[image.sensor.knobs.log]
max_level = "info"
nros build sensor
A hand-written no_std app
An app that writes its own main() instead of using nros::main!() keeps its
network settings in a config.toml beside it, compiled in with
include_str!. It has the board network file’s tables, plus a [node] table
for the session:
# config.toml
[node]
domain_id = 0
locator = "tcp/10.0.2.2:7447"
[eth0]
network = "qemu"
host = 10
use nros_board_mps2_an385::{Config, run};
fn main() -> ! {
run(Config::from_toml(include_str!("../config.toml")), |config| {
let exec = ExecutorConfig::new(config.zenoh_locator)
.domain_id(config.domain_id);
// ...
})
}
If it doesn’t work
- The build names a retired key.
ip,gateway,netmask,transportand[image.<id>.net.<if>]moved to the board network file and the locator. The message names the new spelling. - A board network file is refused. The board’s network belongs to the
host OS (
linux,freertos-posix,threadx-linux), or the board declares no interfaces. Zephyr boards take their address from Kconfig. - An image with a zenoh file is refused. It also states a
locator. With a file, the file is the wiring; remove one of the two.
See also
- system.toml keys: every image key, the network file, the run, flash and console tables.
- Environment variables: the build-time and runtime variables, and the buffer knobs.
- Configuration surface: the Kconfig symbols and where each decision is made.
- Retired configuration files.
Design background
- RFC-0004: configuration and transports
- RFC-0098: generated leaf build config
- RFC-0031: RMW selection and lowering
- RFC-0109: network config layers
- RFC-0103: one owner per fact
- RFC-0120: one resolver for every build road
Build profiles
Needs first: Configure an image
Choose a build profile when an image must be smaller, faster or easier to debug, and profile the build when it takes too long.
nano-ros builds C, C++ and Rust code on your behalf. You choose the
optimization level once, on the image, and the build passes it to every crate
and library it builds: the cargo profile on the cargo driver,
CMAKE_BUILD_TYPE on the CMake one.
Before you start
- A workspace with an image, or a CMake project that adds nano-ros as in Build inside an existing CMake or vendor tree.
Steps
Set the profile on the image
-
Name it in the bringup’s
system.toml, on one image or on[image_defaults]for all of them:[image_defaults] profile = "nros-relwithdebinfo" # the base every image folds over [image.linux] board = "linux" [image.mps2] board = "mps2-an385-baremetal" profile = "nros-minsizerel" # this one goes on a board -
Build. You do not repeat the profile on the command line, and you do not define the
nros-*profiles anywhere: the build writes them into the image’s generated cargo settings underbuild/.nros build mps2 -
Check that the image’s build can apply the profile. Two cases are refused, each naming the image:
- A cargo profile of your own on a CMake image (one with C or C++
nodes). CMake knows only the four build types below, so drop
profilefrom that image and pass the type on the build line:nros build <image> -- -DCMAKE_BUILD_TYPE=RelWithDebInfo. - Any profile on a Zephyr image. Zephyr takes its optimisation from
Kconfig: remove
profileand setCONFIG_SPEED_OPTIMIZATIONS,CONFIG_SIZE_OPTIMIZATIONSorCONFIG_DEBUG_OPTIMIZATIONSin a fragment the image’sos_confignames.
- A cargo profile of your own on a CMake image (one with C or C++
nodes). CMake knows only the four build types below, so drop
The nros-* profiles and the CMake build types they come from:
CMAKE_BUILD_TYPE | cargo profile | Meaning |
|---|---|---|
Debug | dev | debuggable, minimal optimization |
RelWithDebInfo | nros-relwithdebinfo | opt-level 2, debug info, no LTO |
MinSizeRel | nros-minsizerel | opt-level s, fat LTO; smallest images |
Release | release | opt-level 3, fat LTO; fastest code |
| (unset) | nros-relwithdebinfo | a CMake project you configure yourself |
When an image states no profile
An image with no profile builds release on a board, whichever language
its nodes are in: Release on an image with C or C++ nodes, the cargo
profile release on a Rust-only image. An image on the host (linux)
builds cargo’s dev when it is Rust-only, and CMake with no build type when
it has C or C++ nodes. A Zephyr image always takes its optimisation from
Kconfig.
Build a debug image
On a board, release is the default, so a debug build is one flag away.
--profile= replaces the image’s profile for one build, and takes what the
image’s profile key takes: nros build mps2 --profile=dev for a Rust-only
image, and nros build mps2 --profile=Debug for an image with C or C++ nodes.
The = is required. A -DCMAKE_BUILD_TYPE in --cmake-args= is refused,
naming --profile=; Build arguments
lists the rest.
To make debug the image’s default, state profile = "dev" on its
[image.<id>] instead (Debug on an image with C or C++ nodes).
Set it from CMake
When you drive CMake yourself, set CMAKE_BUILD_TYPE as in any CMake project,
and nano-ros derives the cargo profile for the Rust it builds underneath:
cmake --preset linux -DCMAKE_BUILD_TYPE=MinSizeRel
cmake --build build/linux
The configure prints the profile it chose and the target/ directory it
builds into:
-- nano-ros: cargo profile `nros-minsizerel` (CMAKE_BUILD_TYPE=MinSizeRel) → target/nros-minsizerel
Set NROS_CARGO_PROFILE when the two halves should differ, for example a
small C++ image with debuggable Rust:
cmake --preset linux \
-DCMAKE_BUILD_TYPE=MinSizeRel -DNROS_CARGO_PROFILE=nros-relwithdebinfo
An unrecognized build type is an error, never a guess.
Use a profile of your own
Name any profile. When the name is not one of the nros-* profiles, you own
its definition, and nano-ros passes the name through and injects nothing:
[profile.prod]
inherits = "release"
opt-level = 3
lto = "fat"
Put it where cargo already looks: the package’s Cargo.toml for a
one-package project, or a .cargo/config.toml in a directory above the
project. A nano-ros workspace has no root Cargo.toml, and the generated
entry under build/ is rewritten on every build. An undefined name fails as
cargo always does: error: profile 'prod' is not defined.
Find where the build time goes
nros-build-profile reads the timing files the build already wrote and
reports where the time went: code generation, compile and link, which unit
dominated, and which crate was built more than once. It never builds
anything. The release installs it beside nros; release 0.6.0-nros4 and
older do not carry it.
-
For per-crate detail on the cargo driver, build with cargo’s timings. ninja, which the CMake and west drivers use, always writes its log, so those need nothing.
cargo build --timings --manifest-path build/posix-zenoh/linux_entry/Cargo.toml \ --config build/posix-zenoh/linux_entry/nros-cargo.toml -
Point it at the directory that holds
build*/ortarget*/:nros-build-profile build/posix-zenoh/linux_entry --deepIt prints a stage table, the slowest units with
--deep, and hints. Without cargo’s timings you still get the stage table, and a note on how to get the drill-down. -
For CI, write it as JSON and compare runs:
nros-build-profile build/posix-zenoh/linux_entry --jsonThe hints flag a large C unit built with no compiler cache, a crate compiled more than once, and a job count too high for the RAM. Silence them with
--no-hints.
Example
One workspace, a debuggable host image and a small board image:
# src/demo_bringup/system.toml (images)
[image_defaults]
profile = "nros-relwithdebinfo"
[image.linux]
board = "linux"
[image.mps2]
board = "mps2-an385-baremetal"
profile = "nros-minsizerel"
nros build --all
If it doesn’t work
- A board image is larger than expected. It built at the default,
nros-relwithdebinfo, which trades size for build speed. Usenros-minsizerelfor a constrained board. - The profile you chose is not the one used. Two platforms pin their own and say so: NuttX Rust images, and FreeRTOS images under QEMU, which miss zenoh-pico’s handshake window at low optimization.
error: profile '<name>' is not defined. A profile of your own needs a definition where cargo looks for one; see above.
See also
- Configure an image: the size knobs beside the profile.
- Build outputs: where the
target/directory of each profile lands, and the measured sizes per profile.
Build inside an existing CMake or vendor tree
Needs first: Install options, pinning, working offline
Use this page when nano-ros has to live inside a build you already own: a C or C++ CMake tree with its own layout, or a company tree (a BSP, a forked RTOS, a CI system) that drives cargo or CMake itself.
If your project is a nano-ros workspace, you do not need this page. You state
the board once in the bringup’s system.toml, and nros build sets
everything below for you. Start at
Organize a larger workspace instead.
nano-ros is distributed as a release: the nros CLI and the library source it
builds against, the SDK root. Nothing is on crates.io and there is no
prebuilt library or install prefix, so “vendoring” nano-ros means pinning and
mirroring a release, not copying its repository into your tree.
Before you start
- A release installed and pinned, as in Install options, pinning, working offline.
- The board provisioned with
nros setup <board>. For every board with a CMake build, that also installs Corrosion, which a C or C++ configure needs and never downloads.
Steps
Add nano-ros to a CMake tree
-
Ask for the SDK root. It is the installed release’s
share/nano-ros, for the version the project is pinned to:nros locate nano-ros -
Pick the platform and the backend before you add nano-ros, then link it. The variables must be set before
add_subdirectory, because nano-ros reads them when it is included:cmake_minimum_required(VERSION 3.22) project(my_app C) set(NROS_PLATFORM posix) # posix | freertos | nuttx | threadx set(NROS_RMW zenoh) # zenoh | xrce | cyclonedds add_subdirectory("${NANO_ROS_SDK}" nano_ros) add_executable(my_app main.c) target_link_libraries(my_app PRIVATE NanoRos::NanoRos) if(COMMAND nros_platform_link_app) # defined by the zephyr and threadx platforms nros_platform_link_app(my_app) endif()The variables and their values are listed in CMake cache variables. Zephyr and bare metal do not enter this way: Zephyr has its own module, and a bare-metal image is linked by
nros build, which supplies the board’s startup and linker scripts. -
Generate the message bindings your sources include:
nano_ros_generate_interfaces(std_msgs LANGUAGE C DEPENDENCIES builtin_interfaces) target_link_libraries(my_app PRIVATE std_msgs__nano_ros_c) -
Configure with the SDK root and build:
cmake -B build -DNANO_ROS_SDK="$(nros locate nano-ros)" cmake --build buildCMake’s target propagation brings in the nano-ros libraries, the platform’s own system libraries and the per-build configuration header.
The higher-level form is find_package(nano_ros REQUIRED), located with
-Dnano_ros_ROOT=<sdk-root>. The CMake presets nros setup presets writes
pass it for you, so cmake --preset <board> works.
Drive cargo or CMake yourself from CI
In a nano-ros workspace, a CI job that runs cargo or CMake itself prepares the
generated inputs first, without building, and then runs the line
nros build prints:
nros configure
nros build linux --dry-run
nros build: host_node_bringup:linux -> board linux (platform posix), driver cargo
cargo update --workspace --manifest-path build/posix-zenoh/linux_entry/Cargo.toml --config build/posix-zenoh/linux_entry/nros-cargo.toml
cargo build --manifest-path build/posix-zenoh/linux_entry/Cargo.toml --config build/posix-zenoh/linux_entry/nros-cargo.toml
A run of nros configure with nothing changed does nothing, and its stamp
under build/nros/configured/<image>/ holds a digest of every input the image
read, which makes a CI cache key.
Everything the build reads is generated under build/, never beside your
packages: the message crates, the target triple, the runner, the link flags,
the resolved [env] and the [patch.crates-io] rows that point registry-style
names such as nros = { version = "*" } at the SDK root. So a tree moves
freely. After you relocate it, or install another release, the next build
rewrites what is under build/ and touches nothing you track.
Keep your own boards in your tree
Point NROS_EXTRA_BOARD_PATH (an environment variable, or a CMake cache
variable for nano_ros_use_board()) at a directory of board crates in your
tree, laid out like the SDK’s packages/boards/. Board keys stay global: one
name under two roots is an error. A new platform, an RTOS port of your own, is
the one extension that edits nano-ros itself; see
Add a platform.
Example
A complete C project with no system.toml, my_app/CMakeLists.txt:
cmake_minimum_required(VERSION 3.22)
project(my_app C)
set(NROS_PLATFORM posix)
set(NROS_RMW zenoh)
add_subdirectory("${NANO_ROS_SDK}" nano_ros)
add_executable(my_app main.c)
target_link_libraries(my_app PRIVATE NanoRos::NanoRos)
nano_ros_generate_interfaces(std_msgs LANGUAGE C
DEPENDENCIES builtin_interfaces)
target_link_libraries(my_app PRIVATE std_msgs__nano_ros_c)
cmake -B build -DNANO_ROS_SDK="$(nros locate nano-ros)"
cmake --build build
If it doesn’t work
- The configure stops and names
nros setup --tool corrosion. Corrosion is not in the SDK store. Run that command, or thenros setup <board>you already use. - A setting in your CMakeLists has no effect. It was set after
add_subdirectory. Move everyNROS_*variable above it. - A message crate resolves from crates.io. A Rust package named it by
registry name (
std_msgs = "*"). Letnros buildwrite the# nros-managedpath row frompackage.xmlinstead. - You set
NROS_PLATFORMin a nano-ros workspace. The generated root already derives it from the image’sboard. Remove it: two answers to one question.
See also
- Install options, pinning, working offline: pin the release, mirror it, and build with no network.
- Build outputs: where each target family’s artifact lands.
- How a build becomes an image.
- Add a board and its out-of-tree example: board code that lives in your tree.
Design background
Install options, pinning, working offline
Needs first: Install
Install is the short path. This page covers a specific release, a whole workspace, pinning a project, and building with no network.
A release carries everything a project needs: the nros CLI, and the library
as source in its SDK root, which nros build compiles into your project.
There is no prebuilt library, no system-wide install and no nano-ros clone.
Its nros-sdk-index.toml pins every toolchain and SDK version nros setup
provisions, so pinning nano-ros is pinning a release.
Before you start
- Linux. The host board is
linux; macOS is not supported. - The host packages Install lists. Each tool’s absence produces an error that names it.
Host packages
cmake builds the C and C++ quick start and every generated workspace root.
zstd unpacks the release and the prebuilt assets nros setup fetches.
python3-dev is used only by a from-source build of the launch resolver,
which a release ships prebuilt. The Python packages feed rosidl_adapter,
the message-to-IDL step the Cyclone DDS backend uses; empy must stay 3.x.
Fedora and Arch ship no packages for the rosidl Python side, so Install has
them installed with pip install --user; Arch’s externally managed Python
also needs --break-system-packages. To keep them out of your user site,
create a virtual environment (python -m venv ~/.venvs/nros), activate it,
run the same pip install without --user, and activate it in every shell
you build from.
Install a specific release
install.sh installs into ~/.nros/sdk/nros/<version>/ and points
~/.nros/bin/nros at the newest version installed. It refuses an asset whose
checksum it cannot verify.
url=https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh
# a specific release instead of the newest
curl -fsSL "$url" | sh -s -- --version 0.6.0-nros4
# print what would happen, change nothing
curl -fsSL "$url" | sh -s -- --dry-run
NROS_HOME moves the install root away from ~/.nros. nros version then
prints the CLI, codegen and library versions, and nros doctor, run outside a
workspace, checks the install itself.
One install for several users, or a read-only one
A build never writes into the install, so one install can serve every account
on a machine or sit read-only in a container image. Each project keeps its
own build caches, a few GB; NROS_BUILD_ROOT set to a writable directory
shares them.
Provisioning with nros setup
-
See what a board needs before fetching anything:
nros setup linux --dry-runnros setup: linux (rmw zenoh) needs 3 package(s): rust already present (rustup, default stable-x86_64-unknown-linux-gnu) rust target no cross target for this board … (--dry-run: nothing installed) -
Provision the board and the RMW’s host tools.
--rmwdefaults tozenoh:nros setup <board> --rmw <zenoh|xrce|cyclonedds>Packages are prebuilt where the index has a binary for your host, else built from source, announced first. A CMake board also gets Corrosion, and a host with no Rust gets rustup and the stable toolchain in
~/.cargo.
Provision a whole workspace
In a workspace, provision every image at once: run nros setup with no board
at the workspace root, or pass --workspace <dir>. For a Linux and a FreeRTOS
image:
nros new two_ws --board linux --template talker --lang rust --rmw zenoh
cd two_ws
nros new --image freertos --board mps2-an385-freertos # adds [image.freertos]
nros setup
It reads every system.toml, provisions each image’s board and RMW in one
plan, and lists the OS packages the workspace names, with the install command
(--sudo runs it, --check only reports). Every <depend> must resolve
first; one that does not stops it and names its package.xml.
Then build every image. The first build generates the message bindings from your ROS 2 install, so source it in that shell:
source /opt/ros/humble/setup.bash
nros build --all
Other selections: nros setup --list lists every package in the index,
--tool <name> and --source <name> fetch one package, --licenses lists
the license-gated ones, and nros setup --system prints the OS packages a
board needs for your package manager.
ROS 2 and the zenoh router
nros build, nros run and nros configure generate the message bindings
from the ROS 2 install you sourced, so the layouts and type hashes match your
ROS 2 peers. The first configure of a project records the prefix
(AMENT_PREFIX_PATH), and later shells, IDEs and CI steps reuse it. A
project with no message dependency configures without ROS 2.
Running two zenoh nodes needs a router, and nano-ros uses the one ROS 2
ships, rmw_zenohd from ros-<distro>-rmw-zenoh-cpp. Cyclone DDS needs no
router, and the XRCE agent comes from nros setup … --rmw xrce. Start the
router with ROS 2 sourced:
ZENOH_CONFIG_OVERRIDE='listen/endpoints=["tcp/127.0.0.1:7447"];scouting/multicast/enabled=false' \
ros2 run rmw_zenoh_cpp rmw_zenohd
rmw_zenohd reads only ZENOH_CONFIG_OVERRIDE, and installs off PATH, in
<prefix>/lib/rmw_zenoh_cpp/. nano-ros finds it through NROS_RMW_ZENOHD,
then the prefixes you sourced, then $ROS_DISTRO, never PATH: a zenohd
there is usually a different zenoh. With no ROS 2 packages for your distro,
install ROS 2 from source or a container and source its setup.bash.
Pinning a version
The pin is a file, nros-toolchain.toml, beside your project. Commit it.
Every nros you run in that directory or below it is then the pinned
release: the nros on PATH hands the command to it, fetching it with that
release’s own install.sh the first time.
Write the pin, for a project pinned to an older release than the one you
installed (nros pin <version> writes the same file):
mkdir pinned_app && cd pinned_app
printf '[toolchain]\nversion = "0.6.0-nros10"\n' > nros-toolchain.toml
Ask for the pin. The release that answers is the pinned one, fetched on first use, and it names its own manifest:
nros pin
sdk/nros/0.6.0-nros10/share/nros/manifest.toml
Only the newest release is supported and fixes are not backported, so move a pin deliberately; a pinned release keeps installing, as its assets stay published (Release support).
With no pin, nros pin says so:
pinned: NOTHING — no nros-toolchain.toml at or above …/empty.
This project floats: `nros build` will write a pin, and until it does, firmware built here is reproducible only by accident.
Build with it. The pinned release is older than this page, so it takes the
scaffold spelling it shipped with, --workspace:
source /opt/ros/humble/setup.bash
nros new pinned_ws --workspace
cd pinned_ws
nros setup linux --rmw cyclonedds
nros build
Move the pin forward only. nros pin <newer> reports the codegen delta
before it writes (--dry-run writes nothing), the next nros build
regenerates the bindings, and nros setup <board> brings the store up to
the new index:
curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh \
| sh -s -- --version <newer>
nros pin <newer>
nros setup <board>
nros build
Take the toolchain versions the release pinned: its cross compilers, the Cyclone DDS ROS ships and its zenoh-pico are chosen together.
Commits: Pin a commit.
Working offline
Prepare on a machine with a network and the same Ubuntu release and architecture as the offline one, then carry four things across.
1. Carry the host packages
Download them in a plain container of the offline machine’s Ubuntu release, with the ROS 2 apt repository added as Install adds it. apt downloads only what it thinks is missing, so an empty package status tells it nothing is installed. It then carries Install’s host packages, ROS 2, and everything they need:
mkdir debs
docker run --rm -v "$PWD/debs:/debs" ubuntu:24.04 bash -c '
set -e
apt-get update
apt-get install -y curl ca-certificates
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
base=https://github.com/ros-infrastructure/ros-apt-source/releases/download
curl -fL -o /tmp/ros2-apt-source.deb \
"$base/1.3.0/ros2-apt-source_1.3.0.${codename}_all.deb"
dpkg -i /tmp/ros2-apt-source.deb
apt-get update
: > /tmp/nothing-installed
apt-get install -y --download-only -o Dir::State::status=/tmp/nothing-installed \
git curl ca-certificates build-essential \
cmake pkg-config python3 python3-dev zstd \
python3-catkin-pkg python3-empy python3-lark python3-yaml \
ros-jazzy-ros-base ros-jazzy-rmw-zenoh-cpp ros-jazzy-example-interfaces
cp /var/cache/apt/archives/*.deb /debs/'
For Humble, use ubuntu:22.04 and ros-humble-…. For Jazzy on 2026-11-07,
this downloaded 606 packages, 227 MB. On the offline machine,
sudo apt install ./debs/*.deb installs them all, ROS 2 included.
The container’s release must match the offline machine’s. apt takes each package’s newest version on the day, and a carried package older than the offline machine’s own copy would be a downgrade, so download after that machine’s last update.
2. Mirror the release asset
A release is tagged nros-<version> and
its asset is nros-<os>-<arch>.tar.zst, with a .sha256 beside it. The
installer’s dry run prints the exact URL for a version and this host:
curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh \
| sh -s -- --version 0.6.0-nros7 --dry-run
nros-install: 0.6.0-nros7 for linux-x86_64
nros-install: from https://github.com/NEWSLabNTU/nano-ros/releases/download/nros-0.6.0-nros7/nros-linux-x86_64.tar.zst
Download that file and its .sha256, carry both, and install with
NROS_INSTALL_URL=file:///path/to/nros-linux-x86_64.tar.zst sh install.sh.
3. Pin the SDK index
A release reads the index it ships with, so the
toolchains it provisions are the ones it was built with.
nros setup --index <path> uses another copy you have, and
NROS_INDEX_URL=<url> fetches one from a mirror; the index
names every asset’s upstream, so a full mirror rehosts those URLs in your
copy.
4. Provision and prepare while online
Run nros setup <board> (it
stages Corrosion too, or nros setup --tool corrosion alone), then
nros configure in each workspace. It fetches the crates its images need
into cargo’s cache and writes everything generated.
5. Carry the stores
nros setup --offline-dirs prints the directories
to copy, one per line, each with its reason on stderr:
nros setup --offline-dirs
/home/you/.nros
/home/you/.rustup
/home/you/.cargo
~/.nros (or NROS_HOME) holds the CLI, the SDK root and every package
nros setup fetched. ~/.rustup and ~/.cargo are rustup’s homes (or
$RUSTUP_HOME and $CARGO_HOME): the pinned Rust toolchains and cargo’s
registry cache. Without them nros setup tries to download rustup again.
Copy them to the same paths on the offline machine.
6. Build with NROS_OFFLINE=1
nros fetches nothing and runs cargo with CARGO_NET_OFFLINE=true; a build
missing something stops and names it. nros build --offline does the same
for one build.
If it doesn’t work
- The first configure stops on
AMENT_PREFIX_PATH. Source ROS 2 once (source /opt/ros/humble/setup.bash) and configure again; see the troubleshooting index. - A C++ image is refused for an old compiler. With no pinned
arm-none-eabi-gccin the store, the configure uses one fromPATH, and below GCC 11 a C++ image is refused (Ubuntu 22.04’s apt package is 10.3). Runnros setup --tool arm-none-eabi-gcc. - A zenoh example hangs at start with no output. No router is running,
or it listens on another endpoint.
nros setupreports where it foundrmw_zenohd, or the apt packages that provide it. nros doctorreports a retired store entry. Remove it with the command it prints.
See also
- Build inside an existing CMake or vendor tree: nano-ros in a tree you already build.
- Supported boards and the
nrosCLI. - Migrating from install-local, for a project that used nano-ros from a checkout.
Design background
Bring your own C++ library
Needs first: Mix languages, FreeRTOS on mps2-an385
Use this page when a C++ node package needs a general-purpose library that
nano-ros does not provide: Eigen, a JSON parser, a filter library. The
example links Eigen into a C++ talker for the mps2-an385-freertos board.
nano-ros ships no copies of general-purpose C++ libraries, patched or not.
You bring your own copy and patch it for your board yourself. The package’s
CMakeLists.txt finds and links it as it would without nano-ros; nano-ros
neither provides it nor blocks it.
There are two ways to bring the copy:
- As a package in your workspace, beside your node packages. The copy lives in your repository with your patches applied, and every board builds from it. This page’s steps take this route.
- From a prefix you own, where the library’s own CMake install put it. Use a copy installed elsewhere covers it.
Before you start
- Your copy of the library’s source, with your patches applied. This page
uses Eigen 3.4 at
$HOME/src/eigen. Eigen is header-only, so the copy is itsEigen/directory. - A C++ workspace for the board, as the FreeRTOS starter makes one.
This page uses a workspace named eigen_ws, whose node package is
eigen_node:
nros setup mps2-an385-freertos --rmw zenoh
source /opt/ros/humble/setup.bash
nros new eigen_ws --board mps2-an385-freertos --template talker --lang cpp
cd eigen_ws
The board’s toolchain decides what builds
nros build compiles every package with the board’s cross toolchain, not
the host’s compiler, so a library must build for the board’s CPU and C
library. Two things follow.
CMake can find the host’s copy. The board toolchain files let
find_package search host paths, so a host with libeigen3-dev installed
satisfies a plain find_package(Eigen3) with /usr/share/eigen3: a copy you
did not patch, found without a word. The steps below name your copy and
turn the host’s locations off.
FreeRTOS compiles C++ freestanding. The FreeRTOS boards build C++ with
-ffreestanding. The nano-ros C++ API needs no standard library, but Eigen
does, and libstdc++ refuses <cmath> or <vector> there with This header is
not available in freestanding mode. nano_ros_hosted_cxx() makes the C++ of
the package that calls it hosted, and leaves every other package as it was.
The call does nothing on POSIX, Zephyr and NuttX, whose C++ is already hosted.
ThreadX on RISC-V refuses it: that board’s C++ library is a freestanding shim,
with no hosted library to switch to.
Steps
The steps add a package for the library and change three files of the node package:
eigen_ws/
└── src/
├── eigen/ (new)
│ ├── package.xml
│ ├── CMakeLists.txt
│ ├── cmake/
│ │ └── Eigen3Config.cmake
│ └── include/
│ └── eigen3/
│ └── Eigen/
└── eigen_node/
├── package.xml (changed)
├── CMakeLists.txt (changed)
└── src/
└── Talker.cpp (changed)
Add the library as a package
Copy your Eigen into the new package:
mkdir -p src/eigen/include/eigen3 src/eigen/cmake
cp -r $HOME/src/eigen/Eigen src/eigen/include/eigen3/
Give it a package.xml. Its name is what a node package depends on:
src/eigen/package.xml<?xml version="1.0"?>
<package format="3">
<name>eigen</name>
<version>3.4.0</version>
<description>Eigen 3.4, with this project's patches.</description>
<maintainer email="you@example.com">you</maintainer>
<license>MPL-2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
A config file defines Eigen’s own target, Eigen3::Eigen, over the copied
headers:
src/eigen/cmake/Eigen3Config.cmakeget_filename_component(_root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
if(NOT TARGET Eigen3::Eigen)
add_library(Eigen3::Eigen INTERFACE IMPORTED GLOBAL)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_root}/include/eigen3")
endif()
set(Eigen3_FOUND TRUE)
set(EIGEN3_INCLUDE_DIR "${_root}/include/eigen3")
The package’s CMakeLists.txt loads it and records where it is, so a
node package’s find_package(Eigen3) finds this copy:
src/eigen/CMakeLists.txtcmake_minimum_required(VERSION 3.22)
project(eigen LANGUAGES CXX)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake")
set(Eigen3_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake" CACHE PATH "this workspace's Eigen" FORCE)
if(COMMAND ament_package)
ament_package()
endif()
Depend on it from the node package
Add <depend>eigen</depend> to src/eigen_node/package.xml. It builds the
library’s package before the node’s:
src/eigen_node/package.xml<?xml version="1.0"?>
<package format="3">
<name>eigen_node</name>
<version>0.1.0</version>
<description>eigen_node — nano-ros C++ Node pkg.</description>
<maintainer email="you@example.com">you</maintainer>
<license>Apache-2.0</license>
<depend>std_msgs</depend>
<depend>eigen</depend>
<export>
<build_type>nros_cmake</build_type>
</export>
</package>
In src/eigen_node/CMakeLists.txt, call nano_ros_hosted_cxx(), then find
and link Eigen. NO_DEFAULT_PATH keeps the host’s copy out: CMake takes the
Eigen3_DIR the library’s package recorded, and looks nowhere else.
src/eigen_node/CMakeLists.txtcmake_minimum_required(VERSION 3.22)
project(eigen_node VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(nano_ros REQUIRED)
find_package(std_msgs REQUIRED)
# Eigen needs the hosted C++ standard library. This makes the C++ of this
# package hosted on a board whose toolchain is freestanding.
nano_ros_hosted_cxx()
# The build's source probe configures this package without its workspace
# dependencies, so it loads the library's package itself.
if(NOT TARGET Eigen3::Eigen)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../eigen" eigen)
endif()
find_package(Eigen3 REQUIRED NO_MODULE NO_DEFAULT_PATH)
message(STATUS "Eigen from ${Eigen3_DIR}")
nano_ros_add_node(eigen_node CLASS eigen_node::Talker
SOURCES src/Talker.cpp)
target_link_libraries(eigen_node_eigen_node_component
PUBLIC std_msgs__nano_ros_cpp
PRIVATE Eigen3::Eigen)
The add_subdirectory fallback is there for the source probe, which
nros build runs before the build to read each package’s metadata. Today it
configures a node package alone, so a header or target from a sibling
package is missing there unless the package loads it.
Use the library
This talker turns (count, 0) a quarter turn with a fixed-size matrix
before it publishes. Replace src/eigen_node/src/Talker.cpp with:
src/eigen_node/src/Talker.cpp#include "eigen_node/Talker.hpp"
#include <cstdio>
#include <Eigen/Dense>
namespace eigen_node {
void Talker::on_tick() {
++count_;
// A quarter turn: (count, 0) becomes (0, count).
const Eigen::Matrix2f turn{{0.0f, -1.0f}, {1.0f, 0.0f}};
const Eigen::Vector2f v = turn * Eigen::Vector2f(float(count_), 0.0f);
char payload[64];
std::snprintf(payload, sizeof(payload), "Hello World: %d (%.0f, %.0f)", count_,
double(v.x()), double(v.y()));
std_msgs::msg::String msg;
msg.data = payload;
if (pub_.publish(msg).ok()) {
std::printf("Publishing: '%s'\n", msg.data.c_str());
}
}
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
::setvbuf(stdout, nullptr, _IONBF, 0);
::rclcpp::Result r = node.create_publisher(pub_, "/chatter");
if (!r.ok()) return r;
return node.create_wall_timer<Talker, &Talker::on_tick>(timer_, 1000, this);
}
} // namespace eigen_node
Build and run
nros build
The configure output names the copy it found, inside your workspace:
-- Eigen from /home/you/eigen_ws/src/eigen/cmake
Boot the image in QEMU. Each line carries the turned vector:
source /opt/ros/humble/setup.bash
nros run eigen_node
Publishing: 'Hello World: 1 (0, 1)'
Publishing: 'Hello World: 2 (0, 2)'
Use a copy installed elsewhere
A library you build and install with its own CMake, into a prefix such as
$HOME/opt/eigen, needs no package of its own. Drop the add_subdirectory
fallback and the <depend>eigen</depend>, and name the prefix in the
bringup’s system.toml:
[image_defaults.build]
cmake_args = ["-DEigen3_DIR=/home/you/opt/eigen/share/eigen3/cmake"]
[image_defaults.build] cmake_args reaches every image’s configure and the
source probe, and changing it runs the probe again. A path that differs per
image, such as a cross image and a host image built against different
copies, goes in that image’s [image.<id>.build] cmake_args; the probe still
reads only the [image_defaults.build] one.
What hosted C++ costs
Warning: hosted C++ can bring libstdc++’s heap and exception machinery into the image. A
std::vector, a dynamic-size Eigen matrix or astd::stringallocates throughoperator new, from the package’s own code rather than through the platform’s allocator. An image with a package that callsnano_ros_hosted_cxx()cannot claim to be free of allocation:nros image check <image> --no-allocreads the built image and reportsoperator newin itscxx-operator-newfamily. Fixed-size Eigen types, as in the talker above, keep their storage inline.
The FreeRTOS toolchain still compiles with -fno-exceptions and -fno-rtti,
so a library that throws must be built with its no-exceptions option.
If it doesn’t work
- This header is not available in freestanding mode: the package does not
call
nano_ros_hosted_cxx(), or calls it in a different directory from the target that includes the header. - probe FAILED for eigen_node::eigen_node: … Could not find a package
configuration file provided by “Eigen3”: the node package lacks the
add_subdirectoryfallback, so the source probe never loaded the library’s package. For a copy installed elsewhere,[image_defaults.build] cmake_argslacks its-DEigen3_DIR, or names a directory withoutEigen3Config.cmake. - The configure line names
/usr/share/eigen3: thefind_packagecall lacksNO_DEFAULT_PATH, and CMake found the host’s copy. - A compile error inside the library: the library does not support this
board’s CPU or C library as it is, and needs a patch to your copy. Eigen 3.4,
for one, does not compile its vectorized
psincoson anarm-none-eabiCPU with NEON, where newlib’sint32_tislong: its scratch buffer isintwhere Eigen’s integer packets expectint32_t.
Reference
- Third-party code: what an image compiles in besides your libraries.
- Two surfaces: freestanding, and
NROS_CPP_STD: the nano-ros C++ API with and without the standard library.
Pin a commit or a checkout
Needs first: Install options, pinning, working offline
A project that tracks nano-ros main between releases pins a commit
instead. The [toolchain] table takes exactly one of three forms; git
and rev are spelled as in a cargo git dependency:
[toolchain]
version = "0.6.0-nros11" # a release
# or one commit of a repository
git = "https://github.com/NEWSLabNTU/nano-ros"
rev = "09219edc75c9b9a788590c6ac586a7ba45185eab"
# or a nano-ros checkout on this machine
path = "../modules/nros"
revis the full 40-hex commit, and it is valid only besidegit. A branch name, a tag or a short sha is refused: none of them is sure to name the same commit tomorrow.git rev-parse <name>^{commit}gives the sha.pathis relative to the directory that holdsnros-toolchain.toml, as a cargopathdependency is relative to itsCargo.toml; an absolute path is taken as written. It must be the root of a nano-ros clone.
nros pin writes either form for you, from the project directory:
nros pin --rev <40-hex commit>
nros pin --rev <40-hex commit> --git <repository url>
nros pin --path ../modules/nros
--revrefuses a branch, a tag or a short sha, as the pin itself does. Without--git, it keeps the repository the pin already names, else the nano-ros one.--pathtakes the checkout as your shell spells it and records it relative to the pin file. It refuses a directory that is not the root of a nano-ros clone.- Each form replaces the one the file held, so the file always names exactly one.
- As with a release,
--dry-runprints what would change and writes nothing. - In CI (
CIorGITHUB_ACTIONSset) it refuses to write: a pin is a source edit, made at a keyboard and committed.
The first command run under a git pin fetches that one commit into
~/.nros/toolchains/git-<rev>/ and builds it with the tree’s own
scripts/bootstrap.sh, which takes a few minutes. Later commands use it as
they would a release. The host needs git, cargo (from
rustup), a C compiler and Python 3 with headers; unlike
bootstrap.sh, the pin does not install rustup for you. The build takes its
final name only after it finished and its source stamp checked, so an
interrupted or failed build leaves nothing behind and the next command tries
again. A different rev is a different directory, so moving the pin never
rebuilds a toolchain in place.
Nothing writes into that store toolchain, so its stale-CLI check passes on
its own and NROS_SKIP_STALE_CHECK is not needed.
Under a path pin, nros runs that checkout’s own CLI,
packages/cli/target/release/nros; build it there first with
scripts/bootstrap.sh --no-prompt. Its stale-CLI check works as in any
checkout and refuses once a tracked CLI source is edited after the build.
nros toolchain gc and nros toolchain remove keep a git-<rev> toolchain
that a pin names. A toolchain built from a commit is never the default for an
unpinned project; only a pin selects one.
Linux host
Needs first: Run a talker on an emulated board, What you just built, Get started on the Linux host
Status:
nros-board-linux: Verified on host (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a C++ talker for the
Linux host, ran it as an ordinary process, and heard it from ROS 2 over
Cyclone DDS. This page covers what comes after it: how the host image is
configured, what is particular to the host board, how to read the plan
nros run follows, and how to drive the native build yourself.
Use the host board for first experiments, for smoke tests in CI, and to check interoperability with ROS 2 before you move a node to a microcontroller. The node package you write here is the same one an embedded image builds: only the bringup’s image changes.
Configure the platform
The starter’s bringup, src/host_node_bringup/system.toml, holds one image:
[system]
name = "host_node"
rmw = "cyclonedds"
domain_id = 0
[image.linux]
board = "linux"
board = "linux" is what makes the image a host program. The RMW comes from
[system] rmw, and an image can override it with its own rmw key. The
choices on this board are cyclonedds, zenoh and xrce:
- Cyclone DDS needs no daemon. A stock ROS 2 node with
RMW_IMPLEMENTATION=rmw_cyclonedds_cppon the same machine and domain discovers the image directly, which is why the starter uses it. - zenoh dials a router. The image’s default locator is
tcp/127.0.0.1:7447, the port ROS’srmw_zenohdlistens on, andnros runstarts that router before the node and stops it after. Provision the backend first withnros setup linux --rmw zenoh. - XRCE-DDS talks to a Micro-XRCE-DDS agent, which
nros setup linux --rmw xrceinstalls.
Pick and configure the RMW walks through a switch, and Configure an image lists every key an image takes.
A host image reads two settings from the environment when it starts, so the same binary can join another domain or another router without a rebuild:
ROS_DOMAIN_ID=0
NROS_LOCATOR=tcp/127.0.0.1:7447
An embedded image has no environment. The same two facts are compiled in
from its image’s domain_id and locator keys.
Board notes
- The board is named
linuxbecause Linux is all it supports. The platform layer under it is POSIX, but the board pins a sched task to a CPU withsched_setaffinityandcpu_set_t, which macOS, Windows and FreeBSD lack. No other spelling names this board: an image or anros new --boardthat uses one is refused with a hint naminglinux. - The image is a host process. It uses the host’s sockets and network stack, and its console is the process’s standard output. There is no emulator and nothing to flash.
- One board crate covers both the host and the POSIX family driver, so a sched task, a timer or a socket behaves here as it does on any POSIX system.
- The scaffolded examples are copy-out ready. Nothing in a workspace
names a path into the SDK:
nrosfinds its own, and--nano-ros-pathnames another.
Read the run plan
Before it starts anything, nros run resolves a run plan: what launches the
image, where its console appears, and how its middleware reaches the rest of
the system. Print it for the starter’s talker, from the workspace root:
nros run host_node --dry-run --why
--dry-run prints the plan instead of carrying it out, and --why adds
where each fact came from: the command line, the image, your machine’s bench
file, the board’s descriptor, or the runner’s defaults. For this board the
plan has no emulator: the target is a host process, its console is standard
output, and its link is the image’s RMW over the host’s own network.
Drive the native build yourself
nros build writes the generated entry and its build settings under
build/, then runs CMake (for a C or C++ node) or cargo (for a Rust node) on
them. To see the exact native commands without building:
nros build --dry-run
Use the printed lines to build from an IDE or a CI step of your own. Never
edit what nros build writes under build/: the next build regenerates it.
A workspace that lives inside a colcon workspace builds with
colcon build, and source install/setup.bash then puts its executables on
ros2 run’s path.
Deploy on a Linux machine
Host deployment is ordinary process deployment. Copy the executable
nros build printed, or install the colcon workspace, onto the target
machine, set ROS_DOMAIN_ID and, for zenoh, NROS_LOCATOR, and start it
under the service manager you already use. For a zenoh image, run the router
on that machine or name a reachable one in NROS_LOCATOR. The checklist in
Deploy to production applies unchanged.
If it doesn’t work
nros runstops at once and names the router: the image uses zenoh andrmw_zenohdis not on the path. Source ROS 2 and installros-<distro>-rmw-zenoh-cpp, or pass--router <locator>to use a router you already run.- ROS 2 hears nothing: the ROS 2 shell’s
RMW_IMPLEMENTATIONorROS_DOMAIN_IDdiffers from the image’srmwanddomain_id. - Everything else: Troubleshoot.
Reference
- The
linuxboard’s support evidence: its status, where it runs and its breadth. system.tomlkeys and thenrosCLI.- Talk to ROS 2: interoperability with stock ROS 2 nodes, QoS included.
Design background
Zephyr native_sim
Needs first: Run a talker on an emulated board, What you just built, Get started on Zephyr native_sim
Status:
nros-board-zephyr(ZephyrNativeSim): Verified on host (daily). From the board support registry; Board Support Levels explains the words.
The starter made a west workspace
pinned to Zephyr 3.7, scaffolded a talker for board = "zephyr", and ran it
on native_sim, Zephyr’s host build, where the image is a Linux executable.
This page covers what comes after it: where an image’s nano-ros and Zephyr
settings each go, the Zephyr lines nano-ros builds against, what is particular
to native_sim, and how nros build hands the build to west. The
configuration here applies to every Zephyr board; the
mps2-an385 and Nucleo-F767ZI pages add
only their board notes.
Configure the platform
An image’s nano-ros configuration lives in one place, the bringup’s
system.toml. Zephyr’s own settings (networking, POSIX, stacks, heaps) live
in Zephyr’s prj.conf fragments, which the image names with os_config:
[system]
name = "zs_node"
rmw = "zenoh"
domain_id = 0
[image.zephyr]
# a nano-ros board id; west gets native_sim/native/64
board = "zephyr"
locator = "tcp/127.0.0.1:7447"
os_config = ["prj-zenoh.conf"] # Zephyr settings only
[image.zephyr.knobs.zenoh]
max_publishers = 4
nano-ros’s Zephyr module renders the image into a Kconfig fragment and
merges it last, after every conf file. So a prj*.conf file holds Zephyr’s
settings only, and never a CONFIG_NROS_* line: one there is either
overridden or a second source that can disagree with the first.
You write in system.toml | The build gets |
|---|---|
rmw = "xrce" | CONFIG_NROS_RMW_XRCE=y |
| (the node package’s language) | CONFIG_NROS_{C,CPP,RUST}_API=y |
locator = "tcp/…" (zenoh) | CONFIG_NROS_LOCATOR |
locator = "udp/<host>:<port>" (XRCE) | CONFIG_NROS_XRCE_AGENT_ADDR and _PORT |
domain_id = 7 | CONFIG_NROS_DOMAIN_ID |
[image.<id>.knobs.zenoh] max_queryables = 12 | CONFIG_NROS_MAX_QUERYABLES=12 |
env = { NROS_ZEPHYR_TASK_STACK_BYTES = "16384" } | CONFIG_NROS_ZEPHYR_TASK_STACK_BYTES=16384 |
os_config = ["prj-xrce.conf"] | that fragment, ahead of your own EXTRA_CONF_FILE |
A key whose value does not fit its Kconfig symbol, or that exists only under
another RMW, is refused when the build configures, naming the
system.toml line. Configure an image
lists the knobs.
One image per RMW
A bringup built for several backends states one image per RMW and picks one
at build time. The copy-out C talker,
examples/zephyr/c/talker/src/nros_zephyr_talker_c_bringup/system.toml,
does this:
[system]
name = "nros_zephyr_talker_c"
rmw = "zenoh"
domain_id = 0
default_images = ["zephyr_zenoh"]
[image.zephyr_zenoh]
board = "zephyr"
rmw = "zenoh"
os_config = ["prj-zenoh.conf", "prj-zenoh-native-sim.conf"]
[image.zephyr_xrce]
board = "zephyr"
rmw = "xrce"
os_config = ["prj-xrce.conf"]
locator = "udp/127.0.0.1:2018"
nros build builds the default_images, and nros build zephyr_xrce
builds the other. Each image has its own build directory,
build/<platform>-<rmw>/<package>__<image>_west, so switching never reuses
another image’s cache.
What each backend needs from Zephyr goes in its fragment:
- zenoh: TCP and POSIX threads, with pthread pools big enough for
zenoh-pico (
CONFIG_MAX_PTHREAD_MUTEX_COUNT=64,CONFIG_MAX_PTHREAD_COND_COUNT=16). - XRCE-DDS:
CONFIG_NET_TCP=y, on the BSD sockets every image enables. - Cyclone DDS:
CONFIG_CPP=y(its source is C++, even for a Rust node),CONFIG_MAIN_STACK_SIZE=524288, andCONFIG_NET_IPV4_IGMP=yfor discovery. Raise its heap with[image.<id>.knobs.memory] heap_bytes, not in the conf.
The Zephyr lines
nano-ros builds as a module against whichever Zephyr your west workspace pins: the 3.7 LTS line (the starters’ pin) or the 4.x line. The two differ in two places:
- Python. 3.7 needs Python 3.10 or later; 4.x needs 3.12 or later. On a
host with an older Python, make a 3.12 virtual environment and run
westfrom it. - An app with no
system.toml. On 4.x, nano-ros’swestsnippets pick the RMW on the build line,west build -S nros-cyclonedds …. With asystem.toml, the image’srmwdecides on both lines, and a snippet that names a different RMW is refused.
Board notes
board = "zephyr"isnative_sim/native/64. The board’s descriptor states the idwest build -breceives, so an image never names it.- Sockets are the host’s. The board applies nano-ros’s
nros-nsossnippet, which routes the image’s sockets through Zephyr’s NSOS offload to the host kernel. The image reaches a router on loopback with no TAP interface and no root access. Without the snippet,native_simtries to create one and fails witheth_posix: Cannot create zeth. - nano-ros patches Zephyr’s NSOS driver (
recvmsg, IPv4 multicast).nros setup zephyrapplies the patches to your workspace, checked by hash. After awest updateresets the tree, run the same command again to reapply them. - The console is standard output, and the image runs until you stop it.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run zs_node --dry-run --why
The target is a host process: nros run runs the built zephyr.exe, and the
console is its standard output. A zenoh image’s link is the image’s
locator, and nros run starts the router the link needs.
Drive west yourself
On Zephyr, nros build writes a Zephyr application for the image under
build/, then runs west build on it from your west workspace with the
image’s overlays applied (EXTRA_CONF_FILE, EXTRA_DTC_OVERLAY_FILE,
APPLICATION_CONFIG_DIR). Print that west build line without running it:
nros build --dry-run
Copy the line to run west yourself. Anything after -- on the
nros build line goes to west, to its option zone or its CMake zone by
west’s own flag list, so nros build -- -p always -DMY_OPT=1 reaches both.
Two flags are refused, because the image decides them: -b, which comes
from the image’s board, and --sysbuild, which comes from a
sysbuild.conf beside the application.
nros build finds your Zephyr through --zephyr-workspace <dir>,
$ZEPHYR_BASE or $NROS_ZEPHYR_WORKSPACE (the starter exported the last),
in that order. Next it looks for the west workspace your project sits in:
the nearest .west/ at or above the workspace, as west finds it, counts
when its manifest names a zephyr project that is checked out. That tree
carries your own manifest’s pins and patches, so it comes before the store’s
workspace (~/.nros/workspaces/zephyr/<line>), and the build prints one line
naming it:
nros build: Zephyr tree /work/robot/zephyr (the west workspace /work/robot this project is in, not the store's /home/me/.nros/workspaces/zephyr/3.7/zephyr; --zephyr-workspace or ZEPHYR_BASE names another)
When it finds none it stops and prints the west build line and where to run
it, rather than guess. nano-ros never writes into the west workspace.
When a change needs the application’s own CMakeLists.txt or prj.conf,
take the application over with nros materialize zephyr. That writes it to
src/zephyr_entry/, and nros build builds your copy from then on. Delete
the directory to return to the generated one. An application that owns its
west build and has no bringup at all is
A Zephyr app you build with west.
If it doesn’t work
<err> … executor open failed: Transport(ConnectionFailed): the image found no router. Both sides default totcp/127.0.0.1:7447; alocatorchanged on one side must change on the other.Could NOT find Python3 … required is at least "3.12": a 4.x workspace on an older Python. Runwestfrom a 3.12 environment.undefined symbol ETH_NATIVE_POSIX: 4.x renamed itETH_NATIVE_TAP; the board’s NSOS fragment handles it, so a conf file of your own should not set it.- Everything else: Troubleshoot.
Reference
- The
native_simboard’s support evidence. - The module’s Kconfig, every
CONFIG_NROS*symbol:zephyr/Kconfig. - Copy-out talkers:
examples/zephyr/, one per language. The other roles are thezephyr_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}.
ThreadX Linux simulator
Needs first: Run a talker on an emulated board, What you just built, Get started on the ThreadX Linux simulator
Status:
nros-board-threadx-linux: Verified on host (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a talker for
board = "threadx-linux", Eclipse ThreadX’s Linux port, and ran it as an
ordinary host process. This page covers what comes after it: the image’s
configuration, what is particular to the simulator, ThreadX’s sched
tasks, and the native build. The same node package runs on QEMU’s RISC-V
machine with one changed line; the ThreadX RISC-V 64 page
covers that board.
Configure the platform
The bringup’s src/tx_node_bringup/system.toml holds one image. With a
locator added, it reads:
[system]
name = "tx_node"
rmw = "zenoh"
domain_id = 0
[[component]]
pkg = "tx_node"
class = "tx_node::Talker"
name = "tx_node"
[image.threadx]
board = "threadx-linux"
locator = "tcp/127.0.0.1:9000"
locator is where the router is. With no locator, as scaffolded, the
image dials the board’s default, tcp/127.0.0.1:7447, and nros run
starts ROS’s rmw_zenohd on whichever port the image dials. To use a router
you already run, pass --router <its locator>.
The file is the same whatever the node’s language. A C node’s
CMakeLists.txt declares targets and nothing about the deployment, and its
package.xml carries no board. What the image does not state comes from the
board crate’s defaults; Configure an image
lists the keys and knobs.
Both ThreadX boards can be images of one bringup, so one workspace builds for the simulator and for QEMU:
[image.threadx_rv]
board = "rv-virt-threadx"
locator = "tcp/10.0.2.2:9400"
os_config = ["board-net.toml"] # [eth0] network = "qemu", host = 15
With two images, nros run tx_node no longer picks one, so name the image:
nros run threadx or nros run threadx_rv.
Board notes
- The kernel runs inside one Linux process. ThreadX’s threads are
scheduled by its Linux port inside that process, so the build is for your
host and has no cross-compiler or emulator. A Rust node’s entry is still
#![no_std]. - The network is the host’s. NetX Duo’s BSD socket layer
(
nx_bsd_*) sits on the host’s TCP stack, so the image reaches a router on loopback. - A veth pair is optional.
nros setup threadx-linuxcreates no network interface. Without one, the image uses the loopback path, which is all the starter needs. Bring up atap-tx0veth pair by hand (ip link add … type veth …) only when you need a separate host link. - The console is standard output.
- The upstream Linux port types
ULONGas 4 bytes, as NetX Duo expects, so this board needs none of the RISC-V 64 board’s architecture port.
Run sched tasks
ThreadX runs a workspace’s sched tasks: one executor per task, all sharing
one session, each with its own priority and a stack carved from ThreadX’s byte
pool. Declare a task’s ThreadX priority in a [tasks.<name>.threadx] table of
the bringup’s system.toml:
[tasks.control]
class = "real_time"
spin_period = "1000us"
[tasks.control.threadx]
priority = 8
[tasks.telemetry]
spin_period = "10000us"
[tasks.telemetry.threadx]
priority = 16
preempt_threshold = 10 # ThreadX only
time_slice = "5000us"
ThreadX priorities follow the kernel’s own convention: a lower number is a
higher priority. The generated entry boots the lowest-priority task first,
which then takes its declared priority. preempt_threshold and time_slice
are ThreadX’s own mechanisms and lower to nothing on other platforms.
Pick a scheduling model assigns
nodes to tasks and explains the classes.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run tx_node --dry-run --why
The target is a host process, its console is standard output, and its link
is the image’s locator on loopback. --why names where each fact came
from.
Drive the native build yourself
nros build writes the generated ThreadX entry under build/ and runs
cargo or CMake on it. Print the exact commands without building:
nros build --dry-run
To write the generated entry without building, for an IDE or a CI cache
step, run nros configure. Never edit what either command writes under
build/: the next build regenerates it.
If it doesn’t work
nros runstops at once and names the router:rmw_zenohdis not on the path, or another router holds the port. Source ROS 2, or stop the other router.- No
Publishing:line on a first run: a cold first build takes about 80 seconds before the first publish. - Everything else: Troubleshoot.
Reference
- The
threadx-linuxboard’s support evidence. - Copy-out talkers:
examples/threadx-linux/rust/talker/andexamples/threadx-linux/c/talker/. The listener, service and action are thethreadx_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}. - The board crate:
packages/boards/nros-board-threadx-linux/. - Scheduling wiring matrix: ThreadX’s priority levels beside the other platforms’.
Design background
FreeRTOS POSIX
Needs first: Run a talker on an emulated board, What you just built, Get started on FreeRTOS POSIX
Status:
nros-board-freertos-posix: Verified on host (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a C talker for
board = "freertos-posix" over Cyclone DDS and ran it: the FreeRTOS kernel,
through its POSIX port, as an ordinary Linux process. This page covers what comes after it: the
image’s configuration, what is particular to the simulator, moving a
workspace between it and the emulated Cortex-M3, and the native build.
Configure the platform
The bringup’s src/fp_node_bringup/system.toml holds one image. Its
[system] table and image read:
[system]
name = "fp_node"
rmw = "cyclonedds"
domain_id = 0
[image.freertos]
board = "freertos-posix"
The RMW comes from [system] rmw, and an image can override it with its own
rmw key. This board takes cyclonedds or zenoh. Cyclone DDS runs
inside the image’s process and finds its peers by multicast discovery on the
host’s network, so the image has no locator and nothing runs beside it.
With rmw = "zenoh" the image dials a zenoh router on the host, at
tcp/127.0.0.1:7447 unless the image sets a locator.
domain_id is the DDS domain, which ROS 2 calls ROS_DOMAIN_ID; a ROS 2
node on another domain does not see the talker.
Task stacks and priorities come from the board crate’s defaults.
Configure an image lists the keys and
knobs, and Pick a scheduling model
declares sched tasks with [tasks.<name>.freertos] priorities.
Board notes
- The kernel runs inside one Linux process. FreeRTOS’s POSIX port maps each task to a thread of that process and drives the tick from a host timer. Timing follows the host scheduler, so use this board to develop and test application logic, not to measure real-time behavior.
- The network is the host’s. The image uses the host’s sockets, so it finds its DDS peers, or its zenoh router, with no network setup and no root access.
- The console is standard output.
Move a workspace to the emulated board
The node package names no board, so the same C or C++ workspace builds for the mps2-an385 FreeRTOS board in QEMU. Add an image for it beside the first. That board’s starter runs zenoh, so the image names it, with the router it dials:
[image.freertos_qemu]
board = "mps2-an385-freertos"
rmw = "zenoh"
locator = "tcp/10.0.2.2:7447"
10.0.2.2 is QEMU’s gateway to the host. With two images, name the one you
run: nros run freertos or nros run freertos_qemu. The second board needs
its own provisioning, nros setup mps2-an385-freertos --rmw zenoh, and its
router listens on the host’s 0.0.0.0; FreeRTOS on
mps2-an385 covers it.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run fp_node --dry-run --why
The target is a host process and its console is standard output. --why
names where each fact came from.
Drive the native build yourself
nros build writes the generated FreeRTOS entry, the startup task that runs
your node, under build/, then runs CMake on it with the board’s toolchain
file. Print the exact commands without building:
nros build --dry-run
nros configure writes the generated entry without building, for an IDE or
a CI cache step. For a CMake tree that is not a nano-ros workspace, see
Build inside an existing CMake or vendor tree.
If it doesn’t work
nros runsays the router exited: another zenoh router already holds port 7447. Stop it;nros runstarts one for a zenoh image on this board.ros2 topic echoprints nothing: setRMW_IMPLEMENTATION=rmw_cyclonedds_cpp, and check that both sides use the same domain. A firewall that drops multicast also stops DDS discovery.- Everything else: Troubleshoot.
Reference
- The
freertos-posixboard’s support evidence. - The board crate:
packages/boards/nros-board-freertos-posix/. - Scheduling wiring matrix: FreeRTOS’s priority levels beside the other platforms’.
Bare-metal Cortex-M3
Needs first: Run a talker on an emulated board, What you just built, Get started on mps2-an385 in QEMU (bare-metal)
Status:
nros-board-mps2-an385: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a Rust
talker for board = "mps2-an385-baremetal", ran it in QEMU over the board’s
serial port, and heard it from ROS 2. This page covers what comes after it:
moving the image onto the board’s network, what is particular to a board with
no operating system, the run plan, and driving cargo yourself.
Use bare-metal for very constrained Cortex-M targets with no scheduler and no threads. If your target has FreeRTOS or another RTOS, the FreeRTOS on mps2-an385 page is the same board with a scheduler under your nodes.
Configure the platform
The whole deployment is the bringup’s system.toml, compiled into the image:
the generated entry folds the image’s network identity into the
configuration the board applies at boot. There is no configuration file on
the device and no .cargo/ to edit. The target triple, linker script,
--gc-sections flag, QEMU runner and the [patch.crates-io] rows that
resolve nano-ros’s crates all come from the board, and nros build writes
them under build/.
The starter’s image reaches the router over the board’s serial port, the
first link a real board’s program uses. To reach it over the board’s
ethernet instead, on QEMU’s user-mode network, give the image a TCP
locator and an address:
[image.baremetal]
board = "mps2-an385-baremetal"
locator = "tcp/10.0.2.2:10500"
os_config = ["board-net.toml"]
and the address, in a board network file beside system.toml in the
bringup:
[eth0]
network = "qemu"
host = 10
The board package owns the network device, so the device’s address lives in
the board’s own file, which the image names with os_config. 10.0.2.2 is
QEMU’s gateway to the host. With this locator, nros run bm_node starts
the router on the host’s port 10500 when it boots the image. If a zenoh
router of your own already listens on that port, nros run uses it instead
and says so; anything else on the port stops the run before it starts, naming
--router. Within
about 15 seconds of boot the zenoh session opens and the first
Publishing: line appears.
Changing board to "mps2-an385-freertos" and building again builds the
FreeRTOS image of the same node, with no other edit: the node package’s
Cargo.toml names no board crate, RMW backend or panic handler. Those are the
generated entry’s dependencies.
Board notes
- QEMU’s MPS2-AN385, a Cortex-M3. The board crate is
nros-board-mps2-an385, with no-freertossuffix: it carries the Cortex-M3 startup, the linker script, the LAN9118 ethernet driver for smoltcp and the idle wait (wfi). - One entry shape: direct execution. The generated entry runs your
executor in one loop on the reset path.
qemu-arm-baremetalis a retired spelling of the same board; usemps2-an385-baremetal. - A bounded, guarded main stack. The whole image runs on one stack at the
top of RAM, 256 KiB unless the image says otherwise. Below it sits a small
region the MPU blocks. A stack that grows past its size hits that region
and stops the image with
nros: stack overflow: the main stack grew past its stated size. Nothing below the stack is overwritten. Raise the size withNROS_BAREMETAL_STACK_KBin the image’s build environment. A size too big for the image’s statics fails the link, naming the same knob. A size below the image’s stack floor, a heuristic estimate of what nano-ros needs, fails the build with the value to set (A11). - No
allocby default. The build isno_stdwithheaplesscollections. To usealloc, enable the board crate’sallocfeature and supply a#[global_allocator]. - No preemption and no wake primitive. Callbacks run one at a time in the loop. A callback that runs long holds back every other callback until it returns.
- The console is semihosting, so QEMU prints the image’s output on your terminal.
- Nothing is flashed.
mps2-an385is a QEMU machine, andnros setupprovisions no probe or flash tooling for it. A real Cortex-M board is a board package of your own; Add a board takes an STM32F4-Discovery through it, and Flash a real board flashes the result.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run bm_node --dry-run --why
The parts that matter, trimmed, for the starter’s serial image:
[runner]
package = "nros_runner_qemu"
name = "qemu"
[target]
emulator = "qemu:mps2-an385"
[console]
kind = "semihosting"
[link]
kind = "serial"
locator = "serial/UART_0#baudrate=115200"
rmw = "zenoh"
host_peer = "zenoh-router"
--why adds where each fact came from. The emulator, the console and the
serial port are the board descriptor’s. The runner passes QEMU
-nic user,model=lan9118, which wires the guest’s LAN9118 to the user-mode
network; a QEMU line of your own that drops it (-nic none, -nodefaults)
leaves the guest with no network.
Drive cargo yourself
The first build cross-compiles nano-ros’s dependencies for
thumbv7m-none-eabi, about five minutes; later builds take seconds. To use
cargo directly from an IDE, a CI step or with --release, print the exact
cargo line nros build runs against the generated entry:
nros build --dry-run
nros configure writes the generated entry and its cargo settings without
building, before you open the workspace in an IDE. Both are regenerated on
every build: never edit them, and never add a .cargo/config.toml of your
own to carry board facts. Your own toolchain preferences go where cargo
already looks, a parent directory or $CARGO_HOME. See
When nros build drives the build.
If it doesn’t work
- No
Publishing:line over the network: another router holds thelocator’s port, or a QEMU line of your own dropped the NIC. - The talker stalls after you change it: a callback runs long, and nothing preempts it.
- Everything else: Troubleshoot.
Reference
- The
mps2-an385-baremetalboard’s support evidence. - Copy-out talker:
examples/mps2-an385-baremetal/rust/talker/. The other roles, the serial pair among them, are the bare-metal image rows ofexamples/workspaces/rust. - The board crate:
packages/boards/nros-board-mps2-an385/.
FreeRTOS on mps2-an385
Needs first: Run a talker on an emulated board, What you just built, Get started on mps2-an385 in QEMU (FreeRTOS)
Status:
nros-board-mps2-an385-freertos: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a Rust, C or C++
talker for board = "mps2-an385-freertos", FreeRTOS with the lwIP network
stack on QEMU’s Cortex-M3, and heard it from ROS 2. This page covers what
comes after it: the image’s network configuration, what is particular to the
board, waiting for a late router, the run plan, and the native build. The same
kernel runs as a Linux process on the FreeRTOS POSIX
board, for Rust, C and C++ nodes.
Configure the platform
Board, RMW, domain and network identity are declared in the bringup’s
system.toml and compiled into the image: there is no configuration file on
the device. With a locator and an address added, the image reads:
[image.freertos]
board = "mps2-an385-freertos"
locator = "tcp/10.0.2.2:7800"
os_config = ["board-net.toml"]
and board-net.toml, beside system.toml in the bringup:
[eth0]
network = "qemu"
host = 15
locator is where the router is. The guest reaches the host’s router
through QEMU’s gateway, 10.0.2.2, and QEMU forwards the guest’s
10.0.2.2:<port> to the host’s port. The image above dials port 7800, so
start the router as the starter did with its listen/endpoints port changed
to 7800. With no locator, as scaffolded, the image dials
tcp/10.0.2.2:7447. The file is the same whatever language the node is
written in: nothing about the deployment lives in Cargo.toml,
CMakeLists.txt or package.xml.
Switching board is editing the image’s board and building again.
nros build picks the cross-toolchain file the board names, and the
generated entry brings the board crate, its RMW and the FreeRTOS platform
layer. Changing board to "mps2-an385-baremetal" builds the same Rust node
with no RTOS.
Task stacks and priorities come from the board crate’s defaults.
Configure an image lists the keys, and
Pick a scheduling model declares
sched tasks with [tasks.<name>.freertos] priorities, where a larger number
is more urgent.
Wait for a late router
A FreeRTOS image tries once to open its session and stops with
Failed to open session when no router answers, so the starter starts the
router first. An image that should wait for a router started later, as on a
bench where the board powers up first, sets a knob:
[image.freertos.knobs.zenoh]
connect_forever = true # or connect_timeout_ms = 30000 for a bounded wait
Board notes
- QEMU’s MPS2-AN385, a Cortex-M3, with FreeRTOS and lwIP. The board crate,
nros-board-mps2-an385-freertos, builds the kernel, lwIP and the LAN9118 driver. The generated entry, the FreeRTOS startup task that runs your node, depends on it, so nothing you write names it. - Rust, C and C++. The Rust side’s triple (
thumbv7m-none-eabi), link group, QEMU runner and[patch.crates-io]rows are the board’s, written underbuild/. A C or C++ node package names no board in itsCMakeLists.txt. - QEMU’s user-mode network, no TAP. The
10.0.2.0/24subnet and its gateway10.0.2.2are QEMU’s own, so the board needs no root access and no host bridge. - The console is semihosting, printed on your terminal by QEMU.
- Nothing is flashed. No in-tree FreeRTOS board is flashed by a documented flow. A FreeRTOS board of your own is a board package on the FreeRTOS family crate, flashed with its vendor’s tools; see Add a board and Flash a real board.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run fr_node --dry-run --why
The plan names the QEMU runner and the qemu:mps2-an385 machine, the
semihosting console, and the link to the router at the image’s locator.
--why names where each fact came from.
Drive the native build yourself
The first build cross-compiles nano-ros’s dependencies, the FreeRTOS kernel and lwIP: about three minutes for C or C++, five for Rust. Print the exact cargo or CMake commands without building:
nros build --dry-run
nros configure writes the generated entry without building, for an IDE or
a CI cache step. Never edit what either command writes under build/. For a
CMake tree that is not a nano-ros workspace, see
Build inside an existing CMake or vendor tree.
If it doesn’t work
Failed to open session: no router answered on the host’s0.0.0.0at thelocator’s port. Start it first, or setconnect_forever.- The router runs and the image never connects: the router listens on
127.0.0.1, which the guest cannot reach. - Everything else: Troubleshoot.
Reference
- The
mps2-an385-freertosboard’s support evidence. - Copy-out talkers, one per language:
examples/mps2-an385-freertos/. The listener, service and action are thefreertos_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}. - Scheduling wiring matrix.
Design background
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI.
Zephyr on mps2-an385
Needs first: Run a talker on an emulated board, What you just built, Get started on mps2-an385 in QEMU (Zephyr)
Status:
nros-board-mps2-an385-zephyr: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starter made a west workspace for
Zephyr 3.7, scaffolded a Rust talker for board = "mps2-an385-zephyr",
Zephyr’s mps2/an385 Cortex-M3 under QEMU, and heard it from ROS 2. This
page covers what comes after it: what is particular to the board, naming a
Zephyr board nano-ros does not ship, extending the build the Zephyr way, and
reading the run plan. Where an image’s nano-ros and Zephyr settings go, one
image per RMW, and nros build’s hand-off to west are the same on every
Zephyr board; the Zephyr native_sim page covers
them.
Configure the platform
The board’s own configuration puts the image on QEMU’s user-mode network:
its prj.conf gives the guest 10.0.2.15, with gateway 10.0.2.2, and the
locator tcp/10.0.2.2:7447. nros build applies it, so a scaffolded image
states nothing. The gateway is your host, so a router listening on the
host’s 0.0.0.0:7447 is reachable, as the starter’s was. An image whose
router listens elsewhere states its own locator:
[image.zephyr]
board = "mps2-an385-zephyr"
locator = "tcp/10.0.2.2:7800"
The image’s other nano-ros settings (rmw, knobs, os_config fragments)
are the same keys as on every Zephyr board; see
Configure the platform.
Board notes
- Zephyr’s
mps2/an385under QEMU. The image uses Zephyr’s own IP stack on the emulated SMSC911x ethernet.nros runboots it under the QEMU the Zephyr SDK ships,qemu:mps2-an385. - The west workspace needs nano-ros’s patches for this board.
nros setup board mps2-an385-zephyr --zephyr-workspace <ws>applies them and adds the board’s Rust target. Without them, zephyr-lang-rust’s cargo command carries none of nano-ros’s settings for the board, among them the C cross compiler the zenoh-pico crate builds with, and a Rust image fails to build. - Readiness. Expect the first
Publishing:line within about 15 seconds of boot: a cold QEMU boot and Zephyr’s start-up come first. - Nothing is flashed.
mps2/an385is a QEMU machine. A Zephyr board you can hold, with a twin that boots the same image, is the Nucleo-F767ZI.
Name a Zephyr board nano-ros does not ship
An image’s board names a board in nano-ros’s catalog, and the board’s
descriptor states the Zephyr id west build -b receives. So an image writes
board = "mps2-an385-zephyr", never board = "mps2/an385": an image that
names a Zephyr id is refused with the id to write instead. A board the
catalog does not know is refused with the list of ones it does, because the
descriptor supplies more than the -b string: the platform, the toolchain
and the entry kind.
A board is a package. Put an nros-board.toml beside a package’s
package.xml in your workspace, and it joins the catalog:
# src/my_board/nros-board.toml
[[board]]
names = ["my-board"] # what your images say
west_board = "qemu_cortex_m3" # what west is given
platform = "zephyr"
toolchain = "stable"
platform_feature = "platform-zephyr"
link_kind = "none"
entry_kind = "zephyr-staticlib"
Then an image names it, board = "my-board", and builds for it. For a
board shared by several workspaces, list directories shaped like
packages/boards/ in $NROS_EXTRA_BOARD_PATH. nros new board <name> --for-platform zephyr scaffolds the descriptor. That is nano-ros’s
descriptor only: an out-of-tree Zephyr board definition (its devicetree and
board.yml) comes in the Zephyr way, through your module’s board_root.
Add a board takes a board through the
rest, and Flash a real board flashes it.
Extend the build the Zephyr way
nros build runs a plain west build, so every Zephyr extension point is
untouched. The second row edits the application’s CMakeLists.txt, so it
needs an application you own (nros materialize <image>); the rest do not:
| You want | You do |
|---|---|
| your own Kconfig symbols, defined by a workspace package | a zephyr/module.yml in that package; see below |
| a module from outside the workspace | list(APPEND ZEPHYR_EXTRA_MODULES <dir>) before find_package(Zephyr) |
| a driver in that module | zephyr_library() and zephyr_library_sources(), behind your own Kconfig |
| its devicetree binding | dts/bindings/, with settings: {dts_root: .} in the module’s zephyr/module.yml |
| an out-of-tree board, SoC or snippet | the matching board_root, soc_root or snippet_root in that module.yml |
| your Kconfig on for one image | a .conf fragment in the image’s os_config, passed as EXTRA_CONF_FILE |
| a devicetree overlay for one image | an .overlay in the same list, passed as EXTRA_DTC_OVERLAY_FILE |
Only the last two rows are nano-ros’s, and they are how an image differs from its siblings:
[image.zephyr]
board = "mps2-an385-zephyr"
os_config = ["prj-user-extra.conf", "user-widget.overlay"]
There is no image key for arbitrary -D defines: something the
application always needs belongs in its CMakeLists.txt. A mistake in your
module surfaces as Zephyr’s own error, unchanged, because the build is a
plain west build.
A workspace package that is a Zephyr module
An os_config fragment assigns Kconfig symbols, but it cannot define one:
Kconfig refuses CONFIG_MY_MODE=y for a symbol nothing declares. The
package that reads the symbols defines them, as a Zephyr module. Give it a
zephyr/module.yml:
# src/my_support/zephyr/module.yml
name: my_support
build:
kconfig: zephyr/Kconfig
and the definitions in src/my_support/zephyr/Kconfig, in Zephyr’s own
syntax:
# src/my_support/zephyr/Kconfig
config MY_MODE
bool "Turn on my_support's mode"
help
Read by my_support at build time.
The image’s fragment then sets it, as for any Zephyr symbol:
# prj-user-extra.conf, named in the image's os_config
CONFIG_MY_MODE=y
When a node package of the image <depend>s on my_support,
directly or through other workspace packages, nros build adds it to
ZEPHYR_EXTRA_MODULES in the application it generates, or on the west build line of an entry you own, so its symbols are defined and the image’s
os_config fragment can set them.
Who builds the package’s CMakeLists.txt depends on the module’s
build: cmake: key:
- No
cmake:key, as above: the module only defines Kconfig symbols. The generated application adds the package withadd_subdirectory, as it adds every workspace package the image depends on, not only the node packages the launch file names. cmake: .: Zephyr builds the package’s ownCMakeLists.txtas the module, so the application does not add it a second time.cmake: <another directory>: Zephyr builds that directory as the module, and the application still adds the package’s ownCMakeLists.txt.
The same package works unchanged in an application you build with west
yourself.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run zm_node --dry-run --why
The plan names the QEMU runner and the qemu:mps2-an385 machine, the
console, and the link to the router the board’s configuration names.
--why names where each fact came from.
Drive west yourself
Print the west build line nros build runs, with the image’s overlays,
without building:
nros build --dry-run
Drive west yourself explains what goes to west and what is refused.
C++ applications
A Zephyr application reaches the C++ API through the nano-ros Zephyr module.
The module, the image’s system.toml and the prj.conf split are covered
above, in Configure the platform; the RMW,
locator and domain come from the image, never from CONFIG_NROS_* lines in
prj.conf. The C++ side needs CONFIG_CPP=y and CONFIG_STD_CPP14=y in
prj.conf (Zephyr’s own settings), and the application’s CMakeLists.txt
generates the message bindings:
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(my_app LANGUAGES CXX)
nros_generate_interfaces(std_msgs LANGUAGE CPP)
target_sources(app PRIVATE src/main.cpp)
A minimal main() waits for the network, opens the session with the locator
and domain the image rendered into Kconfig, and spins:
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <nros/platform_zephyr.h>
#include <rclcpp/rclcpp.hpp>
#include "std_msgs.hpp"
LOG_MODULE_REGISTER(my_app, LOG_LEVEL_INF);
int main(void)
{
nros_platform_zephyr_wait_network(CONFIG_NROS_INIT_DELAY_MS);
rclcpp::Result ret =
rclcpp::init_in(CONFIG_NROS_LOCATOR, CONFIG_NROS_DOMAIN_ID);
if (!ret.ok()) return 1;
rclcpp::Node node;
if (!rclcpp::create_node(node, "my_node").ok()) return 1;
// ... create publishers, subscriptions, etc.
while (true) {
rclcpp::spin_once(100);
}
}
nros_platform_zephyr_wait_network (<nros/platform_zephyr.h>) is defined
in every Zephyr image. On an image with no IP stack (CONFIG_NET_SOCKETS off,
for example a serial-only zenoh image) it returns 0 at once, so the call needs
no guard. CONFIG_NROS_INIT_DELAY_MS is the module’s start-up delay; your
main() is its only reader.
If it doesn’t work
- Confirm the router listens on the host’s
0.0.0.0at the image’s port. A router on127.0.0.1is unreachable from the guest. - A Rust image that fails to build naming its C compiler or target: run
nros setup board mps2-an385-zephyr --zephyr-workspace <ws>again. - No
Publishing:line within 30 seconds of boot: check the console for the network coming up, then Troubleshoot.
Reference
- The
mps2-an385-zephyrboard’s support evidence. - The Zephyr module, its manifest and its Kconfig:
zephyr/. - Copy-out talkers:
examples/zephyr/.
Design background
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI.
NuttX Arm and RISC-V
Needs first: Run a talker on an emulated board, What you just built, Get started on NuttX in QEMU (Arm) or (RISC-V)
Status:
nros-board-nuttx-qemu(NuttxArm): Verified in emulator (daily);nros-board-nuttx-qemu(NuttxRiscv): Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starters scaffolded a talker for board = "qemu-armv7a-nuttx" (QEMU’s
Arm virt machine) or board = "rv-virt-nuttx" (QEMU’s RISC-V rv-virt),
linked it into a bootable NuttX kernel with nros build, and heard it from
ROS 2. This page covers what comes after them: the image’s configuration,
what is particular to each board, adding nano-ros to a NuttX tree you build
with NuttX’s own make, and the native build.
Configure the platform
Your application’s deployment (board, RMW, domain and an optional
locator) is the bringup’s system.toml, compiled into the image. With a
locator added, the image reads:
[image.nuttx]
board = "qemu-armv7a-nuttx"
locator = "tcp/10.0.2.2:8200"
The file is the same whatever language the node is written in, and nothing
in it names a target triple: armv7a-nuttx-eabihf is a fact about the
board, and the board’s descriptor states it. The guest’s network comes from
the board as well: eth0 at 10.0.2.15, with QEMU’s gateway 10.0.2.2.
With no locator, as scaffolded, the image dials tcp/10.0.2.2:7447. Start
the router as the starter did, listening on the host’s 0.0.0.0 at the port
the image dials (8200 here); the guest cannot reach a router on 127.0.0.1.
An image for the other board sits beside the first in the same bringup:
[image.nuttx_rv]
board = "rv-virt-nuttx"
With two images, name the one you run: nros run nuttx or
nros run nuttx_rv.
Board notes
qemu-armv7a-nuttx: QEMU’s Armvirt, with a virtio-net device on QEMU’s user-mode network.nros runboots the kernel with the store’sqemu-system-armand-icount shift=auto.rv-virt-nuttx: QEMU’s RISC-Vvirt, a 32-bitrv32imaccore. The store’s QEMU is built for Arm and RISC-V 64 only, so this board needs aqemu-system-riscv32from your distribution (Debian and Ubuntu:qemu-system-misc), named withQEMU_SYSTEM_RISCV32. A Rust node builds for the board’sriscv32imac-unknown-nuttx-elftarget withbuild-std.- C is the runtime-checked language; read the board’s support page for what its Rust and C++ rows show.
- A Rust node needs a configured kernel. For one,
nros buildfirst configures and exports the NuttX kernel from the board’s config (a current export is a no-op), then builds the entry with the board’s pinned nightly toolchain. The configure is NuttX’s owntools/configure.sh, which needs the kconfig-frontends tools;nros setup <board> --sudoinstalls them. - The console is the NSH console. A
nros buildimage runs your node at boot. The readiness signal is the firstPublishing: 'Hello World: 1', within about six seconds of boot. - No NuttX hardware board ships. On real hardware the image is an
ordinary NuttX application, built with that board’s
BOARD_CONFIGand flashed as NuttX’s documentation for the board says; see Flash a real board.
Add nano-ros to a NuttX tree you build with make
When your NuttX board ships its own kernel build, nano-ros joins it as an
external application under apps/external/nano-ros/, with its Kconfig
options under Application Configuration › External Modules › nano-ros.
This road needs a NuttX 12 or later checkout of your own, with an apps/
tree beside it ($NUTTX_DIR, $NUTTX_APPS_DIR). In that tree, NuttX owns the
build verb, make, the way Zephyr owns west build:
-
Provision the board, then stage the integration shell into your apps tree once:
"$(nros locate nano-ros)/scripts/nuttx/stage-external-apps.sh" "$NUTTX_APPS_DIR". It writesexternal/Make.defs,KconfigandMakefile, and links the shell in asexternal/nano-ros. Remove$NUTTX_APPS_DIR/Kconfigso NuttX rediscoversapps/external/Kconfig. Run the same command again after you update nano-ros. TheMakefileis what letsmake cleanandmake distcleanclean the external apps; in a tree staged without it, the build after amake distcleanfails to link, and every build prints a line naming this command. -
Bring the symbols nano-ros needs into your configuration. Stock
qemu-armv7a/nshhas noCONFIG_NET, no virtio-net and noTLS_NELEM. With no configuration of your own, configure from the board’s config,packages/boards/nros-board-nuttx-qemu/nuttx-config/arm/defconfig. It#includes upstream’sqemu-armv7a:nshand lists only what differs, so NuttX’s owntools/configure.shmust expand it; copying it to.configdoes not work. Put it in a directory beside a link toboards/arm/qemu/qemu-armv7a/scripts/Make.defs, and pass that directory totools/configure.sh -a <apps dir, relative to the kernel>. configure.sh runskconfig-tweak, so it needs the kconfig-frontends tools (Debian and Ubuntu:kconfig-frontends-nox). With a vendor defconfig, merge the requirements into it instead:CONFIG_NET=y,CONFIG_NET_TCP=y,CONFIG_NET_IPv4=y, the virtio-net options,CONFIG_TLS_NELEM=8,CONFIG_LIBCXXTOOLCHAIN=yandCONFIG_ALLSYMS=n. Then runmake olddefconfig. -
Enable nano-ros in
make menuconfig, or withkconfig-tweakfrom thekconfig-frontendspackage:NROS, the API you use (NROS_C_API,NROS_CPP_API), and the RMW. These options decide what the shell compiles intolibnros_c.a. The board’s config startsnros_nuttx_entry, the entry anros buildimage defines. A make-built kernel that boots NSH setsCONFIG_INIT_ENTRYPOINT="nsh_main"back (kconfig-tweak --set-str CONFIG_INIT_ENTRYPOINT nsh_main). -
Name your project, if the app has one. In your app’s own
Make.defs, beside itsCONFIGURED_APPS +=line:NROS_PROJECTS += $(APPDIR)/external/<app> NROS_IMAGE := <bringup>:<image> # only if several images could matchmakethen runsnros configureon that project, so the generated message bindings exist before anything compiles against them, and builds the image’s own settings into the app. It stops, saying which, when the image’s board, RMW or ROS edition disagrees with the kernel’s configuration from step 3. One NuttX build takes one project. With no project named, the shell builds from your Kconfig choices alone. -
Build the kernel with
makein$NUTTX_DIR. The Rust static libraries build as a sub-step of the app build, and the kernel ELF is$NUTTX_DIR/nuttx.
A kernel built this way boots to the NSH prompt. Run your app by its
program name there, for example nsh> nuttx_c_talker: the build registers
each app as an NSH built-in command. Several apps each declare their own
program name and share the one libnros_c.a.
The staging script stages the shell only. A bringup with several components
is built with nros build and an [image.<id>], as in
examples/workspaces/rust.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run nx_node --dry-run --why
The plan names the QEMU runner and the board’s machine, the console, and the
link to the router at the image’s locator. --why names where each fact
came from.
Drive the native build yourself
Print the exact commands nros build runs, and the QEMU line that boots the
kernel, without building:
nros build --dry-run
The same QEMU line boots a kernel you built with make. nros configure
writes the generated entry without building.
If it doesn’t work
If no Publishing: line appears:
- Confirm the app ran:
psat the NSH prompt shows its task. - Confirm the network:
ifconfigshowseth0at10.0.2.15. - Confirm the router listens on the host’s
0.0.0.0at the port the image’slocatornames. - On RISC-V, confirm
QEMU_SYSTEM_RISCV32names aqemu-system-riscv32.
For DDS on NuttX, raise the network buffer options in the kernel configuration. Everything else: Troubleshoot.
Reference
- The boards’ support pages:
qemu-armv7a-nuttx,rv-virt-nuttx. - The integration shell and its Kconfig:
integrations/nuttx/. - Copy-out talkers, one per language:
examples/qemu-armv7a-nuttx/. The other roles are thenuttx_*andriscv_nuttx_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}.
Design background
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI.
ThreadX RISC-V 64
Needs first: Run a talker on an emulated board, What you just built, Get started on ThreadX in QEMU (RISC-V 64)
Status:
nros-board-threadx-qemu-riscv64: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a talker for
board = "rv-virt-threadx", Eclipse ThreadX with its NetX Duo TCP/IP stack
on QEMU’s RISC-V 64 virt machine, and heard it from ROS 2. This page covers
what comes after it: the image’s network configuration, what is particular to
this board and its architecture port, and the native build. Sched tasks are
declared the same way on both ThreadX boards; the
ThreadX Linux simulator page shows them.
Configure the platform
The guest boots behind QEMU’s user-mode network, so its image states the router’s address as the guest sees it and names a board network file for its own address:
[image.threadx]
board = "rv-virt-threadx"
locator = "tcp/10.0.2.2:9400"
os_config = ["board-net.toml"]
and board-net.toml, beside system.toml in the bringup:
[eth0]
network = "qemu"
host = 15
10.0.2.2 is QEMU’s gateway, which forwards to the host, so a router
listening on the host’s 0.0.0.0 at the locator’s port is reachable. An
image that states no address gets QEMU’s first guest address, 10.0.2.15;
host = N picks 10.0.2.N. With no locator, as scaffolded, the image
dials tcp/10.0.2.2:7447. Start the router as the starter did, with its
listen/endpoints port changed to the one the image dials (9400 here).
The node package does not change between this board and the
Linux simulator: only the image’s board line and its
network keys do, and one bringup can hold an image for each.
Board notes
- QEMU’s
virtmachine, a 64-bit RISC-V core. The UART is on standard input and output, and the network is a virtio-net device on QEMU’s user-mode network.nros setup rv-virt-threadxfetches the RISC-V 64 cross-compiler andqemu-system-riscv64. - Three ThreadX packages in three layers.
nros-board-threadxis the family driver (the kernel and NetX Duo build, and the boot path both boards call).nros-board-threadx-port-riscv64is the architecture port.nros-board-threadx-qemu-riscv64is the board overlay: defaults, console, exit, panic and network bring-up. The generated entry depends on the board crate, so nothing you write names any of them. - Why the architecture port exists. Upstream’s RISC-V 64 port types
ULONGas 8 bytes, and NetX Duo’s packet code assumes 4. nano-ros retypes it tounsigned int, as upstream’s own Linux and AArch64 ports do, and that shifts the offsets the port’s context-switch assembly loads, so the assembly is forked with it. A second RISC-V 64 ThreadX board reuses the port unchanged and writes only an overlay; see Add a board. - Search the port’s
inc/first if you build ThreadX outsidenros build, before$THREADX_DIR/ports/risc-v64/gnu/inc. In the wrong order the build succeeds against the 8-byteULONGand packets corrupt at run time. A_Static_assert(sizeof(ULONG) == 4, …)in the board’s hooks turns the mistake into a build failure. - The app thread’s stack is 512 KiB. Change it with
NROS_MEMORY_APP_STACK_BYTES=<bytes>in the build environment, or with[image.<id>.knobs.memory] app_stack_bytes = <bytes>insystem.toml. Both reach a cargo image. A CMake image keeps 512 KiB. A sched task declared with nostack_bytesgets the same size. - No physical ThreadX board ships. A vendor board (Renesas Synergy, i.MX RT and others) is a board package of your own on the family crate, flashed with that vendor’s tools; see Flash a real board.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run tx_node --dry-run --why
The plan names the QEMU runner and the qemu:rv-virt machine, the console on
the guest’s UART, and the link to the router at the image’s locator.
--why names where each fact came from, the board’s descriptor for most of
them.
Drive the native build yourself
The first build compiles ThreadX and NetX Duo, about three minutes; later builds take seconds. Print the exact cargo or CMake commands, and the QEMU line the run uses, without building:
nros build --dry-run
nros configure writes the generated entry without building. Neither
command’s output under build/ is yours to edit.
Multi-sched-task scheduling
ThreadX supports the multi-sched-task workspace scheduling model: declare per-sched-task ThreadX priorities in the bringup’s
system.toml with [tasks.<name>.threadx] priority tables, and
the generated entry routes the app onto run_sched_tasks — one executor per
sched task, all sharing one session, with per-sched-task stacks carved from the
ThreadX byte pool. ThreadX priorities follow the native convention:
lower number = higher priority. Sched tasks are sorted descending by
raw priority number, so sched_tasks[0] (the numerically-largest, i.e.
lowest-priority sched task) boots first and then adopts its declared
priority. See Scheduling Models
for the mechanics.
If it doesn’t work
- The image boots and never publishes: no router on the host’s
0.0.0.0at thelocator’s port. A router on127.0.0.1is unreachable from the guest. - Corrupted packets in a ThreadX build of your own: the include order above.
- Everything else: Troubleshoot.
Reference
- The
rv-virt-threadxboard’s support evidence. - Copy-out talker:
examples/rv-virt-threadx/rust/talker/. The other roles are theriscv_threadx_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}. - The board crate:
packages/boards/nros-board-threadx-qemu-riscv64/.
Design background
Nucleo-F767ZI
Needs first: Run a talker on an emulated board, What you just built, Get started on the Nucleo-F767ZI
Status:
nros-board-nucleo-f767zi-zephyr: Boots, manual (2026-11-01); reads Builds from 2027-03-02. From the board support registry; Board Support Levels explains the words. The image runs in the board’s twin,renode:nucleo_f767zi, and on the board,nucleo-f767zi.
The starter scaffolded a C talker for
board = "nucleo-f767zi-zephyr", ran it in the board’s Renode twin over the
serial link, and flashed the same image to an ST Nucleo-F767ZI. This page
covers what comes after it: the image’s link and RAM budget, what is
particular to the board and its twin, and what the board does not do yet.
Zephyr’s own configuration (system.toml against prj.conf, one image per
RMW, driving west) is the same on every Zephyr board; the
Zephyr native_sim page covers it.
Configure the platform
The starter’s image reaches the router over USART3, the UART the board’s ST-LINK carries to your USB port as a virtual COM port:
[image.zephyr]
board = "nucleo-f767zi-zephyr"
locator = "serial/serial@40004800#baudrate=115200"
serial@40004800 is Zephyr’s devicetree name for USART3. The board’s own
configuration turns Zephyr’s IP stack off for this image and gives USART3 to
zenoh, so the serial image needs no prj.conf of yours. In the twin,
nros run connects USART3 to a terminal device on your host and starts the
router on it; on the board, nros flash --monitor starts the router on the
ST-LINK’s USB serial device instead.
Fit an image in the board’s RAM
The STM32F767ZI has 384 KiB of main SRAM, and nano-ros’s default pools do not fit it. The board’s descriptor states the one setting every image on this RAM needs, and each image inherits it:
# the board's descriptor, inherited by every image
[knobs.zenoh]
max_large_subscribers = 0
An image that needs a different budget states the knob itself, and the image wins:
[image.zephyr.knobs.zenoh]
max_subscribers = 2
Graph discovery is off on this board’s serial link by default: a host domain’s liveliness tokens would arrive over the UART. An image that makes its own graph queries turns it on, with a cache sized to the domain:
[image.zephyr.knobs.zenoh]
graph_discovery = true
graph_cache_bytes = 8192
The stock Rust talker builds and runs with these two lines. Its link uses 327,168 B of the 384 KiB, about 64 KiB left; the 8 KiB cache costs about 8 KiB of that.
Never set these in prj.conf: a CONFIG_NROS_* line there is a configure
error. Measure static memory reads
an image’s boot report, so you can see how much room a change leaves.
Board notes
- STM32F767ZI, a Cortex-M7 with a double-precision FPU, 2 MiB of flash,
384 KiB of main SRAM and 128 KiB of DTCM, on Zephyr 3.7. The west
workspace needs Zephyr’s
hal_stm32module, andnros setup board nucleo-f767zi-zephyr --zephyr-workspace <ws>applies nano-ros’s patches to it and adds thethumbv7em-none-eabiRust target. The image is soft-float: Zephyr’s board configuration leavesCONFIG_FPUoff. - The twin boots the same ELF. Renode’s
nucleo_f767zimachine runs the image you flash, with USART3 on a host terminal device. A twin result predicts the board result for the parts the twin models. - The console is USART6, on the Arduino header’s D0 and D1 pins, so the ST-LINK cable carries only the zenoh link. Reading the console on the bench takes a USB-to-UART adapter on those pins.
- Flashing is Zephyr’s own runner for the board, OpenOCD over the
ST-LINK. Flash a real board covers
nros flash,nros monitorand naming the port. - The status above is a dated manual check. Someone booted the image in the twin by hand on that date. After the registry’s stale period the word reads Builds until someone boots it again.
Ethernet is not set up yet
The board’s on-chip ethernet MAC works in the twin with Zephyr’s
eth_stm32_hal driver: an early run reached a router over tcp/. That run
needed a host tap device bridged to Renode’s virtual switch, which takes
CAP_NET_ADMIN, and nros run does not set one up. An ethernet image also
needs Zephyr’s IP stack back on and a tighter RAM budget than the serial
image, and its boot report is not yet measured, so neither the starter nor
this page documents one. Use the serial link. WiFi is not available on this
board.
If it doesn’t work
- The twin boots and the router never hears the board: the image’s
locatornames another UART. It must be USART3,serial@40004800. - The build stops on RAM: an image knob raised a pool past the board’s budget. Lower it, or remove the image’s override.
- On the bench, nothing on the console: the console is USART6 on the header pins, not the USB cable.
- Everything else: Troubleshoot.
Reference
- The board’s support evidence: its status, twin and breadth.
- The board package and its descriptor:
packages/boards/nros-board-nucleo-f767zi-zephyr/. - Flash a real board: every board’s hardware row.
Design background
A Zephyr app you build with west
Needs first: Run a talker on an emulated board, What you just built, Get started on Zephyr native_sim
Use this page to add a ROS 2 talker to a Zephyr application you already build
with west build, run it on native_sim against a ROS 2 router, and build the
same application for a real board. The application keeps its own
CMakeLists.txt and prj.conf; nano-ros joins it as one more Zephyr module.
The steps run on the native_sim board; its status is on
its support evidence.
Before you start
Choose this road when the Zephyr application already exists, owns its build,
and has its own drivers, devicetree and prj.conf, and you want west build
and west flash to stay the commands you type. It has no bringup and no
system.toml: nano-ros reads everything about the image from prj.conf, as
any Zephyr module does. For a new project, or one that will grow past one
node, use a nano-ros workspace instead, where nros build writes the Zephyr
application for you: Zephyr native_sim.
You need a Linux host with ROS 2 and ros-<distro>-rmw-zenoh-cpp
(which edition), the
install done, and Zephyr’s host tools, west and
the build tools
Zephyr’s Getting Started
lists. On Debian or Ubuntu:
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
device-tree-compiler python3-pip python3-venv xz-utils file wget clang
pip3 install --user west
export PATH="$HOME/.local/bin:$PATH"
Set up the west workspace
Provision the Zephyr SDK and the zenoh sources nano-ros compiles, and point
Zephyr at that SDK. If your workspace already builds with a Zephyr SDK of its
own, set ZEPHYR_SDK_INSTALL_DIR to that one instead:
nros setup zephyr --rmw zenoh
export ZEPHYR_SDK_INSTALL_DIR="$(nros locate tool zephyr-sdk)"
If you already have a west workspace, skip the next block. This one pins
Zephyr 3.7 and fetches only the modules nano-ros’s boards use. Its last
project, zephyr-lang-rust, is Zephyr’s Rust support; leave it out if you
write no Rust application:
mkdir -p my_zephyr_ws/manifest && cd my_zephyr_ws
manifest/west.ymlmanifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v3.7.2
import:
name-allowlist: [cmsis, picolibc, mbedtls, tinycrypt, mcuboot, net-tools]
- name: zephyr-lang-rust
remote: zephyrproject-rtos
revision: 404fcefdbab0f2711cd342a1fab9d2eda52a1ba9
path: modules/lang/rust
self:
path: manifest
west init -l manifest
west update --narrow -o=--depth=1
pip3 install --user -r zephyr/scripts/requirements-base.txt
export ZEPHYR_BASE="$PWD/zephyr"
Add nano-ros to the build
nano-ros’s Zephyr module ships inside your nano-ros install, and
nros locate nano-ros prints the directory that holds it. Hand that directory
to west as an extra module, on the build line after --:
-DZEPHYR_EXTRA_MODULES="$(nros locate nano-ros)", as the
Build step does. Nothing is added to west.yml and nothing is
cloned. To avoid typing the option, ask for the path once in the application’s
CMakeLists.txt, before find_package(Zephyr):
execute_process(COMMAND nros locate nano-ros
OUTPUT_VARIABLE NROS_MODULE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)
list(APPEND ZEPHYR_EXTRA_MODULES "${NROS_MODULE_DIR}")
Write the application
The application is a stock Zephyr application under apps/my_app/: its build
file, package.xml (the message packages the node uses), prj.conf and the
node source. The talker publishes a counter as std_msgs/Int32 on /chatter
once a second.
In C and C++ the node is a component: a struct or class that holds its
state, and a configure function that creates its publishers and timers. You
write no main(): the module generates the entry point, which opens the RMW
session, creates the node and executor, calls configure, and spins. In Rust
the node is a nano-ros Rust component, built by zephyr-lang-rust.
mkdir -p apps/my_app/src
apps/my_app/src/Talker.c#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <rclc/rclc.h>
#include <std_msgs/std_msgs.h>
typedef struct {
rcl_publisher_t pub;
rcl_timer_t timer;
int32_t count;
} talker_t;
static void on_tick(rcl_timer_t* timer, int64_t last_call_time) {
talker_t* self = RCLC_CONTAINER_OF(timer, talker_t, timer);
(void)last_call_time;
std_msgs__msg__Int32 msg = {.data = self->count};
if (rcl_publish(&self->pub, &msg, NULL) == RCL_RET_OK) {
printf("Published: %d\n", (int)self->count);
}
self->count++;
}
static rcl_ret_t talker_configure(rcl_node_t* node, rclc_executor_t* executor,
talker_t* self) {
setvbuf(stdout, NULL, _IONBF, 0);
self->count = 0;
self->pub = rcl_get_zero_initialized_publisher();
rcl_ret_t rc = rclc_publisher_init_default(
&self->pub, node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
"/chatter");
if (rc != RCL_RET_OK) {
return rc;
}
self->timer = rcl_get_zero_initialized_timer();
rc = rclc_timer_init_default(&self->timer, NULL, 1000ULL * 1000000ULL,
on_tick);
if (rc != RCL_RET_OK) {
return rc;
}
return rclc_executor_add_timer(executor, &self->timer);
}
RCLC_C_COMPONENT(talker_t, talker_configure)
RCLC_C_COMPONENT registers the struct and its configure function with the
generated entry point; the rest is the ROS 2 rclc API. The build file:
apps/my_app/CMakeLists.txtcmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(my_app)
find_package(nano_ros REQUIRED)
find_package(std_msgs REQUIRED)
nano_ros_auto_add_library(talker_lib STATIC src/Talker.c)
nros_components_register_node(talker_lib
PLUGIN my_app::Talker
EXECUTABLE talker
SHAPE configure
TYPED
DEPLOY zephyr)
find_package(nano_ros) and find_package(std_msgs) come from the module.
nros_components_register_node(... DEPLOY zephyr) registers the component,
and makes the module generate the entry point into Zephyr’s app target.
Your application’s other sources still go into app with target_sources.
mkdir -p apps/my_app/src
apps/my_app/src/Talker.hpp#pragma once
#include <rclcpp/rclcpp.hpp>
#include "std_msgs.hpp"
namespace my_app {
class Talker {
::rclcpp::Publisher<std_msgs::msg::Int32> pub_;
::rclcpp::Timer timer_;
int count_ = 0;
void on_tick();
public:
::rclcpp::Result configure(::rclcpp::Node& node);
};
} // namespace my_app
apps/my_app/src/Talker.cpp#include "Talker.hpp"
#include <cstdio>
namespace my_app {
void Talker::on_tick() {
std_msgs::msg::Int32 m;
m.data = count_;
if (pub_.publish(m).ok()) {
std::printf("Published: %d\n", count_);
}
++count_;
}
::rclcpp::Result Talker::configure(::rclcpp::Node& node) {
::setvbuf(stdout, nullptr, _IONBF, 0);
::rclcpp::Result r = node.create_publisher(pub_, "/chatter");
if (!r.ok()) return r;
return node.create_wall_timer<Talker, &Talker::on_tick>(timer_, 1000, this);
}
} // namespace my_app
::setvbuf turns off stdout’s buffering; it is the global one because
Zephyr’s C++ library declares it only there. The build file declares C++,
names the class’s header, and registers the component with
nros_components_register_node(... DEPLOY zephyr), which makes the module
generate the entry point into Zephyr’s app target:
apps/my_app/CMakeLists.txtcmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(my_app LANGUAGES C CXX)
find_package(nano_ros REQUIRED)
find_package(std_msgs REQUIRED)
nano_ros_auto_add_library(talker_lib STATIC src/Talker.cpp)
nros_components_register_node(talker_lib
HEADER Talker.hpp
PLUGIN my_app::Talker
EXECUTABLE talker
SHAPE configure
TYPED
DEPLOY zephyr)
zephyr-lang-rust builds the application: its CMakeLists.txt calls
rust_cargo_application(), which builds the crate with cargo and links it.
It needs the Rust target the board implies, rustup’s clippy, and clang with
libclang. nros setup board adds the target and applies nano-ros’s changes
to the west workspace. From the top of the workspace:
. "$HOME/.cargo/env" # the cargo the install set up
sudo apt-get install -y --no-install-recommends clang libclang-dev
rustup component add clippy
nros setup board zephyr --zephyr-workspace "$PWD"
The crate’s library must be named rustapp and built as a static library:
rust_cargo_application() links librustapp.a. Write the crate, its build
script and its node:
mkdir -p apps/my_app/src
apps/my_app/CMakeLists.txtcmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(my_app)
rust_cargo_application()
apps/my_app/Cargo.toml[package]
name = "my_app"
version = "0.1.0"
edition = "2021"
[lib]
name = "rustapp"
crate-type = ["staticlib"]
[dependencies]
zephyr = "0.1.0"
log = "0.4"
std_msgs = { version = "*", default-features = false }
[dependencies.nros]
version = "*"
default-features = false
features = ["alloc", "rmw-cffi", "macros"]
[dependencies.nros-platform]
version = "*"
default-features = false
features = ["platform-zephyr"]
[dependencies.nros-rmw-zenoh]
version = "*"
default-features = false
features = ["platform-zephyr"]
[build-dependencies]
zephyr-build = "0.1.0"
nros-zephyr-build = "*"
[profile.release]
opt-level = "s"
lto = true
debug = false
apps/my_app/build.rsfn main() {
zephyr_build::export_kconfig_bool_options();
nros_zephyr_build::bake_nros_config();
}
apps/my_app/src/lib.rs#![allow(unused)]
#![no_std]
fn main() {
extern crate zephyr;
use nros::{
Callback, CallbackCtx, Component, DeclarativeNode, ExecutableNode,
NodeContext, NodeOptions, NodeResult, TimerDuration,
};
use std_msgs::msg::Int32;
pub struct Talker;
impl Component for Talker {
const NAME: &'static str = "talker";
const ENTITY_BOUNDS: nros::EntityBounds =
nros::EntityBounds::exact(1, 0, 0, 0, 0);
fn register(ctx: &mut NodeContext<'_>) -> NodeResult<()> {
let mut node = ctx.create_node(NodeOptions::new("talker"))?;
let chatter = node.create_publisher_for_topic::<Int32>("/chatter")?;
let _timer = node.create_timer_for_callback_name(
"on_tick",
TimerDuration::from_millis(1000),
)?;
node.callback_for_name("on_tick").publishes_entity(&chatter)?;
Ok(())
}
}
impl ExecutableNode for Talker {
type State = i32;
const HAS_TICK: bool = false;
fn init() -> Self::State {
0
}
fn on_callback(
count: &mut Self::State,
callback: Callback<'_>,
ctx: &mut CallbackCtx<'_>,
) {
if callback.as_str() == "on_tick" {
let msg = Int32 { data: *count };
if ctx.publish_to_topic::<Int32, 16>("/chatter", &msg).is_ok() {
log::info!("Published: {}", *count);
}
*count += 1;
}
}
}
nros::node!(Talker);
// Keeps the zenoh backend in the static library, then generates the
// application's entry point around the component.
nros::force_link_backend!(nros_rmw_zenoh);
nros::zephyr_component_main!(crate::Talker);
}
Configure
nano-ros reads its settings from Kconfig, so they go in prj.conf beside
Zephyr’s own; west build -t menuconfig shows them under
nros ROS 2 client library
(os_config lookup):
apps/my_app/prj.conf# Zephyr: console and networking
CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_NETWORKING=y
CONFIG_NET_IPV4=y
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_MAX_CONTEXTS=16
CONFIG_DNS_RESOLVER=n
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
# zenoh-pico runs on POSIX threads and wants room
CONFIG_POSIX_API=y
CONFIG_MAX_PTHREAD_MUTEX_COUNT=64
CONFIG_MAX_PTHREAD_COND_COUNT=16
CONFIG_POSIX_THREAD_THREADS_MAX=16
CONFIG_MAIN_STACK_SIZE=16384
CONFIG_HEAP_MEM_POOL_SIZE=65536
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_NET_PKT_RX_COUNT=32
CONFIG_NET_PKT_TX_COUNT=32
CONFIG_NET_BUF_RX_COUNT=64
CONFIG_NET_BUF_TX_COUNT=64
# nano-ros
CONFIG_NROS=y
CONFIG_NROS_CPP_API=y
CONFIG_STD_CPP17=y
CONFIG_NROS_RMW_ZENOH=y
CONFIG_NROS_LOCATOR="tcp/127.0.0.1:7447"
CONFIG_NROS_DOMAIN_ID=0
| Setting | What it chooses |
|---|---|
CONFIG_NROS=y | Turns the module on. |
CONFIG_NROS_CPP_API=y | The library the generated entry point links. The entry point is C++, so a C node sets it too. |
CONFIG_STD_CPP17=y | The C++ standard the entry point compiles with. |
CONFIG_NROS_RMW_ZENOH=y | The middleware: _ZENOH, _XRCE or _CYCLONEDDS. |
CONFIG_NROS_LOCATOR | Where the router is. The default, tcp/127.0.0.1:7447, suits native_sim. |
CONFIG_NROS_DOMAIN_ID | The ROS 2 domain, matching your peers’ ROS_DOMAIN_ID. |
CONFIG_NROS_C_API is for an application that calls the C API from its own
main() and registers no component. For XRCE-DDS, set
CONFIG_NROS_RMW_XRCE=y and name the agent with CONFIG_NROS_XRCE_AGENT_ADDR
and CONFIG_NROS_XRCE_AGENT_PORT. Each middleware’s own Zephyr settings are
listed in One image per RMW. Every
other nano-ros setting is a Kconfig symbol too, listed in the module’s
Kconfig.
On Zephyr 4.x, the module’s snippets (-S nros-zenoh, -S nros-xrce,
-S nros-cyclonedds) select the middleware on the build line instead.
Messages
You run no generator. The build generates the types for every message package
package.xml lists, the same file a ROS 2 package uses:
apps/my_app/package.xml<?xml version="1.0"?>
<package format="3">
<name>my_app</name>
<version>0.1.0</version>
<description>A Zephyr application with a ROS 2 talker</description>
<maintainer email="you@example.com">You</maintainer>
<license>Apache-2.0</license>
<depend>std_msgs</depend>
<export>
<build_type>nros_cmake</build_type>
</export>
</package>
Each <depend> also gets a find_package(<pkg> REQUIRED) line in
CMakeLists.txt. The definitions come from the first place that has the
package: the directories in NROS_INTERFACE_SEARCH_PATH, then a sourced ROS 2
install (AMENT_PREFIX_PATH). Sourcing ROS 2 is required: if neither names a
package, west’s host configure stops and says so, as nros configure does. nano-ros’s
own copies of a few standard packages are read only if you add the directory
the refusal names to NROS_INTERFACE_SEARCH_PATH, and ROS 2 still comes
first. For your own messages, put their interface package anywhere on disk
and add its parent directory to NROS_INTERFACE_SEARCH_PATH.
Finish a Rust application
A Rust application writes package.xml and prj.conf as above, then swaps
the C++ API for the Rust one in prj.conf. build.rs hands the Kconfig
values, among them the locator and the domain, to the crate:
sed -i -e '/^CONFIG_NROS_CPP_API=y$/d' -e '/^CONFIG_STD_CPP17=y$/d' \
apps/my_app/prj.conf
apps/my_app/prj.confCONFIG_RUST=y
CONFIG_NROS_RUST_API=y
nros configure, run in the application directory, generates the Rust types
for the message packages package.xml lists under generated/, and writes
.cargo/config.toml pointing the nano-ros crates at your install. Run it
before the first west build, and again when package.xml changes:
source /opt/ros/humble/setup.bash
cd apps/my_app && nros configure && cd ../..
The application then builds and runs as the C one does. Its log line reads
<inf> nros: rustapp: Published: 1.
Build
From the top of the west workspace, build for native_sim. West’s host
configure generates the message types from your ROS 2 install, so source it first:
source /opt/ros/humble/setup.bash
west build -b native_sim/native/64 -S nros-nsos apps/my_app -- \
-DZEPHYR_EXTRA_MODULES="$(nros locate nano-ros)"
native_sim builds the application as a program for your machine. The
nros-nsos snippet routes its sockets to the host’s (Zephyr’s NSOS); without
it, native_sim tries to create a TAP interface, which needs privileges an
ordinary user or a container lacks.
Run on native_sim
Start the router ROS 2 provides, on the port the talker dials:
source /opt/ros/humble/setup.bash
ZENOH_CONFIG_OVERRIDE='listen/endpoints=["tcp/127.0.0.1:7447"];scouting/multicast/enabled=false' \
ros2 run rmw_zenoh_cpp rmw_zenohd
Started Zenoh router with id
In another terminal, start the talker (west build -t run does the same):
./build/zephyr/zephyr.exe
Published: 1
Published: 2
To see the messages from ROS 2, run
ros2 topic echo /chatter std_msgs/msg/Int32 --qos-reliability best_effort
in a third terminal, with ROS 2 sourced and RMW_IMPLEMENTATION=rmw_zenoh_cpp.
The talker’s publisher is reliable; asking for best-effort receives from a
publisher of either kind.
Build for a real board
The board here is ST’s Nucleo-F767ZI (Zephyr’s nucleo_f767zi). Its ST-LINK
debugger is also a USB serial port, so the talker reaches the router over
that cable with no network on the board: a zenoh serial link. Provision the
board and add its HAL, hal_stm32, to the west workspace:
nros setup nucleo-f767zi-zephyr --rmw zenoh
sed -i 's/net-tools]/net-tools, hal_stm32]/' manifest/west.yml
west update --narrow -o=--depth=1
nros setup board nucleo-f767zi-zephyr --zephyr-workspace "$PWD"
Zephyr reads boards/<board>.conf and boards/<board>.overlay from the
application directory after prj.conf, for that board only, so the
native_sim build stays as it is. These turn the IP stack off, carry zenoh
over USART3, move the console to USART6 (pins D0 and D1), and size the image
for the board’s 384 KiB of RAM:
mkdir -p apps/my_app/boards
apps/my_app/boards/nucleo_f767zi.conf# zenoh over USART3, the ST-LINK USB serial port; no IP stack
CONFIG_NETWORKING=n
CONFIG_NROS_ZENOH_LINK_SERIAL=y
CONFIG_NROS_LOCATOR="serial/serial@40004800#baudrate=115200"
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_RING_BUFFER=y
CONFIG_MAIN_THREAD_PRIORITY=5
# no network driver brings up the RNG, so zenoh's session id uses this one
CONFIG_TEST_RANDOM_GENERATOR=y
# 384 KiB of RAM
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_NROS_MAX_LARGE_SUBSCRIBERS=0
apps/my_app/boards/nucleo_f767zi.overlay/ {
chosen {
zephyr,console = &usart6;
zephyr,shell-uart = &usart6;
};
};
Build into the board’s own directory:
source /opt/ros/humble/setup.bash
west build -p always -b nucleo_f767zi -d build-board apps/my_app -- \
-DZEPHYR_EXTRA_MODULES="$(nros locate nano-ros)"
Zephyr warns that prj.conf’s networking settings were assigned y but got
n. That is expected: the board file turned networking off.
To flash it, start the router on the board’s serial port, with
listen/endpoints=["serial//dev/ttyACM0#baudrate=115200"] in place of the TCP
endpoint above, then run Zephyr’s own west flash -d build-board; the runner
and probe are Zephyr’s and your bench’s.
Flash a real board covers the board, its port and
its twin. The tracks that replay this page boot build-board/zephyr/zephyr.elf
in the board’s Renode twin instead, with USART3 on a host serial port. For the
board’s ethernet, keep CONFIG_NETWORKING=y with its ethernet driver and an
address, and set CONFIG_NROS_LOCATOR to the router’s TCP address.
If it doesn’t work
-
Could not find a package configuration file provided by "nano_ros": the module is not in the build. Check that the build line passes-DZEPHYR_EXTRA_MODULESafter the--. -
attempt to assign the value ... to the undefined symbol NROS_...: the symbol does not exist; searchwest build -t menuconfigwith/.CONFIG_NROS_ROS_EDITIONis a common one. -
No
Published:line within 30 seconds: check the router listens on the locator’s port, the build line has-S nros-nsos, andprj.confturns onCONFIG_NETWORKING,CONFIG_NET_IPV4andCONFIG_NET_TCP. -
A message with an unbounded
stringor sequence fails to generate: give the field a bound in annros-codegen.tomlbesidepackage.xml:[fields] "std_msgs/String.data" = 256 -
Everything else: Troubleshoot.
Design background
An application that owns its build stays outside the workspace model on
purpose: for Zephyr it is a guest that loads nano-ros as a module and states
the middleware, locator and domain in Kconfig, so prj.conf, menuconfig and
-DCONFIG_* are its one source of configuration.
A bare-metal app that owns its main loop
Needs first: Bare-metal Cortex-M3, Use XRCE-DDS, Use a serial link
Use this page when your firmware already decides what runs when, and nano-ros
has to fit inside it. An RTIC application that sets its own interrupt
priorities is the common case, and so is a hand-written superloop. Such an
application cannot use nros::main!(): the macro owns main, and on RTIC it
starts its tasks at one fixed priority from the board’s table. Instead you call
the library layer yourself: install a transport, register the backend, open an
executor over memory you own, and spin it from your own loop.
The page follows a serial-only board talking XRCE-DDS to a micro-ROS Agent over a UART. The same steps hold for USB-CDC and for other byte streams.
Before you start
You need:
- a board crate or application that already boots, with a panic handler;
- a
nros_platform_*provider for the board, supplying the clock, sleep and the allocator (Add a board lists them); - a UART driver you can call from C-ABI callbacks;
- a micro-ROS Agent on the host, at the other end of the serial line.
Add nros-node with its alloc and rmw-cffi features, nros-rmw-xrce-cffi,
and the message crates you publish, such as nros-std-msgs.
Build without an IP stack
A serial-only board has no IP stack, so build with the IP link turned off:
NROS_LINK_IP=0 cargo build --release
With NROS_LINK_IP=0 the XRCE backend builds no UDP transport, and the image
links no nros_platform_udp_* symbol. Your platform provider does not need to
stub them. If such an image is given a udp:// locator, it refuses with a log
line saying it was built with NROS_LINK_IP=0.
Bring nano-ros up from your code
The order matters. Install the transport before any session opens, and register the backend before you open the executor:
src/talker.rs#![allow(unused)]
#![no_std]
fn main() {
use core::{ffi::c_void, mem::MaybeUninit, time::Duration};
use nros_node::{Executor, ExecutorConfig, ExecutorSizing};
use nros_rmw_xrce_cffi::{NrosRmwXrceTransportOps, set_custom_transport_ops};
use nros_std_msgs::msg::Int32;
// The board's UART driver, behind four C-ABI callbacks.
unsafe extern "C" fn uart_open(_: *mut c_void, _: *const c_void) -> i32 { 0 }
unsafe extern "C" fn uart_close(_: *mut c_void) {}
unsafe extern "C" fn uart_write(_: *mut c_void, _buf: *const u8, len: usize) -> i32 { len as i32 }
unsafe extern "C" fn uart_read(_: *mut c_void, _buf: *mut u8, _len: usize, _timeout_ms: u32) -> i32 { 0 }
// The executor's storage, owned by the application (in .bss, priced by mem-report).
const WORDS: usize = ExecutorSizing::DEFAULT.u64_len();
static mut BACKING: [MaybeUninit<u64>; WORDS] = [MaybeUninit::uninit(); WORDS];
pub fn run() -> ! {
// 1. Install the transport (UART: framing on), before any session opens.
let ops = NrosRmwXrceTransportOps {
user_data: core::ptr::null_mut(),
open: Some(uart_open),
close: Some(uart_close),
write: Some(uart_write),
read: Some(uart_read),
};
unsafe { set_custom_transport_ops(&ops, true) }.expect("transport");
// 2. Register the backend (needed where no `.init_array` constructor runs).
nros_rmw_xrce_cffi::register().expect("xrce register");
// 3. Open the executor over the application's own storage.
let config = ExecutorConfig::new("custom://").node_name("talker");
let backing: &'static mut [MaybeUninit<u64>] = unsafe { &mut *(&raw mut BACKING) };
let mut executor = unsafe { Executor::open_in(&config, backing, ExecutorSizing::DEFAULT) }
.expect("session open");
// 4. Register nodes and their entities.
let mut node = executor.create_node("talker").expect("node");
let publisher = node.create_publisher::<Int32>("/count").expect("publisher");
// 5. Spin from the application's own loop (RTIC idle, superloop, ...).
let mut n = 0;
loop {
let _ = publisher.publish(&Int32 { data: n });
n += 1;
let _ = executor.spin_once(Duration::from_millis(10));
}
}
}
What each step does:
- The transport.
set_custom_transport_opstakes four callbacks over your UART driver.readreturns the number of bytes read, 0 on a timeout;writereturns the number written. The second argument turns on framing: passtruefor a byte stream (UART, USB-CDC) andfalsefor a transport that already delivers whole packets. The full contract is innros_rmw_xrce.h, beside the backend. - The backend.
register()adds XRCE to the backends an executor can open. A hosted build does this from a constructor beforemain; bare metal runs none, so call it yourself. Calling it twice is harmless. - The executor.
Executor::open_inopens the session over a buffer you own, here astaticofExecutorSizing::DEFAULT.u64_len()words. It sits in.bss, so a memory report counts it. Thecustom://locator selects the transport from step 1. If the Agent is not up yet the open fails and hands the buffer back, so you can retry it in a loop. - Nodes and entities. Create them from the executor as on any other board.
- The loop.
spin_oncedoes one round of work and returns within the time you pass. In RTIC, call it fromidle; in a superloop, once per pass.
Use your own message packages
Code generation finds message packages in this order: the directories in
NROS_INTERFACE_SEARCH_PATH, then AMENT_PREFIX_PATH, then the copies
nano-ros bundles. Point the variable at your own packages, as a list separated
by : or ;. Each entry is a colcon-style src/ directory, whose
subdirectories each hold one package with its package.xml:
export NROS_INTERFACE_SEARCH_PATH="$HOME/fw/msgs/src"
Code generation reads it whether a nano-ros build runs it or CMake’s
nros_generate_interfaces does.
Message generation covers the bundled
copies and the error a missing package gives.
When the Agent restarts
An Agent that restarts forgets the node’s session. The node notices about a
second after the Agent is back: it asks whether the Agent still holds the
session, and on “no” marks it lost and logs one line saying so. From then on
every publish and spin returns SessionLost, and executor.session_lost() is
true; it stays true. To reconnect, drop everything the old session owns and open again over
the same storage:
#![allow(unused)]
fn main() {
loop {
// The previous executor was dropped, so its borrow of BACKING has ended.
let backing: &'static mut [MaybeUninit<u64>] = unsafe { &mut *(&raw mut BACKING) };
let Ok(mut executor) = (unsafe { Executor::open_in(&config, backing, ExecutorSizing::DEFAULT) })
else {
continue; // Agent not up yet: retry
};
let mut node = executor.create_node("talker").expect("node");
let publisher = node.create_publisher::<Int32>("/count").expect("publisher");
drop(node);
let mut n = 0;
while !executor.session_lost() {
let _ = publisher.publish(&Int32 { data: n });
n += 1;
let _ = executor.spin_once(Duration::from_millis(10));
}
// The Agent restarted: drop the entities first, then the executor.
drop(publisher);
drop(executor);
}
}
Re-opening takes no new memory: the dropped executor hands the buffer back, and the next open uses it again. Drop the entity handles before the executor, since they belong to the old session.
An Agent that is merely down marks nothing lost. To ask on your own schedule,
executor.ping(timeout_ms) returns Ok(()), a Timeout (no answer yet,
which proves nothing), or SessionLost. A loop that calls spin_once does
not need it. A publish that the Agent stopped acknowledging returns
WouldBlock.
If it doesn’t work
- The link fails on
nros_platform_udp_*. The build did not seeNROS_LINK_IP=0. Set it in the environment of thecargo buildthat links the image, and rebuild from clean. - The executor never opens. Check that
register()ran first and the locator iscustom://. Then check the serial line: the Agent must listen on the same port at the same baud rate, with framing on. - The first allocation fails or the heap looks empty. If the board places
its heap in a
NOLOADsection, such as CCM, zero that section before the first allocation.cortex-m-rtzeroes only.bss, and the heap reads all-zero memory as not yet set up.
Flash a real board
Needs first: Run a talker on an emulated board, What you just built, Get started on the Nucleo-F767ZI
Use this page to put an image on a board you hold: record which device on
your machine is which board, read the plan nros flash follows, program the
board, and watch its console. The image is the one you ran in the board’s
twin; nothing is rebuilt for the bench. On a host or in an emulator,
nros run does the same job, and on hardware nros flash does.
Boards with hardware
Every board row that names a physical board, from the board support registry:
| Board | Package | Status | Twin | In this book |
|---|---|---|---|---|
s32z270 | nros-board-s32z270-freertos (s32z270-freertos) | Builds | — | reference page only |
s32z270 | nros-board-s32z270-freertos (s32z270-freertos-rtd) | Not supported | — | reference page only |
s32z270 | nros-board-zephyr (s32z270-rtu0-zephyr) | Builds | — | reference page only |
mr-canhubk344 | s32k344-safety-island | Boots on hardware, manual (2026-10-26); reads Builds from 2027-02-24 | — | reference page only |
nucleo-f767zi | nros-board-nucleo-f767zi-zephyr | Boots, manual (2026-11-01); reads Builds from 2027-03-02 | renode:nucleo_f767zi | starter, platform page, flash steps |
rpi-pico-w | nros-board-rpi-pico-w-zephyr | Not supported | — | reference page only |
A board with a twin and a starter is the path this page follows. A board with only its reference page is one the book does not teach yet: its row says what nano-ros has shown for it.
How a board is described
Every place an image can run is described the same way, in the board’s descriptor:
- a launcher or flasher: a host process, an emulator, or the tool that
programs the board, such as Zephyr’s
west flashrunner; - a console: where the image’s output appears, such as standard output, QEMU’s semihosting, or a serial port;
- a link: how the image’s middleware reaches the rest of the system, such as a serial port carrying zenoh to a router on your host.
nros reads these, so the same verbs work on every board. nros run
launches an image on the host or in an emulator, and refuses a hardware
image, naming the flashing step instead. nros flash programs a board, and
nros monitor attaches to its console.
Before you start
- A workspace whose image runs in the board’s twin, as its starter leaves it.
- The board, on a USB cable. A board whose console is on its pins rather than on the cable, as the Nucleo-F767ZI’s and the Pico W’s are, needs a USB-to-UART adapter to read the console.
Steps
Record the board
With the board attached, nros bench scan matches each
attached USB device to a board by its USB id and records it in
$NROS_HOME/bench.toml, keyed by its serial number, so the same board is
found after a replug or on another USB port. See what it would record
first:
nros bench scan --dry-run
Run it without --dry-run to write the file. nros bench list prints
the file and what is attached now:
nros bench list
The file belongs to your machine and is never committed. A rescan keeps
what you added by hand, such as a debug probe’s serial number (probe)
or a command that power-cycles the board (power_cycle).
Read the flash plan
From the workspace root, print what nros flash
would do, and where each fact came from, without touching the board:
nros flash --dry-run --why --port /dev/ttyACM0
The plan names the flash method, the port and the probe, and the console
--monitor would open. Facts come from five places, highest first: the
command line (--port, --probe, --runner, arguments after --), the
image, your machine’s bench file, the board’s descriptor, and the
runner’s defaults. The port, when you do not pass one, is NROS_PORT,
then the bench file’s entry for the board, then the one attached device
that matches the board. Two candidates are refused, listing both:
nros flash never guesses between two devices.
Flash the board
Flash it:
nros flash
nros flash builds the image if it is stale, then programs it with the
board’s flash method. For a Zephyr board that is Zephyr’s own runner for
the board, the one zephyr/runners.yaml names: OpenOCD over the ST-LINK
for the Nucleo-F767ZI, the UF2 copy for the Pico W (hold BOOTSEL as you
plug it in).
Talk to ROS 2
Flash with --monitor to have nros flash then serve
the board’s link on your host, the way nros run did for the twin: for a
serial link it starts the router on the board’s USB serial device. With
--expect '<text>' it exits 0 when the console prints that text, and
--timeout <seconds> bounds the wait. From a second terminal,
ros2 topic echo hears the board as it heard the twin.
Attach again later
nros monitor opens a running board’s console
without flashing it, with the same --port, --expect and --timeout.
Outside a workspace, --port alone is enough.
Change how an image is flashed
An image overrides any key of its board’s flash or console description in
its own [image.<id>.flash] and [image.<id>.console] tables, key by key,
in the bringup’s system.toml. The image keeps every key it does not state:
[image.stm32.flash]
chip = "STM32F767ZITx" # the part, in the flash method's own spelling (probe-rs)
[image.stm32.console]
baud = 921600 # a serial console's rate
The flash table takes method, command, chip and prepare (steps run
before the flash); the console table takes kind, usb, baud and
command. For one run, --runner <name> picks the flash method’s own runner
(west flash --runner jlink), and arguments after -- go to the flasher
unchanged.
Flash a board nano-ros does not ship
A board you add yourself is a board package of your own;
Add a board takes one from a descriptor to
a first image. Once its descriptor states a flash method, nros flash names
its image like any other. Until then, flash the artifact nros build
printed with the board vendor’s own tool:
| Platform | The artifact | A flashing tool |
|---|---|---|
| Zephyr | the west build directory nros build printed | west flash -d <dir>, with the runner your board’s definition declares, run inside the Zephyr west workspace or with ZEPHYR_BASE set to its zephyr/ |
| Bare-metal or FreeRTOS on Cortex-M | the ELF | probe-rs run --chip <chip> <elf>, or OpenOCD’s program <elf> verify reset exit |
| NuttX | nuttx, nuttx.bin or nuttx.hex from your board’s BOARD_CONFIG | the tool NuttX’s page for your board names |
The board needs a link nano-ros can use: a serial port, or a network interface its board package brings up.
If it doesn’t work
nros runrefuses and names a flashing step: the image’s board is hardware. Usenros flash.nros flashcannot find the board: runnros bench scanwith the board attached, or pass--port.- Two devices match: pass
--port, or record each board withnros bench scan. - The image flashes and never talks: the link is not on the port the
router listens on. Check the plan’s
[link], and that the adapter’s TX and RX are not crossed. - Everything else: Troubleshoot.
See also
- Nucleo-F767ZI: the board’s link, RAM budget and notes.
- Deploy to production: building every image and checking it is ready to ship.
nrosCLI: every flag offlash,monitorandbench.
Design background
PX4 Autopilot (external module)
Support level:
px4_sitl_default. Each page states what nano-ros can show for the board (where it runs, how often, and its breadth), generated from the board support registry; Board Support Levels explains the words.
Single-node starter on PX4 Autopilot via the external-module
copy-out template. PX4’s EXTERNAL_MODULES_LOCATION pattern lets
downstream firmware drop in nano-ros without forking PX4 itself.
C++ only — PX4’s uORB binding is C++-only (Rust + C not in the
coverage matrix).
Prereqs. A PX4-Autopilot ≥ v1.16 clone, the matching cross toolchain (e.g.
gcc-arm-none-eabifor Pixhawk targets), andpython3with the PX4 development requirements installed (bash ./Tools/setup/ubuntu.shonce).
Project layout
PX4 external modules live outside the PX4 source tree and are
hooked in at PX4’s host configure. The template — shipped in the SDK root at
integrations/px4/module-template/ (the SDK root is the installed release’s
share/nano-ros, nros locate nano-ros prints it) — has
the PX4-required
src/modules/<name>/ shape:
my_drone_firmware/
├── PX4-Autopilot/ # PX4 source tree (submodule)
└── px4-modules/ # EXTERNAL_MODULES_LOCATION
└── nano-ros/ # copied from the module template
└── src/
├── CMakeLists.txt # fills config_module_list_external
└── modules/
└── nano_ros_app/
├── CMakeLists.txt # px4_add_module(MAIN nano_ros_app)
└── nano_ros_app.cpp # the user-editable app
Prereq. PX4 is your own checkout — the firmware tree you already build. Clone it (or use the one you have) and initialize its submodules; nano-ros is tested against PX4 v1.17.0.
git clone --branch v1.17.0 https://github.com/PX4/PX4-Autopilot.git
git -C PX4-Autopilot submodule update --init \
--depth 1 --recommend-shallow --recursive
PX4’s own build tools and Python dependencies come from its Tools/setup
scripts. On Ubuntu, once per host (the SITL build needs neither the NuttX
toolchain nor the simulators, so leave those out until you build for a
Pixhawk or run Gazebo):
bash PX4-Autopilot/Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools
Other hosts: see PX4’s development-environment documentation.
Copy the template into your firmware repo; PX4 is pointed at the copy at build time:
mkdir -p px4-modules
sdk="$(nros locate nano-ros)" # this project's nano-ros SDK root
cp -r "$sdk/integrations/px4/module-template" px4-modules/nano-ros
(Releases after 0.6.0-nros4 ship the template; with an older one, copy it from GitHub.)
PX4 enforces the src/modules/<name>/ layout exactly. To make the module
your own, rename nano_ros_app in all three places at once: the directory,
the module list in src/CMakeLists.txt, and the MAIN name in the module’s
own CMakeLists.txt. PX4 has no central module registry, so copying the
template into your tree is how it is distributed.
PX4’s own make <target> is the build verb, and it configures and builds ONE
tree, PX4-Autopilot/build/<target>/. The module joins it through
EXTERNAL_MODULES_LOCATION, passed on that same make line — PX4’s
Makefile forwards it to its CMake configure — and pointing at the dir that
contains the template’s src/ (that’s px4-modules/nano-ros, not its
parent: PX4’s root CMakeLists.txt does
add_subdirectory("${EXTERNAL_MODULES_LOCATION}/src" …)).
The template finds nano-ros itself: an explicit -Dnano_ros_ROOT=<path>
cache variable wins, otherwise it asks the nros on PATH,
which answers with the SDK that binary belongs to. No environment variable is
read. To name the root anyway, pass it through PX4’s
CMAKE_ARGS:
make -C PX4-Autopilot px4_sitl_default \
EXTERNAL_MODULES_LOCATION="$PWD/px4-modules/nano-ros" \
CMAKE_ARGS="-Dnano_ros_ROOT=$sdk" # optional
Not replayed. The
px4probe track builds the plain SITL line under Build; this form, withCMAKE_ARGS, is not run by any probe.
Inside the module, the canonical pattern bridges uORB → nano-ros.
The module is a PX4Module subclass that runs in its own work
queue, opens an nros executor, and forwards uORB messages onto a
zenoh / DDS topic (or vice versa). Edit nano_ros_app.cpp to add
your topic bindings.
Generate px4_msgs
nros px4 msgs generates CDR-serializable px4_msgs::msg::* bindings from a
PX4-Autopilot .msg tree (--px4 <dir>, default $PX4_AUTOPILOT_DIR) into
--output. --lang rust (the default) writes a px4_msgs crate for an XRCE
companion; --lang cpp writes headers and FFI glue for an in-firmware PX4
module. --topics keeps only the messages a bridge carries (by message name
or uORB topic name), pulling in nested types:
nros px4 msgs --output generated/px4_msgs --topics vehicle_status
nros px4 is a command package (nros_px4_tools), not a built-in: nros
runs its executable with the arguments unchanged, and
nros px4 msgs --help prints its flags.
Configure
The template does not ship a Kconfig overlay (no Kconfig.projbuild
files). Module enablement is implicit once EXTERNAL_MODULES_LOCATION
points at the template. Which RMW backends the module registers is the
BACKENDS list of nros_px4_add_module(...) in
src/modules/nano_ros_app/CMakeLists.txt — the template ships BACKENDS uorb
— not a cache variable. (Adding a Kconfig overlay so the module appears under
menuconfig → External modules is a follow-up task; for now the template is
always enabled.)
Build
One make, one tree. For the SITL simulator (POSIX target — easier to
develop against):
make -C PX4-Autopilot px4_sitl_default \
EXTERNAL_MODULES_LOCATION="$PWD/px4-modules/nano-ros"
Or for a Pixhawk (px4_fmu-v5_default here; use your board’s PX4 target):
make -C PX4-Autopilot px4_fmu-v5_default \
EXTERNAL_MODULES_LOCATION="$PWD/px4-modules/nano-ros"
The firmware lands in PX4’s own tree, PX4-Autopilot/build/<target>/
(px4_fmu-v5_default.px4 for the Pixhawk). The first build cross-compiles
nano-ros’s Rust staticlibs alongside PX4’s NuttX kernel + apps (~10 min on a
fresh checkout). Note that the module links prebuilt nano-ros archives
(nros_px4_add_module resolves them in PX4’s host configure and, when one is
missing, stops naming the command that builds it).
Stack sizes on a Pixhawk. Opening a nano-ros session runs in the module’s
NuttX main task and needs about 15 KB of stack on a Cortex-M7. PX4’s default
main task is 2048 B. So once your module opens a session (your own node code in
nano_ros_app_main, or an entry generated from a bringup), state
STACK_MAIN 32768 in nros_px4_add_module(...). A module generated from a
bringup (BRINGUP) also spins on a PX4 work queue (rate_ctrl by default,
3150 B). Raise it in your board config, e.g.
CONFIG_WQ_RATE_CTRL_STACKSIZE=8192. For a BRINGUP module on NuttX, the
host configure checks both against the executor’s floor and refuses with the
setting to raise. SITL needs neither.
Run on the SITL simulator
PX4’s SITL runs the autopilot as a host process. It boots without a simulator attached, which is enough to see the module start. From the SITL build directory, start the PX4 daemon:
cd PX4-Autopilot/build/px4_sitl_default
bin/px4 -d etc/init.d-posix/rcS
It is up once its startup script reports:
Startup script returned successfully
Then, in a second terminal in the same directory, start the module through the daemon’s client command:
cd PX4-Autopilot/build/px4_sitl_default
bin/px4-nano_ros_app start
nano-ros uORB backend registered
Ctrl-C stops the daemon.
To fly a simulated vehicle, run SITL against a simulator instead. With Gazebo (Harmonic) installed per PX4’s documentation:
make -C PX4-Autopilot px4_sitl_default gz_x500 \
EXTERNAL_MODULES_LOCATION="$PWD/px4-modules/nano-ros"
# In the PX4 console:
pxh> nano_ros_app start
# Verify from stock ROS 2 on the same network (only after you have
# added uORB → nano-ros forwarders to nano_ros_app.cpp — the shipped
# template forwards nothing on its own):
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /vehicle_local_position px4_msgs/msg/VehicleLocalPosition
Flash a real board
PX4’s own upload target flashes over the bootloader USB, with the same
EXTERNAL_MODULES_LOCATION as the build (it rebuilds if anything changed):
make -C PX4-Autopilot px4_fmu-v5_default upload \
EXTERNAL_MODULES_LOCATION="$PWD/px4-modules/nano-ros"
Not replayed. No probe runs this flash line (a CI runner has no board), so it is written from the board’s runner, not measured (tracking issue).
QGroundControl can flash the same build/px4_fmu-v5_default/px4_fmu-v5_default.px4
instead. Start the module from the NSH console (nano_ros_app start) or the
board’s startup script.
No probe runs the upload line (a CI runner has no board): it stands
unverified until run against a named board. PX4 SITL is the replay that can
run in CI: the px4 probe track replays this chapter’s SITL build and its
headless run.
Readiness signal. After nano_ros_app start in the PX4
console, the shipped template logs nano-ros uORB backend registered and returns immediately — it doesn’t start a
publisher loop or print a “bridge started” line on its own.
You’re expected to edit nano_ros_app.cpp to wire your
uORB → nano-ros forwards. If nano_ros_app reports register failed, check:
- Module didn’t register — the template logs
nros_rmw_uorb_register() -> <rc>on startup (search the PX4 boot log fornros_rmw_uorb_register). A non-zero<rc>usually means a NuttX kernel-config / feature-gate mismatch. - Once you’ve added forwarders,
zenohdmust be reachable from the autopilot’s network (Pixhawk: configured via QGroundControl orparam set). - uORB topic not advertised yet — start the upstream PX4 module
that publishes it (
commander startetc.) first. - See Troubleshooting — First 10 Minutes.
GitHub source
- PX4 external-module template:
integrations/px4/module-template/ - Worked PX4 example, the source of truth for the register-check shape
(including the weak
nros-rmw-cffiregister stub on the Rust side):packages/testing/nros-px4-register-check/ - PX4 integration roadmap notes:
integrations/px4/README.md
Constraints to be aware of
- uORB binding is C++-only. The PX4 example collapses uORB registration to a C++ port; Rust / C variants exist for non-PX4 RTOSes but not for PX4.
- PX4’s NuttX kernel. Underneath, PX4 runs NuttX; if you need to debug at the kernel layer, the NuttX starter page applies too.
- uORB throughput vs zenoh hops. uORB is in-process pub/sub at ~µs latency; zenoh adds network-RTT. Plan accordingly when bridging high-rate streams.
Next
- Add your own uORB topics to the bridge: see the
nano_ros_app.cpptemplate’s topic-table section. - Multi-vehicle: PX4-XRCE-Agent → nano-ros XRCE backend gives you the standard PX4-ROS bridge with nano-ros on the autopilot side.
- For pure-NuttX (no PX4) firmware: see the NuttX starter.
Pick a scheduling model
Needs first: Organize a larger workspace
Pick a scheduling model when one image runs callbacks of different urgency: a 10 ms control loop beside a 100 ms telemetry publisher, for example, where the control loop must not wait behind the telemetry.
In nano-ros, the unit of scheduling is a sched task: one executor running
on one RTOS thread, with its own priority and spin period, all of them sharing
one middleware session. You name callback groups in code, map each group to a
sched task in system.toml, and give each sched task its priority per RTOS.
The build turns that into the threads each platform has. Where ROS 2 reaches
for a MultiThreadedExecutor and callback groups, nano-ros gives you sched
tasks: an executor dispatches on one thread, and parallelism is a sched task,
not a callback group.
The scheduling theory behind the choice (fixed-priority preemption, rate-monotonic assignment, EDF, priority inversion) belongs to The execution model.
Before you start
- A workspace whose image runs on an RTOS or on Linux.
- The capabilities your platform delivers, from the generated Scheduling wiring matrix: kernel EDF on Zephyr, the sporadic server on NuttX, preemption threshold on ThreadX, core affinity on most.
Steps
-
Name a callback group for each urgency, in the node’s code.
In Rust, call
node.callback_group("ctrl")?before creating the timer or subscription that belongs to it. In C++, use the named form,create_callback_group("ctrl"); an unnamed group runs on the node’s default sched task. -
Map each group to a sched task, on the node’s
[[component]]row:[[component]] pkg = "ctrl_pkg" class = "ctrl_pkg::Control" name = "control_node" group_tasks = { ctrl = "high" } [[component]] pkg = "telem_pkg" class = "telem_pkg::Telem" name = "telem_node" group_tasks = { telem = "low" } -
Declare the sched tasks. A key on
[tasks.<name>]applies on every platform; a key on[tasks.<name>.<rtos>]applies only there:[tasks.high] class = "real_time" spin_period = "1000us" [tasks.high.posix] priority = 80 core = 0 [tasks.high.freertos] priority = 3 [tasks.low] spin_period = "10000us" [tasks.low.posix] priority = 10 [tasks.low.freertos] priority = 2classisreal_time(the default for a priority sched task),best_effortortime_triggered. Priorities are the RTOS’s own numbers, so their direction differs: on FreeRTOS, NuttX and Linux a bigger number is more urgent, and on ThreadX and Zephyr a smaller one is. The table of levels and directions per platform is in the Scheduling wiring matrix. -
Add the platform’s own mechanism where it has one. Scope it to that platform, so it lowers to nothing elsewhere:
[tasks.high.zephyr] priority = 9 deadline = "10000us" # kernel EDF, Zephyr only [tasks.high.nuttx] priority = 99 budget = "5000us" # SCHED_SPORADIC, NuttX only period = "10000us" [tasks.low.threadx] priority = 16 preempt_threshold = 10 # ThreadX only time_slice = "5000us"A
budgeton[tasks.high]itself would switch every platform’s executor to cooperative sporadic gating, which is why these keys go in the platform tables. -
Keep sched tasks below the transport. Each board reserves a priority band for the middleware’s own read and lease threads, and a sched task that outranks them cannot be served by them. The build allocates sched-task priorities from the board’s application pool and refuses a priority that lands on the reserved band. A sched task that really must run above it says so with
above = "transport". -
Choose what a periodic timer does after a stall. When a sched task is preempted past several periods, the timer fires once and counts the missed periods (
TimerOverrunPolicy::Skip, the default, as in rclcpp and Zephyr’sk_timer). Phase is kept, so activations stay on the declared cadence. Replay every missed period instead, for a counter or an accumulator, withexecutor.set_timer_overrun_policy(id, TimerOverrunPolicy::CatchUp). Do not replay a control loop: the replayed activations compute with stale inputs and send a burst of commands. Watchexecutor.timer_overruns(id), or thetimer-overrun-runtimeviolation, rather than the publish rate, which looks nominal underCatchUpduring exactly the stall it should catch. Timer periods are microseconds throughout, including across the C ABI. -
Build. The configure runs the host image once to take its census, and each node logs the sched task it registered on:
nros configure[INFO] Telem::register on a sched task admitting group `telem`
Example
examples/workspaces/realtime-rust/
runs a 10 ms control node on high and a 100 ms telemetry node on low, with
sched-task tables for Linux, FreeRTOS, NuttX, ThreadX and Zephyr in one
system.toml. Its realtime-c and realtime-cpp siblings do the same in C
and C++.
# src/demo_bringup/system.toml (excerpt)
[[component]]
pkg = "ctrl_pkg"
class = "ctrl_pkg::Control"
name = "control_node"
group_tasks = { ctrl = "high" }
[[component]]
pkg = "telem_pkg"
class = "telem_pkg::Telem"
name = "telem_node"
group_tasks = { telem = "low" }
[tasks.high]
class = "real_time"
spin_period = "1000us"
[tasks.high.posix]
priority = 80
core = 0
[tasks.high.freertos]
priority = 3
[tasks.low]
spin_period = "10000us"
[tasks.low.posix]
priority = 10
[tasks.low.freertos]
priority = 2
[image.linux]
board = "linux"
[image.freertos_realtime]
board = "freertos"
panic = "own"
locator = "tcp/10.0.2.2:7891"
nros run demo_bringup:linux
If it doesn’t work
- The build refuses a priority. It lands on the board’s reserved
transport band, or outranks it. Pick one from the application pool the
message names, or state
above = "transport". - A
corepin falls back with a warning on Zephyr. The pin is on the boot sched task, which Zephyr started before nano-ros ran and cannot pin any more. Putcoreon a sched task nano-ros spawns. MultiThreadedExecutordoes not compile. It has no nano-ros form. Move the callbacks that need their own thread to a sched task of their own.
See also
- Analyze timing: check the callbacks a sched task runs for unbounded work.
- Scheduling wiring matrix: what each platform delivers.
- The execution model: how executors, sched tasks, levels and dispatch fit together.
Design background
- RFC-0015: RTOS orchestration
- RFC-0053: ThreadX multi-tier execution
- RFC-0079: priority is allocated, not authored
- RFC-0002: RT execution model (timer overrun policy)
Analyze timing
Needs first: Pick a scheduling model
Analyze timing before you trust a sched task’s period: check the callbacks it runs for the code that breaks a time bound. This page covers the static checks for Rust node packages, the ones a CI job can run on every push.
A callback’s worst case is what matters, not its average. These patterns make it unbounded:
| Pattern | Problem | Check |
|---|---|---|
| an unbounded loop | no upper bound on execution time | Clippy |
| recursion | unbounded stack depth | Clippy, cargo-call-stack |
| heap allocation | non-deterministic time, fragmentation | no allocator, disallowed-methods |
| blocking I/O, a missing timeout | an unbounded wait | review |
| a large stack frame | stack overflow | cargo-call-stack |
Before you start
- A Rust node package that builds with
nros build. rustupwith a nightly toolchain, for the stack analysis.
Steps
-
Run Clippy with the loop and recursion lints as errors, from the node package’s directory:
cargo clippy --all-targets -- \ -D warnings \ -D clippy::infinite_iter \ -D clippy::while_immutable_condition \ -D clippy::never_loop \ -D clippy::empty_loop \ -D unconditional_recursion \ -W clippy::large_stack_arrays \ -W clippy::large_types_passed_by_valueinfinite_iterfinds iterator chains that never end,while_immutable_conditiona loop condition nothing changes, andempty_loopaloop {}with no body (writeloop { core::hint::spin_loop() }). -
Set the size thresholds in a
clippy.tomlbeside the package’sCargo.toml:array-size-threshold = 512 # bytes of stack array trivial-copy-size-limit = 16 # bytes passed by value cognitive-complexity-threshold = 15 -
Keep the heap out of the real-time path. A
no_stdpackage with no#[global_allocator]cannot callBox,VecorStringat all; useheaplesscollections with a fixed capacity:#![allow(unused)] fn main() { let v: heapless::Vec<u8, 256> = heapless::Vec::new(); }A package that needs
allocelsewhere can refuse it in one module with#![deny(clippy::disallowed_methods)]and a list inclippy.toml:disallowed-methods = [ { path = "alloc::vec::Vec::push", reason = "Use heapless::Vec in RT code" }, { path = "alloc::boxed::Box::new", reason = "No heap in RT code" }, { path = "alloc::string::String::new", reason = "Use heapless::String" }, ] -
Measure the stack.
cargo-call-stackneeds nightly and fat LTO (lto = "fat"in the profile), and works best on ano_stdbinary:cargo +nightly install cargo-call-stack RUSTFLAGS="-Z emit-stack-sizes" cargo +nightly build --release cargo +nightly call-stack --release > call_graph.dotThe graph gives each function’s frame size and the deepest path. Calls through function pointers or trait objects may be missing from it.
-
Look for recursion in the same graph. A cycle is recursion:
cargo +nightly call-stack --release 2>&1 | grep -i cycleReplace it with a loop over a bounded stack, such as a
heapless::Vec<&Node, 32>, and handle the full case. -
Review what Clippy cannot prove. It cannot show that a loop ends or that a call has a timeout. Check that every
loophas a reachablebreakorreturn, that a loop in a callback has an iteration limit or a deadline, and that every blocking call states a bound:- nano-ros:
spin_once(timeout); in C++,wait_for_service(10000)andwait_for_action_server(10000). The budget is required; there is no wait-forever form. stdon a host:connect_timeout, a socket read timeout,recv_timeout.
#![allow(unused)] fn main() { // Bounded: stop after a deadline, not when the queue happens to empty. let deadline = Instant::now() + Duration::from_millis(10); while Instant::now() < deadline { match queue.pop() { Some(msg) => process(msg), None => break, } } } - nano-ros:
-
Run it in CI. The job below runs the lints, the stack analysis and Miri, for a project with its firmware in
firmware/and two host-testable crates,my_coreandmy_msgs:name: Real-time static analysis on: [push, pull_request] jobs: clippy-realtime: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: clippy - run: | cargo clippy --all-targets -- -D warnings \ -D clippy::infinite_iter -D clippy::while_immutable_condition \ -D unconditional_recursion -W clippy::large_stack_arrays stack-analysis: runs-on: ubuntu-latest defaults: run: working-directory: firmware steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - run: cargo +nightly install cargo-call-stack - run: | RUSTFLAGS="-Z emit-stack-sizes" cargo +nightly build --release cargo +nightly call-stack --release > stack_analysis.txt if grep -q cycle stack_analysis.txt; then echo "recursion in the call graph"; exit 1 fi miri: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly with: components: miri - run: cargo +nightly miri test -p my_core -p my_msgsMiri runs host tests, so point it at the crates whose logic does not depend on the target: serialization, state machines, protocol code.
Example
The one command to paste for a strict local check:
cargo clippy -- \
-D warnings -D clippy::all \
-D clippy::infinite_iter -D clippy::while_immutable_condition \
-D clippy::never_loop -D clippy::empty_loop \
-D unconditional_recursion \
-W clippy::large_stack_arrays -W clippy::large_types_passed_by_value \
-W clippy::cognitive_complexity
If it doesn’t work
cargo-call-stackreports nothing useful. The build was not fat-LTO, or the package linksstd. Analyze theno_stdfirmware crate.- Timing measured in QEMU is meaningless. QEMU’s Cortex-M3 does not implement the DWT cycle counter, so every read is zero, and wall-clock percentiles track the host’s load. Measure execution times on the real board.
- A lint you need does not exist. Clippy cannot see a blocking call in a callback or an allocation in an interrupt handler. A Dylint library of your own can; see the Dylint documentation below.
See also
- Pick a scheduling model: the periods these checks protect.
- Deploy to production: what to measure on your silicon before shipping.
- Clippy lints, cargo-call-stack, Dylint, heapless.
Trace callbacks
Needs first: Pick a scheduling model
Trace callbacks to see where each one starts and ends on the board’s own
clock, and mark your application’s phases on the same clock. The executor
emits one (marker_id, arg) event per callback start, end and registration
through a trace sink: a function you install, or one the platform installs
for you. Your application emits its own events through the same sink.
Before you start
- An image built with callback tracing: the
trace-callbacksfeature ofnros-c,nros-cppornros. Without it every call below is a no-op, and the marker call still checks its id. - A sink. Zephyr installs one when CTF tracing is on (see the table below). Elsewhere, install your own before the executor registers anything.
Steps
-
Install a sink, if the platform does not. The signature is two
uint32_tvalues, the shape of a platform trace event, so a platform shim installs as is. It runs on every thread that dispatches callbacks, so it must be re-entrant:#include <rclc/rclc.h> static void my_sink(uint32_t marker_id, uint32_t arg) { /* write (marker_id, arg) to a ring, a UART, a trace stream */ } rclc_set_trace_sink(my_sink); -
Mark your application’s own events with an id from the application block, 1 to 15:
enum { PHASE_SENSE = 1, PHASE_PLAN = 2, PHASE_ACT = 3 }; rclc_trace_marker(PHASE_PLAN, cycle);#include <rclcpp/rclcpp.hpp> rclcpp::trace_marker(PHASE_PLAN, cycle);#![allow(unused)] fn main() { use nros::trace_marker::emit_app_marker; emit_app_marker(PHASE_PLAN, cycle)?; }The event goes through the installed sink on the same path as the executor’s events, so it is ordered with them. With no sink installed the call costs a range compare, one load and one branch.
Marker ids
| ids | owner |
|---|---|
| 0 | reserved, never emitted |
| 1 to 15 | your application (RCLC_TRACE_APP_MARKER_FIRST to RCLC_TRACE_APP_MARKER_LAST; C++ rclcpp::kTraceAppMarkerFirst to kTraceAppMarkerLast) |
| 16 to 27 | the executor: callback registration, name, start, end, contract violations, takes |
| 28 and up | reserved for the executor’s future events |
An id outside 1 to 15 is refused: C returns RCL_RET_INVALID_ARGUMENT and
sets the error that rcl_get_error_string reads, C++ returns
ErrorCode::InvalidArgument, Rust returns AppMarkerIdOutOfRange. Each
logs an error and emits nothing. The id is never moved onto another one.
Where the events go
| Platform | Default sink |
|---|---|
| Zephyr | sys_trace_app_marker, into the CTF stream as an app_marker event (fields marker_id, arg), when CONFIG_TRACING_CTF is on. nros setup board adds that event to the Zephyr workspace, so no patch of your own is needed. The sched-task entry installs it, and keeps a sink you installed first. |
| FreeRTOS | none. Install a sink of your own, for example a RAM ring you read with a debugger. |
| POSIX (Linux) | none. Install a sink of your own. |
| NuttX, ThreadX | none. Install a sink of your own. |
A Zephyr tracing backend of your own
Zephyr writes the CTF stream through one backend. To keep it in a recorder of
your own, such as an overwrite-oldest RAM ring, register the backend in your
application and select it by name. nros setup board adds the two Kconfig
symbols that select it, on Zephyr 3.7 and 4.4; stock Zephyr has no way to
select an out-of-tree backend.
#include <tracing_backend.h>
static void ring_init(void) { /* ... */ }
static void ring_output(const struct tracing_backend *backend,
uint8_t *data, uint32_t length) { /* ... */ }
static const struct tracing_backend_api ring_api = {
.init = ring_init,
.output = ring_output,
};
TRACING_BACKEND_DEFINE(my_trace_ring, ring_api);
CONFIG_TRACING=y
CONFIG_TRACING_CTF=y
CONFIG_TRACING_SYNC=y
CONFIG_TRACING_BACKEND_CUSTOM=y
CONFIG_TRACING_BACKEND_CUSTOM_NAME="my_trace_ring"
The name is the first argument of TRACING_BACKEND_DEFINE(). No in-tree
backend is built.
If it doesn’t work
- No events at all. The image was built without
trace-callbacks, or no sink is installed.rclc_trace_markerreturnsRCL_RET_OKin both cases. - Callbacks show as
handle Nwith no names. The sink was installed after the executor registered its callbacks; install it first. rclc_trace_markerreturnsRCL_RET_INVALID_ARGUMENT. The id is outside 1 to 15. Ids from 16 up belong to the executor.- Zephyr:
CONFIG_TRACING_BACKEND_CUSTOMis an undefined symbol. The workspace was provisioned before nano-ros carried the patch. Re-runnros setup board <board>.
See also
- Analyze timing: the static checks for a callback’s worst case.
- C API and C++ API.
Deploy to production
Needs first: Configure an image
Use this page to take an image from a workspace to the machine or board it runs on, verify it from ROS 2, and check it is ready to ship.
The order is the same on every target: build the image, put it where it
runs, then verify ROS 2 communication. On a host or an emulator nros run
does the last two; on hardware nros flash --monitor does.
Before you start
- A workspace whose images build, and the boards provisioned
(
nros setupat the workspace root). - For a zenoh image, ROS 2’s router; see ROS 2 and the zenoh router.
Steps
-
Build every image the workspace declares:
nros build --allAfter each image,
nros buildprints the artifact and the board’s own next command. Where each target family’s artifact lands is in Build outputs. -
Check how the image will run.
--dry-run --whyprints the run plan, and where each fact came from, without running anything:nros run host_node_bringup:linux --dry-run --whyimage = "host_node_bringup:linux" verb = "run" [runner] package = "nros_runner_native" name = "native" [console] kind = "stdio" [link] kind = "tcp" locator = "tcp/127.0.0.1:7447" rmw = "zenoh" host_peer = "zenoh-router" -
Run a host or emulator image, with a smoke test.
nros runbuilds it if it is stale, starts the router its link needs, streams the console, and with--expectexits successfully when the line appears:nros run host_node_bringup:linux --expect 'Publishing:' -
Flash a real board, and watch its console on the same port:
nros flash <bringup>:<image> --monitor --expect 'Publishing:'nros flashruns the board’s human steps (a jumper, a reset), flashes through the board’s flash method, and watches the console.nros monitorattaches to a board that is already running. A board with no flash method stays on the vendor’s own tools. -
Verify from ROS 2. With the router running and ROS 2 sourced:
export RMW_IMPLEMENTATION=rmw_zenoh_cpp ros2 topic list ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effortIf discovery works but samples do not arrive, check the domain ID, the router endpoint, QoS reliability and the board’s network.
-
Check readiness for production, below, on your own board.
Check readiness for production
The in-tree tests run reference boards, mostly under emulation, where cycle counters read zero and wall-clock percentiles track the host’s load. What you ship has to be measured on your silicon, at its clock and load. Count the boxes per group; a group missing two or more is not ready.
Timing, measured on the board
- End-to-end P99 latency, publisher to callback, within your budget.
- Worst-case stack depth per sched task
(Analyze timing), and the platform’s
stack-overflow detection on (FreeRTOS
configCHECK_FOR_STACK_OVERFLOW, Zephyr stack sentinels, NuttXCONFIG_DEBUG_STACK). - Timer overruns under sustained load (timer overrun policy).
- Heap use over 24 hours at nominal load, and no allocation on a hot path.
Platform and network
- Multicast discovery fires on your RTOS and driver, if you use Cyclone DDS.
- The platform clock extends a narrow hardware counter to a monotonic 64-bit value (a 32-bit millisecond count wraps at 49.7 days).
- The image recovers from 5% packet loss, a 30-second partition, and a restart of the router or agent.
- Critical sections are short.
Middleware and interop
- The release pinned with
nros pin, so the backend versions are the tested ones (nros setup --listprints them), and a plan to move the pin: only the newest release is supported, and fixes are not backported (Release support). -
nros doctor --reportoutput filed with the build: the release, each board’s support status and every pinned tool, dated. - The release image built with the release profile, and its digest
recorded. The same pin, lock and ROS 2 packages give the same bytes
from any project directory, as long as nano-ros itself is installed at
the same path (a container gives you both);
nros builddefaults to the debug profile (Build profiles). - Every QoS policy you use is supported by your backend; an unsupported one is reported at entity creation.
- A stock ROS 2 node receives what the image publishes, with each custom message, and QoS profiles match.
- Every nano-ros RTOS in your fleet sees every other.
Safety and operations
- A timeout on every blocking call; nano-ros has no wait-forever form.
- The E2E CRC attached, if you use the
safety-e2efeature (Safety). - A hardware watchdog wired; the executor reports overruns but pets none.
- A log sink chosen (Log and observe a board), time synchronization, and a bootloader and update strategy, none of which nano-ros ships.
- The licenses accepted: nano-ros is MIT OR Apache-2.0, and each component an image compiles in carries its own (Third-party code). nano-ros has no commercial support entity, so plan for in-house expertise.
Example
A workspace with a host image and a board image, built, smoke-tested, then flashed:
nros build --all
nros run host_node_bringup:linux --expect 'Publishing:'
nros flash <bringup>:<image> --monitor --expect 'Publishing:'
Run an image: nros run
nros run builds the image if it is stale, starts what its link needs, and
streams the console, for host images and emulators. --expect '<line>' exits
successfully when that line appears. On a real board it refuses and names the
flashing step instead; Flash a real board
covers nros flash, nros monitor and nros bench.
Run plans
Before it runs anything, nros run resolves a run plan: which launcher,
which console and which link, and where each fact came from. The facts come
from five levels, highest first: the command line, the image, your machine’s
bench file, the board’s descriptor, and the runner’s defaults.
--dry-run --why prints the plan without running it, as in step 2. Each
platform page under Platforms reads its
board’s plan.
If it doesn’t work
nros runrefuses and names a flashing step. The image’s board is hardware. Usenros flash --monitor.- The image starts but never prints. A zenoh image blocks opening its
session until it reaches the router. Check the router runs, on the
endpoint in the run plan’s
[link]. nros flashcannot find the board. Runnros bench scanwith the board attached, or pass--port.
See also
- Troubleshoot: failures by symptom.
- Build outputs: artifacts and the vendor commands that take them.
nrosCLI: every flag ofrun,flash,monitorandbench.
Design background
- RFC-0072: RTOS integration, nano-ros is a guest
- RFC-0065: colcon-like workspace builder
- RFC-0075: zenoh router provenance
- RFC-0118: target execution model
Log and observe a board
Needs first: Run a talker
Use this page to log from a node, choose which records are kept, publish them
on /rosout, and find out what happened on a board that has no console.
nano-ros logs through nros-log, which has the Logger and severity surface
of rclcpp::Logger and rcutils_logging. Every record goes to one sink per
platform: stderr on Linux, Zephyr’s log subsystem, NuttX’s syslog, a UART on
FreeRTOS and ThreadX. The table is in
Platform differences.
Before you start
- A node package in a workspace that runs, for example the talker of Run a talker.
Log from a node
use nros_log::{Logger, Severity};
use nros_log::{log_info, log_warn};
static LOGGER: Logger = Logger::new("my_node");
fn main() {
nros_log::register_logger(&LOGGER);
nros_log::init(nros_log::sinks::default());
log_info!(&LOGGER, "started; domain = {}", 42);
log_warn!(&LOGGER, "queue depth {} exceeds soft limit", 5);
}
Inside a node, prefer the Node::logger() accessor — it resolves
to the same intern’d entry when the name matches:
#![allow(unused)]
fn main() {
let mut node = executor.create_node("my_node")?;
log_info!(node.logger(), "subscribed to {}", topic);
}
rclrs’s modifiers chain off the logger, and each applies per call site:
#![allow(unused)]
fn main() {
use nros_log::ToLogParams;
log_info!(node.logger().once(), "link up");
log_warn!(node.logger().skip_first(), "late sample {}", seq);
log_debug!(node.logger().only_if(verbose), "state {:?}", state);
// needs the platform clock; a clockless image refuses it at compile time
log_warn!(node.logger().throttle(Duration::from_millis(500)), "lag {} ms", lag);
}
#include <rclc/rclc.h> /* also brings the RCLC_LOG_* macros */
int main(void) {
rclc_support_t support = rclc_support_get_zero_initialized();
rcl_allocator_t allocator = rcl_get_default_allocator();
/* locator: build, then NROS_LOCATOR */
rclc_support_init(&support, 0, NULL, &allocator);
/* the executor first, then the node bound to it */
rclc_executor_t executor = rclc_executor_get_zero_initialized_executor();
rclc_executor_init(&executor, &support.context, 1, NULL);
rcl_node_t node = rcl_get_zero_initialized_node();
rclc_executor_node_init(&executor, &node, "my_node", NULL);
rclc_logger_t logger = rclc_node_get_logger(&node);
RCLC_LOG_INFO(logger, "started; domain=%u", 42);
RCLC_LOG_WARN(logger, "queue depth %u exceeds soft limit", 5);
rcl_node_fini(&node);
rclc_executor_fini(&executor);
rclc_support_fini(&support);
return 0;
}
#include <rclcpp/rclcpp.hpp>
int main() {
rclcpp::init_in("tcp/127.0.0.1:7447", 0);
rclcpp::Node node;
rclcpp::create_node(node, "my_node");
auto logger = node.get_logger();
RCLC_LOG_INFO(logger, "started; domain=%u", 42);
RCLC_LOG_WARN(logger, "queue depth %u exceeds soft limit", 5);
rclcpp::shutdown_in();
return 0;
}
The first log call in C or C++ installs the platform sink, so those call sites need no init step.
Set the level
-
Set the compile-time ceiling. Records below it are compiled out: a Rust call becomes a constant-false branch, and a C or C++ record is refused by the same check. State it per image, or per board in its descriptor:
# system.toml: this image only [image.linux.knobs.log] max_level = "info"The value is
trace(the default),debug,info,warn,error,fataloroff, or0–6as Zephyr’sCONFIG_NROS_LOG_MAX_LEVELstates it.nros config explainprints which rung decided it. -
Move a logger’s level at run time, above the ceiling:
#![allow(unused)] fn main() { let logger = nros_log::get_logger("my_node"); logger.set_level(nros_log::Severity::Warn); // silences Trace, Debug, Info logger.unset_level(); // follows the default again nros_log::Logger::set_default_level(nros_log::Severity::Debug); }A logger with no level of its own follows its nearest dotted ancestor (
my_node.plannerfollowsmy_node), then the process default,Info. In C the same verbs arerclc_logger_set_level,rclc_log_set_default_levelandrclc_logger_set_level(logger, RCLC_LOG_SEVERITY_UNSET). -
Make a child logger with upstream’s spelling:
node.logger().create_child("planner")?in Rust,node->get_logger().get_child("planner")in C++, andrclc_logger_get_child(node_log, "planner")in C. Names are capped at 48 bytes and runtime loggers come from a bounded arena: when a child cannot be made, Rust returns an error, C returnsNULL, and C++ logs through the parent and refusesset_levelon the child.
Publish records on /rosout
-
Nothing to declare: every image carries the
rosoutcapability unless itssystem.tomlstatesnode_interfaces = "none"(a bare CMake project that setsNROS_FEATURESitself listsrosoutin it). -
Log through the node’s logger and spin. The executor creates one
/rosoutpublisher for each node on the spin after the node is built, and publishes the queued records from every spin:
#![allow(unused)]
fn main() {
let logger = executor.create_node("my_node")?.logger();
loop {
nros_log::log_info!(logger, "tick");
executor.spin_once(budget);
}
}
rclc_executor_node_init(&executor, &node, "my_node", NULL);
rclc_logger_t log = rclc_node_get_logger(&node);
for (;;) {
RCLC_LOG_INFO(log, "tick");
rclc_executor_spin_some(&executor, 10000000);
}
auto log = node.get_logger();
for (;;) {
RCLC_LOG_INFO(log, "tick");
rclcpp::spin_once(10);
}
A node that should not publish /rosout calls
executor.disable_rosout_on(node_id) (Rust). In C the node must be bound
with rclc_executor_node_init; a legacy rclc_node_init_default node is
not in the executor’s table, so it keeps the explicit
rclc_rosout_publisher_init once and rclc_rosout_pump from the spin
loop. The explicit spelling in Rust (nros::rosout::pump) and C++
(rclcpp::rosout::Publisher) still works but adds a second publisher to
the node, and is deprecated.
- Read them from ROS 2:
ros2 topic echo /rosout, orrqt_console.
Where this differs from ROS 2:
- It is switched per image. It is on for every node of the image unless
the image opts out with
node_interfaces = "none"; each node’s publisher counts in the image’s pools. - The QoS is volatile. The executor’s publisher is
qos_bounded(): volatile at the queue depth. Upstream’s profile (nros::rosout::qos(), keep-last 1000, transient-local) is expensive on a board; with the bounded one a late subscriber misses the boot records. - Which loggers publish follows the ROS release. On Humble only a node’s
logger reaches
/rosout, not a child or a freeget_logger("x"); Iron and Jazzy also publish a node’s children. - The stamp is the platform’s monotonic clock, so
rqt_consoleshows uptime as a time of day. - It costs
.bss: 5,760 bytes at the defaults, from 16 queued records. An image without the feature pays nothing.
The sink never publishes from inside a log call: it copies the record into a
ring, and the executor publishes it on the spin thread. Records published,
lost to a full ring, or logged during a publish are counted
(nros::rosout::published(), dropped(), suppressed()), and losses are
reported on /rosout itself. The buffer sizes are knobs:
see Logging.
Observe a board with no console
Some boards have no console you can read, for example one whose only wired
UART carries the zenoh serial link, where a log line would corrupt the
transport’s framing. Reach for these in order. A debug probe is not always a
passive instrument there. On a Cortex-M, pyocd reads memory without stopping
the core when it attaches with connect_mode="attach" and is not told to halt. A halt
stops the image: the router drops the session once a halt outlasts the zenoh
lease (60 s, measured on an S32K344 over serial), and the board re-opens it
on its own about a minute after it resumes. Keep halted reads short.
-
Read the boot record. With
CONFIG_NROS_BOOT_REPORT=y, the image keeps one fixed-size record in RAM, theNROS_BOOT_REPORTsymbol, as it boots. It survives the failures that stop a log from ever printing. It holds the knobs the image was compiled with, the last boot stage it reached, the allocation that did not fit and which allocator refused it, the heap’s peak and capacity, samples dropped as too large, the domain and the rung that decided it, and a count ofERRORandFATALrecords with the first one’s file and line. After the run, halt the core and save it, with the address and size from the image’s own symbol table:read ADDR LEN <<< "$(arm-none-eabi-nm -S build/zephyr/zephyr.elf \ | awk '$4=="NROS_BOOT_REPORT"{print "0x"$1, "0x"$2}')" pyocd commander -t <target> -c halt -c "savemem $ADDR $LEN report.bin"The
nrosCLI has no command that decodes the bytes yet. The record is off by default, and an image without it is byte-identical to one built before the feature existed. -
Read the fault record.
CONFIG_NROS_FAULT_LOG=yreplaces Zephyr’s fatal-error handler with one that writes the reason, the faulting PC, LR and PSR, and the thread name into a.noinitrecord that survives a functional reset. SetCONFIG_THREAD_NAME=ytoo, or the thread reads?.CONFIG_NROS_FAULT_LOG_FLASH=yalso copies it to the storage partition at the next boot. A power-on or pin reset may zero that RAM. -
Read a live log over RTT, last. Move the console to an unwired UART in a devicetree overlay, and read SEGGER RTT over the SWD link:
script -qec "pyocd rtt -t <target> -a $(arm-none-eabi-nm build/zephyr/zephyr.elf \ | awk '$3==\"_SEGGER_RTT\"{print \"0x\"$1}')" /dev/nullIt needs the
zephyrproject-rtos/seggermodule in the workspace, passed with-DZEPHYR_EXTRA_MODULES=<path>; a TTY, whichscriptprovides; and the control block’s address,-a. SetCONFIG_SEGGER_RTT_BUFFER_SIZE_UP=16384, or the default 1 KiB buffer wraps before a late reader sees anything. Check anything found this way again with the probe detached, using the two records above.
Example
A Rust node that logs once at start and throttles a warning, in an image
whose ceiling is info:
#![allow(unused)]
fn main() {
use nros_log::{log_info, log_warn, ToLogParams};
log_info!(node.logger().once(), "link up");
log_warn!(node.logger().throttle(Duration::from_millis(500)), "lag {} ms", lag);
}
[image.linux.knobs.log]
max_level = "info"
The logging demos, one node package per language, are in
examples/workspaces/features.
If it doesn’t work
- A
debug!record never appears. The compile-time ceiling is above it, or the logger’s level is. Lowermax_level, then the logger’s level. - Nothing reaches
/rosout. The image statesnode_interfaces = "none"(or a bare CMake project’sNROS_FEATURESomitsrosout), the queue is never pumped, or the record came from a child or free logger on Humble. - A throttled call does not compile.
throttleneeds the platform clock; a clockless image refuses it.
See also
- Environment variables: logging: the ceiling and the buffer knobs.
- Platform differences: logging: where records go, and the severity numbers.
- Use a serial link: the two settings a Zephyr board joining over a UART needs.
Design background
Use simulated time
Needs first: Parameters and launch files
Use simulated time when a node runs against a simulator or a replayed bag, and its timers should follow the simulation’s clock instead of the wall.
nano-ros implements ROS 2’s mechanism: rosgraph_msgs/msg/Clock on /clock,
the use_sim_time parameter, and timers that state which clock advances
them. As in rclcpp, the method name carries the choice:
| You write | It advances with | Follows /clock |
|---|---|---|
create_wall_timer(period, cb) | the platform’s monotonic clock | no |
create_timer(clock, period, cb) | the clock you pass | yes, for a ROS-time clock |
Keep a wall timer for a watchdog or a keep-alive, anything whose job is to
notice that real time passed; a paused simulator must not pause it. Older
nano-ros code used create_timer for the wall timer. It no longer means that,
and there is no alias.
Before you start
- A node package whose timers should follow the simulation.
- A
/clocksource: a simulator, orros2 bag play --clock.
Steps
-
Declare the
sim_timecapability in the image’ssystem.toml. It is one of the stock node interfaces, sonode_interfaces = "stock"brings it with the parameter services and/rosout:[system] features = ["param_services", "sim_time"] # or: node_interfaces = "stock"The capability selects the
sim-timefeature ofnros(and ofnros-c/nros-cpp) for you, in Rust, C and C++ images alike. The/clocksubscription costs a callback slot, an executor arena entry with its receive buffer, a subscriber and a liveliness token, once per executor. The pools reserve it whenever the capability is built in, becauseuse_sim_timecan be set true at any time. An image that cannot spare it leaves the capability out, or statesnode_interfaces = "none". -
Turn it on with the parameter, as in ROS 2: from a launch file, a parameters file, or at run time. The runtime acts on
use_sim_timeitself; nothing in your code reads it:talker: ros__parameters: use_sim_time: trueAn image built with parameter services declares
use_sim_time = falsefor every node, as rclcpp does, so this works on a node whose author never mentioned simulated time:ros2 param set /talker use_sim_time trueA declaration of your own still wins. To attach the source in code instead, call
node.install_ros_time_source()?, ornode.install_ros_time_source_on("/sim/clock")?for a remapped clock. -
Write the timers that should follow it on the ROS clock:
#![allow(unused)]
fn main() {
executor.register_timer_on_clock(
TimerDuration::from_millis(100),
TimerClockSource::Ros,
|| { /* … */ },
)?;
}
TimerClockSource::Steady is the default and costs nothing extra: it uses
the spin delta the executor already measured. Ros and System read their
clock on every poll, a platform call on a board, which is why they have their
own entry point.
rclcpp::Timer t;
RCLCPP_TRY(node.create_timer(t, *node.get_clock(), 100, on_tick));
-
Read the time. A node’s clock is ROS time, and with no
/clocksource it reads system time, asrclcpp::Clockdoes, so the node still runs standalone:rclcpp::Time now = node.get_clock()->now(); node.get_clock()->ros_time_is_active(); // is a /clock source driving it? node.get_clock()->started(); // has a first sample arrived? -
Start the source and run the node:
ros2 bag play my_bag --clock
Example
A talker that publishes every 100 ms of simulated time, switched on from its parameters file:
# config/talker.param.yaml
talker:
ros__parameters:
use_sim_time: true
#![allow(unused)]
fn main() {
executor.register_timer_on_clock(
TimerDuration::from_millis(100),
TimerClockSource::Ros,
|| { /* publish */ },
)?;
}
ros2 bag play my_bag --clock
What happens at the edges
- Paused: the delta is zero, so a ROS-time timer does not fire. Wall timers on the same executor keep their cadence.
- Replayed at 0.5× or 2×: the timer tracks the rate, because it advances by the clock’s own delta.
- A jump backwards (a bag looping, a simulator reset) restarts the period.
- A jump forwards lands as a backlog, and the timer overrun policy
decides:
Skip(the default) fires once,CatchUpreplays every period. - Unsubscribing keeps the last simulated time rather than snapping back
to the wall. Clear it on purpose with
Clock::clear_ros_time_override().
Where nano-ros differs from rclcpp
- One simulated clock per image. The override is process-wide; two nodes in one image cannot be on different simulated times.
- No jump callbacks.
create_jump_callbackandrcl_jump_threshold_thave no counterpart. - No
wait_until_startedorsleep_until. Pollstarted()from your spin loop. - Timers only. Message delivery, QoS deadlines and transport leases stay on the monotonic clock, so a link stays up while the simulation is paused.
If it doesn’t work
-
ROS-time timers never fire. A never-connected
/clocklooks exactly like a paused one. Five seconds after the source attaches with no sample, the image logs one warning:use_sim_time is true but no /clock sample has arrived in 5s: ROS-time timers are running on SYSTEM time meanwhile. Publish rosgraph_msgs/msg/Clock (ros2 bag play --clock), or set use_sim_time false.Publish
/clock, or turnuse_sim_timeoff. The warning comes once;Executor::sim_time_silence_warnings()answers the same question in code. -
Message ages are enormous. The
max-age-runtimerule comparesheader.stampwith the epoch clock, not ROS time. Stamp from the epoch clock, or leave that rule off for the topic under simulation.
See also
- Pick a scheduling model: the timer overrun policy.
- ROS 2 clock and time: the upstream design.
Design background
Set the wall clock from the board
Needs first: Configure an image
Take the wall clock from the board when it already knows the time, from an RTC, a GNSS receiver or its own SNTP task, and messages should be stamped with it.
An image has one wall clock. Clock::system(), rclcpp::Clock::now() and
the executor all read it, and [knobs.clock] source says where it comes
from. With source = "board", nano-ros asks a function your board or
application defines, nros_board_wall_clock_ns, until it answers.
Before you start
- An image on Linux (POSIX) or FreeRTOS, bare metal or
freertos-posix. Zephyr, ThreadX and NuttX images refuseboardwhen they build. - Somewhere the board keeps the time: an RTC, a GNSS fix, or a task of its own that syncs it.
Steps
Select the board
Select the board as the image’s wall-clock source in system.toml:
[image.robot.knobs.clock]
source = "board"
To fall back to the platform’s own clock when the board never answers, list both, in order:
[image.robot.knobs.clock]
source = "board,platform"
Define the hook
Define the hook in a package the image launches. It returns true and
writes nanoseconds since the Unix epoch once the board’s clock is set,
and false until then. nano-ros asks it every 10 ms, so it must return
at once: read a value your RTC driver or sync task keeps, and never wait
on the hardware or the network here.
#![allow(unused)]
fn main() {
// src/robot_board/src/lib.rs
#[unsafe(no_mangle)]
pub unsafe extern "C" fn nros_board_wall_clock_ns(out_ns: *mut u64) -> bool {
// `board_time_ns` is yours: the time your RTC or sync task holds,
// or None until it is set.
let Some(now) = board_time_ns() else { return false };
if out_ns.is_null() {
return false;
}
// SAFETY: non-null, and nano-ros passes a pointer valid for a u64.
unsafe { out_ns.write(now) };
true
}
}
nano-ros calls the hook from C, after your crate on the link line, so
the linker can leave out a Rust function nothing in Rust reaches. Name
it once in the component’s register to keep it in:
#![allow(unused)]
fn main() {
core::hint::black_box(
nros_board_wall_clock_ns as unsafe extern "C" fn(*mut u64) -> bool,
);
}
/* src/robot_board/src/board_clock.c */
#include <stdbool.h>
#include <stdint.h>
bool nros_board_wall_clock_ns(uint64_t *out_ns) {
uint64_t now;
/* board_time_ns is yours: false until your RTC or sync task has a time. */
if (out_ns == NULL || !board_time_ns(&now)) {
return false;
}
*out_ns = now;
return true;
}
// src/robot_board/src/BoardClock.cpp
#include <cstdint>
extern "C" bool nros_board_wall_clock_ns(std::uint64_t* out_ns) {
std::uint64_t now = 0;
// board_time_ns is yours: false until your RTC or sync task has a time.
if (out_ns == nullptr || !board_time_ns(&now)) {
return false;
}
*out_ns = now;
return true;
}
Put it in an object file of the image, or in an archive linked after
nano-ros. A board that ships it in a static archive under CMake adds that
archive to the image’s LINK_DEPENDS.
Build and run
Build and run the image. On its first wall-clock read it prints where the clock came from:
nros: wall clock from board
Check the clock is set
Before publishing data whose stamp matters, check that the clock is set.
wall_clock_state() says whether it is synced and which source answered:
#![allow(unused)]
fn main() {
if let Some(st) = nros::wall_clock_state() {
if st.synced {
// publish stamped data
}
}
}
nros_wall_clock_state_t st = rclc_wall_clock_state();
if (st.synced) {
/* publish stamped data */
}
const nros_wall_clock_state_t st = ::rclcpp::Clock::wall_clock_state();
if (st.synced) {
// publish stamped data
}
When the board never answers
The source is resolved on the image’s first wall-clock read, and that read
waits for it. The hook is asked every 10 ms for up to
clock.fallback_settle_ms (10 s by default). The first true sets the
clock; after that the hook is never called again.
If the window runs out, the next source in the list is tried. If none
answers, clock.epoch_failure decides:
epoch_failure | The image prints | Then |
|---|---|---|
unstamped (default) | nros: no wall-clock source answered (board, platform); stamps are unset (header.stamp reads 0) | runs on |
halt | nros: no wall-clock source answered (board, platform); halting, as clock.epoch_failure = halt asks | stops |
The list in parentheses is the sources the image tried, in order.
[image.robot.knobs.clock]
source = "board,platform"
fallback_settle_ms = 30000 # a GNSS fix can take longer than 10 s
epoch_failure = "halt" # peers here refuse an unstamped sample
Which stamps follow it
Choosing a source changes the clock nano-ros reads. A sample’s source timestamp is stamped by the RMW backend, and only zenoh asks nano-ros:
| RMW | A sample’s source timestamp |
|---|---|
| zenoh | the image’s wall clock, from the board |
| Cyclone DDS | the host’s CLOCK_REALTIME, whatever the image selected |
| XRCE-DDS | 0: the client delivers no source timestamp |
A header.stamp your code writes from Clock::system() or
rclcpp::Clock::now() follows the board on every RMW.
If it doesn’t work
- The link fails on
nros_board_wall_clock_ns. nano-ros has no default hook: an image that selectsboardmust define it. Define it in a package the image launches, or, if it is in an archive, link that archive after nano-ros. - The clock reads 0 on FreeRTOS. A read before the scheduler starts has no clock yet. Read the time from a task.
- A C or C++ image refuses
boardat configure. For now, an image whose components build their own executables cannot select it. Use a Rust image, or components that build no executable. - The image refuses
boardat build. It is a Zephyr, ThreadX or NuttX image; only POSIX and FreeRTOS ports take a board clock for now.
See also
- Use simulated time: timers that follow
/clockinstead of the wall. - Configuration surface: every
clock.*knob. - Platform API: the wall-clock calls a port provides.
Run managed nodes
Needs first: Parameters and launch files
Use a managed node when something outside the node decides when it starts
work: a supervisor, a test, or an operator running ros2 lifecycle set.
A managed node is ROS 2’s lifecycle node (REP-2002). It has a state machine
(unconfigured, inactive, active, finalized) and five services that
read and drive it. nano-ros follows stock ROS 2 here:
- Each managed node has its own machine, under the node’s own name:
/sensor_node/get_state,/sensor_node/change_stateand the rest. ros2 lifecycle nodeslists exactly the image’s managed nodes.- A node that is not managed has no machine. It publishes from boot, as a
plain
rclcpp::Nodedoes.
Which nodes are managed
A node is managed when one of these says so, and in no other case:
| Where | What you write |
|---|---|
| The launch file | <lifecycle_node> instead of <node> |
| The node’s contract | lifecycle: true |
| The node’s C++ code | a class deriving from rclcpp_lifecycle::LifecycleNode |
The order the image builds its nodes in decides nothing. A node with none of the three stays plain, whether or not the bringup has a launch file.
A node marked in the launch file needs no code of its own for this: its machine runs default transition callbacks, which all succeed.
Before you start
- A workspace with a launch file, as at the end of Parameters and launch files.
- ROS 2 sourced on the host, for the
ros2 lifecycleverbs.
Steps
sensor_ws/
└── src/
└── sensor_node_bringup/
├── launch/
│ └── system.launch.xml (changed)
└── system.toml (changed)
-
Mark the node managed in the launch file. Change the talker’s
<node>to<lifecycle_node>; nothing else in the element changes:src/sensor_node_bringup/launch/system.launch.xml<?xml version="1.0"?> <launch> <arg name="topic" default="/sensor/reading"/> <lifecycle_node pkg="sensor_node" exec="sensor_node" name="sensor_node"> <param name="period_ms" value="500"/> <remap from="/reading" to="$(var topic)"/> </lifecycle_node> <node pkg="monitor_node" exec="monitor_node" name="monitor_node"> <remap from="/reading" to="$(var topic)"/> </node> <node pkg="server_node" exec="server_node" name="server_node"/> <node pkg="client_node" exec="client_node" name="client_node"/> <node pkg="action_server_node" exec="action_server_node" name="action_server_node"/> <node pkg="action_client_node" exec="action_client_node" name="action_client_node"/> </launch> -
Say in the bringup’s
system.tomlwhich state managed nodes boot to. Add a[lifecycle]block; its presence also builds the lifecycle services into the image:[lifecycle] autostart = "active"autostartThe node boots to Transitions run at boot "none"unconfigurednone "configure"inactiveconfigure "active"activeconfigure, then activate -
Build and run the image as before.
What ROS 2 sees
The stock ros2 lifecycle verbs work against the image as they do against
an rclcpp system:
ros2 lifecycle nodeslists/sensor_nodeonly; the other five nodes are plain.ros2 lifecycle get /sensor_nodeanswersactive, asautostartasked.ros2 lifecycle set /sensor_node deactivatemoves it toinactive, andros2 lifecycle list /sensor_nodenames the transitions open from there.
What publishers send in each state
A managed node’s publishers send only while the node is active. In
unconfigured, inactive and finalized, publish returns success and
the message is dropped. Each publisher prints one line, for its first
dropped message:
publishing on `/sensor/reading` while its node is not active: the message is dropped, and so is every message until the node is activated
- The publishers open as the node activates, before its
on_activateruns, so a message published insideon_activategoes out. - They close after
on_deactivateruns, and stay closed when an activation fails. - nano-ros opens and closes them itself, on every ROS 2 edition. A call to a
publisher’s own
on_activate()is accepted and does nothing. - Subscriptions, services, clients, timers and
/rosoutare not gated: they work in every state.
In C++, a publisher held as rclcpp_lifecycle::LifecyclePublisher still
drops a message published inside on_activate: it starts sending only once
on_activate has returned SUCCESS. Publish from a timer or callback that
runs after activation instead.
One boot state per image
autostart is one value for the whole image: every managed node boots to
it. A launch file or contract that states a different value for two nodes of
one image is refused at build time, naming both nodes. Give the image one
value, and drive any node that should differ with ros2 lifecycle set after
boot.
A program that makes its own nodes managed
A hand-written program (its own main) can make nodes managed in its code
instead of in a launch file. The build cannot see those nodes, so it reserves
service slots for one managed node only. With some backends, XRCE among them,
the extra nodes’ lifecycle services then fail to register at boot.
Say how many nodes the program makes managed:
[system]
features = ["lifecycle"]
[lifecycle]
managed_nodes = 2
Each managed node gets its own five lifecycle services, and the build reserves
room for all of them. managed_nodes needs lifecycle in a features list,
and must be at least 1.
If the services still fail to register, a C++ rclcpp_lifecycle::LifecycleNode
reports it: its ok() is false and error_what() names the lifecycle
services. Check ok() after constructing the node, as for any rclcpp::Node.
Write the node’s own callbacks
A Rust component made managed by the launch file runs the default callbacks. A component cannot supply its own transition callbacks yet.
A C component made managed by the launch file runs the default callbacks. A component cannot supply its own transition callbacks yet.
A hand-written C program binds each node to its executor with
rclc_executor_node_init before it creates the node’s entities. The
executor refuses an entity on a node that is not bound, and the message names
that call. A generated entry binds every node for you.
Derive from rclcpp_lifecycle::LifecycleNode and override the transitions
you need, with upstream’s signatures. The rest default to SUCCESS:
#include <rclcpp_lifecycle/lifecycle_node.hpp>
class ManagedTalker : public rclcpp_lifecycle::LifecycleNode {
public:
explicit ManagedTalker(rclcpp::NodeHandle h)
: rclcpp_lifecycle::LifecycleNode(h, "managed_talker") {}
CallbackReturn on_configure(const rclcpp_lifecycle::State&) override {
pub_ = create_publisher<std_msgs::msg::Int32>("/chatter");
return pub_.get() != nullptr ? CallbackReturn::SUCCESS : CallbackReturn::FAILURE;
}
private:
rclcpp_lifecycle::LifecyclePublisher<std_msgs::msg::Int32>::SharedPtr pub_;
};
The class is managed because its code says so: its constructor registers
the lifecycle services, and it needs no <lifecycle_node> in the launch
file.
What a managed node does not do yet
There is no per-node autostart. Every managed node in an image boots to
the image’s one value (above).
See also
system.tomlreference- Contract format: the
lifecyclefact - rclcpp compatibility:
rclcpp_lifecycle::LifecycleNode
Troubleshoot
Needs first: Run a talker
Use this page when a build or a running image fails in a way the page you were following does not cover. Find the symptom, then apply its fix.
Some topics keep their own failures:
- First build and first run: the troubleshooting index.
- ROS 2 sees nothing (domain ID, QoS, client mode, edition): Talk to ROS 2.
- Serial links: Use a serial link.
- Several backends in one binary: Bridge between backends.
Before you start
Run the doctor in the workspace. It checks the SDK paths, toolchains and environment, and names what is missing:
nros doctor
Outside a workspace it checks the install instead, and reports store entries you can remove, with the command to remove them.
Steps
- Run
nros doctorand fix what it names. - Run the failing step again with
--dry-runwhere it has one (nros build,nros run,nros flash), to see the plan and the exact command. - Find the symptom in the sections below.
zenoh-pico multiple client issues
Symptom: the first of several zenoh clients on one router starts, and the
next fails to open its session (-102, _Z_ERR_TRANSPORT_OPEN_FAILED) or to
declare a publisher or subscriber (-78, _Z_ERR_SYSTEM_OUT_OF_MEMORY, or
-128, _Z_ERR_GENERIC).
Fix: -102 means the client could not reach the router: check its
locator and that the router listens there. -78 is an allocation that did
not fit. Raise the image’s heap, or the zenoh pool that filled, which the
image names at start-up; the knobs are in
Environment variables.
zenoh-pico version compatibility
Symptom: publishing fails at once with -100
(_Z_ERR_TRANSPORT_TX_FAILED), then -73 (_Z_ERR_SESSION_CLOSED).
Fix: compare the zenoh on both sides. nano-ros does not pin the router, because the router is the one ROS ships:
grep 'define ZENOH_C ' \
/opt/ros/$ROS_DISTRO/opt/zenoh_cpp_vendor/include/zenoh_configure.h
nros setup --list | grep zenoh-pico
Read the header, not dpkg -l: the package version is a wrapper version.
Under zenoh’s 1.x wire guarantee the two need not match, so a mismatch is
evidence rather than a diagnosis.
Multiple Zephyr native_sim instances
Ephemeral port conflict
Symptom: two native_sim instances (a talker and a listener) both fail to
open their sessions, or one fails with -100.
Cause: native_sim’s test entropy source gives every instance the same random sequence, so both pick the same ephemeral port.
Fix: give each instance its own seed:
./build-listener/zephyr/zephyr.exe --seed=12345
./build-talker/zephyr/zephyr.exe --seed=67890
Cyclone DDS: two native_sim nodes never discover each other
Symptom: with Cyclone DDS, the publisher prints
Publishing: 'Hello World: N' and the subscriber never prints I heard:, with
no error.
Cause: the same fixed entropy gives both participants the same DDSI GUID prefix, and a node drops discovery from a peer that shares its own GUID.
Fix: distinct seeds, as above. On native_sim, Cyclone discovery is
unicast to 127.0.0.1. Real hardware has real entropy and multicast, and
needs neither workaround.
Network configuration issues
- QEMU cannot reach the network. An image on QEMU’s built-in
qemunetwork uses user-mode networking and needs nothing on the host. An image on a network of your own needs[image.<id>.run] nicnaming a host bridge or TAP device; see Configure an image. - Zephyr native_sim. Sockets are forwarded to host system calls, so there
is no bridge to configure. Point each image at a router on host loopback,
tcp/127.0.0.1:7447.
An XRCE node goes silent after its Agent restarts
Symptom: a node on XRCE-DDS keeps running, but ROS 2 no longer sees its
topics after the micro-ROS Agent was restarted. The node logs one line,
XRCE session lost: the Agent is reachable but no longer holds this session (it restarted).
Cause: an Agent that restarts forgets every session it held. About a
second after it is back, the node asks it whether it still holds the session,
and on “no” marks the session lost. From then on every publish, spin and ping
returns SessionLost (C: RCLC_RET_NOT_FOUND; C++:
NROS_CPP_RET_TRANSPORT_ERROR), and
Executor::session_lost() is true. An Agent that is only down marks nothing:
the node carries on once the same Agent answers again.
Fix: drop the executor and open it again, then create the nodes and
entities again. The loop is in
When the Agent restarts.
How soon the node asks is XRCE_SESSION_PROBE_MS (override it with -D), in the
compile-time XRCE table.
Message too large or truncated
Symptom: TransportError::MessageTooLarge, payloads that arrive
corrupted, or large messages (images, point clouds) that disappear.
Cause: a message passes several static buffers on its way, and must fit each: zenoh’s defragmentation and batch sizes, XRCE’s transport MTU, and the entity’s own receive buffer.
Fix: raise the transport limit for the image, for example
NROS_ZENOH_FRAG_MAX_BYTES or XRCE_TRANSPORT_MTU, from the
buffer tuning tables,
and size the entity’s buffer in code:
#![allow(unused)]
fn main() {
let sub = node.create_subscription_sized::<MyMsg, 4096>(/* … */)?;
}
Build issues
- The zenoh-pico source is not found. Let provisioning fetch it:
nros setup <board> --rmw zenoh, ornros setup --source zenoh-pico. - A changed knob has no effect. An old CMake cache holds the previous
value. Remove the image’s directory under
build/and build again.
The link fails: a region overflowed
Symptom: the build stops at the link with the linker’s line, for example on a nucleo-f767zi-zephyr image whose heap was raised:
region `RAM' overflowed by 122432 bytes
nros build ends with the command that failed and, after it, what the
image reserves in that region:
nros build: image `talker_node_bringup:zephyr` does not fit its memory: the link overflowed `RAM` by 122,432 B.
What the image reserves:
main stack 33,368 B, CONFIG_MAIN_STACK_SIZE
measured under the stack-floor row `talker/rust/zenoh@nucleo-f767zi-zephyr`: static walk 69,648 B (an upper bound through an indirect call, not a size), measured peak 28,888 B, margin 10 %
heap 393,216 B, `[image.zephyr.knobs.memory] heap_bytes`
To make room, lower what the image adds (a pool or cache knob it raised), the heap, or the main stack: `CONFIG_MAIN_STACK_SIZE` in a conf file `[image.zephyr] os_config` names.
Fix: give back at least the bytes it names. Lower a knob you raised (a
pool, a cache, the heap) before the main stack: the stack-floor row is the
stack the image was measured to need. The whole tool output is in the
image’s build log; What nros build produces
says where.
Rust and C FFI issues
Subscriber callback crashes
Symptom: a callback registered from Rust through C crashes, or reads
garbage fields, such as sub->callback=0x60.
Cause: the C side kept a pointer to a struct the Rust code then moved, for example by returning it from a function.
Fix: give the struct a stable address before you hand it to C: a
static (with MaybeUninit), a Box, or Pin. Or have the C side keep an
index instead of a pointer.
Function pointer ABI mismatch
Symptom: a callback passed between Rust and C receives garbage arguments.
Fix: declare it extern "C" fn, not a plain fn.
Example
The usual first pass on a failing image:
nros doctor
nros build <image> --dry-run
nros run <bringup>:<image> --dry-run --why
If it doesn’t work
- Look the error up in the troubleshooting index, which also lists the zenoh-pico error codes.
- File an issue with the doctor’s output and the dry-run plan.
See also
- Log and observe a board: what to read when a board has no console.
- Deploy to production: the run plan and the verify step.
Port a C++ node
Needs first: Move a ROS 2 project over
Port a C++ node when you have one that builds with colcon build against ROS 2
Humble and you want it on nano-ros, with as few source edits as possible.
nano-ros declares the rclcpp:: names in its own C++ headers, and its SDK
root carries the CMake side: the ament_* verbs, Find<pkg>.cmake modules
for the most-cited ROS 2 packages, and diagnostic_updater. So a port is
mostly build glue. What the source still needs is what the compiler names:
nano-ros has no exceptions, and a few handles observe rather than own.
Before you start
- nano-ros installed, the host provisioned with
nros setup linux, and ROS 2 sourced for the first configure. - The package’s message dependencies reachable through
AMENT_PREFIX_PATH. For a project with its own message packages, source the project’s install too (source <project>/install/setup.bash); nano-ros generates its own bindings from those.msgfiles.
Steps
-
Keep the package’s
CMakeLists.txtas it is. It needs no nano-ros line:cmake_minimum_required(VERSION 3.20) project(my_node LANGUAGES CXX) find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(std_msgs REQUIRED) add_executable(my_node src/my_node.cpp) ament_target_dependencies(my_node rclcpp std_msgs) ament_package()find_package(rclcpp)resolves to nano-ros’s find module, which wins over an installed ROS 2 even when ROS 2 is sourced, because CMake tries modules first. Every target an ament verb creates, or that linksrclcpp::rclcpp, is built withNROS_CPP_STD, thestd::shared_ptr-shaped API ported code expects. -
Add one root
CMakeLists.txtbesidesrc/. It is the only file that names nano-ros:cmake_minimum_required(VERSION 3.22) project(my_workspace LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(NROS_PLATFORM posix) set(NROS_RMW zenoh) add_subdirectory("${NANO_ROS_SDK}" nano_ros) set(NROS_INTERFACE_SEARCH_PATH "${CMAKE_SOURCE_DIR}/src") include("${NANO_ROS_SDK}/cmake/NanoRosAmentSurface.cmake") nros_workspace_interfaces() # every message package in src/, in order add_subdirectory(src/my_node)Add each package before the packages that
find_packageit; the configure refuses an out-of-order find by name. -
Configure and build:
source /opt/ros/humble/setup.bash cmake -B build -DNANO_ROS_SDK="$(nros locate nano-ros)" cmake --build build -
Fix what the compiler names. Most stock nodes need no edit. These are the two most common, from the stock ros2/examples ports:
A global
Node::SharedPtrassigned from a temporary does not compile, because nano-ros’sSharedPtrobserves the node rather than owning it. Keep the node in a local first:// Before g_node = rclcpp::Node::make_shared("minimal_service"); // After auto node = rclcpp::Node::make_shared("minimal_service"); g_node = node;A
try/catchdoes not compile, because nano-ros is built-fno-exceptions. A failed call reports a result instead:// Before try { publisher->publish(message); rclcpp::spin_some(node); } catch (const rclcpp::exceptions::RCLError & e) { RCLCPP_ERROR(node->get_logger(), "unexpectedly failed with %s", e.what()); } // After publisher->publish(message); rclcpp::spin_some(node);A node you construct by hand, outside a generated entry, cannot throw either: check
node.ok()after constructing it. The other spellings and what each maps to are in rclcpp compatibility. -
Run it against the router your ROS 2 peers use:
NROS_LOCATOR=tcp/127.0.0.1:7447 ./build/src/my_node/my_node -
Size the pools for a large node. A package built this way declares no entity counts, so each pool starts at its embedded default and start-up stops at the first one that fills, naming its knob. In a nano-ros workspace, let the census count them. For an image that runs on a board (not on the host), this is the default: a C/C++ component that states no
entitiesis counted by its census, the configure running the program once on the host and sizing the pools from what it created. Writing it down says the same thing:[[component]] pkg = "my_pkg" class = "my_pkg::MyNode" name = "my_node" entities = "census"The census build needs a host C and C++ compiler, CMake, Ninja, the host Rust target and the store’s Corrosion; the configure names whichever is missing. A component whose sources call an RTOS API directly cannot build for the host, and its configure is refused with two fixes: list its entities (
entities = ["publisher:std_msgs/msg/String:/chatter", "timer"]), or writeentities = "defaults"to keep the embedded defaults on purpose.Otherwise set the knobs in the configure’s environment. Autoware’s
autoware_external_cmd_selector(12 subscriptions, 7 publishers, a service) needed:export NROS_EXECUTOR_MAX_CBS=40 NROS_ZENOH_MAX_LIVELINESS=128 \ NROS_ZENOH_MAX_PUBLISHERS=32 NROS_ZENOH_MAX_SUBSCRIBERS=32 \ NROS_ZENOH_MAX_QUERYABLES=32 -
To run it on a board, add a per-platform directory beside the source with a
system.tomlnaming the board, and build it withnros build:find_package(nano_ros REQUIRED) nano_ros_add_executable(minimal_publisher ../src/minimal_publisher.cpp ROS2_MAIN)No C runtime calls
mainon a board, so the build renames yourmainand calls it from the platform’s entry, withargc == 0.ROS2_MAINgives the package the C++ standard library (on Zephyr, also setCONFIG_REQUIRES_FULL_LIBCPP=yandCONFIG_GLIBCXX_LIBCPP=yinprj.conf) and theNROS_CPP_STDAPI. A board has no command line, so state the launch file’s parameters on the image:[image.<id>] params_files = ["config/x.param.yaml"] ros_args = ["--ros-args", "-p", "update_rate:=10.0"]Zephyr’s
native_simcannot run a ported node; use a Cortex-M board such as mps2-an385 in QEMU.
Example
examples/templates/cpp-port-minimal-publisher/
vendors the ROS 2 tutorial’s minimal_publisher.cpp unmodified and builds it
through the steps above, on Linux and, from its mps2-an385-freertos/ and
zephyr/ directories, on two boards. Its package CMakeLists.txt is the
stock ament_cmake_auto shape:
find_package(ament_cmake_auto REQUIRED)
find_package(rclcpp REQUIRED)
ament_auto_find_build_dependencies()
ament_auto_add_executable(minimal_publisher src/minimal_publisher.cpp)
ament_target_dependencies(minimal_publisher rclcpp)
ament_auto_package()
Several programs in one package
An ament package often builds more than one executable, and a ported one
keeps them. Each nano_ros_add_executable (or ament_auto_add_executable)
is its own program:
nano_ros_add_executable(talker src/talker.cpp ROS2_MAIN)
nano_ros_add_executable(listener src/listener.cpp ROS2_MAIN)
nros build builds them all. As with ros2 run <pkg> <exec>, you choose
which one runs when you run the image:
nros run my_bringup:linux --exec listener. With several programs and no
--exec, nros run refuses and lists them. A bringup can also choose the
program in its launch file, by naming the package and the executable:
<launch>
<node pkg="my_pkg" exec="listener" name="listener"/>
</launch>
nros run then takes that program with no --exec. Every node in such a
launch file must name one of the image’s own packages: nothing else in that
bringup is built, so a node from any other package is refused.
On a board, each program is its own firmware, and each links its own copy of the kernel and the network stack, so two programs cost two images’ flash. On a board sized by a census of its program (a cross board, for a package whose bringup declares no components), every program’s census is taken and the image is sized for the larger: each pool is the most any one program needs.
One limit applies for now: Zephyr builds one program per package, because a west build is one Zephyr image. A second program is refused when the build configures, naming both programs; give it a package of its own.
What still needs an edit
-
Exceptions. Guard a
throwwith#if defined(__cpp_exceptions)and abort in the other arm. -
MultiThreadedExecutor. A compile error naming the alternative: parallelism is a sched task (Pick a scheduling model), not a callback group. Linux scheduling calls such assched_setschedulerbecome no-ops on a board, where the sched task’s priority applies. -
A thread per action goal. Run the goal from the accepted callback; a goal handle used from a thread you start races the executor.
-
Unbounded strings and sequences in a message you subscribe to stop the compile. Bound them in a
nros-codegen.tomlat the workspace root:[fields] "std_msgs/String.data" = 256 -
Message strings are
rclcpp::FixedString<N>, notstd::string: assign withmessage.data = s.c_str(). -
Out of scope:
tf2,image_transport,pluginlib,class_loaderanddlopencomposition, and generic publishers by type name alone (pass the type hash:create_generic_publisher(topic, type, type_hash, qos)). Parameters are not persisted across boots.
If it doesn’t work
find_package(<pkg>)is refused, naming an installed file. nano-ros does not ship that upstream library (bondcpp,tf2_ros). Remove the dependency, or port the library into your workspace as a package.- A node’s publishers silently do nothing. It failed to construct, and
without exceptions nothing said so. Check
node.ok()after a hand-written construction. - A stored timer or subscription keeps running after you drop it. Its
SharedPtris a handle, not an owner. Calltimer_.reset()to release it;timer_->reset()restarts it, as upstream. ${CMAKE_SOURCE_DIR}points at the wrong directory. Every package configures in one CMake run, so it is the workspace root. Use${PROJECT_SOURCE_DIR}.
See also
- rclcpp compatibility: every upstream spelling and what it maps to, and the measured ports.
- How nano-ros differs from ROS 2.
- Message generation: the CMake spellings for message bindings.
Design background
- RFC-0089: ROS 2 API adoption, and the compile-or-conform rule
- RFC-0018: C++ API design
- RFC-0033: message field capacity
Move a ROS 2 project over
Needs first: Organize a larger workspace
Use this page to move an existing ROS 2 workspace (a src/ of packages built
with colcon, run with ros2 launch) to nano-ros, before you port the nodes
one by one.
nano-ros keeps the workspace and package vocabulary: a src/ of packages
with package.xml manifests, launch files in the ROS 2 schema, and the
ROS-shaped names of nodes, topics, services, actions and QoS. It changes the
setup boundary, because it targets embedded builds that have no shared
libraries and no runtime plugin loading:
| You have (ROS 2) | You get (nano-ros) |
|---|---|
a distro install, then rosdep install | the nros CLI, then nros setup <board> --rmw <rmw> |
colcon build | nros build <image>, which drives cmake, cargo or west |
ros2 launch pkg file, ros2 run | nros run <bringup>:<image>: the launch topology is compiled in |
RMW_IMPLEMENTATION=… at start-up | [system] rmw = "…" in the bringup’s system.toml, at build time |
package.xml | kept as it is |
.launch.xml, .launch.py | kept, in the bringup package; resolved at build time |
| message packages from the ament index | bindings generated under build/ by nros build |
find_package(rclcpp), ament_target_dependencies | kept: nano-ros’s own find modules and ament verbs |
The full account of the differences is in How nano-ros differs from ROS 2.
Before you start
- A ROS 2 Humble workspace that builds with
colcon build. - ROS 2 Humble installed. nano-ros generates its message bindings from it,
and its zenoh router is ROS 2’s
rmw_zenohd.
Steps
-
Install the CLI and provision the host, in place of the distro install and
rosdep:curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh | sh export PATH="$HOME/.nros/bin:$PATH" nros setup linux --rmw zenohFor a board, name it:
nros setup mps2-an385-freertos --rmw zenohfetches its cross compiler, emulator and SDK sources into~/.nros/sdk. Nothing is installed system-wide. -
Add a bringup package. It replaces the
ros2 launchcommand line: apackage.xml, asystem.toml, and your launch files underlaunch/:cd src nros new system my_robot_bringup --components talker_pkg,listener_pkgnros new system: scaffolded bringup pkg my_robot_bringup at …/src/my_robot_bringup (2 component(s))It writes a
[[component]]row per package withclass = "<pkg>::TODO"; set each to the node’s class. Move the launch files you run intomy_robot_bringup/launch/, replacing the generatedsystem.launch.xml. Stock XML launch files work as they are;.launch.pyfiles are resolved at build time too. -
State the backend and the target once, in the bringup’s
system.toml. These two lines replaceRMW_IMPLEMENTATIONand any cross-compile recipe:[system] name = "my_robot" rmw = "zenoh" # zenoh | cyclonedds | xrce [image.linux] board = "linux" [image.freertos] board = "mps2-an385-freertos" # the platform follows from the boardOn Linux,
ROS_DOMAIN_IDandNROS_LOCATORstill work at run time. On a board the same values come from the image row, because a board has no environment to read them from. -
Port the nodes. A C++ node keeps its source and its
CMakeLists.txt; see Port a C++ node. For a Rust or C node, the Tutorial shows the node package shapes. -
Build and run one image:
source /opt/ros/humble/setup.bash nros build linux nros run my_robot_bringup:linuxThe first build records the ROS 2 prefix, so later shells need not source ROS 2. A POSIX C++ workspace can still be built with
colcon buildfor its existing consumers. -
Check it from stock ROS 2:
export RMW_IMPLEMENTATION=rmw_zenoh_cpp ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
Example
The whole move for a two-node project that ran as
ros2 launch my_robot system.launch.xml with Cyclone DDS:
my_robot_ws/
└── src/
├── talker_pkg/ # unchanged
├── listener_pkg/ # unchanged
└── my_robot_bringup/
├── package.xml
├── system.toml
└── launch/system.launch.xml # moved here, unchanged
# src/my_robot_bringup/system.toml
[system]
name = "my_robot"
rmw = "cyclonedds"
default_launch = "system.launch.xml"
[[component]]
pkg = "talker_pkg"
class = "talker_pkg::Talker"
name = "talker"
[[component]]
pkg = "listener_pkg"
class = "listener_pkg::Listener"
name = "listener"
[image.linux]
board = "linux"
nros setup linux --rmw cyclonedds
nros build linux
nros run my_robot_bringup:linux
Cyclone DDS needs no router, so this interoperates with rmw_cyclonedds_cpp
nodes directly.
If it doesn’t work
- Changing
RMW_IMPLEMENTATIONchanges nothing. The backend is compiled in. Edit[system] rmwand build again. - A stock ROS 2 node does not hear the image. The two use different domain IDs or QoS reliability, the ROS 2 side is on a different RMW, or no zenoh router runs. See Talk to ROS 2.
- A
<depend>stopsnros setup. It names something that is neither a workspace package, a message package, a system key nor a package your ROS install provides. Remove it or add the package. - The store keeps growing. Provisioning never overwrites.
nros toolchain listshows each entry and when it was last read, andnros toolchain gc --older-than 90dproposes what to remove; it removes nothing without--delete, and never an entry a pin names.
See also
- Port a C++ node.
- How nano-ros differs from ROS 2 and micro-ROS.
- Switch the RMW per image and Bridge between backends.
Design background
How a build becomes an image
Ask nros build what it would do for a host image, and it prints the handoff
without running it:
nros build: host_node_bringup:linux -> board linux (platform posix), driver cargo
cargo update --workspace --manifest-path build/posix-zenoh/linux_entry/Cargo.toml --config build/posix-zenoh/linux_entry/nros-cargo.toml
cargo build --manifest-path build/posix-zenoh/linux_entry/Cargo.toml --config build/posix-zenoh/linux_entry/nros-cargo.toml
Three things in those lines are the subject of this page. The image is named
by its bringup and its id, host_node_bringup:linux, and it resolves to one
board. The build is done by an ordinary tool, here cargo, on a project you
did not write: linux_entry lives under build/, generated. And every
setting the compiler sees comes from a generated file beside it,
nros-cargo.toml, never from your shell or a .cargo/config.toml of your
own.
The rest of this page explains why a nano-ros image is built this way: what
ends up in the binary, what nros build generates, which tool it hands off
to, and how nano-ros fits into a project whose build you already own.
The layers in an image
An image is your nodes and the layers under them, linked into one binary:
Application your Rust, C or C++ node packages
Board package hardware and network bring-up, the entry point
Core runtime executor, nodes, publishers, services, actions,
parameters, CDR serialization
RMW backend zenoh, XRCE-DDS, Cyclone DDS, or your own
Platform clock, memory, threads, sleep, random, sockets
Each layer owns one job. The core runtime is middleware-agnostic: it owns the executor, the entities and serialization. Your message types are generated Rust, C or C++ types with CDR serialization, and the RMW backend receives serialized bytes only. Publishing runs one way through the stack and receiving runs back:
your message -> CDR serializer -> RMW publish (bytes) -> transport
transport -> RMW receive (bytes) -> CDR deserializer -> your callback
That boundary keeps a backend small, and it lets one message type work the same from all three languages.
The platform layer supplies what a desktop ROS 2 gets from its operating system: a monotonic clock, memory, threads, sockets. On bare metal it can also expose a network poll hook, so the runtime advances the network stack while it waits. The board package joins a platform to real hardware: it brings up the clock, the network interface and its drivers, and it provides the entry point that starts the scheduler or the main loop.
Every layer is chosen when you build. The RMW backend is the image’s rmw,
the platform follows from its board, and nothing is loaded at run time. A
binary may link more than one backend and bridge between them
(Bridge between backends).
When nros build drives the build
In a nano-ros workspace you write node packages and a bringup, and no build
file for the image. nros build makes one. It is one pipeline for every
board. Stages 1 to 4 are nros configure, which nros build runs first and
which you can also run on its own; stage 5 is the build:
- Discover. It walks the
package.xmlfiles of the workspace and puts the packages in dependency order. - Resolve. It picks the image: the one you named, else the bringup’s
[system] default_images. With several images and no default it lists them and stops, rather than guess. - Preflight. It checks that the toolchains, SDKs and sources the board needs are present.
- Generate. It writes the message bindings, the resolved system, the
image’s entry and a root build file under
build/. - Hand off. It runs the native tool on what it generated, and passes the
tool’s output through untouched. The tool’s own configure step (CMake’s or
west’s, the host configure) reads what
nros configurewrote and never runs it again.
The tool is chosen by the board, not by the languages in the image:
| The image | The driver |
|---|---|
| a Zephyr board | west, on a generated Zephyr application |
| any C or C++ package, any other board | CMake; Rust packages join through Corrosion |
| only Rust packages, any other board | cargo, on the generated entry package |
CMake wins when the languages mix because Corrosion lets CMake consume a cargo crate, and nothing lets cargo consume a CMake project. A Zephyr image gets no generated root at all: a Zephyr application already is a complete CMake project, and its Kconfig files are yours.
Because the last stage is the native tool, a compiler error is the compiler’s,
unchanged. --dry-run prints the exact commands, and running them yourself
gives the same artifact. No command line carries a --target: the board’s
triple, its link flags and its emulator runner are in the settings generated
for the image. What the tool leaves behind, and where, is listed in
What nros build produces.
The entry is the system
The generated entry is the main() of the image. It constructs each
component the bringup names, applies the launch file’s parameters, and runs
them on the executor. Running the entry is launching the system.
So system.toml and the launch file are inputs on your host, and they never
reach the device. The build resolves them and bakes the result into code the
compiler sees: which nodes exist, their names and remappings, the parameter
values, the pool sizes the contract asked for. A launch condition is decided
at build time, and changing the system means building and flashing again.
A value meant to change at run time is a parameter.
The same rule decides where a configuration fact belongs. A fact true of
every copy of a board (its name, platform, target triple, how it boots) is in
the board’s package, beside its nros-board.toml. A fact true of your
machine or your application (where your SDK lives, which serial port, which
config headers) is in the bringup’s system.toml, in the image’s
[image.<id>] block or the [board_config.<board>] block beside it. If a
fact would survive publishing the board, it is a board fact. If it names a
path on your disk, it is yours. The keys are in
system.toml keys, and the task is
Configure an image.
When your build drives the build
A project started with nros new builds through nros build, as above. An
RTOS project you already have, and are adding nano-ros to, keeps its own
build: a vendored Zephyr or NuttX tree, an STM32Cube or MCUXpresso project, a
PX4 firmware. Here nano-ros
is a library your project imports, and your build tool stays in charge. It
never compiles your kernel, never owns your linker script, and never replaces
your build system.
What nano-ros adds to such a build is small and fixed: the client runtime as a
static library behind a C ABI, the generated code for your messages and your
system, and a thin C shim that your build compiles. The shim is source, not a
prebuilt, so it compiles against your own FreeRTOSConfig.h, lwipopts.h or
sdkconfig. A mismatch between your kernel’s configuration header and a
prebuilt binary would be an ABI break nothing reports.
Each host build system gets a small shell that makes nano-ros look native to it:
| Your build | How nano-ros joins it | The shell in the release |
|---|---|---|
Zephyr (west) | a west module | zephyr/ |
NuttX (make and Kconfig) | an apps/external/ application | integrations/nuttx/ |
| FreeRTOS or ThreadX, CMake project | add_subdirectory(nano-ros) | cmake/platform/ |
PX4 (make px4_…) | a module directory, generated ahead of PX4 | integrations/px4/ |
| PlatformIO | a library with a pre-build codegen script | library.json, integrations/platformio/ |
In every row the split is the same: your build owns compiling and linking,
and nano-ros owns the shell and the code it generates on your host. Where the
host build has a configure step, its shell calls nros configure from that
host configure, so the generated code is current before anything compiles.
PX4 and PlatformIO have no host configure that could run it from inside, so
nros configure runs before them and leaves a tree they build natively. The steps are in
Build inside an existing CMake or vendor tree,
Zephyr, NuttX
and PX4.
FreeRTOS has one exception. For the QEMU reference board, nano-ros can build
the FreeRTOS kernel and lwIP for you from a kernel checkout, so the demo works
with no SDK. With a kernel your SDK vendors, do not use that path: your SDK
builds the kernel, picks its port and owns FreeRTOSConfig.h, and nano-ros
compiles against your include directories like every other row above.
Why it has this shape
Three choices shape almost everything else in the stack.
The RMW layer is nano-ros’s own. ROS 2’s rmw.h assumes a heap, an OS
scheduler with preemptive threads, a dynamic loader and middleware that
dispatches in its own background threads. None of that holds on a Cortex-M3
with 64 KB of RAM. The nano-ros RMW leaves the I/O buffers to the caller,
replaces wait sets with an explicit call that drives I/O, and binds the
backend when the image links, through a C ABI table. A backend can be written
in C or C++ as well as Rust. RMW API design has
the full argument.
One future type, and no hidden spin. rclcpp owns the spin loop, and rclc
has no future type at all; neither suits a single-threaded MCU. nano-ros has
one Promise<T> that you poll, block on with a timeout, or .await, and the
library never runs a spin loop you did not ask for: every blocking helper
takes the executor and drives it. The client library
explains it.
Platform capabilities are separate. zenoh-pico needs a heap, threads, sockets and a clock. XRCE-DDS needs a clock and four C functions. Bare metal has no scheduler. So each capability is its own trait, which a platform may stub when it lacks it, and each method states whether it blocks, whether it can fail and what an unsupported call does. The headers behind the Platform API and C ABI state it for every symbol.
Where nano-ros differs from ROS 2
nros buildtakes the place ofcolcon build. It reads the samepackage.xmlfiles, but it generates the image’s build itself and has no install space: what the native tool writes in its build tree is the deliverable.- The RMW is chosen when you build, not when you run. There is no
RMW_IMPLEMENTATIONplugin loader, because many targets have no dynamic loader. - No
ros2 launchon the device. The launch file is read at build time, and the entry is the launched system. - The board is part of the build. An image names a board, and the board decides the toolchain, the build tool and how the image runs.
How nano-ros differs from ROS 2 and micro-ROS covers the API side.
Design background
- RFC-0072: your build owns compiling and linking; nano-ros owns the shell and the host-time code generation; the bringup never reaches the device.
- RFC-0065: the five stages, and the driver chosen by the board.
- RFC-0120:
nros configure, the one resolver every road calls before its host configure. - RFC-0072:
an existing RTOS project keeps its own build tool; a project started with
nros newbuilds throughnros build. - RFC-0054: C headers as the one source of the ABI.
- RFC-0121: the workspace layout and the generated entry.
- RFC-0122: behaviour bringups and the copy-out examples.
The execution model
The real-time example workspace runs a 10 ms control node and a 100 ms telemetry node in one image, each on a sched task of its own:
[[component]]
pkg = "ctrl_pkg"
class = "ctrl_pkg::Control"
name = "control_node"
group_tasks = { ctrl = "high" }
[[component]]
pkg = "telem_pkg"
class = "telem_pkg::Telem"
name = "telem_node"
group_tasks = { telem = "low" }
When the configure takes the image’s census, each node logs where it landed:
[INFO] Telem::register on a sched task admitting group `telem`
Why two sched tasks, and not one executor that runs both nodes? This page answers that question: how an executor runs callbacks, how the two ways of receiving data differ, where preemption comes from, and how the RTOS underneath schedules the threads nano-ros creates. The task itself is Pick a scheduling model.
A callback runs to completion
An executor runs one callback at a time, to completion. Within one thread nothing interrupts your code mid-callback, so a callback that becomes ready while another runs waits for it to return. Its worst case is its own execution time plus the longest other callback that can be running when it wakes:
response time >= own execution time + longest other callback on the thread
Put the 1 ms control loop and a 5 ms telemetry callback on one thread, and the loop misses its deadline every time the two meet, whatever priority or class either has. Priorities and classes decide which ready callback runs next. They cannot stop one that is already running. Preemption needs a second thread, which is what a sched task is.
Two ways to receive
Every entity (a subscription, a service, a client, an action server or client, a timer) can be used through one of two layers, with separate verbs, so the choice is visible in the source:
| You poll | The executor dispatches | |
|---|---|---|
| Rust verbs | Node::create_polling_subscription, create_polling_service, create_client, create_publisher | Executor::register_subscription, register_service, register_timer, register_action_server; or rclrs’s Node::create_subscription(topic, callback) |
| You get | an owned handle you take() from, or a Promise<T> | a callback that runs when data, a request or a timer is ready |
| Who schedules | your loop or your RTOS task | spin_once |
The polled constructors are named create_polling_* because rclrs’s
create_subscription takes a callback, and a polled form under the same
name would compile a ported line into a different contract.
Poll when your code already owns its schedule (a bare-metal loop, one
FreeRTOS task per entity) or when the flow is request and response: a
service client’s call returns a Promise<Reply>, and an action client’s
send_goal leads to get_result. Typed service and action clients have only
the polling form. Dispatch when the code is callback-shaped, the way rclcpp
code is: one closure per entity, all routed by one spin_once. A dispatched
callback and its captures are stored in the executor’s arena, whose size the
build sets; a polled handle needs no arena entry.
Both layers share one session and mix freely in one node. C and C++ split
them by type: rclc_polling_subscription_t and the rclcpp::Poll*
templates are the polling forms, beside the dispatched rcl_subscription_t
and rclcpp::Subscription. A polled handle can also take a wake callback,
so an RTOS task sleeps until data lands instead of polling; a backend that
cannot wake falls back to polling. The signatures are in the
Rust, C and
C++ API references.
What one spin does
spin_once(timeout) waits for I/O, up to the timeout, in the platform’s own
wait primitive, so the thread sleeps rather than spins. When I/O is ready it
drains all of it, runs the ready callbacks, and then the expired timers and
guard conditions. The backend may report its own next internal event (a
lease keep-alive, a heartbeat), and the wait is capped at that.
Draining everything is the right default for one task doing all the ROS
work: it gives the most throughput. Its cost is that a timer can wait
behind every subscription callback that was ready before it. SpinOptions
bounds a blocking spin:
| Option | Effect |
|---|---|
max_callbacks(n) | return after n callbacks, so a loop re-checks timers between them |
timeout(d) | return after d, for a cyclic frame that gives ROS a fixed slot |
spin_once() | one round of work, then return |
poll_interval(d) | how long one pass may wait on the transport (default 10 ms) |
With max_callbacks(1) a timer waits behind one callback, not all of them.
With timeout(d) the work left over resumes next frame; a single callback
longer than the slot still overruns it. Neither option bounds a callback
itself, so a hard deadline still needs its own thread.
Sched tasks and levels: preemption from the kernel
A sched task is one executor on one RTOS thread, with its own priority and spin period. All of an image’s sched tasks share one middleware session. A more urgent task’s thread has a higher kernel priority, so when it wakes the kernel preempts a less urgent one mid-callback. That is the second thread the bound above asks for.
You don’t have to write sched tasks yourself. The build derives levels
from the contract: each node’s rank comes from its trigger rate (rate
monotonic: a faster timer is more urgent), and each distinct rank is one
level, up to a cap that depends on the platform. When the ranks outnumber
the cap, adjacent levels merge, and the build reports each node that lost
its own rank. A sched task you declare in [tasks.<name>], bound to a
callback group with group_tasks, is a pin: its members share one level at
its stated priority, and derivation places only the nodes no task binds.
Three more rules shape what you see:
- Priorities are allocated. A level takes its priority from the board’s
application band, below the threads the transport runs for itself. A
priority that would land in that band is refused, unless the task says
above = "transport". - The boot level is the least urgent. It runs on
main()and owns the session; the build spawns the others. - On a multi-core host, levels run in parallel. Preemption shows only when they compete for one CPU.
On Linux, the 1 kHz-loop-beside-5 ms-telemetry case is measured: on its own
level, the loop misses no deadline in 60 s on a PREEMPT_RT kernel, and on
one level it does.
Inside a level: scheduling classes
Within a level, a callback’s scheduling class orders the ready work:
| Class | Orders ready work by | Use it for |
|---|---|---|
Fifo (default) | registration order within a priority bucket | most callbacks |
Edf | absolute deadline | periodic work with stated deadlines on one level |
Sporadic | Fifo, plus a budget per replenishment period | a callback whose CPU share must be capped |
BestEffort | last, after every other bucket | logging, telemetry |
A sched task’s class (real_time, best_effort or time_triggered) is
the deployment-side spelling.
Who enforces a budget
A level whose sched task states a budget and a period has exactly one enforcer. The kernel takes it where it can; otherwise the executor enforces the same numbers at callback boundaries. The image prints which:
nros: level budget sched_task=`capped` 2000us/10000us enforced by the KERNEL
On Linux the kernel enforces it with SCHED_DEADLINE, for a spawned
real_time level, when the process holds CAP_SYS_NICE. On NuttX it is
SCHED_SPORADIC. Zephyr, FreeRTOS and ThreadX have no kernel budget, so the
executor enforces it. Without CAP_SYS_NICE, a Linux image keeps running:
it prints the refusal once, with the setcap command that fixes it, and
every level runs at the default policy. That image has levels but no
preemption between them.
Linux measures a SCHED_DEADLINE budget as an amount of work, not as CPU
time. The kernel charges a running level for its time scaled by how fast the
CPU is clocked against its maximum. So on a CPU running below full speed,
which is common under the powersave governor, a 2 ms budget lasts longer
than 2 ms. On one measured host it lasted a median 1.15 times as long, and up
to about 5 times. The closer the level’s CPUs run to their maximum frequency,
for example under the performance governor, the closer the budget comes to
CPU time.
The RTOS underneath
Each level is an ordinary RTOS thread, and the RTOS schedules it. All of the supported kernels schedule by fixed-priority preemption: the highest-priority ready thread runs, and a more urgent thread that becomes ready preempts it at once. Rate-monotonic assignment, which the level derivation uses, gives shorter periods higher priority, and it is optimal among fixed-priority assignments for independent periodic tasks. A task’s worst-case response time under it is:
R_i = C_i + Σ_j ⌈R_i / T_j⌉ × C_j (over every higher-priority task j)
where C is a worst-case execution time and T a period. The task meets
its deadline when R_i ≤ D_i.
Earliest deadline first (EDF) runs the task with the nearest deadline. It
can schedule any task set up to 100% utilization, where rate-monotonic
assignment is guaranteed only to about 69% in general, but it is harder to
analyze and less predictable in overload. nano-ros has EDF as the executor’s
Edf class on every platform, and Zephyr also has it in the kernel.
Round-robin shares the CPU in time slices among threads of the same priority. It prevents starvation, at the price of jitter. FreeRTOS slices equal priorities by default, so two levels at one priority there would buy no preemption, only memory, and the build merges them.
Each kernel has its own mechanism beyond this, which you reach through a per-RTOS table of a sched task:
- ThreadX preemption threshold: a thread may be preempted only by threads above its threshold, which makes a non-preemptible region without masking interrupts.
- NuttX
SCHED_SPORADIC: a sporadic server that caps an aperiodic task’s CPU share by a budget per period. - Zephyr: cooperative threads (preempted only by interrupts), preemptive threads, and kernel EDF among threads of one priority.
Priority numbers run in opposite directions: on FreeRTOS, NuttX and Linux a bigger number is more urgent, and on ThreadX and Zephyr a smaller one is. What each platform delivers is generated in the Scheduling wiring matrix.
Priority inversion
A high-priority task that waits on a lock held by a low-priority one can be held up indefinitely by a medium-priority task that preempts the holder. The usual cures are priority inheritance (the holder runs at the waiter’s priority), which every supported kernel offers on its mutexes, and priority ceilings (the holder runs at the lock’s fixed ceiling), which NuttX offers. The cheaper cure is to share nothing between levels: give each level its own data, and pass values between them as messages.
Deferred dispatch
By default a callback runs inline: from the executor’s spin, on the
thread that drives the transport. A node declares otherwise through
Node::DISPATCH, a DispatchStrategy:
Inline(the default) is served on every platform.Deferredqueues the callback for a dispatch task, which decouples its latency from network polling. The entries generated for the supported boards have no dispatch task, since each sched task’s loop is already the only task that runs its callbacks, so aDeferrednode runs inline there. It still builds unchanged for an entry that does drain the queue.FromIsris reserved and refused bynros check: no generated entry dispatches from an interrupt handler.
The strategy is per node, not per callback, so a node is wholly one or the
other. A deferred callback runs on a different task from the one that
registered it, so its state cannot live in a closure’s captures without a
heap. A Deferred node therefore registers with the _static forms
(create_subscription_static) and gets a tag, a &'static str identifier.
Its state lives in the node’s State, and its on_callback matches the tag
against the event. An inline closure’s captures live on the spin task’s
stack frame, no heap, no boxing, so closures stay on the inline path; the
macro refuses a closure on a Deferred node.
The queue under Deferred is the executor’s own, and you can use it without
the macros: set_deferred marks a callback, set_defer_notifier says which
one is queued, and run_deferred or run_deferred_handle runs it from a
task whose priority nano-ros owns. The queue is one bit per callback slot,
so it allocates nothing, and a timer cannot be deferred.
What nano-ros does not run on
Every shape on this page keeps one promise: nano-ros decides which callback runs and at what priority. A loop owned by a foreign async runtime or event loop (tokio, Embassy, Qt, GLib) would decide that instead, so no real-time bound could be stated, and nano-ros does not support one. The same holds for a hand-written drain loop on a thread nano-ros did not create.
Timing evidence
nano-ros states no measured worst-case execution times. The analysis it supports is static: you check the callbacks a sched task runs for unbounded loops, recursion and missing timeouts with Clippy and a call-stack tool (Analyze timing), and the level derivation uses execution times where a callback record carries one. Certification evidence (ISO 26262, DO-178C) needs a static WCET tool on the final binary: aiT from AbsInt is the commercial standard, and Platin is an open-source option that works on LLVM output.
Where nano-ros differs from ROS 2
- No
MultiThreadedExecutor, and callback groups do not make threads. An executor dispatches on one thread. Parallelism is a sched task, and a callback group only names which sched task its callbacks run on. - Threads and priorities are generated. The build creates the RTOS threads, allocates their priorities from the board’s band and spawns them from the generated entry. You state rates and tasks, not thread code.
- The spin is a poll loop. There is no wait set:
spin_oncedrives I/O, and its wait is bounded bypoll_interval. - Polled entities are first-class. ROS 2 receives through callbacks;
nano-ros also has
create_polling_*, under a different name.
The ROS 2 executor documentation describes the model nano-ros departs from.
Design background
- RFC-0002: the executor’s scheduling contexts, and the twelve scenarios the model answers.
- RFC-0108: preemption levels, how they are derived and the budget enforcer.
- RFC-0079: priority is allocated, not authored.
- RFC-0113: every supported way to run nano-ros keeps the real-time promise; the dispatch strategies.
- RFC-0053: ThreadX multi-tier execution.
Static memory and pools
The memory report of a hosted zenoh image lists its largest RAM symbols first:
## top 5 RAM symbols
131,072 25.3% nros_rmw_zenoh::shim::subscriber::LARGE_PAYLOADS
88,560 17.1% linux_entry::__nros_entry_run::__NROS_SCHED_TASK_EXECUTOR_BACKING
88,552 17.1% nros_node::executor::backing::EXECUTOR_BACKING
87,072 16.8% g_sessions
33,536 6.5% nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX
None of these is a heap. Each is a static array, sized when the image was built: a ring of large-message slots, the executor’s storage, the transport’s session table, a ring of service requests. Together they are most of the image’s RAM, and they are the same size whether the node creates one publisher or twenty. This page explains why nano-ros keeps its memory this way, where each size comes from, and what still allocates. The task of reading your own image is Measure static memory.
Why static
A microcontroller with 64 KB of RAM has no room for a heap that fragments,
and a malloc that can fail at run time is a failure a review has to
account for. So the
nano-ros core is #![no_std]: the executor, nodes, publishers,
subscriptions, services, actions, timers, parameters and CDR serialization
all work with no allocator. Their storage is fixed-size pools, carved at
build time.
A pool is an array of slots. Every slot costs its bytes whether an entity uses it or not. So an over-provisioned pool is wasted RAM, and an under-provisioned one is a create call that fails at run time, when the pool is full. Neither failure shows up at the compiler. The design answer is to size each pool from what the image declares, rather than from a guess.
Where a pool’s size comes from
The pools that dominate static RAM are derived per image from what the image’s components declare: the entity inventory of the contract (how many publishers, subscribers, services, clients and nodes), the message types they use and the parameters they declare. The build writes the answers into the image’s generated settings, so you state nothing for them:
- The entity counts size the transport’s publisher, subscriber and queryable tables, the liveliness tokens and the executor’s callback slots.
- The message types size the receive buffers: the largest small-class type the image subscribes to sets the small slot, and the large class gets its own pool, which is zero bytes when no subscribed type is large.
- The executor’s arena, which holds the dispatched callbacks and their captures, is sized from the same inventory.
The transport’s wire buffers, the network stack’s socket pools and the parameter store limits are not derived: they depend on your traffic, not on your entities, so they are yours to set (Tune throughput and latency).
A value you state always wins over a derived one. The order is: an exported
environment variable, then the image’s [image.<id>.knobs], then the board
descriptor’s [knobs], then the derived value, and the crate’s default only
when nothing is stated and nothing can be derived. nros config explain
shows which of these answered for each knob.
Two properties of the message-derived sizes follow from how they are found:
- They are upper bounds. The bounds come from every type in the interface closure the image links, not only the types it subscribes to, so a size is never too small but can be larger than you need. The build names the type that set it.
- One unbounded type stops the derivation. A
stringor a sequence with no bound has no largest size. The build then derives nothing, keeps the stated or default values, and names every unbounded type and the member that makes it so. Bounding the field in the.msg(string<=64), or capping it innros-codegen.toml, restores it.
Today some pools are sized by the backend you link rather than by what your node does: a publisher-only node still reserves the service pools. An image that looks larger than its entities suggest is expected, and turning those knobs down is the remedy. The Static pool inventory lists every knob and what it sizes.
The node interfaces an image carries
A ROS 2 node serves six parameter services, publishes /rosout and declares
use_sim_time without being asked, and so does a nano-ros node: every image
gets them unless it opts out. In nano-ros those are capability axes,
param_services, rosout and sim_time, and each costs pool slots: six
queryables per node and a /parameter_events publisher for the first, one
publisher per node for the second (the executor creates each node’s /rosout
writer), and for the third the /clock subscription that setting
use_sim_time true creates: one per executor, a subscriber, a callback slot,
an executor arena entry with its receive buffer and a liveliness token. That
subscription is reserved whenever sim_time is built in, not only when the
parameter starts true, because ros2 param set can turn it on at any time.
The node_interfaces key decides them per image:
[image.pico]
board = "rpi-pico-w-zephyr"
node_interfaces = "none" # this image keeps none of them, even if declared above
"stock" (the default) adds all three axes to whatever the image declares
in features, and "none" removes all three. It can be stated in
[system], [image_defaults] or [image.<id>], and the most specific table
wins. The pools, the sizing descriptor’s infra_families and the C/C++ and
Zephyr capability settings all follow the result, so turning the interfaces
off is how a memory-tight image gives their slots back. A board whose budget
holds one service server, such as the Pico W, needs it: with the interfaces
on, its build stops and names the knob it would have to raise. Two
differences from stock ROS 2 remain: /rosout is VOLATILE (rcl’s is
TRANSIENT_LOCAL), and a node does not subscribe to /parameter_events.
The three service inboxes (zenoh)
The zenoh backend shows how a pool is split so that each part is sized for its own traffic. Every service server is a zenoh queryable, and each queryable owns an inbox ring: requests wait there between the transport’s read task and the executor’s spin. The rings sit in three tables, one per family, so a family is sized for its own requests rather than for the largest request any service could send:
| Symbol | Holds | One ring is | Knobs |
|---|---|---|---|
USER_SERVICE_INBOX | your services | depth × (slot + 12 B) | NROS_SERVICE_INBOX_BYTES, NROS_SERVICE_INBOX_DEPTH |
ACTION_INBOX | the four queryables of each action server | depth × (slot + 12 B) | NROS_ACTION_INBOX_BYTES, NROS_ACTION_INBOX_DEPTH |
BUILTIN_INBOX | the runtime’s own parameter and lifecycle services | depth × (slot + 12 B) | NROS_PARAMS_SERVICE_INBOX_BYTES, NROS_PARAMS_SERVICE_INBOX_DEPTH |
The 12 B is a ring entry’s length, sequence and overflow flag. Each table holds one ring per queryable of its family, for every session, and the image’s queryable pool is partitioned among the three.
A slot’s size comes from, in order: a value you state; otherwise the largest
request type the image declares a server for (for user and action services),
or the largest set_parameters request the declared parameters can produce
(for the builtin family). With nothing declared, the user and action slots
keep 1,024 B and the builtin table is empty. A bringup that declares params
instead of param_services builds the parameter store but registers no
service, so the builtin family claims no queryable at all.
On one image on an S32K344, BUILTIN_INBOX measured 24
parameter queryables × 1 × (1,016 + 12) = 24,672 B, and USER_SERVICE_INBOX
fell from 3,744 B to 288 B when those 24 queryables left it. Read your own
figures off the memory report, not off the formula: the compiler sizes the
table, so the report is exact.
The executor’s storage
The executor’s own backing is usually the largest single owner in an image
with several sched tasks: each sched task has an executor, and each executor
has its storage. The C and C++ entries reserve it as one static sized by a
generated header (NROS_CPP_EXECUTOR_STORAGE_SIZE for C++), the Rust entry
as EXECUTOR_BACKING, and each component’s state has a generated slot of
its own. The executor carves more than callbacks from its backing: when the
image builds a parameter store, the store, the parameter services’ state,
their request and reply buffers and the slot a remote set decodes into are
carved there too. A Promise is allocation-free: it borrows its client’s
reply slot rather than owning a buffer, so a pending service call costs no
extra storage.
What alloc adds
alloc is an opt-in feature. It adds what needs a heap:
With alloc | Why |
|---|---|
Serialize and Deserialize for String and Vec<T> | heap containers |
boxed timer callbacks (Box<dyn FnMut()>) | a closure stored by the timer |
handle_request_boxed, a service reply in a Box | a reply too large for the stack |
the blocking Executor::spin, spin_period and halt_flag | a shared halt flag (Arc<AtomicBool>) |
the heap fallback for parameter services, and -p / --params-file overrides | storage the backing did not carve, and owned override strings |
The core ParameterServer API works without alloc, and so do parameter
services whenever the build knows the image builds a store: without alloc,
a build that carves no store is refused at compile time, naming
NROS_PARAM_STORE. There is no std feature. A hosted program has std
itself; the env feature reads the process environment, and log routes
nano-ros’s diagnostics to the log logger you install.
The transport still allocates
Turning off alloc removes the Rust side’s heap use (Box, Vec, String).
It does not remove allocation in the C libraries the RMW backends link. They
keep their own session state, stream buffers and protocol metadata, through
the platform’s allocator:
| Backend | Allocates through |
|---|---|
| zenoh | malloc on POSIX, k_malloc on Zephyr, pvPortMalloc on FreeRTOS, a bump allocator on bare metal |
| XRCE-DDS | malloc on POSIX and NuttX, k_malloc on Zephyr, pvPortMalloc on FreeRTOS; only when an entity is set up |
| Cyclone DDS | per message |
So an image with a transport is not free of allocation, and a feature list is
evidence that an image is heap-free and not proof of it: a vendored C
dependency or a weak-symbol fallback can link an allocator without any Cargo
feature changing. The proof is the linked image’s symbol table. nano-ros’s
own executor path is heap-free in that checked sense: its CI links an image
of the executor, component install and spin, with no transport, and fails on
any allocation symbol in it. The shipped examples all enable alloc.
Where nano-ros differs from ROS 2
- The core needs no allocator, and entities fit the pools. ROS 2 creates entities on the heap whenever you ask. A nano-ros image creates them in slots sized at build time, and a create past the pool’s size fails.
- Message fields have a fixed capacity. A ROS 2
stringor sequence grows on the heap. A nano-ros field is a fixed-capacity type: its bound, or a default capacity when the.msgstates none. A field with no bound also stops the size derivation, so a bounded field is the norm. - Memory is a build output. The sizes come from the contract, and the memory report reads them off the linked image.
Design background
- RFC-0100: the sizing model: pool sizes derived from what an image declares.
- RFC-0034: the platform layer split, and the platform’s allocator.
- RFC-0113: why no async runtime drives the executor.
The client library
A nano-ros service client, from the Linux examples, sends one request and then keeps the loop in its own hands:
let mut executor = Executor::open(&config)?;
let mut node = executor.create_node("add_two_ints_client")?;
let mut client = node.create_client::<AddTwoInts>("/add_two_ints")?;
let mut promise = client.call(&AddTwoIntsRequest { a: 2, b: 3 })?;
loop {
executor.spin_once(core::time::Duration::from_millis(0));
if let Ok(Some(reply)) = promise.take() {
log_info!(&LOGGER, "Result of add_two_ints: {}", reply.sum);
break;
}
}
Three things here differ from rclcpp. The node comes from the executor, not
the other way round. The call returns a Promise, not a
std::shared_future. And the loop that drives I/O is the application’s,
not the library’s. This page explains why the nano-ros client library, the
API above the RMW layer in Rust, C and C++, has this shape. The signatures
are in the Rust, C and
C++ API references.
Why a fourth client library
ROS 2 ships rclcpp for C++, rclc for C on microcontrollers, and rclrs for
Rust. Each assumes something an RTOS target may lack. rclcpp blocks a thread
inside rclcpp::spin(node) and waits on std::shared_future, which needs
std::thread and a condition variable. rclc runs on a microcontroller, but
it has no future type, so a request and its reply become an explicit state
machine of callbacks. rclrs targets hosted Rust with std.
nano-ros needs one library that runs on a Cortex-M3 with no threads and on a
Linux workstation, from the same node code. Its core is no_std Rust, and
the C and C++ APIs are thin layers over it, spelled like rclc and rclcpp so
ported code reads familiar.
The executor owns the session
In rclcpp the executor is a separate object you add nodes to
(exec.add_node(node)), there are several executor classes, and each node
holds its own RMW context. In nano-ros the executor is the session’s owner:
let mut executor = Executor::open(&config)?; // opens the transport
let mut node = executor.create_node("my_node")?; // borrows the session
let publisher = node.create_publisher::<Int32>("/topic")?;
There is one executor type, no separate context object, and no add or remove
node lifecycle. The handles a node creates are owned, so they outlive the
node; the usual pattern scopes the node to the creation calls. The entry
that nros build generates goes further: it opens the session once and runs
each sched task’s executor over it, and an executor can also hold several
sessions at once, for a bridge between backends
(Bridge between backends).
No hidden spin
rclcpp::spin(node) blocks the calling thread inside the library and owns
the dispatch loop. That cannot work on bare metal: there is no thread to give
up, and the application’s loop has to stay in user code, to service
interrupts, poll the network stack and manage power.
nano-ros never runs a loop you did not ask for. The building block is
spin_once(timeout), one pass of I/O and callbacks, and every other verb is
a loop over it that you could write yourself:
| Verb | Shape | Needs alloc |
|---|---|---|
spin_once(timeout) | one pass | no |
spin_some(max) | rclcpp’s drain: run what is ready, then return | no |
spin_forever(options) | never returns; the body of an RTOS task | no |
spin(options) | rclrs’s name and shape: until cancelled, a timeout, or a callback count | yes |
spin_period(period) | fixed rate, drift-compensated | yes |
So the verbs that reach a no_std no-alloc target are spin_once,
spin_some and spin_forever. In a generated entry you rarely call any of
them: each sched task’s loop is generated, and your code is callbacks and
handles.
One promise, two ways to wait
A service call or an action goal returns a Promise<T>. The same value
serves two patterns:
- Poll it. Keep running other work, spin, and call
promise.take(), which returnsNoneuntil the reply has arrived. The example at the top of this page does this. - Block on it.
promise.wait(&mut executor, timeout)spins the executor in a loop until the reply arrives or the timeout passes.
A Promise borrows its client’s reply slot and a sequence number. It needs
no allocation, and it is not a Future: there is deliberately no third
pattern of .await on a foreign runtime. A Future completes only while
something else spins the executor, and then that runtime’s scheduler, not
nano-ros, decides when the reply is handled (see
What nano-ros does not run on).
Why every blocking call takes the executor
Promise::wait, a subscription’s wait_next, the C++ Future::wait and
C’s rclc_client_call all take the executor, or a handle to it, although
the executor created the thing they wait on. There are two reasons.
The first is that no other thread drives I/O. If wait did not have the
executor, it could not spin, the network would stand still, and the wait
would always time out. Passing the executor makes that dependency explicit
at the call site, where it cannot be forgotten.
The second is borrowing. A promise borrows the session through its client,
and the executor owns the session, so the promise cannot also hold the
executor. Passing &mut executor at the call, while the promise is a
separate object, is how a wait gets a mutable executor while a request is in
flight.
The same model in C and C++
C++ wraps the promise as rclcpp::Future<T>, and its wait takes the
executor’s handle for the same reason the Rust API takes &mut executor:
auto fut = client.send_request(req);
ResponseType resp;
RCLCPP_TRY(fut.wait(executor.handle(), 5000, resp));
The handle comes from executor.handle(), or rclcpp::global_handle() for
the free functions. There is no hidden global executor.
C has no generics, so it has no promise type, but the pattern is the same: a blocking call that drives the executor for you, beside an asynchronous send whose result arrives by callback while you keep spinning:
/* Blocking: spins the attached executor until the reply or the timeout. */
size_t reply_len = 0;
rclc_client_call(&client, req_buf, req_len, reply_buf, sizeof(reply_buf), &reply_len);
/* Asynchronous: returns at once; the result comes to a callback. */
rclc_action_send_goal_async(client, &goal, sizeof(goal));
rclc_action_client_set_result_callback(client, on_result);
/* keep calling rclc_executor_spin_some() */
Where nano-ros differs from ROS 2
- Nodes come from the executor. There is no
rclcpp::Node::make_sharedwith a context of its own, and noadd_node. - No
rclcpp::spin(node)that owns a thread. The loop is yours, or the generated entry’s. - A
Promise, not astd::shared_futureor a RustFuture. You poll it or block on it with the executor. - One executor type. No
MultiThreadedExecutororStaticSingleThreadedExecutor; parallelism is a sched task (The execution model).
For the rest of the C++ surface (what rclcpp names exist, and how they
behave), see How nano-ros differs from ROS 2 and micro-ROS
and the rclcpp documentation.
Design background
- RFC-0113:
one wait serves every platform and RMW; why there is no
Futurepath.
Safety
The safety example workspace turns on end-to-end message integrity with one line in its bringup:
# src/demo_bringup/system.toml
[system]
features = ["safety"]
Its talker is a plain talker. Its listener declares a validated subscription and reads a verdict with every message:
if let Some(status) = ctx.integrity() {
if status.is_valid() {
// CRC matched, no sequence gap, not a duplicate
} else {
state.integrity_faults += 1;
}
}
Where does that verdict come from, what does it protect against, and what does it not? This page explains the end-to-end (E2E) safety protocol: a CRC-32 and a sequence check on every sample, added by the runtime, with no code in the node that publishes.
The transport is a black channel
A ROS 2 transport is trusted: a message is serialized, sent and deserialized with no check that it arrived intact, in order and once. A safety-related deployment cannot assume that. EN 50159, the railway standard for communication over an untrusted channel, treats the transport as a black channel: whatever is in between may corrupt, repeat, drop, insert, reorder or delay a message, or pretend to be another sender. The defence lives at the two ends, not in the channel.
nano-ros already sends most of what the ends need. Every zenoh sample carries
a 33-byte attachment, for interoperability with rmw_zenoh_cpp:
| Bytes | Field | Purpose |
|---|---|---|
| 0–7 | sequence number (i64) | increases by one per publisher |
| 8–15 | timestamp (i64, ns) | publication time |
| 16 | length prefix (always 16) | |
| 17–32 | rmw_gid | random per-publisher identifier |
Without the feature, the subscriber parses this into the message info and checks nothing. With it, the publisher adds one field and the subscriber validates.
What the feature adds
features = ["safety"] turns on the safety-e2e feature of the runtime, and
NROS_SAFETY_E2E for a C or C++ build. Then:
- The publisher computes a CRC-32 over the serialized CDR payload and appends it to the attachment, which grows to 37 bytes. The payload format does not change. The CRC travels in the attachment, out of band from the payload it covers, so it is checked over a different data path.
- The subscriber recomputes the CRC over the payload it received and
compares, and tracks the sequence number it expects next. Each message gets
an
IntegrityStatus:
| Field | Meaning |
|---|---|
gap | how many messages were lost before this one (0 is normal) |
duplicate | the sequence number is below the expected one |
crc_valid | Some(true) matched, Some(false) corrupted, None no CRC sent |
is_valid() is true when there is no gap, no duplicate, and the CRC was
checked and matched. A message with no CRC is not valid: nothing checked it. The first message a subscriber sees sets the expected
sequence, so joining late is not a gap.
The CRC is CRC-32/ISO-HDLC, the Ethernet polynomial, through a lookup table generated at compile time. Its execution time does not depend on the data, only on its length, which suits timing analysis. The cost is a 1 KB table in read-only memory, four more attachment bytes per subscriber buffer, and a 16-byte validator per subscriber.
The plain take() path is unchanged. Only a subscription declared with
safety (create_subscription_for_callback_name_with_safety for a declarative
node, take_validated for a polled one, and the matching C and C++ forms)
returns a verdict.
What it protects against, and what it does not
| Threat (EN 50159) | Defence | In nano-ros |
|---|---|---|
| Corruption | CRC | yes: crc_valid |
| Repetition | sequence number | yes: duplicate |
| Deletion | sequence number | yes: gap |
| Resequencing | sequence number | yes: a late message reads as a duplicate |
| Insertion | sequence and source | partly: an unexpected sequence number shows as a gap or a duplicate |
| Delay | timestamp and timeout | no: the timestamp is sent but not checked |
| Masquerade | source authentication | no: the GID is sent but not checked |
Freshness needs a clock both ends agree on, and source authentication needs the subscriber to know which publishers to expect. Neither is built. The protocol also has no state machine across messages: each message is valid or not on its own, and what the application does after a run of faults is the application’s decision. A watchdog that supervises liveness and deadlines is separate from this protocol.
Interoperability
The protocol never breaks a peer that lacks it. rmw_zenoh_cpp and a
nano-ros image without the feature read the first 33 bytes of the attachment
and ignore the rest.
| Sender | Receiver | CRC | Sequence | Result |
|---|---|---|---|---|
| nano-ros with safety | nano-ros with safety | checked | tracked | full protection |
| nano-ros with safety | nano-ros without, or ROS 2 | ignored | not tracked | works, no protection |
| nano-ros without, or ROS 2 | nano-ros with safety | None | tracked | delivered, is_valid() false |
This includes every stock ROS 2 node. On zenoh, a nano-ros subscriber with
safety receives a ROS 2 node’s messages normally, and reports every one of
them as not valid: is_valid() is false and crc_valid is None, because
ROS 2 sends no CRC. Earlier releases reported them as valid.
So mixing protected and unprotected nodes degrades protection; it never
stops traffic. A subscriber that wants to accept messages from an unprotected
publisher reads crc_valid itself and decides; is_valid() never vouches for
a message nothing checked. A safety argument has to check that every link it relies on is
protected at both ends, because nothing on the wire will refuse an
unprotected one.
The CRC path lives in the zenoh backend, which is why the safety workspace
also states rmw = "zenoh": the protocol is zenoh-only. Cyclone DDS and
XRCE-DDS have no place to carry the CRC, so an image that declares safety
with one of them as its RMW does not build: the build stops and names the
RMWs that carry it.
Compared with AUTOSAR E2E
| AUTOSAR E2E profiles 1 and 2 | nano-ros | |
|---|---|---|
| CRC | 8-bit | 32-bit |
| Counter | 4-bit | 64-bit, no rollover in practice |
| Data ID | 16-bit | 128-bit GID, sent but not checked |
| Timeout | configurable | not built |
| State machine | yes | no: a verdict per message |
The CRC and the counter are wider than those AUTOSAR profiles. The timeout and the state machine are missing.
How it is checked
The CRC and the validator have Verus proofs: the CRC is deterministic and
detects a single flipped bit, the expected sequence advances on a normal
message, a gap is reported as exactly the number of missing messages, and
is_valid holds exactly when there is no gap, no duplicate and a CRC that
was checked and matched. The proofs run against a model of the validator’s
state, which the production tests tie to the real type. CI runs them weekly,
and the is_valid proof covers the rule that a message with no CRC is not
valid.
Where nano-ros differs from ROS 2
ROS 2’s client libraries and rmw_zenoh do not check a message end to end;
a ROS 2 subscriber gets the message and its info, and nothing else. nano-ros
adds the check below the client API, so it is a system feature you declare
in the bringup, not code in a node. A ROS 2 peer still talks to a protected
nano-ros node, but its messages carry no CRC, so a protected subscriber
reports them as not valid while still delivering them, and a protected
nano-ros publisher’s CRC is invisible to it.
Design background
- RFC-0028: the E2E safety protocol, the threat model and the future extensions (freshness, source authentication, watchdog supervision).
How nano-ros differs from ROS 2 and micro-ROS
A ported rclcpp node compiles against nano-ros with the same includes and the same names. One line it needs that upstream does not:
rclcpp::Node node("talker");
if (!node.ok()) return 1; // replaces upstream's try/catch
Upstream’s rclcpp::Node constructor throws when the node cannot be
created. nano-ros is built with -fno-exceptions, so the constructor records
the failure instead, and the node answers false to ok(). The vocabulary
is the same; the reason underneath is not.
That is the pattern of this page. nano-ros keeps ROS 2’s vocabulary and wire format so existing nodes port and talk to ROS 2 peers. Where it differs, the reason is almost always the same: it runs on a microcontroller with little RAM to spare, no dynamic loader and often no threads. This page states each difference plainly, then compares nano-ros with micro-ROS, its closest peer. The tasks are Port a C++ node and Move a ROS 2 project over.
What stays the same
- The entity model. A node owns publishers, subscriptions, services, clients, action servers, action clients, timers and parameters, with ROS 2’s names (see the ROS 2 concepts).
- Names and types. Topic, service and action names follow ROS 2’s
conventions, message types are rosidl-shaped (
std_msgs/msg/Int32), and CDR is the encoding on the wire. - Packages. A workspace is a
src/of packages withpackage.xmlmanifests. - The wire. The zenoh backend is compatible with upstream
rmw_zenoh: a nano-ros publisher and an rclcpp subscriber on the same router exchange messages with no bridge (Talk to ROS 2). - The C and C++ spellings. The C API uses rclc’s names, argument order and arity; the C++ API uses rclcpp’s.
What changes in the workflow
- One release, no package registry. The
nrosCLI is a GitHub release, and the library ships as source inside it, compiled into your build. Nothing comes from crates.io or a ROS 2 apt repository. - Per-board provisioning, no
rosdep.nros setup <board>fetches the toolchains and SDKs for exactly that board and RMW into the user’s store, with no system-wide install. The zenoh router is not provisioned: it comes from a ROS 2 install. nros build, notcolcon build. It reads the samepackage.xmlfiles and drives cargo, CMake or west, with no install space (How a build becomes an image).- Message code lands in your build. There is no installed
_msgslibrary. The message definitions still come from your ROS 2 install, throughAMENT_PREFIX_PATH, so the layouts and type hashes match your ROS 2 peers (Message generation). - No
ros2 launchon the device. The launch file is read at build time, and the generated entry is the launched system. - Configuration is build-time on embedded. On a host,
ROS_DOMAIN_IDand the other environment variables work. An embedded image bakes the same values fromsystem.toml.
What changes in the API
The executor is the entry point
ROS 2 starts with a global init (rclcpp::init, rclc_support_init), then
nodes, then optionally an executor. nano-ros inverts it: an Executor opens
the session, and every node, entity and timer is created from it, in storage
sized at build time. On a target with tens of kilobytes of RAM, a global
allocator behind every create_publisher is a cost the image cannot carry,
so the sizing moves to the build. The client library
explains the model.
Polling and callbacks are both first-class
rclcpp is callback-only: every subscription has a callback the executor
dispatches. nano-ros also has polled entities, under a different name
(create_polling_subscription), so you choose per entity. A real-time loop
often wants the predictability of an explicit poll; an event-driven service
wants a callback (The execution model).
No async runtime and no multi-threaded executor
rclrs has an async spin and rclcpp has a MultiThreadedExecutor. nano-ros has
neither, on purpose. A future polled by tokio or Embassy runs when that
scheduler decides, so nano-ros could not state when a callback runs or at what
priority. Parallelism is a sched task instead: an executor on an RTOS thread
at a priority the build derives.
The heap is optional
ROS 2 assumes std and a heap. The nano-ros core is no_std with
fixed-size pools, and alloc is opt-in
(Static memory and pools). The C transport
libraries still allocate through the platform’s allocator.
The backend is chosen when you build
ROS 2 reads RMW_IMPLEMENTATION at process start and loads a shared library.
nano-ros links the backend when it builds the image, from the bringup’s
rmw. Most embedded targets have no dlopen; linking only the chosen
backend keeps its C client out of an image that does not use it; and the
build knows what to link. The cost is that changing backends means
rebuilding. One binary can still link several backends and bridge between
them (Bridge between backends).
How each backend reaches ROS 2
The three backends differ less in what they can carry than in the shape of the network around the device: what else has to run, who does discovery, and what happens when a process goes away.
- zenoh. The device runs zenoh-pico, a small C client, in client mode,
and connects to a zenoh router over serial, TCP or UDP. The router is ROS
2’s own
rmw_zenohd; ROS 2 nodes runningrmw_zenoh_cppconnect to the same router, which forwards messages without translating them. The device joins ROS 2 graph discovery through liveliness tokens, soros2 topic listsees it. On a serial-only link the build leaves out the device’s own graph cache, its view of the other nodes, to save RAM. Zenoh also defines a peer mode with no router, which nano-ros does not ship: its multicast transport and scouting cost flash, and every nano-ros deployment reaches its peers through a router.NROS_SESSION_MODE=peeris refused at session open. If the router stops, the device keeps running but reaches no one. - XRCE-DDS. The device runs the Micro XRCE-DDS client, the same one
micro-ROS uses, and asks an agent,
MicroXRCEAgent, to create DDS entities on its behalf. The agent does discovery and bridges data to the DDS data space, so ROS 2 nodes on any DDS RMW reach the device through it. The client allocates when a session or entity is created, never per message. While the agent is down, the device has no connectivity, and an agent that restarts makes the device open its session again (When the Agent restarts). - Cyclone DDS. The image links Eclipse Cyclone DDS, the implementation
ROS 2 itself uses through
rmw_cyclonedds_cpp. The device is a full DDS participant: SPDP and SEDP discovery over UDP multicast (or a static unicast peer list), the same wire protocol and no key rewriting. Nothing runs beside it, and when a peer goes away only that peer’s samples stop. Cyclone allocates withmallocand runs its own receive threads, so it needs a heap and an operating system with a network stack.
All three are linked through one RMW C ABI below the client library, which is why a node package does not change when its image’s backend does.
No introspection on the device
ros2 topic list, ros2 node info and the rmw_get_* graph queries run on
a host. A nano-ros image answers what its backend’s discovery exposes, and you
introspect it from a ROS 2 host over the interop path. Every byte of
introspection is a byte a microcontroller pays for, when a ROS 2 host is one
router hop away.
QoS: the full profile, with support stated per backend
The QoS profile has the full DDS field set, and the standard profiles
(_DEFAULT, _SENSOR_DATA, _SERVICES_DEFAULT, _PARAMETERS,
_SYSTEM_DEFAULT) match upstream field for field. What differs is
enforcement. Each backend advertises which policies it can enforce
(Session::supported_qos_policies()), and creating an entity with a policy
the backend cannot honour fails at once with IncompatibleQos. A requested
policy is never dropped silently. Upstream reports a mismatch later, as a
run-time event; most mismatches are configuration errors visible at start-up.
Manual liveliness is the sharpest case. assert_liveliness() exists in every
language, but only Cyclone DDS puts it on the wire. zenoh-pico’s liveliness is
a session keep-alive with no per-topic lease, so under a manual kind zenoh,
XRCE-DDS and uORB answer UNSUPPORTED rather than an Ok that would mean
nothing was sent. The run-time side is
Use QoS, status events and discovery,
and per-backend coverage is the Per-RMW feature matrix.
Parameters: one store, a smaller surface
nano-ros keeps the vocabulary (declare_parameter<T>, get_parameter<T>,
set_parameter<T>, has_parameter) and the remote services, so
ros2 param list and ros2 param set reach a node with parameter services
on. Underneath there is one store, owned by the executor and keyed by node,
with a slot count fixed at build time; it is also the store the services read,
so what you declare is what ros2 param get returns. A node does not own its
parameters, because a store per node is a fixed arena per node on a target
that has one.
What is smaller than rclcpp, and why:
| rclcpp | nano-ros | Why |
|---|---|---|
ParameterDescriptor (ranges, read-only, description) | not exposed | metadata is a host concern; the type is enforced at declare time |
three set callbacks (pre_set, on_set, post_set) | one validation callback per C server | each callback is an indirection slot per node; one covers range checks |
set_parameter returns SetParametersResult with a reason | a return code | a reason string needs a heap or a fixed buffer |
set_parameters_atomically | not exposed | needs a transaction log |
declare_parameters with a std::map | C++ on a hosted build only, returning Result | the map needs an allocator |
| overrides from the command line, launch file or YAML | the launch file at build time; ~/set_parameters over the wire; -p and --params-file on a hosted build | an embedded image has no command line |
An array value is rclcpp::Seq<T, N>, an array parameter, with no heap: the
store copies the elements into its own slot. When you need the full upstream
surface, run it on a host ROS 2 node and keep the embedded node a leaf. The
calls and /parameter_events are in the
rclcpp compatibility reference.
Where C++ code behaves differently
Most of the rclcpp surface either works or fails to compile. Three things compile and behave differently, each for a reason:
Node::ok(). With no exceptions, a failed constructor cannot throw, so you ask. A generated entry checks it and halts naming the node; a hand-writtenmainmust check, or a failed node goes on to create publishers that do nothing.Node::SharedPtrobserves; it does not own. It is a copyable handle, not astd::shared_ptr, on every target, embedded included. A node is constructed by the entry and outlives everything it is handed to, so no ownership needs counting.shared_from_this()returns the handle and never throwsbad_weak_ptr. nano-ros cannot derive fromstd::enable_shared_from_this, because itsstd::weak_ptrmember exists only where<memory>does, and two translation units of one image could then disagree about the node’s layout. Assigning a temporarymake_sharedresult to aNode::SharedPtris a compile error, since the handle would dangle; writeauto.rclcpp::TimerBaseis a name, not a hierarchy. It is an alias of the one flatrclcpp::Timer, with no vtable: the executor dispatches through a plain function pointer, so a polymorphic base would cost bytes with no caller. The clock is a run-time field and a second verb,rclcpp::create_timer, not a type parameter, soWallTimerandGenericTimerdo not exist. ASharedPtrto a timer, subscription, service or client is a small handle too: dropping it leaves the entity running, andreset()on the handle releases it.
Compared with micro-ROS
micro-ROS is the closest peer: a ROS 2 client stack for microcontrollers. The two differ mostly in what they assume about the network and the language.
nano-ros compared with micro-ROS and mros2 sets the two side by side, with each claim sourced, and says where micro-ROS is the better choice.
Moving from micro-ROS is mostly a rename, and in C often not even that: the
C API keeps rclc’s spellings, so rclc_publisher_init_default,
rclc_executor_init and rclc_executor_t are nano-ros’s names too. The one
change is node creation: a node is bound to its executor with
rclc_executor_node_init, so the executor is initialised first and the node
is bound before its entities are created. An existing XRCE agent serves nano-ros’s XRCE-DDS
backend unchanged. A custom transport is a platform-level transport rather
than rmw_uros_set_custom_transport
(Add a transport).
Design background
- RFC-0113: why there is no async executor.
- RFC-0089: adopting the ROS 2 API, and the compile-or-conform rule: a ported line either behaves as upstream’s or does not compile.
nano-ros compared with micro-ROS and mros2
Three open-source projects put ROS 2 nodes on microcontrollers: micro-ROS, mros2 and nano-ros. They make different trade-offs, and each is the right choice for some projects. This page compares them so you can pick one.
Every claim about nano-ros links to the page or file in this book or its repository that shows it. Every claim about another project cites that project’s own documentation or release, read on 2026-11-10. Where a project publishes nothing on a point, the table says “not published” rather than guessing. If you find a claim here that is out of date, open an issue: the other projects move too.
At a glance
| nano-ros | micro-ROS | mros2 | |
|---|---|---|---|
| Node API | Rust; C with rclc’s names; C++ with rclcpp’s names | C: rcl and rclc1 | C++, a subset “compatible with rclcpp”2 |
| Middleware | zenoh, XRCE-DDS or Cyclone DDS, chosen per image | XRCE-DDS (rmw_microxrcedds)3 | RTPS through embeddedRTPS on lwIP2 |
| Process beside the device | a zenoh router, an XRCE-DDS agent, or none with Cyclone DDS | always the Micro XRCE-DDS Agent3 | none2 |
| Topics, services, actions, parameters | all four | all four; actions through rclc, no parameter client4 | topics only2 |
| Operating systems | see Supported boards | FreeRTOS, Zephyr and NuttX as the main ones, plus modules for ESP-IDF, Mbed, ThreadX, Arduino and more5 | Mbed OS, ESP-IDF; TOPPERS/ASP3 up to v0.3.2; POSIX partly2 |
| Formal checks | Kani bounded model checking and Verus proofs (Internals → Formal verification; Safety for the message-integrity proofs) | none found in its docs | none found in its docs |
| License | MIT or Apache-2.0 (LICENSE-MIT, LICENSE-APACHE) | Apache-2.06 | Apache-2.02 |
| Latest release | see Install | micro_ros_setup 6.1.0, 2026-08-117 | v0.5.4, 2023-10-058 |
Where micro-ROS is stronger
micro-ROS is the established choice, and for many projects it is the better one.
- Backing and support. It is backed by the ROS 2 Embedded Working Group, a formal ROS 2 working group, and eProsima sells commercial support for Micro XRCE-DDS3. nano-ros is maintained by one research lab and has no commercial support.
- Boards and vendor tools. micro-ROS lists officially supported boards with long-term support, among them ESP32, Raspberry Pi Pico, Teensy, Arduino Portenta H7 and Renesas EK RA6M59. It has modules for vendor tools such as STM32CubeMX, Renesas e2studio and PlatformIO5. nano-ros supports fewer boards; Supported boards lists them, with what has been tested on each.
- Distributions. micro-ROS tracks Humble, Jazzy, Kilted, Lyrical and Rolling5. nano-ros targets Humble and Jazzy.
- Published measurements. micro-ROS publishes a memory study for its client on an ESP32: about 400 B of RAM for each extra publisher, about 500 B for each subscriber and about 300 B for each service or client10.
Choose micro-ROS when you already have rclc code and an agent in your deployment, when you need one of its supported boards or vendor tools, or when you need commercial support.
Where mros2 is stronger
mros2 talks RTPS straight from the board, with no agent and no router2: a board on the same network as ROS 2 nodes is simply another DDS participant. Its C++ API follows rclcpp. Its scope is narrower: topics only, no services, actions or parameters, and no arrays in messages2. Its last release was in 20238.
nano-ros reaches the same agentless setup with its Cyclone DDS backend (Use Cyclone DDS), on the boards that backend supports.
Where nano-ros is different
- Three languages, one node model. A node is written in Rust, C or C++, and the book’s starters show each language on each board (Welcome has the table, generated from the probe results). The C API keeps rclc’s names and the C++ API keeps rclcpp’s, so code from micro-ROS or ROS 2 ports with few changes (How nano-ros differs from ROS 2 and micro-ROS).
- The middleware is a build choice. The same node builds for zenoh,
XRCE-DDS or Cyclone DDS, chosen per image
(Switch the RMW per image). One
image can bridge two of them
(Bridge between backends). The
zenoh backend talks to upstream
rmw_zenohwith no bridge (Talk to ROS 2). - Memory is sized when you build. Node, topic and message pools are fixed at build time from what the workspace declares (Static memory and pools).
- Scheduling beyond priorities. Tasks get EDF and sporadic classes and budgets (The execution model).
- End-to-end integrity and proofs. An opt-in CRC and sequence check guards each message, and the CRC and its validator carry Verus proofs (Safety).
- The starters and the Tutorial are replayed. Their shell steps run in CI from a clean install, and each starter’s status line says how its board was last checked.
What one image costs
One measured image, so you can judge the size for yourself. A Rust talker
over zenoh on the MPS2-AN385 bare-metal board (the
bare-metal starter), built with
nros build -- --release at commit a9dc35a5e1 on 2026-11-09 and read with
arm-none-eabi-size:
| Bytes | |
|---|---|
| Code and constants | 397,852 |
| RAM outside the heap | 40,128 |
| Heap, sized by the board | 132,816 |
This is not comparable with micro-ROS’s per-entity figures above: theirs are increments on an ESP32 over XRCE-DDS, this is a whole image over zenoh with its network stack. A like-for-like comparison would need both projects built for the same board, middleware and message set; nobody has published one.
-
micro-ROS, Client library, https://micro.ros.org/docs/concepts/client_library/introduction/, read 2026-11-10. ↩
-
mros2 README, https://github.com/mROS-base/mros2, read 2026-11-10. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8
-
micro-ROS, Features and architecture, https://micro.ros.org/docs/overview/features/, read 2026-11-10. ↩ ↩2 ↩3
-
micro-ROS, ROS 2 feature comparison, https://micro.ros.org/docs/overview/ROS_2_feature_comparison/, read 2026-11-10. ↩
-
micro-ROS,
micro_ros_setupREADME, https://github.com/micro-ROS/micro_ros_setup, read 2026-11-10. ↩ ↩2 ↩3 -
micro-ROS, License, https://micro.ros.org/docs/overview/license/, read 2026-11-10. ↩
-
micro-ROS,
micro_ros_setupreleases, https://github.com/micro-ROS/micro_ros_setup/releases, 6.1.0 released 2026-08-11. ↩ -
mros2 releases, https://github.com/mROS-base/mros2/releases, v0.5.4 released 2023-10-05. ↩ ↩2
-
micro-ROS, Supported hardware, https://micro.ros.org/docs/overview/hardware/, read 2026-11-10. ↩
-
micro-ROS, Memory profiling, https://micro.ros.org/docs/concepts/benchmarking/memo_prof/, read 2026-11-10: ESP32 with FreeRTOS, UDP over Wi-Fi, MTU 512 B, XRCE history 4, RMW history 8. ↩
Glossary
The nano-ros terms this book uses, each in a sentence or two taken from the page that explains it, with a link to that page. A term ROS 2 uses the same way (node, topic, QoS, launch file) is not listed; see the ROS 2 documentation.
| Term | Meaning | Explained in |
|---|---|---|
| board descriptor | The board package’s nros-board.toml: the facts true of every copy of a board, such as its name, platform, target triple and how it boots, and its [knobs]. | How a build becomes an image |
| board package | The layer that joins a platform to real hardware: it brings up the clock, the network interface and its drivers, and provides the entry point that starts the scheduler or the main loop. | How a build becomes an image |
| board registry | The one place a board’s facts and support evidence are recorded. The board pages, the support levels and their status words are generated from it. | Board Support Levels |
| bringup package | Says what runs and where. It holds a package.xml and a system.toml, and optionally launch/ and config/; it has no Cargo.toml, no CMakeLists.txt and no code. | Organize a larger workspace |
| census | The host image generated from a launch file, run once in census mode: it constructs every component against a recording backend and writes what they created. The configure compares it with the contract row by row. | Tell the build what your system creates |
| command package | An ordinary package in your workspace, with a package.xml and a small descriptor, that adds a verb to nros. nros help --all lists each extension verb with the package that provides it. | Runner and command packages |
| component | A [[component]] row in system.toml: which node package runs in the bringup. | Add a second node |
| contract | The <stem>.contract.yaml beside a launch file (or system.contract.yaml in a bringup with no launch/) that states what the image creates, ahead of the build. The build sizes the image’s pools from it. | Contract format reference |
| generated entry | The program’s entry (its main()), which nros build and nros run generate under build/ for each [image.*] block, so there is no package to write for it. | What you just built |
| host | A [host.<name>] block in system.toml: which machine a node runs on, with launch and nodes keys. An image needs no host, and a host needs no image. | Organize a larger workspace |
| image | One program: the bringup’s nodes, built for one board with one RMW. It is an [image.<id>] block in system.toml, not a package. | What you just built |
| knob | A build-time setting, such as a pool size, set on the image ([image.<id>.knobs.<group>]), by the board descriptor’s [knobs], or by an exported variable. nros config explain prints each knob’s value and which rung set it. | Configure an image |
| level | A rank the build derives from the contract: each node’s rank comes from its trigger rate, and each distinct rank is one level, up to a cap that depends on the platform. | The execution model |
| link | How an image’s middleware reaches the rest of the system. nros reads it, with the launcher or flasher and the console, from the board’s descriptor. | Flash a real board |
| locator | The address an image dials. On zenoh it is the only thing a board needs to find the router. | Configure zenoh |
| materialize | nros materialize copies an image’s generated entry into src/<image>_entry/; from then on nros build uses your copy and does not regenerate it. The last resort. | Organize a larger workspace |
| node package | A library that says what a node does: its publishers, subscriptions, timers and callbacks. It has no main(), no board and no deployment settings, so one node package runs on every board. | Organize a larger workspace |
| runner package | An ordinary package in your workspace that teaches nros run, nros flash and nros monitor to drive a launcher, flasher or console nano-ros does not ship a runner for. | Runner and command packages |
| sched task | One executor on one RTOS thread, with its own priority and spin period. All of an image’s sched tasks share one middleware session; parallelism is a sched task, not a callback group. | Pick a scheduling model |
| static pool | An array of slots, carved at build time, that holds the runtime’s entities with no allocator. Every slot costs its bytes whether an entity uses it or not, so each pool is sized from what the image declares. | Static memory and pools |
| status word | A board’s support level, derived from evidence and never typed: where the board’s image runs, how often that run happens, and which board’s test matrix stands for its breadth. The words and what each means are listed on the generated support-levels page. | Board Support Levels |
| twin | An emulated model of a real board. A board with a hardware twin runs the same firmware in an emulator first and then on the board. | Welcome |
| witness | A board that runs its platform family’s test matrix. A board that inherits shares the witness’s code path and adds its own smoke evidence. | Board Support Levels |
Third-party code
What an image compiles in besides nano-ros itself, under which license, and
where nano-ros carries patches. Use it to answer a reviewer’s “what is in this
binary, and from whom”. Which rows apply follows from three choices in the
image’s system.toml: its platform (the board’s), its RMW, and its locator.
C and C++ sources
| Component | Compiled into | License | Upstream | Patches |
|---|---|---|---|---|
| zenoh-pico | every image with rmw = "zenoh" | EPL-2.0 OR Apache-2.0 | eclipse-zenoh/zenoh-pico | fork delta |
| Mbed TLS | a zenoh image built with TLS (the link-tls feature) | Apache-2.0 OR GPL-2.0-or-later | Mbed-TLS/mbedtls | none |
| Micro XRCE-DDS Client, Micro-CDR | every image with rmw = "xrce" | Apache-2.0 | eProsima | none |
| Eclipse Cyclone DDS | every image with rmw = "cyclonedds" | EPL-2.0 OR EDL-1.0 (BSD-3-Clause) | eclipse-cyclonedds/cyclonedds | fork delta |
| FreeRTOS kernel | FreeRTOS boards | MIT | FreeRTOS/FreeRTOS-Kernel | none |
| lwIP | FreeRTOS boards with a network | BSD-3-Clause | lwip-tcpip/lwip | fork delta |
| Eclipse ThreadX | ThreadX boards | MIT | eclipse-threadx/threadx | fork delta |
| NetX Duo | ThreadX boards with a network | MIT | eclipse-threadx/netxduo | fork delta |
| Apache NuttX | NuttX boards | Apache-2.0 | apache/nuttx | fork delta |
| Zephyr RTOS and its modules | Zephyr boards | Apache-2.0 (modules: see each module) | zephyrproject-rtos/zephyr | none; fetched by west at the version the SDK index pins |
The host-side tools nros setup installs (the cross-compilers, QEMU, the XRCE
agent) build and run images but are not linked into one. QEMU is a fork, and
its delta is listed under Forks with the others.
Rust crates
An image’s Rust dependencies are an ordinary cargo graph. List them, with
their licenses, from the image’s generated cargo root — the directory
nros build prints on its entry → line:
cargo metadata --format-version 1 --manifest-path <entry-dir>/Cargo.toml \
| python3 -c 'import json,sys; [print(p["name"], p["version"], p.get("license") or "-") for p in json.load(sys.stdin)["packages"]]' \
| sort -u
That lists every crate cargo resolved, build-time ones included. None of them is a fork: every crate comes from crates.io or from this repository.
Forks
nano-ros builds some of these from a patch branch on its own fork rather than from the upstream release. Each fork’s page lists the commits it carries on top of a pinned upstream ref, generated from the pin the release builds: Forks nano-ros carries.
Forks nano-ros carries
Every submodule that tracks a patch branch, and what it adds to a pinned upstream ref: one section per fork below. Repositories nano-ros authors itself have no upstream and no section.
| Fork | Upstream | Base |
|---|---|---|
| zenoh-pico | eclipse-zenoh/zenoh-pico | 1.10.1 |
| cyclonedds | eclipse-cyclonedds/cyclonedds | 0.10.5 |
| lwip | lwip-tcpip/lwip | STABLE-2_2_1_RELEASE |
| threadx | eclipse-threadx/threadx | v6.4.5.202504_rel |
| netxduo | eclipse-threadx/netxduo | v6.4.5.202504_rel |
| nuttx | apache/nuttx | nuttx-12.13.0 |
| qemu | qemu/qemu | v11.0.0 |
| ros2-rust-examples | ros2-rust/examples | main |
The forks whose URL names jerry73204 are on the nano-ros maintainer’s own GitHub account. Each one’s shipped line is the branch its section names, and every patch on it is listed there against the pinned upstream ref.
Authored by nano-ros (no section): third-party/px4/px4-rs, packages/cli/third-party/play_launch.
The zenoh-pico fork
nano-ros builds packages/rmw/zenoh/zpico-sys/zenoh-pico from the fork jerry73204/zenoh-pico, branch nano-ros-1.10.1, not from upstream eclipse-zenoh/zenoh-pico.
| Upstream base | 1.10.1 (merge base e1ab223a28aa) |
| Commits on top | 99 |
| Upstream commits the pin lacks | 0 |
| Files changed | 130, +11816/−307 |
Pinned commit: e9675d97b462c8fca0d8140efa02f7156c7e4297
Commits on top of upstream
| commit | subject |
|---|---|
| db65ca086a | Add serial support for Unix platform |
| f9bdc3a7d3 | Add NuttX support |
| 71b85b724a | Fixed FreeRTOS z_realloc that returned NULL |
| ca6dc91a25 | Reset start time after the TCP send completes |
| 4e5912217f | Use non-blocking try-lock for keep-alive sends |
| 4f059f4e3f | Set SO_SNDTIMEO on FreeRTOS lwIP TCP socket |
| a1dfc5c363 | Add lwip_socket_thread_init for LWIP_NETCONN_SEM_PER_THREAD support |
| 5bb427db3c | Skip TCP_NODELAY and SO_LINGER on NuttX (cross-compile header mismatch) |
| 72a027d000 | Fix Race 2: report OOM from _z_unsafe_register_pending_query |
| 194ff76515 | Add Z_FEATURE_LINK_IVC link transport (NVIDIA Tegra IVC) |
| dc5051294b | zero-copy IVC link transport |
| 0bde6a0838 | ZENOH_ORIN_SPE platform header |
| 8084b38f6b | fix: provide _z_socket_close stubs for ZENOH_ORIN_SPE |
| a60450b80d | nros: link-custom — runtime-pluggable user transport |
| a1c28b4222 | nros: link-custom follow-ups — stream-flow, real I/O routing |
| 01510cae3d | fix(zephyr): repair zenoh socket startup |
| 046d0b43a3 | freertos: harden lwIP TCP open path |
| 29e72077ac | freertos: init lwIP TLS before TCP ops |
| 82db2b90c3 | fix: open filters for single-threaded clients |
| 3adfd87ae2 | freertos: guard vendored z_malloc/z_realloc/z_free behind Z_FEATURE_NROS_PLATFORM_ALLOC |
| 2adfbe692b | freertos: guard vendored z_sleep_/z_random_ behind Z_FEATURE_NROS_PLATFORM_{SLEEP,RANDOM} |
| bca4ae6c5c | zephyr: drop Z_CONFIG_SOCKET_TIMEOUT to the 100 ms default |
| f79e40d7da | transport: opt-in split tx locking (Z_FEATURE_TX_SPLIT_LOCK) |
| 9c9da7cd7d | transport: extend the split-lock steal to the batch overflow path |
| f8a894c36e | transport: declarations always bypass the tx batch (express) |
| 39ae4201b6 | transport: drain all buffered frames in the polled unicast read |
| f8544eceb7 | freertos/lwip: drain-loop in _z_send_tcp — write_all semantics on tiny lwIP buffers |
| c644f0516c | endpoint: include custom.h under Z_FEATURE_LINK_CUSTOM — int-conversion on gcc >= 14 |
| d1676165d5 | unicast rx: reset the buffer only when empty, so a pass can resume |
| 56870a5119 | zephyr: socket lengths are socklen_t, not unsigned int |
| 9faedbb660 | feat(link): a CAN / CAN FD link |
| e0d08c2c8e | fix(link/can): CAN is a MULTICAST link, not a unicast one |
| 57d1883e53 | fix(link/can): a CAN link owns its receive queue, not a global one |
| 8b46b32f29 | docs(link/can): the identifier defaults are a starting point, not an allocation |
| dd2fdc69a5 | serial: retry the INIT instead of giving up on the first timeout |
| 027f3b6d51 | config: let an embedder set Z_TRANSPORT_LEASE without editing a generated header |
| daef338464 | feat(isotp): CAN unicast over ISO-TP |
| 45e740e49b | feat(isotp): vendor isotp-c and implement unix on it as well |
| b1884d973a | feat(isotp): Zephyr port on Zephyr’s own ISO-TP |
| eabd1522c2 | fix(isotp): use Zephyr 3.7’s isotp_msg_id API, not the pre-3.7 one |
| 768867a014 | fix(isotp): start the CAN controller on Zephyr before binding |
| 9ea9a17e01 | deps(isotp-c): vendor from a fork carrying ISO_TP_NO_FORMATTED_ERRORS |
| 7b77c04abb | feat(isotp): take stmin and bs from the endpoint |
| 68593d56be | isotp: the Zephyr binding lives beside the other link transports |
| bbcce89c73 | fix: do not free a live transport under a publishing task |
| 7f24d85ac7 | fix: give every zenoh task its lwIP per-thread netconn semaphore |
| f469e19dcb | fix: abort the connection on teardown instead of shutting it down |
| 5c5fb463cf | config: the #ifndef guards belong in config.h.in, or a cmake run deletes them |
| 2768dba270 | config: config.h.in keeps the NuttX socket-timeout split |
| 37f022f225 | fix: NuttX belongs in the _z_socket_get_endpoints guard, or the link duplicates it |
| 04bb4282b7 | fix: INET6_ADDRSTRLEN has no guaranteed definition off Linux/macOS/BSD |
| a2b8aabd0a | fix: name the capability the randomness arms need, instead of a platform |
| 040c81eeeb | fix(nano-ros): one rejected network message no longer stops the read task |
| b02447a594 | fix(nano-ros): lock the declaration cache against the reconnect replay |
| 6e7703c8fa | fix(nano-ros): a DECLARE_FINAL holds the interest it calls back into |
| c18f07ed37 | fix(nano-ros): a Zephyr serial send that fits the TX ring does not wait for the wire |
| dab9298020 | zephyr: carry nano-ros’s UART serial backend into uart_zephyr.c |
| 694e040b68 | fix: allow a build with no socket link at all |
| d6a01dc35f | zephyr: network.c builds without an IP stack |
| cdb83388b0 | fix(nano-ros): bound the FreeRTOS _z_condvar_wait to one slice |
| 8e322301ca | fix(collections): release the mutex when a condvar call fails |
| d1972006c6 | fix(freertos): compare wait_until deadlines in modular tick arithmetic |
| e067492cac | fix(rpi_pico, threadx/stm32): compare wait_until deadlines in modular tick arithmetic |
| eb16da9185 | fix(threadx/stm32): convert ticks to time by multiplying first, and round durations up |
| a9bf6504e1 | fix(threadx/stm32): extend the tick count to 64 bits so the clock survives the wrap |
| 2bc805d78c | fix(nano-ros): the custom link’s read_exact waits for the rest of a message |
| 276c594cf5 | feat(nano-ros): a frame budget on the unicast read task |
| 79b752601d | fix(nano-ros): a DROP put dropped for congestion reports success |
| f7ab9657e9 | config: carry a generated config.h for builds that do not run this CMake |
| 663a0c72dc | fix: a send during an outage fails at once instead of waiting it out |
| 06ac6bf808 | feat: zp_spin_once drives a multi-thread executor from the caller |
| 9249abba16 | fix(nano-ros): the CAN links assume a started controller |
| 2594f6b431 | fix(nano-ros): the multicast CAN link refuses a classic interface at open |
| f90e738892 | fix(nano-ros): a multicast JOIN on CAN advertises the frame, not Z_BATCH_MULTICAST_SIZE |
| 3c5cbc473b | fix: expire a peer on ITS lease, keep-alive on ours |
| 8d5ac2fe10 | test: a peer is judged on its own lease, silence summed |
| d7ea813365 | feat: zp_next_wake_ms, the executor’s next due work minus link reads |
| 26ad81545c | fix: retire the polled Zephyr serial receive |
| fed5d711d7 | fix(zephyr serial): accept a UART with no runtime configuration |
| 50e059eaa7 | fix: read the connect timeout without the unstable API |
| c78dbffd91 | feat: zp_next_wake_ms in a multi-thread build |
| cf22843737 | feat: FreeRTOS system layer under a custom platform header |
| f84c6be5a4 | fix: a connect budget bounds each attempt’s handshake |
| 6827fe1f2b | fix: a connect budget bounds the TCP connect too |
| 15f3b01293 | fix: a write the peer stops taking ends the session |
| fb5f5cdc6c | fix: the POSIX TCP and UDP links compile only when enabled |
| 01f5761aff | fix: under split lock, a parked batch ships before the fragments that overflowed it |
| 19a47ae7b1 | fix: a send holds a transport use, so split lock frees publishers again |
| aa0f454535 | fix(nano-ros, lwip): the lwIP socket glue and links include no <unistd.h> |
| c05434a70f | feat(nano-ros, freertos): Z_FEATURE_NROS_PLATFORM_TIME routes the wall clock to nano-ros |
| 328f56dea3 | fix(nano-ros): a client session on IVC dereferenced NULL for its peer socket |
| 2996fdefaa | feat(nano-ros): peer mode on a link that joins two endpoints |
| 92efaba647 | fix(nano-ros): a session on IVC can neither wait in its handshake nor read |
| e27088048b | feat(nano-ros): an RPMsg link, sharing one framing with IVC |
| 26041f73d2 | fix(nano-ros): a framed link’s read waits, so the thread reading it does not spin |
| a10194cd68 | fix(nano-ros): a custom link reads through its own read again |
| d7d0094c38 | fix: under split lock, no send waits for the link holding the tx mutex |
| e0b8077c4e | fix: a client whose link reaches end-of-stream closes and reopens |
| e9675d97b4 | fix: the BSD-recv TCP links report end-of-stream too |
Reproduce:
base=1.10.1
head=jerry73204:zenoh-pico:e9675d97b462c8fca0d8140efa02f7156c7e4297
gh api "repos/eclipse-zenoh/zenoh-pico/compare/$base...$head" --jq '.ahead_by'
The cyclonedds fork
nano-ros builds third-party/dds/cyclonedds from the fork NEWSLabNTU/cyclonedds, branch nano-ros, not from upstream eclipse-cyclonedds/cyclonedds.
| Upstream base | 0.10.5 (merge base 2cdd114cbd18) |
| Commits on top | 36 |
| Upstream commits the pin lacks | 0 |
| Files changed | 67, +4137/−216 |
Pinned commit: 05b3c9eda50a389cbcc197c24eb0e9743344cd92
Why each patch exists, and what retires it: cyclonedds-fork-delta.md.
Commits on top of upstream
| commit | subject |
|---|---|
| 454df330c7 | Removed warnign |
| b8fed02821 | Improve topic name support |
| 03352a5b95 | Add missing atomic uintptr/uint64 functions |
| e95551609c | Allow more children per entity |
| 76360fb739 | Move handle flag bitmasks and update debug code |
| 35f3dc28c7 | add warning supressions |
| 5041f3560c | Add 4319 msvc 2022 suppression |
| 290152c0af | fix(zephyr): tolerate NSOS socket gaps |
| 22150fbf47 | fix(freertos): avoid TLS-only DDS state |
| 902f770700 | ddsrt: add ThreadX NetX port |
| 56e6170a1c | fix(threadx): stabilize Cyclone DDS runtime |
| e8ce731539 | fix(ddsrt/threadx): multicast byte-order + multi-iovec datagram sendto |
| 5558c6ae61 | fix(ddsrt/threadx): network byte order for parsed/interface addresses (177.26) |
| 12b4af2c5a | fix(ddsrt/threadx): join multicast with INADDR_ANY interface (177.26.RX) |
| 6eb92277bc | fix(ddsrt/threadx): drop duplicate ddsrt_setsockreuse (use generic) |
| 4aa337b0dd | q_sockwaitset: AF_UNIX socketpair self-pipe on native-IP-stack Zephyr |
| 4c8ff8c276 | ddsrt/posix: fail loudly when pthread_mutex_init fails |
| 1d794c0ae8 | ddsi_udp: Zephyr multicast join via struct ip_mreqn |
| 5b87ee52ba | fix(ddsrt/posix): say which pool ran out, and fix cond/rwlock too |
| 942dda3ccb | ddsi/addrset: stripe the lock instead of one mutex per addrset |
| a09babf32d | ddsrt: Zephyr-native sync backend — k_mutex/k_condvar instead of pooled pthreads |
| 8601ca66a1 | ddsrt: the freertos/threadx sync ports say what failed before aborting |
| 99cfac8803 | ddsrt: give every FreeRTOS thread its lwIP per-thread netconn semaphore |
| ae14b312b2 | ddsrt: initialise the atomics mutexes at runtime on the Zephyr backend |
| 6e2ad36f6d | ddsrt/posix: route the heap through nano-ros’s platform allocation funnel |
| 556f79d4f4 | build: resolve Cyclone’s own paths by project, not by CMAKE_SOURCE_DIR |
| 8e6ff48a4c | ddsi: allocate and free through ddsrt, not libc, in four mismatched places |
| d97a71e25f | ddsrt: one funnel heap for every port, instead of an arm inside one of them |
| 79bd9cb9dc | ddsrt: name threads on Zephyr, instead of leaving every one anonymous (#1) |
| 7f064c11ed | ddsi: re-arm a suppressed-NACK acknack no earlier than now, instead of from a stale timestamp |
| 67ff751877 | ddsi: assert that an acknack event still needing a NACK is still scheduled |
| f241020d99 | ddsrt: on Zephyr, destroy a thread’s attr after pthread_join, not after create |
| 2314625c52 | ddsi: rate-limit and back off a persistently failing select in the waitset |
| 8665a51f70 | ddsrt: take the log sink lock exclusively where the scratch buffer is shared |
| 404fc5d960 | ddsrt: re-take the mutex after a timed k_condvar_wait on Zephyr 4.x |
| 05b3c9eda5 | ddsi: store XE (enum) plist fields at the ABI’s enum size |
Reproduce:
base=0.10.5
head=NEWSLabNTU:cyclonedds:05b3c9eda50a389cbcc197c24eb0e9743344cd92
gh api "repos/eclipse-cyclonedds/cyclonedds/compare/$base...$head" --jq '.ahead_by'
The lwip fork
nano-ros builds third-party/freertos/lwip from the fork jerry73204/lwip, branch nano-ros, not from upstream lwip-tcpip/lwip.
| Upstream base | STABLE-2_2_1_RELEASE (merge base 77dcd25a7250) |
| Commits on top | 3 |
| Upstream commits the pin lacks | 0 |
| Files changed | 5, +139/−3 |
Pinned commit: 96b63e3115dfc010c07d4a4231d93195a814e82c
Commits on top of upstream
| commit | subject |
|---|---|
| 6233eb61c8 | Use pvPortMalloc for per-thread netconn semaphore allocation |
| de76e778f9 | fix(freertos): create netconn semaphores lazily |
| 96b63e3115 | sockets: optional per-socket receive notification |
Reproduce:
base=STABLE-2_2_1_RELEASE
head=jerry73204:lwip:96b63e3115dfc010c07d4a4231d93195a814e82c
gh api "repos/lwip-tcpip/lwip/compare/$base...$head" --jq '.ahead_by'
The threadx fork
nano-ros builds third-party/threadx/kernel from the fork NEWSLabNTU/threadx, branch nros-lp64-ulong, not from upstream eclipse-threadx/threadx.
| Upstream base | v6.4.5.202504_rel (merge base 4b6e8100d932) |
| Commits on top | 4 |
| Upstream commits the pin lacks | 0 |
| Files changed | 2, +107/−8 |
Pinned commit: ee703dae8045e682d36f8cbf7a0099901d32ffec
Commits on top of upstream
| commit | subject |
|---|---|
| 13d061a73a | fix(linux port): key LONG/ULONG and ALIGN_TYPE on the data model, not x86_64 |
| 9a29f1bd3f | fix: key the LP64 thread-timeout compensation on the data model, not x86_64 |
| 9fdb09bea8 | fix(linux port): run each thread on its own ThreadX stack |
| ee703dae80 | fix(linux port): raise a below-floor thread stack, never hang on it |
Reproduce:
base=v6.4.5.202504_rel
head=NEWSLabNTU:threadx:ee703dae8045e682d36f8cbf7a0099901d32ffec
gh api "repos/eclipse-threadx/threadx/compare/$base...$head" --jq '.ahead_by'
The netxduo fork
nano-ros builds third-party/threadx/netxduo from the fork NEWSLabNTU/netxduo, branch nano-ros, not from upstream eclipse-threadx/netxduo.
| Upstream base | v6.4.5.202504_rel (merge base b54bf0180199) |
| Commits on top | 3 |
| Upstream commits the pin lacks | 0 |
| Files changed | 2, +114/−16 |
Pinned commit: 393b862521d1dc43d6d12b6fa1fd377de963acff
Commits on top of upstream
| commit | subject |
|---|---|
| 669760b0df | Fix UINT pointer truncation in BSD recv + add extract bounds check |
| d0c2e80e2d | Fix x86_64 pointer truncation in BSD socket layer |
| 393b862521 | BSD: per-socket receive notification |
Reproduce:
base=v6.4.5.202504_rel
head=NEWSLabNTU:netxduo:393b862521d1dc43d6d12b6fa1fd377de963acff
gh api "repos/eclipse-threadx/netxduo/compare/$base...$head" --jq '.ahead_by'
The nuttx fork
nano-ros builds third-party/nuttx/nuttx from the fork jerry73204/nuttx, branch nano-ros, not from upstream apache/nuttx.
| Upstream base | nuttx-12.13.0 (merge base b9b5d9afbf5a) |
| Commits on top | 6 |
| Upstream commits the pin lacks | 0 |
| Files changed | 5, +236/−32 |
Pinned commit: aea00d736d698994a7c0a7339b56b04af30ec21e
Commits on top of upstream
| commit | subject |
|---|---|
| 44844788d9 | Fix signal constants to match Linux/POSIX convention |
| 7f252631e4 | Uncomment SIG_IGN and SIG_DFL check |
| 9739ad21cc | Implement bulk TLB invalidation |
| d230b7d383 | drivers/virtio/virtio-net: negotiate CTRL_VQ+CTRL_RX, enable ALLMULTI/PROMISC |
| c3fa5dfb06 | drivers/virtio/virtio-net: move ctrl-queue DMA buffers off the stack |
| aea00d736d | qemu-armv7a: give .bss its own program header |
Reproduce:
base=nuttx-12.13.0
head=jerry73204:nuttx:aea00d736d698994a7c0a7339b56b04af30ec21e
gh api "repos/apache/nuttx/compare/$base...$head" --jq '.ahead_by'
The qemu fork
nano-ros builds third-party/qemu/qemu from the fork NEWSLabNTU/qemu, branch nano-ros-v11.0.0-patches, not from upstream qemu/qemu.
| Upstream base | v11.0.0 (merge base 98b060da3a4f) |
| Commits on top | 7 |
| Upstream commits the pin lacks | 0 |
| Files changed | 10, +149/−22 |
Pinned commit: 7689da2d98389ee9b86372d51e5380da9f847e23
Commits on top of upstream
| commit | subject |
|---|---|
| 699fa98296 | hw/net/lan9118: add can_receive + flush on FIFO drain |
| 1edd124e68 | python: add pyproject.toml with modern setuptools backend |
| dbd1049b06 | python/mkvenv: drop -e flag for local package install |
| 729262e975 | hw/net/lan9118: flush queued packets when RX is enabled |
| c6f4c95716 | hw/net/lan9118: a full RX fifo is back-pressure, not an error |
| 98e749c2ce | hw/net/lan9118: fast-forward frees the skipped words |
| 7689da2d98 | target/arm: teach arm_cpu_has_work about halting reasons |
Reproduce:
base=v11.0.0
head=NEWSLabNTU:qemu:7689da2d98389ee9b86372d51e5380da9f847e23
gh api "repos/qemu/qemu/compare/$base...$head" --jq '.ahead_by'
The ros2-rust-examples fork
nano-ros builds packages/cli/testing_workspaces/ros2_rust_examples from the fork jerry73204/ros2_rust_examples, branch add-justfile, not from upstream ros2-rust/examples.
| Upstream base | main (merge base e7c18ef53a55) |
| Commits on top | 3 |
| Upstream commits the pin lacks | 5 |
| Files changed | 2, +149/−2 |
Pinned commit: c30b901dcb2ed5cb7e9056857f71a7232b3c480c
The pin is 5 upstream commit(s) behind main’s tip; the delta below is against the merge base.
Commits on top of upstream
| commit | subject |
|---|---|
| ab3927a8d7 | Ignore colcon-generated files and editor temp files |
| 38f7036366 | Add a justfile |
| c30b901dcb | Add just run-* recipes |
Reproduce:
base=main
head=jerry73204:ros2_rust_examples:c30b901dcb2ed5cb7e9056857f71a7232b3c480c
gh api "repos/ros2-rust/examples/compare/$base...$head" --jq '.ahead_by'
Contract format reference
Every key a contract file (<stem>.contract.yaml beside a launch file, or
system.contract.yaml in a bringup with no launch/) accepts. The contract
format is ros-launch-manifest’s, and this page is its format reference at
v0.3.27, the release the nros CLI is built
against (commit 10b73e8c2d16). The CLI reads a contract with that
release’s parser, so a key this page does not list is a parse error.
To write a contract for your own nodes, see Tell the build what your system creates.
Every key below is accepted in the context that heads its section, and a key that is not listed is a parse error. Contexts whose keys are chosen by the author — nodes:, topics:, services:, actions:, includes:, paths:, args:, external_topics:, the endpoint maps under pub:/sub:/srv:/cli:, and the parameter names under a node’s params: — have no section here, because no allowlist applies to them.
This is the core grammar. A contract that use:s an extension may also write the keys that extension declares, in hazards.<name> and safe_state.settle: those are listed per extension in extension-reference.md (the bundled vehicle.braking and the reference extensions), and extension-guide.md says how to write one.
The kind column is the rule of contract-primitives.md as data: a fact is what the code does, a requirement is what it must achieve, meta is structure, and a consequence is computable from the facts — a second copy the graph already knows, kept only where the graph has no answer (an external source). scripts/derivation_census.py counts how often each consequence agrees.
manifest
| key | kind | status | meaning |
|---|---|---|---|
version | meta | Manifest format version. Absent means 1. | |
use | meta | The extensions this contract uses, a map of name -> version requirement (use: { vehicle.braking: "^1" }; ^, ~, = or >=). With it, hazards.<name> and safe_state.settle may carry the keys those extensions declare; without it an unknown key is an error. | |
rlm | meta | since v0.1.49 | The grammar release this file needs, v<major>.<minor>.<patch> (or >= that). Checked before any other key: a checker whose grammar is older refuses the file naming both releases, instead of refusing the first key it does not know as if it were a typo. A checker before v0.1.49 refuses the key itself as unknown. Optional; beside version, which is the file format and stays 1. |
args | meta | Arguments this manifest requires, supplied by the launch scope. | |
exclude_patterns | removed | Removed — it was parsed and read by nothing, so it excluded nothing. Mark an expected-absent side with external:. | |
nodes | meta | Node declarations, keyed by bare node name. | |
topics | meta | Topic declarations, keyed by topic name. | |
services | meta | Service declarations, keyed by service name. | |
actions | meta | Action declarations, keyed by action name. | |
includes | meta | Child scopes, each an inline manifest (the file-reference form was removed in v0.1.59). | |
paths | removed | Renamed event_chains: in v0.3.20 and refused since v0.3.27: a manifest level’s end-to-end requirement is an event chain (AUTOSAR TIMEX’s TimingDescriptionEventChain); a node’s internal paths: keep the word. play_launch migrate <contract> --write rewrites it. | |
event_chains | meta | since v0.3.20 | Event chains: end-to-end requirements naming two topics and a budget (AUTOSAR TIMEX’s TimingDescriptionEventChain: a latency from stimulus to response). The route between the ends is derived from the nodes’ paths, never written. paths: before v0.3.20, the word a node’s internal paths keep. |
hazards | meta | Hazards: what is watched, how long the system has, and which path reaches the safe state. | |
functions | removed | Renamed capabilities: in v0.3.19 and refused since v0.3.27: it is a monitored capability, not IEC 61508’s safety function. play_launch migrate <contract> --write rewrites it. | |
capabilities | meta | since v0.3.19 | Named capabilities: what a set of topics together provides, available while its topics are and lost when a fault removes them (capability monitoring in the automated-driving literature; functions: before v0.3.19). A mode requires capabilities; a hazard may monitor one by name. |
modes | meta | Operational modes: what each requires, and the fallback sequence (the ordered degradation levels) to fall to when it is lost. | |
independence | requirement | since v0.3.13 | Independence requirements, a list of { of, not_sharing }: the nodes or capabilities in of share none of the deployment facts in not_sharing, pairwise (independence-violated). Freedom from interference between nodes of different integrity in one process is derived, with no key (interference-shared-process). |
severity_levels | removed | Renamed integrity_levels: in v0.3.3: an ASIL, SIL or DAL is an integrity level, and ISO 26262’s severity is the S0-S3 class it is derived from. play_launch migrate <contract> --write rewrites it. | |
integrity_levels | removed | Deprecated in v0.3.24 and refused since v0.3.27: a scale is a profile, named by use:: use: { iso26262: "^1" } for [QM, ASIL_A..ASIL_D], iec61508 for [none, SIL_1..SIL_4], or a local <name>.profile.yaml for another scale. play_launch migrate <contract> --write writes the use: entry when the list is a reference profile’s scale. | |
external_topics | removed | Removed in v0.3.15 (deprecated since v0.1.59): the second place for the fact topics.<name>.external states. Move each entry under topics: as <name>: { external: <side>, type, qos }; play_launch migrate <contract> --write does it. | |
chains | removed | Removed — state the requirement as an event chain and let the route be derived. | |
if | meta | Only on an INLINE includes: entry, whose value is a nested manifest: include this child only when the condition holds. Refused at the root of a standalone manifest. | |
unless | meta | Only on an INLINE includes: entry: include this child unless the condition holds. Refused at the root of a standalone manifest. | |
policy | removed | Deprecated in v0.3.24 and refused since v0.3.27: a rule’s severity is project policy for the tool, not a fact of the system. Pass check --deny <rule> instead (--deny measured-unsupervised for unsupervised_measured: error). | |
links | fact | since v0.3.4 | Named links: <name>: { max_transport, clock }, one transport stated once, with its source. A subscriber names the link its hop crosses (sub.<ep>.link). Visible to this manifest and its inline includes. |
supervision | removed | Moved to the per-target platform file in v0.3.22 and refused here since v0.3.27: the tick and switch time are facts of the processor and its scheduler, so state them in <stem>.system.<target>.yaml as supervision: { tick, switch }. | |
acknowledged | meta | since v0.2.3 | Findings the author has read and keeps: a list of { rule, at, reason }, at the contract’s root only. The consumer reports a warning or info whose rule id and path match an entry as acknowledged, with the reason, and counts it apart from the warnings; an entry matching an error is itself an error (errors cannot be acknowledged), and one matching nothing is a warning, so an acknowledgement cannot outlive its finding. |
let | meta | since v0.2.4 | Names for values, stated once and read as $(let <name>): a mapping of name to value, in order, at the contract’s root. An entry may read earlier entries (and $(param), $(var)); a forward reference or a cycle is an error. Separate from launch configurations: $(var) never reads it. |
nodes.<name>
| key | kind | status | meaning |
|---|---|---|---|
if | meta | Include this node only when the condition holds. | |
unless | meta | Include this node unless the condition holds. | |
lifecycle | fact | True for a ROS 2 managed node; runtime monitors skip checks until it is Active. | |
pub | meta | Publisher endpoints, keyed by endpoint name. A key is a LOCAL name: the node’s FQN is prefixed to it, so a / in a key is refused; connect the topic with a launch remap or a topics: entry. | |
sub | meta | Subscriber endpoints, keyed by endpoint name. A key is a LOCAL name: the node’s FQN is prefixed to it, so a / in a key is refused; connect the topic with a launch remap or a topics: entry. | |
srv | meta | Service server endpoints, keyed by LOCAL endpoint name. Not neutral when omitted: a consumer sizes the image’s pools from this list (an embedded realizer derives its service counts from it), so a server the code creates and the contract leaves out is found at boot, not here. | |
cli | meta | Service client endpoints, keyed by LOCAL endpoint name. Not neutral when omitted, for the same reason as srv:: pools are sized from the list. A reaction route crosses a client -> server edge as a message (the resolver’s reaction walk); a server with no path its request triggers latches the request for its own timer, and the walk charges that timer’s period as a sampling hop. | |
paths | meta | This node’s internal paths, keyed by path name. | |
criticality | consequence | Scheduling criticality: high | |
concurrency | fact | Which of this node’s paths may NOT run concurrently. Absent means all of them serialize: every path of the node waits for any other that is running (a single-threaded executor), and the checker charges that wait (path-exclusion). Declare exclusive groups to say which may in fact overlap. | |
params | fact | Parameters this node declares, keyed by name, each { type: <ROS 2 type> }. Names and types only: a string or array capacity is a board fact, not a contract one. params: {} means the node declares no parameters; a missing params: means not stated. The two stay distinct in the model: {} becomes an empty contracts.node_params entry, a missing key none. |
pub/sub/cli.<endpoint>
| key | kind | status | meaning |
|---|---|---|---|
min_rate_hz | removed | Renamed min_rate: in v0.3.21 and refused since v0.3.27: a rate is a value with its unit (min_rate: 100Hz). play_launch migrate <contract> --write rewrites it. | |
min_rate | fact (pub) / requirement (sub) | since v0.3.21 | Lower bound on this endpoint’s rate. A REQUIREMENT, not a mechanism: nothing fires when a period passes. A fault is detected only by a mechanism that does – a QoS lease_duration or deadline, or a max_age someone evaluates (on_violation.mechanism) – so min_rate never counts as a hazard’s detector. A publisher that promises no rate states aperiodic: true instead of leaving this out. A frequency with its unit (100Hz, 1.5kHz, $(param rate) Hz); a bare number is refused, so a rate cannot be read as a period. min_rate_hz (a number of Hz) before v0.3.21. |
max_rate_hz | removed | Renamed max_rate: in v0.3.21 and refused since v0.3.27: a rate is a value with its unit (max_rate: 100Hz). play_launch migrate <contract> --write rewrites it. | |
max_rate | fact (pub) / requirement (sub) | since v0.3.21 | Upper bound on this endpoint’s rate. A frequency with its unit (100Hz, 1.5kHz, $(param rate) Hz); a bare number is refused, so a rate cannot be read as a period. max_rate_hz (a number of Hz) before v0.3.21. |
max_age | requirement | Subscriber: maximum data age at receive (now - header.stamp). | |
max_age_ms | removed | Removed — write max_age: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. | |
state | fact | Subscriber: read-latest rather than causal. The node caches the message and a timer path reads it, so a reaction arriving here waits for that timer: the walk charges one period (the timer’s jitter too, when stated) as a sampling hop, shown as (+Nms sampling) in a route. | |
required | fact | Subscriber: this endpoint must be connected. | |
qos | fact | QoS overrides for this endpoint. | |
max_transport | removed | Refused on an endpoint since v0.3.27 (a subscriber’s since v0.3.17, a client’s deprecated in v0.3.24): a transport is the hop of one endpoint, stated once with its source on a link the endpoint names (link: <l>, links.<l>.max_transport). The link’s value is the endpoint’s: charged in path and chain latencies, in a hazard’s reaction route on the guard edge, and on a call’s request leg. play_launch migrate <contract> --write writes the link. | |
link | fact | since v0.3.4 | The link this endpoint’s hop crosses, a name under links:: a subscriber’s, the edge that ends at it, or since v0.3.24 a client’s, its request leg (charged on a reaction route’s success branch through the call; the response leg is not modelled). The link’s max_transport is the endpoint’s, charged wherever a written one is; writing both is refused. A max_transport written on the subscriber instead is refused since v0.3.17. |
max_transport_ms | removed | Removed — write max_transport: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. | |
on_violation | requirement | The reaction this subscriber owes when its assumption is violated. | |
ingress | removed | Renamed arrival_curve: in v0.3.7: a token bucket bounding what arrives is network calculus’s arrival curve. play_launch migrate <contract> --write rewrites it. | |
arrival_curve | requirement | since v0.3.7 | Subscriber: what this endpoint is made to ABSORB, an arrival curve in token-bucket form (network calculus: rate ρ, burst σ) { rate_hz, burst }. Not a QoS policy, and not the rate it needs (min_rate_hz): a consumer bounds the device’s read path and the router’s pacing by it. Both keys required, so an unstated burst never reads as unbounded. Refused under pub:/cli:. |
min_interarrival | requirement | since v0.1.68 | Subscriber: the least time between two arrivals. Its callback is then a sporadic task (T_min). An event input with no rate bound, no min_interarrival and no budget is unanalysable: a consumer that supervises a deadline refuses it. Refused under pub:/cli:, and above 1 / min_rate_hz. |
budget | requirement | since v0.1.68 | Subscriber: the execution time its callback may use per budget_period. Its callback is then served (a server of budget Q per period P, analysed as a periodic task). Requires budget_period, and may not exceed it. Refused under pub:/cli:. |
budget_period | requirement | since v0.1.68 | Subscriber: the server period P of budget. Only beside budget. |
call | fact | since v0.1.69 | Client: how the code waits for the response. blocking: the callback that sends the request waits for it, so under a preemptive executor the server must run at a more urgent level (a less urgent one is a priority inversion, its own level a deadlock). async: the request is sent and a later callback takes the response. Absent means not stated: a consumer checks a stated call and reports an unstated one. Refused under pub:/sub:. |
timeout | fact | since v0.2.5 | Client: how long the code waits for the response before it gives up (a duration, $(param …)-capable): spin_until_future_complete with a timeout, a pending-request prune, a tick-counting poll. A fact about the code, not a requirement. Absent means the client may wait forever (rclcpp’s default), so a reaction route through the call is unbounded unless the degradation level is supervised (call-unbounded). Refused under pub:/sub:. |
on_timeout | fact | since v0.2.5 | Client: what the code does when timeout passes, { enters: <mode> }, { reaction: <event chain> } or { retry: { attempts, backoff }, then: { enters | reaction } }. A route through the call is charged the worse of the success branch and timeout x attempts + backoff x (attempts - 1) + this reaction’s route. Refused under pub:/sub:. |
on_rejected | fact | since v0.2.5 | Client: what the code does when the server answers and refuses (success: false), { enters: <mode> } or { reaction: <event chain> }. Needed when the route continues at the client after a blocking call (call-rejected-unhandled). Refused under pub:/sub:. |
buffer | fact | Buffering discriminator for a state subscriber: latest | |
on_demand | removed | Renamed aperiodic: in v0.3.7: an activation with no period and no minimum separation is an aperiodic task. play_launch migrate <contract> --write rewrites it. | |
aperiodic | fact | since v0.3.7 | Publisher: aperiodic – publishes only when asked (a service call, an operator) and promises no rate. Unlike an omitted min_rate_hz, which says nothing, this is acted on: no rate is derived for the topic, no runtime rate monitor is generated for the endpoint, and a subscriber’s min_rate_hz or a topic rate_hz against it is a rate-hierarchy error. Refused beside min_rate_hz, and under sub:/cli:. |
jitter | removed | Removed — jitter is a property of a route, not one publisher. Use max_jitter on a path. | |
jitter_ms | removed | Removed — see jitter. |
srv.<endpoint>
| key | kind | status | meaning |
|---|---|---|---|
max_response | requirement | Deadline for answering a request on this service. | |
min_interarrival | requirement | since v0.1.68 | The least time between two requests. The server’s callback is then a sporadic task (T_min). See min_interarrival on a subscriber. |
budget | requirement | since v0.1.68 | The execution time the server’s callback may use per budget_period (a served callback). Requires budget_period, and may not exceed it. |
budget_period | requirement | since v0.1.68 | The server period P of budget. Only beside budget. |
idempotent | fact | since v0.2.5 | A repeated request has the effect of one. Licenses a client’s on_timeout.retry (call-retry-not-idempotent): a retry after a lost response runs the operation twice. |
stale_after | fact | since v0.2.5 | The server refuses a request older than this, by the request’s source timestamp. Without it a request the client timed out on may still act after the client’s fallback (call-late-effect). |
max_response_ms | removed | Removed — write max_response: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. |
topics.<name>
| key | kind | status | meaning |
|---|---|---|---|
if | meta | Declare this topic only when the condition holds. | |
unless | meta | Declare this topic unless the condition holds. | |
type | fact | ROS message type. Required. | |
pub | meta | Publishing endpoints, as node/endpoint. | |
sub | meta | Subscribing endpoints, as node/endpoint. | |
qos | fact | Topic-level QoS, overridable per endpoint. | |
rate_hz | removed | Renamed rate: in v0.3.21 and refused since v0.3.27: a rate is a value with its unit (rate: 100Hz). play_launch migrate <contract> --write rewrites it. | |
rate | consequence | since v0.3.21 | Publication rate. Derivable from the timers that drive it — see derivable-rate. A frequency with its unit (100Hz, 1.5kHz, $(param rate) Hz); a bare number is refused, so a rate cannot be read as a period. rate_hz (a number of Hz) before v0.3.21. |
max_transport | removed | Removed in v0.3.15 (deprecated since v0.1.60): a transport is the hop into ONE subscriber, stated on that subscriber through a link (nodes.<n>.sub.<ep>.link naming a links: entry). play_launch migrate <contract> --write writes the value as one link and names it on each of the topic’s subscribers declared in the same file. | |
max_transport_ms | removed | Removed — write max_transport: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. | |
drop | requirement | Permitted message loss on this topic. | |
external | meta | Mark one side of this topic as provided by an external system: pub | sub | both, or the map { side, on_silence }. |
services.<name>
| key | kind | status | meaning |
|---|---|---|---|
if | meta | Declare this service only when the condition holds. | |
unless | meta | Declare this service unless the condition holds. | |
type | fact | ROS service type. | |
server | meta | Server endpoints, as node/endpoint. | |
client | meta | Client endpoints, as node/endpoint. | |
external | meta | Mark one side of this service as provided by an external system: server | |
max_transport | removed | Deprecated in v0.3.24 and refused since v0.3.27: a transport is the hop of one endpoint, stated on a link the client names (cli.<e>.link: <l>, links.<l>.max_transport). play_launch migrate <contract> --write rewrites it. |
actions.<name>
| key | kind | status | meaning |
|---|---|---|---|
if | meta | Declare this action only when the condition holds. | |
unless | meta | Declare this action unless the condition holds. | |
type | fact | ROS action type. | |
server | meta | Server endpoints, as node/endpoint. | |
client | meta | Client endpoints, as node/endpoint. | |
external | meta | Mark one side of this action as provided by an external system: server | |
call | fact | since v0.1.69 | How every client in client waits for its result: blocking (the callback that sends the goal waits for the result) or async (a later callback takes it). Absent means not stated. See call on a cli: endpoint. |
includes.<name>
| key | kind | status | meaning |
|---|---|---|---|
manifest | removed | Removed in v0.1.59 – nothing ever loaded the named file, so the include declared nothing. Write the child contract inline as includes.<name>: { nodes: ..., ... } (its if/unless at that inline manifest’s root), or delete the entry; a launch include’s own contract is found next to its launch file. |
args.<name>
| key | kind | status | meaning |
|---|---|---|---|
type | meta | Argument type: bool, or omitted for a free string. | |
choices | meta | Permitted values. Consulted only when type is absent. |
paths.<name> / event_chains.<name>
| key | kind | status | meaning |
|---|---|---|---|
if | meta | Declare this path only when the condition holds. | |
unless | meta | Declare this path unless the condition holds. | |
input | removed | Removed in v0.3.15 (deprecated since v0.1.59): write trigger: { input: [...] }, which play_launch migrate <contract> --write does. A path with no trigger: is unclassified; a timer is trigger: { timer: ... }. | |
output | fact | Endpoints (node path) or topics (event chain) this path produces. | |
max_latency | requirement | Latency budget for this path. On a NODE path: take -> publish of one callback, and the cost a reaction route charges for the hop; an embedded realizer may ALSO turn it into a derived node deadline and a runtime latency monitor in the image, so a cost that must not be a deadline (a queueing wait, a link) belongs in its own key (max_transport, a timer’s jitter), not here. On a EVENT CHAIN: the NOMINAL end-to-end traversal of the subtree, checked by chain-latency; a hazard’s fault route is derived separately by walking the reactions, and does not read it. | |
max_latency_ms | removed | Removed — write max_latency: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. | |
correlation | removed | Removed — nothing ever read it. State fan-in policy with sync:. | |
tolerance | removed | Removed in v0.3.16 — the stamp spread a fan-in path accepts is sync.max_interval, one quantity under one key. With a sync: block, write it there; without one no synchroniser waits, so the key bounded nothing: add sync: { policy: approximate, max_interval: <d> } if the path does synchronise (its derived output rate becomes the MIN of its inputs, not their sum), else delete it. migrate folds it into an existing sync:. | |
tolerance_ms | removed | Removed; its successor tolerance was removed in v0.3.16 — write sync: { max_interval: <n>ms }. | |
drop | requirement | Event chain only: the end-to-end loss budget, max_count: N / W and max_consecutive: K (or the bare N / W). No topic on the path’s route may permit more loss than the whole (drop-tightness). On a node path it is refused since v0.1.60: nothing read it there; the loss belongs on the topic the path outputs (topics.<t>.drop), where play_launch migrate moves it. | |
trigger | fact | What causes this path’s output: timer | |
sync | fact | Fan-in synchronization policy for an input trigger with two or more endpoints. | |
max_jitter | requirement | Permitted variation in this path’s latency. | |
min_latency | fact | Best-case latency. Exists so that max_jitter is falsifiable. | |
safe_state | fact | What this path produces when it is a reaction: the endpoint it commands, and the plant’s settle time. | |
miss | requirement | What a missed deadline costs and what to do about it. | |
segments | removed | Removed with chains: — a written route is a second copy of the graph. |
trigger
| key | kind | status | meaning |
|---|---|---|---|
timer | fact | Periodic self-clocked callback. | |
input | fact | Output caused by these input endpoints or topics. |
trigger.timer
| key | kind | status | meaning |
|---|---|---|---|
rate_hz | removed | Renamed rate: in v0.3.21 and refused since v0.3.27: a rate is a value with its unit (trigger: { timer: { rate: 100Hz } }). play_launch migrate <contract> --write rewrites it. | |
rate | fact | since v0.3.21 | Timer rate. Required, and must be greater than zero. A frequency with its unit (10Hz; a bare number is refused), or the map form { value, source } (since v0.1.61) to say where the rate comes from: source: allocated lets the consumer refuse a period outside the range it derives. A reference the checker cannot evaluate ($(param rate) Hz with no launch tree) still makes the path timer-triggered; only the period is unknown, and a rule that needs it says the comparison was not made. rate_hz (a number of Hz) before v0.3.21. |
jitter | fact | since v0.1.49 | Release jitter: how late a tick may be released after its nominal instant, measured (a duration, less than one period). A reaction that waits for this timer is charged period + jitter (the reaction walk’s sampling hop and dwell-expiry’s notice) instead of a bare period. Absent: ticks are on time. A budget: the map form { duration, source } applies. |
param | fact | since v0.1.58 | The parameter of this path’s node that holds the timer’s RATE, Hz (update_rate). Its resolved launch value must equal rate_hz (timer-param). At most one of param and period_param. |
period_param | fact | since v0.1.58 | The parameter of this path’s node that holds the timer’s PERIOD, seconds. Its resolved launch value must equal 1 / rate_hz (timer-param). |
sync
| key | kind | status | meaning |
|---|---|---|---|
policy | fact | Fan-in policy. Required. | |
max_interval | fact | Widest permitted spread between matched inputs. | |
max_interval_ms | removed | Removed — write max_interval: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. | |
timeout | fact | How long to wait for the remaining inputs. | |
timeout_ms | removed | Removed — write timeout: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. |
drop
| key | kind | status | meaning |
|---|---|---|---|
max_count | requirement | Permitted losses over a window, as N / W. | |
max_consecutive | requirement | Permitted consecutive losses. |
qos
| key | kind | status | meaning |
|---|---|---|---|
reliability | fact | reliable | |
durability | fact | volatile | |
depth | fact | History depth. | |
history | fact | keep_last | |
lifespan | fact | How long a message stays valid after publication. | |
lifespan_ms | removed | Removed — write lifespan: <n>ms (or ns/us/s). The unit in a NAME is what lets a value be 1000x wrong and still parse. | |
liveliness | fact | automatic | |
deadline | fact | QoS deadline between consecutive messages. | |
lease_duration | fact | Liveliness lease: how often a publisher must assert it is alive. Checked pub against sub by qos-match. |
miss
| key | kind | status | meaning |
|---|---|---|---|
tolerate | requirement | Permitted misses over a window, as N / W. | |
consecutive | requirement | Permitted consecutive misses. | |
action | requirement | What to do on a miss: continue |
concurrency
| key | kind | status | meaning |
|---|---|---|---|
exclusive | fact | Groups of path names that may not run at the same time. |
params.<name>
| key | kind | status | meaning |
|---|---|---|---|
type | fact | ROS 2 parameter type: bool | |
default | fact | since v0.2.4 | The value a $(param <name>) reads when no launch source sets the parameter (the code’s compiled-in default, stated). Without it, reading an unset parameter is param-unset. |
hazards.<name>
| key | kind | status | meaning |
|---|---|---|---|
integrity | requirement | since v0.3.3 | Integrity level from the HARA (ASIL_D, SIL_3, DAL_A, …): the level the analysis assigns, not ISO 26262’s S0-S3 severity class, which is one of its inputs. Consumed, never computed. |
severity | removed | Renamed integrity: in v0.3.3: an ASIL, SIL or DAL is an integrity level, and ISO 26262’s severity is the S0-S3 class it is derived from. play_launch migrate <contract> --write rewrites it. | |
description | meta | What the hazardous event is. | |
guards | removed | Renamed monitors: in v0.3.7: the topics watched for a fault are its monitored signals (in formal methods a guard is a transition’s condition). play_launch migrate <contract> --write rewrites it. | |
monitors | meta | since v0.3.7 | The monitored signals: topics watched for the fault. A bare name is one guard (a topic, or a capability by name: a redundant set is capabilities.<f>: { all_of: [...] }, guarded as f); a list is a group lost when any member is. |
on | fact | Fault classes the monitors report, one or a list: omission | |
ftti | requirement | Fault-tolerant time interval: fault to hazardous event, absent reaction. Checked by fault-reaction-time. | |
enters | removed | Renamed leaves: in v0.3.19 and refused since v0.3.27: it names the mode the fault takes away, while supervise.enters names the level a miss enters. play_launch migrate <contract> --write rewrites it. | |
leaves | meta | since v0.3.19 | The mode this hazard takes away (enters: before v0.3.19). The system leaves it by its fallback: sequence: each level in order, by its own reaction:, each checked in its own right (degradation-level-time) and the minimal risk condition (the last level) against ftti. The named mode’s own reaction:, if it has one, is not what this hazard runs. (supervise.enters is the opposite direction: it names the level a miss enters, whose own reaction: runs.) Exactly one of leaves and reaction; a name that is not a mode of this scope is leaves-unknown-mode. The hazard must take the mode away: the capabilities its fault removes, a redundant group’s m counted, must include at least one the mode requires, or the entry is leaves-not-removed (warning). |
reaction | meta | The event chain whose route reaches the safe state: a one-level reaction. Exactly one of leaves and reaction. A mode named here is refused since v0.3.15 (it was the pre-0.1.59 spelling of leaves): write leaves: <mode>, which play_launch migrate does. | |
when | fact | The value that is the fault, { field: <name>, <op>: <constant> } (the constant may be read from the launch tree, since v0.3.18), on a hazard whose guard is a detector’s output. Requires reported among the on: classes (when-requires-reported). | |
detection | fact | Fault to detection when that is physics, not a detector’s timeout (an occlusion building pressure), a duration or { duration, source }. Charged before the detection the consumer derives from the detectors, so stating it never buys slack. Usually derived by an extension (source: { derived: ... }). | |
deadline_by | requirement | <extension>/<check>: the check that is this hazard’s requirement when it is not a time (a safety distance). A hazard states ftti, deadline_by, or both. | |
requirement | meta | since v0.3.13 | The hazard analysis’s requirement this hazard implements, { id, source }. The id is named in every diagnostic about the hazard. |
reaction_total | removed | Read-only: the consumer computes it (detection + route + settle) and hands it to extension checks. A contract never writes it. |
modes.<name>
| key | kind | status | meaning |
|---|---|---|---|
description | meta | What this mode is. | |
requires | fact | Capabilities (or bare topics) this mode needs; it is available while every one holds. | |
fallback | requirement | Modes to fall to, in order, when this one is lost: the fallback sequence of degradation levels. The last is the minimal risk condition (MRC) and must require nothing losable. | |
reaction | meta | The event chain that reaches this mode’s safe state. | |
overrides | requirement | Requirement values that apply IN THIS MODE, pinned over the scalar declared elsewhere. | |
min_dwell | requirement | since v0.3.3 | A transitional degradation level’s dwell time (window: before v0.3.3): while the level stays available the system stays AT LEAST this long (the time the level promises whoever it waits for, a driver’s takeover time), then takes the next level. The level below starts no sooner than the deadline and within its own reaction route after it, and that route is where the deadline’s notice is charged (dwell-expiry); its first hop crosses no link (the owner reads its own clock), so a guard edge’s max_transport is not charged there. When a timer path of the owner reaches the level below, the route starts there, its tick charged on the first hop, whichever node detected the fault. A duration, or { duration, param } binding it to the parameter that enforces it. Since v0.3.18 the duration may be a range, { duration: { min: 8s, max: 15s }, param }: min is the least time promised, max the longest the level lasts while available, and every level below is charged max (a single duration is both); the parameter’s value must lie in the range (dwell-param). Never on the minimal risk condition (dwell-at-mrc); unbound is dwell-unbound. |
window | removed | Renamed min_dwell: in v0.3.3: a least time in a mode before the next is the switched-systems dwell time. play_launch migrate <contract> --write rewrites it. | |
exit | requirement | { holds: <capability>, to: <mode> }: while this level is active, the capability holding ends the fallback sequence in to. Only on a level with a min_dwell. to is outside every fallback: list, or (since v0.3.18) a level ABOVE this one in a fallback sequence that lists both, which the exit re-enters: its dwell restarts, and a fault from then on is walked as any other (mode-exit-target). | |
commands | requirement | since v0.3.13 | What this level commands: { <topic>: [<predicate>, ...] }, each predicate in the when: shape ({ field, <op>: <constant> }; since v0.3.18 the value may read the launch tree, as in when:). While the level is active, every message on the topic satisfies every predicate (safe-state-violated). A topic named here is a final element: it has one publisher, its arbiter (arbiter-bypass); the level’s reaction reaches it (commands-unreached); silence on it is judged by its consumer (final-element-silent). |
requires_lost | fact | since v0.3.18 | Capabilities (or bare topics) of which at least one must be LOST for this level to be available, beside every requires holding: a level that exists only after a loss (holding the lane while the main computer is gone). A hazard whose fault removes none of them skips the level: the walk neither checks nor charges it, as it skips a level whose requires the fault removes. A name may not be in both lists (a parse error). Never on the minimal risk condition, which must always be available (requires-lost-at-mrc). |
advance | requirement | since v0.3.18 | { holds: <capability> }: while this level is active, the capability holding takes the next level of the fallback sequence at once, before the dwell’s least time: the way DOWN out of a dwell early (a deadline shortened by the situation). Only on a level with a min_dwell (a parse error otherwise). It only shortens the level, so what the levels below are charged is unchanged. Some node implementing the level must take the capability’s topic on a path trigger (mode-advance-unwired). |
within | requirement | since v0.3.18 | This level’s own deadline: the longest from the fault to the level being entered, a duration or { duration, source }. For every hazard whose walk reaches the level, the level’s row (detection + every dwelling level waited out above it, its route and its charged dwell + the level’s route + its settle) must fit it (level-within). Judged beside the hazard’s ftti, not instead of it: a level without a dwell is judged against both, a dwelling level against its within only. A level a hazard skips is not judged for that hazard. |
hazards.<name>.monitors[]
| key | kind | status | meaning |
|---|---|---|---|
all_of | removed | Removed in v0.1.59 – an inline redundant group is the same group capabilities.<f>: { all_of: [...] } states by name. Declare the capability and monitor it by name: monitors: [<f>]; play_launch migrate does it. |
on_violation
| key | kind | status | meaning |
|---|---|---|---|
on | fact | Fault classes that trigger the reaction: omission | |
reaction | meta | A path on this node whose trigger includes the subscription. | |
within | requirement | This hop’s share of the fault reaction time. | |
mechanism | fact | Where the runtime observer reads the violation: qos (default) |
arrival_curve
| key | kind | status | meaning |
|---|---|---|---|
rate_hz | removed | Renamed rate: in v0.3.21 and refused since v0.3.27: a rate is a value with its unit (rate: 100Hz). play_launch migrate <contract> --write rewrites it. | |
rate | requirement | since v0.3.21 | Sustained messages per second the subscriber absorbs. Finite and > 0, and not below the endpoint’s own min_rate. A frequency with its unit (100Hz, 1.5kHz, $(param rate) Hz); a bare number is refused, so a rate cannot be read as a period. rate_hz (a number of Hz) before v0.3.21. |
burst | requirement | since v0.1.64 | Messages that may arrive back to back before pacing applies. An integer >= 1. |
safe_state
| key | kind | status | meaning |
|---|---|---|---|
emits | fact | The endpoint this reaction commands the safe state on. | |
settle | fact | How long the plant takes to reach the safe state once commanded. settle: <d> is shorthand for settle: { duration: <d> }; the map is { duration ; response ; source } plus the keys of a used extension that derives settle.duration (v0.2.0: the braking profile decel, jerk with the hazard’s entry_speed is the bundled vehicle.braking’s; settle-derived prints its trace). response is added to either (omitted: 0). Both a duration and a derivation: the derivation is charged and the two compared (settle-conflict). |
capabilities.<name>
| key | kind | status | meaning |
|---|---|---|---|
all_of | meta | Members of a redundant group, lost only when every member is. At least two. | |
of | meta | The topics a value capability reads. Requires when:; without one, write the bare list. | |
when | fact | The predicate that LOSES the capability by value. A value capability is lost by the value or by silence. | |
m | fact | since v0.3.13 | A redundant group’s count, IEC 61508’s MooN: held while at least m of the all_of members hold. Only beside all_of; an integer from 1 to the member count. Omitted: 1 (held while any member holds). A hazard that loses k members removes the group only when fewer than m remain (n - k < m), which is what enters-not-removed counts. |
when
| key | kind | status | meaning |
|---|---|---|---|
field | fact | One scalar field of the message, a dotted path from its root. Checked against the .msg when the ament index resolves it (when-field-unknown). | |
equals | fact | The field equals the constant: a bool, a number, a message constant name (upper snake case) or a string. Since v0.3.18 a number may be read: $(let <name>), $(param ...) or $(var ...), or an expression of them (see Values read from the launch tree), the same for every operator. It is evaluated per launch to a number in SI units (a $(let) of 60 km/h is 16.67); a $(param) or $(var) may be written without a unit, as a plain number in the field’s own unit. Unknown without a launch tree, and then not judged. | |
not_equals | fact | The field differs from the constant. | |
lt | fact | The field is below the constant, a number. | |
le | fact | The field is at most the constant, a number. | |
gt | fact | The field is above the constant, a number. | |
ge | fact | The field is at least the constant, a number. |
modes.<name>.exit
| key | kind | status | meaning |
|---|---|---|---|
holds | fact | since v0.1.59 | The capability whose holding ends the fallback sequence. Some node implementing the level must take its topic on a path trigger (mode-exit-unwired). |
on | removed | Removed in v0.3.15 (renamed holds: in v0.1.59), so that on names fault classes only. Write holds: <capability>; play_launch migrate <contract> --write rewrites it. | |
to | meta | The mode the exit ends in: one outside every fallback: list, or (since v0.3.18) a level above this one in a fallback sequence that lists both, re-entered with its dwell restarted (mode-exit-target). |
modes.<name>.advance
| key | kind | status | meaning |
|---|---|---|---|
holds | fact | since v0.3.18 | The capability whose holding leaves the dwelling level early, to the next level of the fallback sequence. Some node implementing the level must take its topic on a path trigger (mode-advance-unwired). |
modes.<name>.min_dwell.duration (range form)
| key | kind | status | meaning |
|---|---|---|---|
min | requirement | since v0.3.18 | The least time the level lasts while available (positive): the promise to whoever it waits for. The level below starts no sooner, unless advance holds. |
max | requirement | since v0.3.18 | The longest the level lasts while available, at least min: the level below starts no later than this plus its own route, and every level below is charged it. |
safe_state.settle
| key | kind | status | meaning |
|---|---|---|---|
duration | fact | The written settle (a measured duration): settle: { duration: 2s } is settle: 2s. Beside an extension’s keys, the fallback when a hazard does not write a key the derivation needs (settle-entry-missing), and compared against the derivation (settle-conflict). Required when no extension derives the settle. | |
response | fact | since v0.1.58 | The actuation delay: from the safe state’s command to the plant’s first response, the final element’s part of the safety function response time (IEC 62061, ISO 13849); for a vehicle, from the braking command to the deceleration it then holds (a duration). Added to the settle, a written duration or a derived one alike (an extension that reads settle.response, as vehicle.braking does, adds it in its own formula; settle-derived and --explain print both parts). Omitted: 0, so a written duration that already includes the response omits it. The map form { duration, source } applies. |
source | meta | since v0.1.60 | Where the written duration comes from, as a budget’s source:. Requires duration: a profile’s settle is derived from its parameters. |
supervise | requirement | since v0.1.61 | The runtime supervision of the WHOLE settle (since v0.1.62): from the safe state’s command to standstill, the written duration or the derived profile plus the response. { reaction: <path> | enters: <mode>, mechanism: executor | timer, observes: <node>/<subscriber> }: the platform arms due = command + settle + how late it sees standstill (observes: that input’s period + its max_transport), and a vehicle not at standstill by then starts the reaction. The consumer’s overrun case charges the level up to the settle’s end, that observation, the detection and the reaction’s route and settle. v0.1.61 took it on a written duration only. |
<budget> (map form)
| key | kind | status | meaning |
|---|---|---|---|
duration | requirement | since v0.1.58 | The budget itself, with a unit. Required. max_latency: { duration: 149ms, source: ... } states the same budget as max_latency: 149ms, plus where it comes from. Accepted by max_latency, max_jitter, max_transport, max_age, max_response, within (a subscriber’s reaction, and a mode’s own deadline since v0.3.18), ftti, a timer’s jitter, a settle’s response and a mode’s min_dwell (where it is the least time the level lasts while it stays available: the level below starts no sooner; positive; since v0.3.18 also the range { min, max }). See Bounds below. |
param | fact | since v0.1.58 | The parameter whose resolved launch value, in seconds, must equal duration. On max_age: a parameter of this subscriber’s node (max-age-param). On a mode’s min_dwell: <node>.<parameter> (dwell-param), whose value must lie in the range when the dwell is one. No other bound takes one. |
source | meta | since v0.1.58 | Where the budget comes from: requirement (chosen: a hazard analysis, a decision, a configured value), measured (an observed maximum plus a margin: NOT a bound), derived (computed from other numbers of the contract or the image’s parameters) or analysed (an upper bound from an analysis). { measured: { max, n, margin } } states the observations, and the consumer checks that max x (1 + margin), rounded up to the next ms, reproduces duration (budget-rule). allocated (since v0.1.61): chosen inside a range the consumer derives. |
supervise | requirement | since v0.1.61 | The runtime checks the budget while the system runs and a miss starts a fallback: { reaction: <path> | enters: <mode>, mechanism: executor | timer }. The consumer derives the detection delay and checks that the overrun case (the budget + the detection + the fallback’s route and settle) fits the hazard’s FTTI. A budget’s level is derived from this and source: analysed -> bound; supervised; measured alone -> unsupervised. Not on a min_dwell (a least time). |
source.measured
| key | kind | status | meaning |
|---|---|---|---|
max | fact | since v0.1.58 | Single-term form: the largest value observed (a duration). For a timer tick with period, the largest lateness beyond the period. |
n | fact | since v0.1.58 | Single-term form: how many samples the maximum is over. |
period | fact | since v0.1.58 | Single-term form: a timer tick’s period, charged without margin: the term is period + max x (1 + margin). |
margin | requirement | since v0.1.58 | The margin over the observed maximum, a fraction (0.2 = 20 %). Required with max or terms. |
run | meta | since v0.3.4 | Where the observations were made (since v0.3.4): a run directory, a date, a method, free text. play_launch measure writes the run it read. |
terms | fact | since v0.1.58 | Several terms summed, a map of name -> { max, n, period }: each is rounded up to the next ms on its own, then they are added (tick: { period: 100ms, max: 14.84ms }, work: { max: 25.04ms } -> 118 + 31 = 149 ms). Refused beside max. |
source.derived
| key | kind | status | meaning |
|---|---|---|---|
by | fact | The extension that derived the value, a dotted name (vehicle.braking). Required. | |
version | fact | The extension’s version, MAJOR.MINOR.PATCH. Required. | |
sha256 | fact | The sha256 of the extension’s canonical ASCII form, 64 lowercase hex digits. | |
inputs | fact | The inputs the derivation read, a map of name -> value as written (entry_speed: 8.33 m/s). | |
trace | fact | The derivation’s steps, a list of lines, printed by --explain. |
source.measured.terms.<name>
| key | kind | status | meaning |
|---|---|---|---|
max | fact | since v0.1.58 | The largest value observed for this term (a duration). Required. |
n | fact | since v0.1.58 | How many samples the maximum is over. |
period | fact | since v0.1.58 | A timer tick’s period, charged without margin. |
<budget>.supervise
| key | kind | status | meaning |
|---|---|---|---|
reaction | fact | since v0.1.61 | The path a miss starts: a path of the budget’s own node (as on_violation.reaction), else an event chain of the manifest. Exactly one of reaction and enters. |
enters | fact | since v0.1.61 | The mode a miss enters; its reaction: event chain is what runs. Exactly one of reaction and enters. |
mechanism | fact | since v0.1.61 | What checks the budget. Required. executor: checked in the spin loop, so the detection waits for the longest callback on that executor, and a stuck callback is not caught (slowness, not a hang). timer: an independent timer and thread, which catches both and adds the platform’s switch (supervision.switch). |
observes | fact | since v0.1.62 | A settle’s supervision only: what the platform watches to see the safe state reached, { input, reached }. input is the subscriber it is seen on; reached is the predicate on that input’s message that holds once the safe state is reached ({ field: twist.twist.linear.x, le: 0.01 }), and names the field an early check measures. The consumer derives how late the safe state is seen: the input’s period (the slowest of the topic’s rate and the subscriber’s min_rate) + the subscriber’s transport, and adds it to the supervised deadline. A run time needs reached to judge the settle without knowing the domain. Since v0.3.25 the bare string form (observes: <node>/<subscriber>) is deprecated: it reads for one release as { input }, and migrate writes the map. Refused on any other budget. |
early | requirement | since v0.3.1 | A settle’s supervision only: the response check, { within, decrease }. The platform arms a second, earlier due, command + within + the observation (observes), and judges the observed field (observes.reached.field) against the value it saw when it armed: met when it has decreased by at least decrease, or reached holds; a miss starts the same reaction as the settle’s. The consumer charges its own overrun row (the level up to the command + within + the observation + the detection + the reaction’s route and settle) and checks decrease against how much the nominal profile changes the field by within (supervised-early). Refused on any other budget. |
resume | fact | since v0.3.2 | The reaction hands its output back and resumes it, { after }: once the reaction has run, the path that normally publishes the reaction’s output takes it over again when it next runs; if that path then stays silent for after, the reaction resumes the output, once and for good. The consumer charges the gap (after + this supervision’s detection delay) once on every overrun row whose fallback is this reaction (supervised-fit). Absent: the reaction keeps its output, and no gap is charged. |
links.<name>
| key | kind | status | meaning |
|---|---|---|---|
max_transport | requirement | since v0.3.4 | The bound on one message’s transport across the link, from the publish to the subscriber’s take. Required. A best-effort link (serial, TCP, DDS between processes or hosts) has no derivable worst case: state it measured, with source: { measured: { max, n, margin, run } } (link-unsourced otherwise). play_launch check --against <run> holds it: a message in a run over the bound is transport-exceeded. |
clock | fact | since v0.3.4 | synced or unsynced (the default): whether the two ends’ clocks are comparable. Synced: a message’s stamp age at the receiver is its transport, so it can be measured per message. Unsynced: only arrivals can be timed, so measure cannot propose the bound. |
monitor | removed | Removed in v0.3.15: it was parsed and read by nothing (a runtime link monitor, was not adopted). A link’s bound is measured and sourced, and check --against holds it against runs; a fault on the link is detected by the receiver’s own silence detector. |
<budget>.supervise.resume
| key | kind | status | meaning |
|---|---|---|---|
after | fact | since v0.3.2 | How long the handed-back output may stay silent before the reaction resumes it: <n> periods of the path that publishes the reaction’s output in the normal case (the consumer reads its timer’s period), or a duration. Positive. Required. |
safe_state.settle.supervise.early
| key | kind | status | meaning |
|---|---|---|---|
within | requirement | since v0.3.1 | When the check runs, from the safe state’s command (a duration, positive). Past the settle’s response and before the settle’s end; the observation is added, as on the settle’s own due. Required. |
decrease | requirement | since v0.3.25 | The least the observed field must have decreased by within, against the value the platform saw when it armed: a quantity with its unit, in the field’s dimension (0.25 m/s for a speed), positive. The consumer refuses a decrease above what the nominal profile changes the field by within (an extension’s derive settle.speed_lost, as vehicle.braking 1.1 states, for a speed), which would call a nominal stop a fault. Required. |
drop | removed | Renamed decrease: in v0.3.25 and refused since v0.3.27: the response check measures the observed field, which need not be a speed (decrease: 0.15 m/s). play_launch migrate <contract> --write rewrites it. |
safe_state.settle.supervise.observes
| key | kind | status | meaning |
|---|---|---|---|
input | fact | since v0.3.25 | The subscriber the safe state is seen on, <node>/<subscriber> of this manifest. Required. |
reached | fact | since v0.3.25 | The predicate on the input’s message that holds once the safe state is reached, in the grammar of when: ({ field, <op>: <constant> }). Its field is also the field an early check measures. Optional for the static checks; a run time judges the settle by it. |
acknowledged[]
| key | kind | status | meaning |
|---|---|---|---|
rule | meta | since v0.2.3 | The rule id of the finding, as the diagnostic prints it (reaction-unguarded). Required, non-empty. |
at | meta | since v0.2.3 | The dotted path the diagnostic reports (hazards.<h>.reaction; check --format json prints it as path). Required, non-empty. Two entries naming the same rule and path are refused. |
reason | meta | since v0.2.3 | Why the finding is kept, printed beside it. Required, non-empty. |
cli.<endpoint>.on_timeout
| key | kind | status | meaning |
|---|---|---|---|
enters | meta | since v0.3.19 | The mode the call falls to when the wait passes. Without retry:. Exactly one of enters and reaction. |
reaction | meta | since v0.2.5 | The event chain that runs when the wait passes. Without retry:. A mode named here is the pre-v0.3.19 spelling of enters: (deprecated-spelling; play_launch migrate rewrites it). |
retry | fact | since v0.2.5 | The code asks again: { attempts, backoff }. Sound only when every server declares idempotent: true (call-retry-not-idempotent), and bounded only with attempts and then: (call-retry-unbounded). |
then | meta | since v0.2.5 | What the code does after the last attempt, { enters: <mode> } or { reaction: <event chain> }. Only beside retry:. |
cli.<endpoint>.on_timeout.retry
| key | kind | status | meaning |
|---|---|---|---|
attempts | fact | since v0.2.5 | The tries in all, the first included (>= 1). Absent: the code retries without a bound. |
backoff | fact | since v0.2.5 | The wait between two tries (a duration, $(param …)-capable). |
on_rejected / on_timeout.then
| key | kind | status | meaning |
|---|---|---|---|
enters | meta | since v0.3.19 | The mode the call falls to. Exactly one of enters and reaction is required. |
reaction | meta | since v0.2.5 | The event chain that runs. A mode named here is the pre-v0.3.19 spelling of enters: (deprecated-spelling; play_launch migrate rewrites it). |
topics.<name>.external (map form)
| key | kind | status | meaning |
|---|---|---|---|
side | meta | since v0.3.13 | Which side is external: pub |
on_silence | fact | since v0.3.13 | What the external consumer does when the topic goes quiet: { after: <d> }, it reaches its safe state by itself after after of silence. Only with an external sub side. Without it, silence on a commanded topic is final-element-silent. |
topics.<name>.external.on_silence
| key | kind | status | meaning |
|---|---|---|---|
after | fact | since v0.3.13 | Silence after which the external consumer is in its safe state. A positive duration. Required. |
hazards.<name>.requirement
| key | kind | status | meaning |
|---|---|---|---|
id | meta | since v0.3.13 | The requirement’s id in the hazard analysis (R1, SG-04). Required, non-empty. |
source | meta | since v0.3.13 | Where the requirement is written (HARA rev 3, section 4.2), or the evidence for it. |
independence[]
| key | kind | status | meaning |
|---|---|---|---|
of | meta | since v0.3.13 | The nodes or capabilities that must be independent, pairwise. At least two. |
not_sharing | requirement | since v0.3.13 | The deployment facts no two of them share: process |
trigger.timer.rate (map form)
| key | kind | status | meaning |
|---|---|---|---|
value | fact | since v0.1.61 | The rate, Hz. Required; greater than zero. |
source | meta | since v0.1.61 | Where the rate comes from, as a budget’s source:. allocated: chosen inside the range the consumer derives, which refuses a period outside it. |
Bounds
Every key below is a spelling of one bound: a value with a unit, what it limits (its kind), from which side, where the number comes from (source, in the map form) and, for two of them, the parameter of the image that must carry it (param). The keys keep their names; each parses to the bound its row gives. map form says what the key accepts besides its bare value: { duration, source } (the budget map form above), or that plus param.
| key | where | kind | limit | unit | map form |
|---|---|---|---|---|---|
max_latency | paths.<name> / event_chains.<name> | latency | at most | duration | { duration, source } |
min_latency | paths.<name> / event_chains.<name> | latency | at least | duration | |
max_jitter | paths.<name> / event_chains.<name> | jitter | at most | duration | { duration, source } |
jitter | trigger.timer | jitter | at most | duration | { duration, source } |
min_rate | pub/sub/cli.<endpoint> | rate | at least | Hz | |
max_rate | pub/sub/cli.<endpoint> | rate | at most | Hz | |
max_age | pub/sub/cli.<endpoint> | age | at most | duration | { duration, source, param }; param: a parameter of the subscriber’s node, seconds (max-age-param) |
max_transport | pub/sub/cli.<endpoint> | transport | at most | duration | { duration, source } |
max_transport | topics.<name> | transport | at most | duration | { duration, source } |
max_transport | links.<name> | transport | at most | duration | { duration, source } |
max_response | srv.<endpoint> | response | at most | duration | { duration, source } |
within | on_violation | deadline | at most | duration | { duration, source } |
ftti | hazards.<name> | deadline | at most | duration | { duration, source } |
detection | hazards.<name> | latency | at most | duration | { duration, source } |
min_dwell | modes.<name> | least time | at least | duration | { duration, source, param }; param: <node>.<parameter>, seconds (dwell-param) |
within | modes.<name> | deadline | at most | duration | { duration, source } |
settle | safe_state | response | at most | duration | { duration ; response ; source } plus a used extension’s keys (settle: <d> is { duration: <d> }) |
duration | safe_state.settle | response | at most | duration | |
response | safe_state.settle | response | at most | duration | { duration, source } |
max_count | drop | count | at most | count / window | |
max_consecutive | drop | count | at most | count | |
tolerate | miss | count | at most | count / window | |
consecutive | miss | count | at most | count |
Values read from the launch tree
A quantity may READ a number instead of restating it: a duration, a rate, a count, the duration: or value: of a braces form, a QoS duration, and an extension key typed param. The value is an expression:
value := term (('+' | '-') term)*
term := factor (('*' | '/') factor)*
factor := number unit? | ref unit | '$(let' name ')' | '(' value ')'
ref := '$(param' [node] name ')' | '$(var' name ['@' node] ')'
| reference | reads |
|---|---|
$(param [<node>] <name>) | the node’s effective parameter value; one argument: the node the key sits under; a bare node: a node key of this contract; /<fqn>: any node of the launch tree |
$(var <name> [@<node>]) | a launch configuration, at the end of the contract’s launch file (or where <node> was declared) |
$(let <name>) | an entry of the root let: |
A $(param) or $(var) takes a unit, always ($(param watchdog_ms) ms): a parameter carries none, and reading it in SI would make a 100 ms lease a 100 s one. On a count it takes none. A $(let) carries its entry’s unit. Units are rlx’s (extension-reference.md); a value of the wrong dimension for its key is param-dimension. source: beside a reference is a parse error (source-on-reference): the reference is the value’s source. A value with no reference is the literal it always was.
The consumer that holds the launch tree evaluates every reference per scope instance and hands each rule a plain number; a contract read alone leaves the value unknown (the key absent), never zero.
A predicate’s value (since v0.3.18): the constant of equals, not_equals, lt, le, gt or ge, in a when: (on a hazard or a capability) or in a mode’s commands, may be such a value, for example { field: longitudinal.velocity, le: $(let v_odd) }. The grammar does not know the field’s dimension, so any is accepted and the value is the number in SI units: a $(let) of 60 km/h compares as 16.67. There, and only there, a $(param) or $(var) may be written without a unit: it is then a plain number in the field’s own unit. Unknown without a launch tree, the predicate stays in the contract and is not judged; it is never read as held. A value relative to the field’s own past (the value it had when the level was entered) is not in the grammar.
Integrity level to criticality
A node a hazard reaches (it feeds, detects for, reacts for, or commands for the hazard) takes a scheduling criticality from the hazard’s integrity, the MAX over every hazard that reaches it. The first entry of the scale is “no safety requirement” and derives nothing; the other n entries split into three buckets by ceil(3 rank / n) (1 low, 2 medium, 3 high). A written criticality on such a node is an error; on a node no hazard reaches it stands. The default scale (no profile named by use:):
| integrity | criticality |
|---|---|
QM | none |
ASIL_A | low |
ASIL_B | medium |
ASIL_C | high |
ASIL_D | high |
A contract that uses a profile (use: { iec61508: "^1" }) draws integrity levels from the profile’s integrity_scale and takes each level’s criticality from the profile’s criticality map, stated level by level, instead of the split above. Reference profiles ship with the checker: iso26262, iec61508, iec61511, do178c, iec62304, iso13849, en50129 (iso26262 is the default scale and map above).
Configuration surface
One fact can be spelled several ways. Only one of them is a place to make a decision; the rest carry that decision across a layer boundary. This page separates the two, because a list that does not is a list of nine ways to set a locator.
Every symbol on this page is one a user may set. Kconfig says so
itself: each carries a PROMPT, which is what a prompt means. An earlier
draft split these into public and carrier by asking who read them, and got
the layer wrong — cmake reading ${CONFIG_X} to emit ZPICO_X=<value> is
cmake CARRYING the choice, not owning it.
The real carriers are one layer down and are NOT Kconfig symbols: the
ZPICO_* / NROS_* environment variables, the -D cache variables and
the compile definitions this page’s symbols feed. Setting one of those by
hand bypasses the question Kconfig asked.
The evidence column is where each value is consumed, so a symbol with no
reader stands out: a prompt asking a question whose answer is discarded is
worse than no prompt.
189 Kconfig symbols — 102 settable, 1 provided for application code, 86 derived, 0 dead.
Facts with more than one spelling
Where a decision has an authority OUTSIDE Kconfig, that authority is the place to set it and these symbols carry it.
RMW backend
Set it here: [system].rmw in the bringup’s system.toml
| symbol | default | class | evidence |
|---|---|---|---|
CONFIG_NROS_RMW_ZENOH | — | public | cmake, rust-source, kconfig select/depends |
CONFIG_NROS_RMW_XRCE | — | public | forwarded-to-cargo, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_RMW_CYCLONEDDS | — | public | cmake, rust-source, kconfig select/depends |
nano_ros_workspace(BACKEND …) and -DNROS_RMW are the cmake carriers. cmake already warns that BACKEND silently beats the cache var; nothing yet compares either against [system].rmw.
ROS domain id
Set it here: [system].domain_id in system.toml
| symbol | default | class | evidence |
|---|---|---|---|
CONFIG_NROS_DOMAIN_ID | 0 | public | forwarded-to-cargo, c-source, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_CYCLONEDDS_DOMAIN_ID | NROS_DOMAIN_ID | public | c-define, c-source, cmake, rust-source |
CONFIG_NROS_CYCLONEDDS_DOMAIN_ID defaults FROM NROS_DOMAIN_ID — the one derivation edge in this cluster. Do not pin it to a literal: a Cyclone DDS image would then run on that domain whatever domain_id says.
Router / agent endpoint
Set it here: [system].locator in system.toml
| symbol | default | class | evidence |
|---|---|---|---|
CONFIG_NROS_LOCATOR | tcp/127.0.0.1:7447 | public | c-source, cmake, rust-source |
CONFIG_NROS_XRCE_AGENT_ADDR | 127.0.0.1 | public | cmake, rust-source |
CONFIG_NROS_XRCE_AGENT_PORT | 2018 | public | cmake, rust-source |
Zephyr is exempt from the cmake precedence chain by design (see the exemption comments in NanoRosEntry.cmake — no line ref, they move), so the Kconfig spelling is the carrier there rather than an override.
Executor sizing
Set it here: environment knobs at build time (see the pool inventory)
| symbol | default | class | evidence |
|---|---|---|---|
CONFIG_NROS_EXECUTOR_MAX_CBS | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_SC | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_NODES | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_ARENA_BYTES | 0 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_MONITORS | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_AGE_MONITORS | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_SHUTDOWN_CBS | 2 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_ACTION_CLIENTS | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_SUBSCRIPTION_BUFFER_BYTES | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_PARAM_SERVICE_BUFFER_BYTES | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_PARAMETERS | -1 | derived | forwarded-to-cargo, c-source, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_NAME_BYTES | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_STRING_VALUE_BYTES | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_ARRAY_LEN | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_STRING_ARRAY_LEN | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_BYTE_ARRAY_BYTES | -1 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_DESCRIPTION_BYTES | 256 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_MAX_CONSTRAINTS_BYTES | 0 | derived | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_EVENTS_DEPTH | 1 | derived | forwarded-to-cargo, cmake, rust-source |
On Zephyr the Kconfig spelling IS how a user sets these — it is a carrier only in the sense that the env var is what the build script reads, so the Kconfig value must reach the build environment.
Public — set these
Read by compiled code or forwarded to a build script. On Zephyr the
CONFIG_ spelling IS the way to state these; the env var is the carrier.
| symbol | default | evidence |
|---|---|---|
CONFIG_NROS_ARENA_EXHAUSTION_IS_FATAL | y if NROS_BOOT_REPORT | cmake, rust-source |
CONFIG_NROS_BATCH_UNICAST_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_BOOT_REPORT | y if ARCH_POSIX | c-source, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_CAPABILITY_LIFECYCLE | — | forwarded-to-cargo, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_CAPABILITY_PARAM_SERVICES | — | forwarded-to-cargo, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_CAPABILITY_ROSOUT | — | cmake, rust-source |
CONFIG_NROS_CAPABILITY_SIM_TIME | — | cmake, rust-source |
CONFIG_NROS_CODEGEN_TOOL | — | cmake |
CONFIG_NROS_CONSOLE_WHOLE_LINES | y if SMP | c-source, cmake, kconfig select/depends |
CONFIG_NROS_CONSOLE_WHOLE_LINES_BUFFER_BYTES | 160 | c-source, cmake, rust-source |
CONFIG_NROS_CPP_API | — | cmake, rust-source, kconfig select/depends |
CONFIG_NROS_CYCLONEDDS_CONFIG_XML | — | c-source, cmake, rust-source |
CONFIG_NROS_C_API | — | cmake, rust-source |
CONFIG_NROS_EPOCH_FROM_ZENOH | — | cmake, rust-source |
CONFIG_NROS_EPOCH_FROM_ZENOH_INTERVAL_MS | -1 | cmake, rust-source |
CONFIG_NROS_EXECUTOR_ARENA_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_EXECUTOR_BACKING_U64S | -1 | cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_LEVELS | 8 | rust-source |
CONFIG_NROS_FAULT_LOG | n | c-source, cmake, kconfig select/depends |
CONFIG_NROS_FAULT_LOG_FLASH | n | c-source |
CONFIG_NROS_FRAG_MAX_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_GET_POLL_INTERVAL_MS | -1 | cmake, rust-source |
CONFIG_NROS_GET_REPLY_BUF_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_GRAPH_CACHE_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_GRAPH_MAX_ENTITIES | -1 | cmake, rust-source |
CONFIG_NROS_HEAP_EXHAUSTION_IS_FATAL | y if NROS_BOOT_REPORT | c-source, rust-source |
CONFIG_NROS_LOG_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_MAX_ARRAY_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MAX_BYTE_ARRAY_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MAX_PARAMETERS | -1 | cmake, rust-source |
CONFIG_NROS_MAX_PARAM_CONSTRAINTS_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MAX_PARAM_DESCRIPTION_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MAX_PARAM_NAME_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MAX_STRING_ARRAY_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MAX_STRING_VALUE_LEN | -1 | cmake, rust-source |
CONFIG_NROS_MONITOR_ARM_GRACE_MS | 0 | forwarded-to-cargo, c-source, cmake, rust-source |
CONFIG_NROS_MONITOR_ARM_ON_CALL | — | c-source, cmake, rust-source |
CONFIG_NROS_NET_VLAN_TAG | 0 | c-source, cmake, rust-source |
CONFIG_NROS_PARAMS_STORE | — | cmake, rust-source, kconfig select/depends |
CONFIG_NROS_PARAM_EVENTS_DEPTH | -1 | cmake, rust-source |
CONFIG_NROS_PARAM_SERVICE_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_PARAM_SERVICE_INBOX_BYTES | -1 | cmake, rust-source |
CONFIG_NROS_PARAM_SERVICE_INBOX_DEPTH | -1 | cmake, rust-source |
CONFIG_NROS_RUST_API | NROS_RMW_ZENOH | cmake, rust-source, kconfig select/depends |
CONFIG_NROS_SERVICE_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_SNTP_EPOCH | — | cmake, rust-source |
CONFIG_NROS_SUBSCRIBER_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_SUBSCRIBER_LARGE_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_SUBSCRIBER_RING_DEPTH | -1 | cmake, rust-source |
CONFIG_NROS_SUBSCRIPTION_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_TRACE_CALLBACKS | — | cmake, kconfig select/depends |
CONFIG_NROS_TRACE_TAKES | — | c-source, cmake, rust-source |
CONFIG_NROS_TRACE_TIMER_EVERY | 1 | forwarded-to-cargo, c-source, cmake, rust-source |
CONFIG_NROS_VIOLATION_DRAIN_REPORT | — | c-source, cmake, rust-source |
CONFIG_NROS_XRCE_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_XRCE_SERVICE_REPLY_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_XRCE_SERVICE_REQUEST_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_XRCE_SUBSCRIBER_BUFFER_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_ZENOH_AUTO_RECONNECT | y | cmake |
CONFIG_NROS_ZENOH_LEASE_FACTOR | 3 | c-define, cmake |
CONFIG_NROS_ZENOH_LEASE_MS | 60000 | c-define, cmake |
CONFIG_NROS_ZENOH_LINK_CAN | n | cmake, kconfig select/depends |
CONFIG_NROS_ZENOH_LINK_ISOTP | n | cmake, kconfig select/depends |
CONFIG_NROS_ZENOH_LINK_SERIAL | n | cmake, rust-source, kconfig select/depends |
CONFIG_NROS_ZENOH_LINK_TCP | y | cmake |
CONFIG_NROS_ZENOH_LINK_UDP_MULTICAST | n | cmake |
CONFIG_NROS_ZENOH_LINK_UDP_UNICAST | n | cmake |
CONFIG_NROS_ZENOH_LINK_WS | n | cmake |
CONFIG_NROS_ZENOH_MULTI_THREAD | y | cmake, kconfig select/depends |
CONFIG_NROS_ZENOH_PUBLICATION | y | cmake |
CONFIG_NROS_ZENOH_QUERY | y | cmake |
CONFIG_NROS_ZENOH_QUERYABLE | y | cmake |
CONFIG_NROS_ZENOH_RAWETH_TRANSPORT | n | cmake |
CONFIG_NROS_ZENOH_SCOUTING | n | cmake |
CONFIG_NROS_ZENOH_SERIAL_FIFO_RXWATER | 1 | c-define |
CONFIG_NROS_ZENOH_SERIAL_FIFO_WATERMARK | — | cmake, kconfig select/depends |
CONFIG_NROS_ZENOH_SERIAL_ISR_STATS | — | cmake |
CONFIG_NROS_ZENOH_SERIAL_RX_RING_BYTES | 1024 | cmake, rust-source |
CONFIG_NROS_ZENOH_SERIAL_TCM | — | cmake, kconfig select/depends |
CONFIG_NROS_ZENOH_SERIAL_TX_RING_BYTES | 2048 | cmake |
CONFIG_NROS_ZENOH_SERIAL_UART_ASYNC | — | cmake, kconfig select/depends |
CONFIG_NROS_ZENOH_SERIAL_UART_ASYNC_RX_TIMEOUT_US | 25 | cmake |
CONFIG_NROS_ZENOH_SUBSCRIPTION | y | cmake |
CONFIG_NROS_ZEPHYR_EDMA_WARM_RESET_QUIESCE | y | cmake, rust-source |
CONFIG_NROS_ZEPHYR_HEAP_SIZE | -1 | cmake, rust-source |
CONFIG_NROS_ZEPHYR_LEVEL_WORKER_FRAME_BYTES | 13312 | c-source, cmake, rust-source |
CONFIG_NROS_ZEPHYR_MAX_SCHED_TASKS | NROS_ZEPHYR_MAX_TIERS if NROS_ZEPHYR_MAX_TIERS != 0 | c-define, c-source, cmake, rust-source |
CONFIG_NROS_ZEPHYR_MAX_TIERS | 0 | kconfig select/depends |
CONFIG_NROS_ZEPHYR_SCHED_TASK_STACKS_IN_DTCM | NROS_ZEPHYR_TIER_STACKS_IN_DTCM | c-source, cmake |
CONFIG_NROS_ZEPHYR_SCHED_TASK_STACK_BYTES | 16384 | c-define, c-source, cmake, rust-source |
CONFIG_NROS_ZEPHYR_STACKS_IN_DTCM | n | c-source, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_ZEPHYR_TASK_SLOTS | 2 if NROS_RMW_ZENOH && NROS_ZENOH_TX_BATCH | c-define, c-source, cmake |
CONFIG_NROS_ZEPHYR_TASK_STACK_BYTES | 16384 | c-define, c-source, cmake, rust-source |
CONFIG_NROS_ZEPHYR_TIER_STACKS_IN_DTCM | NROS_ZEPHYR_STACKS_IN_DTCM | kconfig select/depends |
Provided for application code
No reader in THIS tree, and not dead: the guides teach an application
to use these in its own main(). Kconfig generating the macro is the
service. Each names where that contract is written down.
| symbol | default | evidence |
|---|---|---|
CONFIG_NROS_INIT_DELAY_MS | 2000 | book/src/guide/platforms/zephyr.md (its C++ applications section) shows an application calling nros_platform_zephyr_wait_network(CONFIG_NROS_INIT_DELAY_MS) from its own main(); book-internals/src/testing/zephyr-dev-setup.md:220 documents it as a knob. |
Derived — selected by another symbol
No Kconfig prompt, so not asked about directly.
| symbol | default | evidence |
|---|---|---|
CONFIG_NROS_ACTION_INBOX_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ACTION_INBOX_DEPTH | 4 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_CLOCK_EPOCH_FAILURE | unstamped | c-source, rust-source |
CONFIG_NROS_CLOCK_FALLBACK_SETTLE_MS | 10000 | c-source, rust-source |
CONFIG_NROS_CLOCK_HLC_INTERVAL_MS | 1000 | c-source, cmake, rust-source |
CONFIG_NROS_CLOCK_SNTP_ATTEMPTS | 3 | c-source, rust-source |
CONFIG_NROS_CLOCK_SNTP_RESYNC_INTERVAL_MS | 0 | c-source, cmake, rust-source |
CONFIG_NROS_CLOCK_SNTP_RESYNC_STACK_BYTES | 8192 | c-source, cmake, rust-source |
CONFIG_NROS_CLOCK_SOURCE | platform | c-source, cmake, rust-source |
CONFIG_NROS_CLOCK_SOURCE_HAS_SNTP | — | kconfig select/depends |
CONFIG_NROS_CLOCK_UPGRADE | never | c-source, rust-source |
CONFIG_NROS_EXECUTOR_BACKING_BYTES | -1 | cmake, rust-source |
CONFIG_NROS_EXECUTOR_EXTRA_SESSIONS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_MAX_VIOLATIONS | 8 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_EXECUTOR_RUNTIME_REMAPS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_LOG_BUFFER_BYTES | 256 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_LOG_DYNAMIC_LOGGERS | 16 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_LOG_EARLY_RECORDS | 4 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_LOG_MAX_LEVEL | 0 | forwarded-to-cargo, c-source, cmake, rust-source |
CONFIG_NROS_LOG_ROSOUT_RECORDS | 16 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MAX_LARGE_SUBSCRIBERS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MAX_LIVELINESS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MAX_PENDING_GETS | 4 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MAX_PUBLISHERS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MAX_QUERYABLES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MAX_SUBSCRIBERS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_MEMORY_HEAP_BYTES | 1048576 if NROS_RMW_CYCLONEDDS | forwarded-to-cargo, c-source, cmake, rust-source |
CONFIG_NROS_PARAMS_SERVICE_INBOX_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PARAMS_SERVICE_INBOX_DEPTH | 1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_PUBSUB_QOS_DEPTH | 10 | rust-source |
CONFIG_NROS_RMW_LOCAL_QUERYABLE | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_RMW_SUBSCRIBER_SLOTS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_SERVICE_INBOX_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_SERVICE_INBOX_DEPTH | 4 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_SNTP_SERVER | 10.0.2.2 | c-source, rust-source |
CONFIG_NROS_SNTP_TIMEOUT_MS | 3000 | c-source, rust-source |
CONFIG_NROS_SUBSCRIBER_BUFFER_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_BUFFER_BYTES | 1024 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_CUSTOM_TRANSPORT_MTU | NROS_XRCE_TRANSPORT_MTU | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_GRAPH_RESYNC_MS | 5000 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_MAX_SERVICE_CLIENTS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_MAX_SERVICE_SERVERS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_MAX_SUBSCRIBERS | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_SERVICE_REPLY_BUFFER_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_SERVICE_REQUEST_BUFFER_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_STREAM_HISTORY | 16 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_SUBSCRIBER_BUFFER_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_SUBSCRIBER_RING_DEPTH | 32 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_XRCE_TRANSPORT_MTU | 512 | forwarded-to-cargo, cmake, rust-source, kconfig select/depends |
CONFIG_NROS_ZENOH_BATCH_UNICAST_BYTES | 1024 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_FRAG_MAX_BYTES | 2048 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_GET_POLL_INTERVAL_MS | 10 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_GET_REPLY_BUFFER_BYTES | 4096 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_GRAPH_CACHE_BYTES | 65536 | cmake, rust-source |
CONFIG_NROS_ZENOH_GRAPH_DISCOVERY | `n if (NROS_ZENOH_LINK_SERIAL | |
CONFIG_NROS_ZENOH_GRAPH_MAX_ENTITIES | 0 | cmake, rust-source |
CONFIG_NROS_ZENOH_READ_PRIORITY | 200 | c-define, cmake, rust-source |
CONFIG_NROS_ZENOH_RX_TASK_BUDGET_FRAMES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_RX_TASK_BUDGET_REST_US | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_SERVICE_BUFFER_BYTES | 1024 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_SOCKET_TIMEOUT_MS | 100 | c-define, cmake, rust-source |
CONFIG_NROS_ZENOH_SUBSCRIBER_LARGE_BYTES | -1 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_SUBSCRIBER_RING_DEPTH | 4 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_TX_BATCH | y | cmake, rust-source, kconfig select/depends |
CONFIG_NROS_ZENOH_TX_BATCH_FLUSH_MS | 50 | forwarded-to-cargo, cmake, rust-source |
CONFIG_NROS_ZENOH_TX_SPLIT_LOCK | y | cmake, rust-source |
CONFIG_NROS_ZEPHYR_LOG_SINK_BUFFERS | 16 if MP_MAX_NUM_CPUS >= 8 | c-source, rust-source |
system.toml keys
The keys a bringup’s system.toml takes for an image, the files beside it,
and a bridge binary’s nros-bridge.toml. The page is hand-kept; a gate holds
the [image.<id>] table’s key set to the CLI’s own schema, both ways, so a key
the CLI accepts cannot be missing here and a key it refuses cannot be listed.
The Kconfig symbols an image can also set are in
Configuration surface.
Where each setting lives
| File | Owns | Per |
|---|---|---|
system.toml | The deployment: [system] (RMW, domain, capability features, [safety], sched tasks), [[component]] (what runs), and one [image.<id>] per target with its .run, .flash, .console and .knobs tables. One schema for Rust, C and C++ | bringup package |
Cargo.toml | Rust toolchain facts only: the crate, its language dependencies, the RMW feature menu. No board, no target triple | Rust node package |
CMakeLists.txt | C and C++ toolchain facts only: targets and language dependencies. No platform, board or RMW set() | C or C++ node package |
package.xml | Package identity and message <depend>s | every package |
build/<coord>/<image>_entry/nros-cargo.toml | Generated, never edited: target, runner, rustflags, cross compiler, derived pool sizes as [env], the nros-* profiles, the [patch.crates-io] rows | image |
config.toml | Hand-written no_std apps with their own main() only: [node], [<interface>], [network.<name>] | application |
A system.toml beside a Cargo.toml or CMakeLists.txt is refused.
Precedence, highest first: a command-line or build flag, [image.<id>],
[system], the board descriptor’s [knobs], the built-in default.
nros config show prints the resolved values with where each came from.
[image.<id>]
| Key | Meaning |
|---|---|
board | nano-ros board id, resolved through the board catalog. Never a framework’s own board string |
framework | The entry framework the image boots with (owned-spin, rtic). Absent: the board’s first listed framework. zephyr is refused: a Zephyr board decides its entry shape |
launch | Launch file, relative to the bringup. Absent: [system] default_launch |
args | Launch arguments bound at resolve time, such as { host = "robot1" } |
rmw | Backend for this image. Absent: [system] rmw |
domain_id, locator | Override [system]’s. locator is what the image dials. On a linux image, $ROS_DOMAIN_ID / $NROS_LOCATOR override them at run time, and the image warns at boot naming both values when they differ |
os_config | Layer-1 files, in order: a board network file (.toml), Zephyr prj-*.conf or .overlay fragments. conf is read as its alias. Paths are relative; see “Where os_config files are found” |
rmw_config | The middleware’s own file for this image, or { <domain> = "<file>" } per [[domain]] |
panic | Panic policy: platform, halt or own |
before_boot | "<pkg>::<fn>" the generated entry calls before the board boots. Rust only |
profile | Build profile: a cargo profile (dev, release, nros-relwithdebinfo, nros-minsizerel, or one of your own) or a CMake build type (Debug, Release, RelWithDebInfo, MinSizeRel). Each pair names the same build. A CMake image builds its C, C++ and Rust with it. A cargo profile of your own has no build type there and is refused: drop profile from that image and set the type with nros build <image> -- -DCMAKE_BUILD_TYPE=<type>. A Zephyr image refuses profile and takes its optimisation from Kconfig. See Build profiles |
variant | Framework build variant (Zephyr prj_<buildtype>.conf) |
features | Capability axes for this image, added to [system]’s |
build | [image.<id>.build] cmake_args = ["-DFOO=ON", …]: arguments for every CMake configure of this image, one argument per entry, after [image_defaults.build]’s and before nros build --cmake-args=. The same rules as --cmake-args= apply: -D, -U, -W*, --log-level, --log-context and --debug-find only, and a name nros build passes itself or a -DCONFIG_* is refused, saying where it goes instead. There is no cargo_args: put features in the package’s manifest. Build arguments lists every rule |
node_interfaces | "stock" adds the node interfaces an rclcpp node has by default (the six parameter services, the /rosout publisher and the use_sim_time parameter with its /clock time source, i.e. the param_services, rosout and sim_time features) to this image; "none" removes them, even where [system] declared them. Also accepted in [system] and [image_defaults]; the most specific statement wins. Absent everywhere: "stock", so every image serves the six parameter services, publishes /rosout and declares use_sim_time unless it states "none". The exception is an image whose framework is "rtic": the RTIC entry cannot serve the parameter services, so such an image gets none of them unless a table states "stock" or its features name one, and the build then refuses it with the reason. A memory-tight image (one service server, as on the Pico W) states "none" |
node_features | Cargo features of the image’s Rust node packages: "<feat>" in every node declaring it, "<pkg>/<feat>" in that node only. Refused on a C/C++ entry and for a feature no node declares |
serdes, ros_edition | Serialization provider and ROS edition. Absent: the [system] value |
env | { NAME = "value" } for an application’s own build variable. A registry knob here is an error naming its knobs spelling |
entry | The workspace package that is this image’s application, when it cannot be derived |
producers | false builds without the host board’s census recorder and profiler |
runs_nano_ros | false states that this image’s hand-written entry never initialises nano-ros (a test program that drives a device directly). Its census is then recorded empty without building or running the program on the host, and the image is sized for zero entities. Only an image sized by its owned entry’s census may state it (a hand-written entry on a cross board, in a bringup with no [[component]]); on any other image it is refused. Without it, such a program exits 0 in census mode with no census, and the configure refuses. true is the default. Never folded from [image_defaults] |
params_files, ros_args | Parameters and ROS arguments baked into the image for rclcpp::init |
no_inventory | "<reason>": why this image declares nothing to derive its pool sizes from (no contract wiring, no parameters), so it keeps the configured defaults by design. Optional: such an image gets a note either way, and this line records the reason in its place. An empty reason is refused, and so is the line on an image whose declarations DO derive its sizes. It never excuses a declaration that fails to derive: under NROS_PROBE_FAILURE=refuse (every fixture lane), that stops the build. Never folded from [image_defaults] |
stack_floor_image | The key its measured stack peak (an [[observed]] row) is filed under in config/stack-floors.toml, <template>/<lang>/<rmw>@<board>. nros new writes it; unset, the image is keyed <bringup>@<board> |
stack_floor | "check" (the default) or "raise". The floor is a heuristic: the deepest call path a walk of the compiled code finds, plus a margin, usually well above the stack the image really uses (A11). With "raise", a FreeRTOS image whose floor is above the stack it states is built once more at the floor instead of failing. The raise never lowers a stack, is worked out again on every build and is never stored. The build prints the value it used |
Retired and refused by name: ip, gateway, netmask, transport,
[image.<id>.net.<if>], and the old [deploy.<id>] table.
Folding over [image_defaults]
| Kind of key | How a specific block folds over the defaults |
|---|---|
scalars (board, rmw, profile, …) | replaced |
node_features | replaced as a whole when the image states it |
args | merged |
no_inventory, runs_nano_ros | never folded: each image states its own |
os_config, features | concatenated, defaults first |
[system] default_images = ["<id>", …] is what a bare nros build builds.
Without it, a workspace with more than one image lists them and stops.
Images that never run together: [image_alternatives]
[image_alternatives]
fvp-tap = ["fvp-tap", "fvp-tap-stats", "fvp-tap-trace", "fvp-tap-trace-ring"]
Each key names a group; its value lists two or more images that are one host
built different ways, of which only one is ever booted. Two images of one group
may state the same static address and the same mac on a network; any other
two images may not (see “Board network file” below). Membership is symmetric:
no member is the base. Building several members is fine; building is not
running. Nothing infers a group from image names, boards or os_config lists.
Refused, at parse: a member no [image.<id>] declares, an image in two groups
(merge them), a group of fewer than two images, and an image listed twice in
one group. A single-package leaf builds one image and refuses the table.
Sharing a fragment between bringups: include
A workspace with several bringups can state what they share once, in a fragment file, and name it from each bringup:
# src/pubsub_bringup/system.toml
include = ["../../shared/system-defaults.toml"]
[system]
name = "rust_pubsub"
default_launch = "system.launch.xml"
# shared/system-defaults.toml
[system]
rmw = "zenoh"
domain_id = 0
[image_defaults]
rmw = "zenoh"
examples/workspaces/rust
shares one fragment between its five bringups this way. The rules:
| Rule | |
|---|---|
| Paths | include is a list of paths, each relative to the file that names it. A fragment may include further fragments. |
| Tables | merge key by key, at every depth |
| A key in two files | refused, naming both files. A fragment does not override the bringup, and the bringup does not override the fragment. A bringup that needs another value does not include that fragment. |
[[component]], [[domain]], other arrays of tables | concatenated: each include’s entries in the listed order, then the file’s own |
| A file reached twice, or through itself | refused |
| Not in a fragment | [system] name (the bringup names its system), [sources] and [tools] (this machine’s paths, read from the bringup’s own file) |
Every road reads the expansion: nros build, the CMake configure, west
and colcon. Editing a fragment rebuilds what it reaches, as editing the
system.toml does. nros new --workspace --from refuses to move a system.toml
that names fragments, because their paths are relative to it.
Where os_config files are found
The two kinds of file in os_config are looked up from different places:
| File | Looked for in, first hit wins |
|---|---|
Board network file (.toml) | The directory of system.toml |
Zephyr fragment (.conf, .overlay, .dts) | <bringup>/boards/<board>/, then the west application’s directory, then the directory of system.toml |
A generated application holds no files of yours, so a fragment is found beside
system.toml. When entry names a west application of your own, a fragment
with the same name in that application’s directory is used in place of the
bringup’s. That is how a board or an application overrides a shared fragment.
Board network file
Named by os_config, beside system.toml. One table per interface, and any
network other than the built-in qemu:
| Key | Table | Meaning |
|---|---|---|
network | [<if>] | The network the interface is on. Default: the board’s (qemu on QEMU boards) |
host | [<if>] | Last octet within the network’s subnet |
address | [<if>] | Full IPv4, or "dhcp" on a network with dhcp = true |
mac | [<if>] | Optional. Derived from the board’s mac_prefix and the image’s names when absent |
vlan | [<if>] | Optional. An 802.1Q VLAN id, 1-4094, the interface’s traffic is tagged with. Taken only where the board’s interface states vlan = true (s32z270-rtu0-zephyr) |
subnet, gateway | [network.<name>] | The network’s addressing. An interface never states them |
dhcp | [network.<name>] | The network leases addresses |
The built-in qemu network is QEMU user-mode networking, 10.0.2.0/24, with
gateway and router host 10.0.2.2. An interface on qemu with no address
takes 10.0.2.15. The resolved answer is written to
build/nros/net/<image>.toml.
Refused, naming the image: an address outside its subnet or equal to the
gateway; a network no file defines; two images with one static address or MAC
on a network other than qemu, unless both are in one [image_alternatives]
group; two files defining one network differently; a
board network file on a board whose network belongs to the host OS (linux,
freertos-posix, threadx-linux) or that declares no interfaces; an image on
a network other than qemu with no locator, when its RMW’s descriptor states
a host peer ([rmw.host] peer other than "none": zenoh, XRCE-DDS). A
Cyclone DDS image has no router to name and is not refused.
On a Zephyr board
A Zephyr board takes a board network file once its [board.net] declares its
interface (fvp-aemv8r-smp, mps2-an385-zephyr and s32z270-rtu0-zephyr
do). nros build renders
the resolved interface into Zephyr’s own Kconfig,
build/nros/net/<image>.conf, appended last to EXTRA_CONF_FILE:
| Resolved | Rendered |
|---|---|
| any address | CONFIG_NET_CONFIG_SETTINGS=y, CONFIG_NET_CONFIG_AUTO_INIT=y, CONFIG_NET_CONFIG_NEED_IPV4=y |
a static address (address or host) | CONFIG_NET_DHCPV4=n, CONFIG_NET_CONFIG_MY_IPV4_ADDR, CONFIG_NET_CONFIG_MY_IPV4_NETMASK from the subnet |
a network gateway | CONFIG_NET_CONFIG_MY_IPV4_GW |
address = "dhcp" | CONFIG_NET_DHCPV4=y, CONFIG_NET_CONFIG_MY_IPV4_ADDR="" |
Zephyr configures the first auto-started interface at boot and, on a lease,
waits for it (up to CONFIG_NET_CONFIG_INIT_TIMEOUT) before the application
starts. Refused: a board or file with a second interface (Zephyr’s
NET_CONFIG configures one; configure another in the application), a stated
mac (the driver takes it from devicetree or generates one), and an
os_config fragment that sets a rendered symbol, naming the fragment, the
symbol, both values and the board network file. A symbol the file does not
render, such as CONFIG_NET_DHCPV4_INITIAL_DELAY_MAX, stays the fragment’s.
An interface with a vlan tag keeps the address rows above, with these in
place of NET_CONFIG_AUTO_INIT=y and NET_CONFIG_NEED_IPV4=y:
| Resolved | Rendered |
|---|---|
vlan = <tag> | CONFIG_NET_CONFIG_AUTO_INIT=n, CONFIG_NET_VLAN=y, CONFIG_NET_IF_MAX_IPV4_COUNT=2, CONFIG_NROS_NET_VLAN_TAG=<tag> |
Zephyr’s VLAN is a virtual interface attached to the Ethernet one, and its own
boot-time configuration (CONFIG_NET_CONFIG_MY_VLAN_ID) tags the Ethernet
interface but still adds the address, or starts DHCPv4, on the untagged one.
So the nros module does it instead, at the same init level: it tags the first
Ethernet interface, makes the VLAN interface the default, and hands it to
Zephyr’s net_config_init_by_iface with the rendered address or lease, which
waits for the address up to CONFIG_NET_CONFIG_INIT_TIMEOUT. The untagged
interface stays up with no address.
[image.<id>.run], .flash and .console
| Table | Key | Meaning |
|---|---|---|
.run | nic | "slirp" (default on qemu), { bridge = "<dev>" } or { tap = "<dev>" }, for the first interface under QEMU or an Arm FVP. An FVP has no bridge mode, so it takes "slirp" or { tap = "<dev>" } |
.run.fvp | params | Arm FVP model parameters this image chooses, each as after -C: ["bp.pl011_uart1.out_file=trace.log"]. Read only on a board whose emulator is an FVP, and refused on any other. A parameter cannot hold whitespace or ;, so an out_file path with a space in it cannot be stated |
.flash | command | Replaces the board’s flash method; {hex} and other placeholders are checked |
.flash | prepare | Human steps before flashing: { say = "…", wait_for = "<event>" } |
.console | baud, … | Overrides a key of the board’s [board.console] |
An image on a network other than qemu with no nic is physical only, and
launching it under QEMU is refused.
On an Arm FVP board, the board’s own model parameters ([board.run.fvp] params in its descriptor) come first, then the image’s nic, then the
image’s [image.<id>.run.fvp] params, which are [image_defaults.run.fvp]’s
followed by its own. Each layer adds to the ones before it rather than
replacing them. The model keeps the last value a parameter is given, so an
image overrides a board parameter by naming it again. They are bound when the
image is configured, so west build -t run and nros run boot the same
model. The cost is that changing one, such as the TAP name, re-configures the
image.
[image.<id>.can] and [canN]
The CAN frame driver (<nros/platform_can.h>) opens one default device,
named in exactly one place, chosen by the board’s [board.net] stack:
| Board stack | The device is named in | Its rates live in |
|---|---|---|
"host" (linux, freertos-posix, threadx-linux) | [image.<id>.can] device = "vcan0" (or [image_defaults.can]) | the host OS (ip link) |
"os" (Zephyr, native_sim too) | the devicetree overlay in os_config: chosen { nros,can = &can1; };, default zephyr,canbus | devicetree (bus-speed, bus-speed-data) |
"board" (FreeRTOS, ThreadX, bare metal) | the board network file’s [canN] table | the same table: bitrate, dbitrate |
| Key | Table | Meaning |
|---|---|---|
device | [image.<id>.can] | The host interface the driver opens. Host boards only |
driver | [image.<id>.can] | "mock", the one backend an image chooses. Only on a board that runs as a host process: [board.run] host = true and no [board.flash] (linux, freertos-posix, threadx-linux, zephyr on native_sim) |
bitrate | [canN] | The nominal bitrate, bit/s. Required |
dbitrate | [canN] | The CAN FD data-phase bitrate, bit/s |
frames | [canN] | With several [canN] tables, marks the one the driver opens |
Every other backend is derived from the board, never stated. Refused, each
naming the right home: device on an "os" or "board" board, a [canN] on
a host or "os" board, driver = "mock" on a board that is not a host
process, several [canN] with none marked (or more than one marked), any
other driver, and a device on a board whose [board.net] links lack can.
The resolved device rides NROS_IMAGE_NET as a can row and is written to
build/nros/net/<image>.toml under [can]. The application opens it with
nros_platform_can_open(&can, NULL, want_fd): on a host board the board
hands the device to the SocketCAN backend at boot (a Rust entry), or a
generated constructor does before main (a C or C++ entry). A
second device is opened by its name instead of NULL.
The middleware’s own file
| Backend | Default file, beside system.toml | Same document ROS 2 reads as |
|---|---|---|
| zenoh | rmw/zenoh.json5 | ZENOH_SESSION_CONFIG_URI |
| Cyclone DDS | rmw/cyclonedds.xml | CYCLONEDDS_URI |
| XRCE-DDS | none: the endpoint is the image’s locator | — |
[system] rmw_config names another default file; [image.<id>] rmw_config
names one image’s. A named file that does not exist is refused. An image with
a zenoh file that also states a locator is refused. The flat
rmw/zenoh.conf is retired.
[image.<id>.knobs.<group>]
The same shape as a board descriptor’s [knobs.<group>]. The key is the knob
registry row’s board key where it has one (executor.max_cbs); otherwise the
NROS_* name without NROS_, split at the first _
(NROS_EXECUTOR_MAX_SC is executor.max_sc). An unknown key, a wrong type
or an out-of-range value stops nros build, naming the key. The image rung
sits above the board and below an exported variable.
Standalone config.toml
| Table | Keys |
|---|---|
[node] | domain_id, locator |
[<interface>] | as the board network file, plus a board’s own facts ([uart0] baud, [eth0] device on ThreadX Linux) |
[network.<name>] | subnet, gateway |
[node.rt.<rtos>] | raw task priorities, such as app_priority, zenoh_read_priority on FreeRTOS |
Read with Config::from_toml(include_str!("../config.toml")). A file in the
retired [[transport]] shape panics at boot, naming the new spelling.
Cargo features of the nros crate
| Feature | Selects |
|---|---|
rmw-cffi | the C-vtable RMW registry the backend registers into |
platform-bare-metal, platform-freertos, platform-nuttx, platform-threadx, platform-zephyr, platform-posix | the platform |
ros-humble, ros-iron | the ROS edition |
std, alloc | optional, by target |
The generated entry selects these from the image. rmw in system.toml
picks which linked backend is active.
nros-bridge.toml
A bridge binary’s own file, beside system.toml’s keys because it configures
the same thing, a running image, but read at run time by the program, not by
the build.
Consumed by nros::run_from_config (Rust) and the future C/C++ mirror
(nros::run_from_config in nros-cpp).
Not the orchestration
nros.toml. This is the bridge runtime config (multi-RMW byte forwarding). It is namednros-bridge.tomlto avoid colliding with the orchestrationnros.toml(component/system build config) — different lifecycle, different schema.
The file lives next to the binary (or anywhere the program can read it) and selects:
- Which RMW backends to open, under what locator / domain.
- How those backends are wired into bridge entries that forward traffic between them.
The binary’s Cargo.toml (or target_link_libraries) still selects
which backends are linked — the TOML file selects which of the
linked backends are used in this run. Backend names in the file
that don’t match a linked backend surface as
ConfigError::OpenSession.
Top-level structure
# nros-bridge.toml — sibling of the binary
[[node]]
name = "field"
rmw = "zenoh"
locator = "tcp/10.0.0.1:7447"
[[node]]
name = "control"
rmw = "cyclonedds"
locator = "domain=0"
[[bridge]]
type = "std_msgs/Int32"
type_hash = "RIHS01_..."
from = { node = "field", topic = "/sensor/raw" }
to = { node = "control", topic = "/sensor/raw" }
Run via:
fn main() -> Result<(), nros_bridge::ConfigError> {
nros_bridge::run_from_config("nros-bridge.toml")
// or, via the umbrella feature: nros::run_from_config("nros-bridge.toml")
}
[[node]]
One block per backend session. The first [[node]] becomes the
primary session (extra_sessions[0] in Executor::open_multi); the
rest open as extras keyed by rmw.
| Key | Type | Default | Notes |
|---|---|---|---|
name | string | required | Logical name. Bridge entries reference this. |
rmw | string | required | Canonical backend name: "zenoh", "xrce", "cyclonedds". Must match a backend the binary linked in. |
locator | string | "" | Backend-specific locator. Zenoh uses tcp/..., udp4/..., serial/...; DDS uses domain=<n>; XRCE uses udp4://...:port. |
domain_id | u32 | 0 | ROS domain id passed to the backend. |
namespace | string | "/" | Default namespace applied to handles created on this node. |
Locator scheme grammar (zenoh)
| Scheme | Example | Meaning |
|---|---|---|
tcp/<host>:<p> | tcp/10.0.0.1:7447 | TCP unicast |
udp/<host>:<p> | udp/10.0.0.1:7447 | UDP unicast |
serial/<dev> | serial//dev/ttyUSB0 | UART (host-side) or board UART (bare-metal) |
tls/<host>:<p> | tls/router.example.org:7447 | TLS over TCP (requires link-tls on backend) |
DDS / XRCE follow their native locator conventions; consult each backend’s docs for the exact form.
[[bridge]]
One block per topic forwarded between two [[node]]s. Each bridge
creates a RawSubscription on the source side and an
EmbeddedRawPublisher on the destination side and pumps bytes once
per executor tick.
| Key | Type | Default | Notes |
|---|---|---|---|
type | string | required | ROS type name ("std_msgs/Int32"). Backends use it for liveliness / discovery. |
type_hash | string | "" | ROS 2 RIHS type hash for the typed binding. May be left empty if both sides ignore it. |
from | endpoint | required | { node = "<name>", topic = "<topic>" }. The source node + topic. |
to | endpoint | required | { node = "<name>", topic = "<topic>" }. The destination node + topic. |
Bidirectional bridges are two [[bridge]] entries — one in each
direction. The runtime stamps a bridge_origin attachment field on
forwarded frames and drops on receive when the origin matches the
local backend, so an echo pair does not loop.
Error semantics
run_from_config returns ConfigError:
| Variant | Cause |
|---|---|
Io | File read failed (missing / unreadable). |
Parse | TOML malformed or a required field missing. |
UnknownNode | A [[bridge]] references a node name no [[node]] declared. |
OpenSession | Executor::open_multi rejected a spec — usually a backend name no RMW_INIT_ENTRIES entry registered under. |
BuildNode | create_node_on failed (registry exhausted, name too long, …). |
BuildEntity | Creating the source subscription or destination publisher failed (typically backend rejection of the topic name / type / QoS). |
Any error short-circuits the runtime; bridges that opened cleanly before the failure are not pumped.
Linked-backend matrix
| Backend name | Cargo dep that contributes the RMW_INIT_ENTRIES entry |
|---|---|
zenoh | nros-rmw-zenoh = { ... } |
xrce | nros-rmw-xrce-cffi = { ... } |
cyclonedds | nros-rmw-cyclonedds static lib (CMake side, --whole-archive) |
Add a backend to your Cargo.toml (or target_link_libraries) to
make its name available in the TOML; remove it to fence off use even
when the TOML file lists it (yields OpenSession at startup).
Design background
- RFC-0004: configuration and transports
- RFC-0065: colcon-like workspace builder
- RFC-0098: generated leaf build config
- RFC-0109: network config layers
- RFC-0118: target execution model
Environment Variables Reference
Set a runtime variable in the shell that starts the program. Set a
build-time knob in the shell before nros build, or per image in
system.toml (an [image.<id>] env row, or the knob-registry table where
the section below says so).
The checkout’s .env file for in-tree builds: see
Internals → Build Commands.
Runtime Configuration
Examples use ExecutorConfig::from_env() for configuration:
| Variable | Description | Default |
|---|---|---|
ROS_DOMAIN_ID | ROS 2 domain ID | 0 |
NROS_LOCATOR | RMW locator (tcp/…, udp/…, serial/…, or tls/…) | tcp/127.0.0.1:7447 |
NROS_SESSION_MODE | Session mode: client or peer | client |
Retired legacy names:
ZENOH_LOCATORandZENOH_MODEare no longer read. Setting either is a startup ERROR naming its replacement (NROS_LOCATOR/NROS_SESSION_MODE) — Rust panics inresolve_hosted/ returnsInitError::RetiredEnvVarfromnros::init, C / C++ init returnsRCL_RET_INVALID_ARGUMENT/NROS_CPP_RET_INVALID_ARGUMENTand logs the reason. Refused rather than ignored: an ignored locator would dial the default router and read as “no delivery”.
Retired TLS names:
ZENOH_TLS_ROOT_CA_CERTIFICATE,ZENOH_TLS_ROOT_CA_CERTIFICATE_BASE64andZENOH_TLS_VERIFY_NAME_ON_CONNECTare retired. This release still reads them; a later one refuses them. State TLS in the image’s session file instead: see Configure zenoh, step 6.
TLS Notes
- POSIX: requires
libmbedtls-dev(install it with your host’s package manager). File-path and base64 cert loading are both supported. - Bare-metal: only a base64 certificate is supported (no filesystem). The certificate is embedded at build time.
- The
link-tlsCargo feature must be enabled on both the example and thenroscrate.
Build-Time Configuration
| Variable | Description | Required |
|---|---|---|
ZENOH_PICO_DIR | CMake install prefix for pre-built zenoh-pico (use with system-zenohpico feature on zpico-sys) | Only with system-zenohpico |
NROS_EXTRA_BOARD_PATH | Extra board-search roots (PATH-style : separated). Each entry is a directory shaped like packages/boards/ — subdirs carrying nros-board.toml crates or */boards/<name>/board.cmake bundles. Read by the nros CLI’s board catalog AND nano_ros_use_board() (also settable as a CMake cache var there). Board keys stay global: a name found under two roots is an error, never shadowed. | (unset) |
NROS_BUILD_ROOT | One writable directory for the probe-build caches nros build keeps, shared by every project that sets it. Unset, each project keeps its own; a build never writes into the installed release. See one install for several users. | (unset) |
NROS_PROBE_FAILURE | What a failed source probe does to nros build and nros configure. Before a build, nros configures the workspace’s C and C++ packages once to read their metadata (the source probe). warn prints each failure and builds the failed packages’ components on default sizes, and the build’s last line counts the failures. refuse makes any failure an error: set it in CI, where nobody reads a warning. Another value is an error. When no probe in the workspace succeeds, the build stops under either value. | warn |
ARM FVP (FVP_BaseR_AEMv8R)
User-provided: nano-ros does not download or distribute the model. Install the
AEMv8-R FVP from Arm (x86_64 Linux only), install its runtime dependency
libatomic1, then set one of the variables below. See the
ARM FVP getting-started chapter for the
end-to-end build+run walk-through.
| Variable | Description | Default |
|---|---|---|
ARMFVP_BIN_PATH | Directory containing FVP_BaseR_AEMv8R (Zephyr-canonical, highest priority). | (unset) |
ARM_FVP_DIR | Install root; resolver scans models/Linux64_GCC-*/ underneath. | (unset) |
The model is found in this order: ARMFVP_BIN_PATH, ARM_FVP_DIR, then
FVP_BaseR_AEMv8R on PATH. Set ARMFVP_BIN_PATH at BUILD time as well as
run time, because Zephyr’s armfvp.cmake caches the location at configure: a
build directory configured before the model was found caches ARMFVP-NOTFOUND
and must be re-configured. nros doctor reports whether the model resolves
and through which variable.
Changing how the FVP is resolved or run in the tree: see Internals → Zephyr in-tree examples.
Vendored source trees
You normally set none of these. nros setup puts each tree in the shared
store, and every build locates it through one ladder: this
variable, then the project’s [sources] row in system.toml, then a checkout
submodule you are editing, then the store, then the checkout’s own copy.
nros locate <name> --why prints which rung answered. Set a variable only to
build against a tree of your own.
| Variable | Tree |
|---|---|
FREERTOS_DIR | FreeRTOS kernel source |
LWIP_DIR | lwIP source |
NUTTX_DIR | NuttX RTOS source |
NUTTX_APPS_DIR | NuttX apps source |
THREADX_DIR | ThreadX kernel source |
NETX_DIR | NetX Duo source |
CYCLONEDDS_SOURCE_DIR | Cyclone DDS source |
FREERTOS_PORT, FREERTOS_CONFIG_DIR, THREADX_CONFIG_DIR and
NETX_CONFIG_DIR are board facts: each board’s nros-board.toml states
them, and the build carries them from there. They are not user inputs.
Buffer Tuning
All optional – platform-appropriate defaults apply if unset. See Configuration for deployment-scenario guidance and platform guides for target-specific sizing.
Zenoh-pico (NROS_ZENOH_*)
Each knob here used to be spelled ZPICO_<X>. That old spelling is
retired: set in the environment or
in an [image.<id>] env row, it stops the build with an error naming the
NROS_ZENOH_* name to use.
| Variable | Description | Default | Crate |
|---|---|---|---|
NROS_ZENOH_FRAG_MAX_BYTES | Max reassembled message size after defragmentation | 65536 / 2048 | zpico-sys |
NROS_ZENOH_BATCH_UNICAST_BYTES | Max unicast batch size before fragmentation | 65536 / 1024 | zpico-sys |
NROS_ZENOH_BATCH_MULTICAST_BYTES | Max multicast batch size | 8192 / 1024 | zpico-sys |
NROS_ZENOH_MAX_PUBLISHERS | Max concurrent publishers in zenoh shim | 8 | zpico-sys |
NROS_ZENOH_MAX_SUBSCRIBERS | Max concurrent subscribers in zenoh shim | 8 | zpico-sys |
NROS_ZENOH_MAX_QUERYABLES | Max concurrent queryables in zenoh shim | 8 | zpico-sys |
NROS_ZENOH_MAX_LIVELINESS | Max concurrent liveliness tokens in zenoh shim. DERIVED when the image declares anything: one per node name plus the session’s own, one per publisher, subscriber, service server and client, and the parameter and lifecycle families’ servers and publisher. A stated value wins. | 16 when nothing is declared | zpico-sys |
NROS_ZENOH_MAX_PENDING_GETS | Max concurrent in-flight service calls | 4 | zpico-sys |
NROS_ZENOH_MAX_TL_PUBLISHERS | Retention slots for TRANSIENT_LOCAL publishers in the zenoh shim. Each also takes one NROS_ZENOH_MAX_QUERYABLES slot: a transient-local publisher declares a queryable so a late joiner can query its last sample. An image whose endpoints are declared DERIVES this (an action_server row counts one for its /status), and a stated value below the declared demand fails the build naming the knob. | 2 | nros-rmw-zenoh |
NROS_ZENOH_TL_RETAIN_BYTES | Bytes one retained TRANSIENT_LOCAL sample may hold. A larger publish is SENT but not retained, and says so once at WARN. | 1024 | nros-rmw-zenoh |
NROS_ZENOH_TL_RETAIN_DEPTH | Samples each TRANSIENT_LOCAL publisher retains and replays, oldest first, to a late joiner. DERIVED from the deepest KEEP_LAST(N) a transient-local publisher declares; the publisher is granted and advertises min(asked, this). Must be >= 1. | 1 when nothing is declared | nros-rmw-zenoh |
NROS_SUBSCRIBER_BUFFER_BYTES | small receive-class slot per subscriber in the zenoh shim; the executor arena reads the same name. (ZPICO_SUBSCRIBER_BUFFER_SIZE is a dead spelling — nothing reads it.) | 1024 | nros-rmw-zenoh |
NROS_ZENOH_SUBSCRIBER_LARGE_BYTES | large size-class slot, for subscriptions whose type does not fit the small block | 16384 | nros-rmw-zenoh |
NROS_ZENOH_SUBSCRIBER_LARGE_THRESHOLD_BYTES | The small/large class split: a subscription whose rx_buffer_hint exceeds it is served from large. The cmake message-bound derivation assumes the shipped value (NROS_MESSAGE_BOUNDS_DEFAULT_SMALL_CEILING), so moving it can make a derived class count disagree with runtime routing, which surfaces as a failed create_subscription. | 2048 | nros-rmw-zenoh |
NROS_ZENOH_PUBLISHER_TX_BUFFER_BYTES | Per-publisher TX arena for the zero-copy loan path; costs NROS_ZENOH_MAX_PUBLISHERS x this. | 1024 | nros-rmw-zenoh |
NROS_ZENOH_MAX_LARGE_SUBSCRIBERS | How many large-class blocks this image reserves. 0 is legal: an image whose subscribed types all fit NROS_SUBSCRIBER_BUFFER_BYTES declares 0 and stops paying RING_DEPTH x LARGE_SIZE — 65,536 B at the defaults — for a class it never routes into. A hint no class can hold then fails create_subscription rather than dropping every sample. DERIVED, on both lanes — a Zephyr image gets it from Kconfig’s -1 sentinel, and a cargo image gets it from the build settings nros build generates under build/, joined over the types the image’s components subscribe to. Setting it here still wins. | 2 | nros-rmw-zenoh |
NROS_ZENOH_SERVICE_BUFFER_BYTES | Per-service-server static buffer in zenoh shim | 1024 | nros-rmw-zenoh |
NROS_PARAMS_SERVICE_INBOX_BYTES | Bytes one request slot holds in the inbox ring of a ROS parameter service queryable (six per node) or a REP-2002 lifecycle one (five per node) – the BUILTIN family, which the zenoh shim selects by service name. DERIVED: with nothing stated, the contract’s declared parameters bound it, as the largest request a set_parameters over the worst-declared node can produce (672 B on the one reference image, against the transport’s 1,024). A contract declaring a string- or array-valued parameter needs the parameter store’s capacities to price, which the RMW cannot see, so the shim abstains there and the user-service slot stands. Setting it here still wins. | derived, else NROS_SERVICE_INBOX_BYTES | nros-rmw-zenoh |
NROS_PARAMS_SERVICE_INBOX_DEPTH | Requests one parameter or lifecycle service queryable holds before the newest is dropped. One, because this traffic is one request and one reply from a client that waits (ros2 param, rclcpp’s SyncParametersClient) and a node’s services are polled serially in one spin. Raise it to 2 for an image serving a parameter dashboard. Must be >= 1. | 1 | nros-rmw-zenoh |
NROS_ZENOH_GET_REPLY_BUFFER_BYTES | Stack buffer for service client replies | 4096 | zpico-sys |
NROS_ZENOH_GET_POLL_INTERVAL_MS | Single-threaded polling interval in zenoh_shim_get() | 10 | zpico-sys |
NROS_NET_MAX_SOCKETS | Max concurrent TCP sockets (smoltcp); brokered default. (ZPICO_SMOLTCP_MAX_SOCKETS is retired.) | 1 (brokered) | nros-smoltcp |
NROS_NET_MAX_UDP_SOCKETS | Max concurrent UDP sockets (smoltcp); 1 by default, 4 with the nros-smoltcp/rtps feature. (ZPICO_SMOLTCP_MAX_UDP_SOCKETS is retired.) | 1 (brokered) | nros-smoltcp |
NROS_NET_BUFFER_BYTES | Per-socket staging buffer (smoltcp). (ZPICO_SMOLTCP_BUFFER_SIZE is retired.) | 2048 | nros-smoltcp |
NROS_NET_CONNECT_TIMEOUT_MS | TCP connection timeout (smoltcp). (ZPICO_SMOLTCP_CONNECT_TIMEOUT_MS is retired.) | 30000 | nros-smoltcp |
NROS_NET_SOCKET_TIMEOUT_MS | TCP read/write timeout (smoltcp). (ZPICO_SMOLTCP_SOCKET_TIMEOUT_MS is retired.) | 10000 | nros-smoltcp |
Zenoh-pico transmit path
Build-time knobs of the zenoh-pico transmit path. The defaults are the
platform’s ([knobs.zenoh] tx_* in its nros-platform.toml, over a built-in
default of off): Zephyr turns batching and split locking on.
nros config explain --platform <name> prints the value each one resolves
to and the rung that set it.
| Variable | Image key | Zephyr Kconfig | Meaning | Default |
|---|---|---|---|---|
NROS_ZENOH_TX_BATCH | [image.<id>.knobs.zenoh] tx_batch | CONFIG_NROS_ZENOH_TX_BATCH | Collect publishes and send one batch per flush | platform’s |
NROS_ZENOH_TX_BATCH_FLUSH_MS | [image.<id>.knobs.zenoh] tx_batch_flush_ms | CONFIG_NROS_ZENOH_TX_BATCH_FLUSH_MS | Flush period (ms): the most a batched sample waits | 50 |
NROS_ZENOH_TX_SPLIT_LOCK | [image.<id>.knobs.zenoh] tx_split_lock | CONFIG_NROS_ZENOH_TX_SPLIT_LOCK | Send one batch while publishers fill the next; needs batching | platform’s |
NROS_ZENOH_SUBSCRIBER_RING_DEPTH | — | — | Samples one subscriber’s receive ring holds; a full ring evicts the oldest. Derived from the declared QoS depths when unset | 4 when nothing is declared |
A publisher’s tx_express QoS flag sends its samples outside the batch.
XRCE-DDS (NROS_XRCE_*)
These are read by nros-rmw-xrce-cffi’s build script, either from the
environment or — on Zephyr — from CONFIG_<name> in .config. They set the
C client’s own #defines, such as XRCE_BUFFER_SIZE. A define is not an
environment variable, so exporting XRCE_BUFFER_SIZE has no effect and
reports no error.
| Variable | Description | Default | Min | Crate |
|---|---|---|---|---|
NROS_XRCE_BUFFER_BYTES | Per-slot receive buffer. See the note below — this is the receive ceiling. | 1024 | 64 | nros-rmw-xrce |
NROS_XRCE_SUBSCRIBER_RING_DEPTH | Queued samples per subscriber | 32 | 1 | nros-rmw-xrce |
NROS_XRCE_MAX_SUBSCRIBERS | Max concurrent subscribers. On Zephyr, DERIVED — see below. | 8 | 0 | nros-rmw-xrce |
NROS_XRCE_MAX_SERVICE_SERVERS | Max concurrent service servers. On Zephyr, DERIVED — see below. | 4 | 0 | nros-rmw-xrce |
NROS_XRCE_MAX_SERVICE_CLIENTS | Max concurrent service clients. DERIVED from the sizing descriptor — see below. | 4 | 0 | nros-rmw-xrce |
NROS_XRCE_STREAM_HISTORY | Reliable stream history depth; sizes the per-session output buffer | 16 | 4 | nros-rmw-xrce |
NROS_XRCE_CUSTOM_TRANSPORT_MTU | Custom transport MTU; stream buffers are MTU x STREAM_HISTORY | 4096 | 128 | nros-rmw-xrce |
NROS_XRCE_TRANSPORT_MTU | UDP/TCP transport MTU, and the Zephyr default of CUSTOM_TRANSPORT_MTU | 4096 (Zephyr 512) | 128 | nros-rmw-xrce |
NROS_XRCE_SUBSCRIBER_BUFFER_BYTES | Subscriber ring entry size; derived from the declared subscriptions when unstated (Zephyr: -1) | buffer_bytes’s | 1 | nros-rmw-xrce |
NROS_XRCE_SERVICE_REQUEST_BUFFER_BYTES | Application service-server request entry size. DERIVED from the declared servers’ requests beside the builtin split | buffer_bytes’s | 1 | nros-rmw-xrce |
NROS_XRCE_SERVICE_REPLY_BUFFER_BYTES | Service-client reply slot size. DERIVED from the declared clients’ replies | buffer_bytes’s | 1 | nros-rmw-xrce |
NROS_XRCE_BUILTIN_SERVICE_SERVERS | How many service-server slots are the parameter / lifecycle services’. DERIVED beside the total | 0 (no split) | 0 | nros-rmw-xrce |
NROS_XRCE_BUILTIN_SERVICE_REQUEST_BUFFER_BYTES | Request entry size of a builtin-family slot | buffer_bytes’s, raised to the parameter request | 1 | nros-rmw-xrce |
Dropping MAX_SUBSCRIBERS, MAX_SERVICE_* and SUBSCRIBER_RING_DEPTH to 1,
BUFFER_BYTES to 256, STREAM_HISTORY to 4 and CUSTOM_TRANSPORT_MTU to 512
takes the session struct from ~390 KB to ~10-20 KB.
Every variable in this table is a knob-registry row, so a project states it
per image as [image.<id>.knobs.xrce] buffer_bytes = 256 — the name without
NROS_XRCE_, lowercased (max_subscribers, max_service_servers,
max_service_clients, subscriber_ring_depth, subscriber_buffer_bytes,
service_request_buffer_bytes, service_reply_buffer_bytes, stream_history,
transport_mtu, custom_transport_mtu) — rather than as an env row.
On Zephyr the three entity caps DERIVE, and the minimum is 0
CONFIG_NROS_XRCE_MAX_SUBSCRIBERS and CONFIG_NROS_XRCE_MAX_SERVICE_SERVERS
default to -1, which means take the number from the entities this image
declares (the contract sidecar beside the bringup’s launch file, or beside the
bringup’s system.toml when it has no launch/). A listener that declares
one subscription and no service is built with one subscriber slot and zero
service-server slots, which is what took the session struct from 427,968 bytes
to 59,088 on the zephyr cpp listener.
Stating a number in Kconfig or the environment still wins over the derivation,
in both directions.
CONFIG_NROS_XRCE_MAX_SERVICE_CLIENTS also defaults to -1, and its number
comes from the image’s sizing descriptor on every road that writes one: the
declared service clients plus three per action client (send_goal,
cancel_goal, get_result). With no descriptor, or one that does not state
both counts, the crate default of 4 stands.
Zero is a legal, honoured value for all three caps — it is not rounded up to 1.
So creating an entity the image never declared does not truncate silently: the
create fails with InvalidConfig and the backend logs which cap it hit, which
knob moves it, and that the count came from the declaration.
NROS_XRCE_SUBSCRIBER_RING_DEPTH is deliberately NOT derivable — no inventory
knows how deep a burst a subscriber must survive — but it does have a
Kconfig symbol, and on Zephyr that is the way to set it: a Zephyr cargo build
sees only the knobs nros_cargo_build.cmake forwards, and shell exports do
not survive that.
NROS_XRCE_BUFFER_BYTES is the XRCE receive ceiling
A subscriber’s receive ring entry is a fixed uint8_t data[XRCE_BUFFER_SIZE],
so a subscription’s own buffer size cannot raise it: asking for
create_subscription_sized::<M, 16384> still stops at 1024, because the 16384
buffer is the destination of a copy that never happens. A sample that does not
fit is refused on take with MessageTooLarge.
The static cost is XRCE_SUBSCRIBER_RING_DEPTH x XRCE_BUFFER_SIZE per
subscriber, which is why the default is small — raise it deliberately, and
consider lowering the ring depth at the same time.
A payload at or above the transport MTU (4096) arrives fragmented; the receive path reads the fragment chain and delivers it whole.
Compile-time only (not environment variables)
These are #defines in packages/rmw/xrce/nros-rmw-xrce/src/internal.h with no
env or Kconfig knob. Changing them means editing that header.
| Define | Description | Default |
|---|---|---|
XRCE_ENTITY_CREATION_TIMEOUT_MS | Timeout for entity creation | 1000 |
XRCE_SERVICE_REPLY_TIMEOUT_MS | Per-attempt service reply timeout | 50 |
XRCE_SERVICE_REPLY_TOTAL_MS | Total service reply budget | 5000 |
XRCE_SESSION_FLUSH_TIMEOUT_MS | Session flush timeout | 100 |
XRCE_SESSION_CREATION_RETRIES | Session creation retries | 3 |
XRCE_MAX_PENDING_REPLIES | In-flight service replies | 4 |
XRCE_SERVICE_REQUEST_RING_DEPTH | Queued service requests per server | 4 |
XRCE_DEFAULT_AGENT_PORT | Default agent port | 2018 |
XRCE_SESSION_PROBE_MS | Silence before the backend asks the Agent whether it still holds the session; 0 turns the check off | 1000 |
CMake cache variables
For a CMake project that adds nano-ros with add_subdirectory and has no
system.toml. Set them before add_subdirectory. In a nano-ros workspace the
generated root sets them from the image, and none is yours to set.
| Variable | Default | Values |
|---|---|---|
NROS_PLATFORM | posix | posix, freertos, nuttx, threadx (also the legacy freertos_armcm3, nuttx_armv7a, threadx_linux, threadx_riscv64). esp_idf is refused |
NROS_BOARD | (unset) | required for threadx: threadx-linux or rv-virt-threadx |
NROS_RMW | zenoh | zenoh, dds, xrce, cyclonedds |
NROS_ROS_EDITION | humble | humble, iron, jazzy |
NROS_FEATURES | (empty) | extra cargo features for the Rust build, such as rosout |
NROS_SKIP_BOOTSTRAP | OFF | ON skips the configure-time source bootstrap of a checkout; an installed SDK takes its sources from nros setup |
NROS_CARGO_PROFILE | derived from CMAKE_BUILD_TYPE | the cargo profile for the Rust half; see Build profiles |
Binary size (embedded)
Carried in the image’s generated [env], from the board’s [knobs] or your
environment; a value you export wins.
| Variable | Default | Effect |
|---|---|---|
NROS_LINK_IP | on | 0 on a serial-only image drops zenoh-pico’s TCP and UDP link code and, with --gc-sections, the smoltcp platform code |
NROS_ZENOH_NO_SMOLTCP | off | 1 skips the smoltcp glue on bare metal |
NROS_HEAP_SIZE | per platform crate | bare-metal static heap, in bytes; see Build outputs |
Logging
Also stated as [knobs.log] <key> on a board, [image.<id>.knobs.log] <key>
on an image, or CONFIG_<knob> on Zephyr.
| Variable | Key | Default | What it sizes |
|---|---|---|---|
NROS_LOG_MAX_LEVEL | max_level | trace | compile-time ceiling: trace, debug, info, warn, error, fatal, off, or 0–6 |
NROS_LOG_BUFFER_BYTES | buffer_bytes | 256 (128–4096) | the per-call formatting buffer, and the message in each early and /rosout slot |
NROS_LOG_EARLY_RECORDS | early_records | 4 (0 = drop, counted) | records held before init installs the sinks |
NROS_LOG_ROSOUT_RECORDS | rosout_records | 16 | the /rosout queue |
NROS_LOG_DYNAMIC_LOGGERS | dynamic_loggers | 16, 32 on Linux hosts (0 = lookup only) | loggers created at run time |
Core (NROS_*)
| Variable | Description | Default | Crate |
|---|---|---|---|
NROS_EXECUTOR_MAX_CBS | Max executor callback slots (compile-time fixed array size) | 4 | nros-node |
NROS_EXECUTOR_ARENA_BYTES | Executor arena size in bytes (compile-time fixed array size) | 4096 | nros-node |
NROS_EXECUTOR_SUBSCRIPTION_BUFFER_BYTES | Default subscription/service buffer size (bytes) | 1024 | nros-node |
NROS_MAX_CONCURRENT_GOALS | Max concurrent goals per action server (compile-time constant, not env-var configurable) | 4 | nros-c |
NROS_PARAMS_MAX_PARAMETERS | Max parameters in parameter server | 32 | nros-params |
NROS_PARAMS_MAX_NAME_BYTES | Max parameter name length | 64 | nros-params |
NROS_PARAMS_MAX_STRING_VALUE_BYTES | Max string parameter value length | 256 | nros-params |
NROS_PARAMS_MAX_ARRAY_LEN | Max bool, integer or double array parameter length | 32 | nros-params |
NROS_PARAMS_MAX_STRING_ARRAY_LEN | Max string-array parameter length, in elements | 32 | nros-params |
NROS_PARAMS_MAX_BYTE_ARRAY_BYTES | Max byte array parameter length | 256 | nros-params |
NROS_PARAMS_MAX_DESCRIPTION_BYTES | Max parameter description length; longer is truncated and logged, 0 = none (max 256). Unset, a workspace image whose every node was probed by nros configure gets the longest description its code sets (at least 16) | 256 | nros-params |
Design background
- RFC-0103: one owner per fact — the one source-location ladder, the
NROS_<ID>knob spelling, and knob-registry rows
Build arguments
The arguments nros build passes on to CMake and cargo, where each one can
be stated, the order they apply in, and what is refused. The CLI’s own
flags are listed in the CLI reference.
Where an argument can be stated
| Where | Spelling | Reaches |
|---|---|---|
The bringup’s system.toml | [image_defaults.build] cmake_args = ["-DFOO=ON", …] | every image’s CMake configure, and the source probe |
The bringup’s system.toml | [image.<id>.build] cmake_args = ["-DFOO=ON", …] | that image’s CMake configure |
| The command line | --cmake-args=<args> | every CMake configure of this build |
| The command line | --cargo-args=<args> | every cargo command of a cargo image |
| The command line | --profile=<name> | the image’s profile, for this build |
In system.toml, each list entry is one argument. There is no cargo_args
key: a feature a package needs goes in its own manifest.
The source probe is the CMake configure nros build runs once for the whole
workspace, before the build, to read each C and C++ package’s metadata. It
reads only [image_defaults.build] cmake_args, so a path the probe needs,
such as a library’s -D<Lib>_DIR, goes there. Changing that list runs the
probe again.
A CMake image or a west image ignores --cargo-args=, and a cargo image runs
no CMake configure, so it ignores --cmake-args=.
How a value is read
| Form | Means |
|---|---|
--cmake-args="-DA=1 -DB='x y'" | one value, split with plain POSIX quoting and no expansion: two arguments, -DA=1 and -DB=x y |
--cmake-args=-DA=1 --cmake-args=-DB=2 | the flag repeats; the values add up in order |
--cmake-args=@args.txt | one argument per line of args.txt, read from the current directory; blank lines and # comments are skipped, and the file cannot name another @file |
--cargo-args=<args> | split, repeated and read from @<file> the same way |
--profile=dev, --profile=Debug | what [image.<id>] profile takes: a cargo profile or a CMake build type |
The = is required on all three. The space-separated colcon form,
--cmake-args -DA=1, is refused, because it cannot tell a CMake argument
from the next nros build flag. The refusal shows the rewritten form:
error: nros build takes `--cmake-args=<args>`, with `=`: the space-separated colcon form cannot tell a CMake argument from the next `nros build` flag.
instead of: --cmake-args -DA=1
write: --cmake-args="-DA=1"
One value may hold many arguments, and the flag may be repeated.
Order
The CMake arguments of one configure apply in this order, so a later one wins:
[image_defaults.build] cmake_args[image.<id>.build] cmake_args- each
--cmake-args=, in the order given on the command line
What is allowed
| Tool | Allowed arguments |
|---|---|
| CMake | -D (every spelling), -U, -W*, --log-level, --log-context, --debug-find |
| cargo | --features and -F, --no-default-features, --all-features, -v, -q, --timings, --locked, --offline, --frozen |
In a workspace with more than one package, name a feature with its package:
--cargo-args=--features=<pkg>/<feature>.
What is refused, and where it goes instead
Each refusal names the argument and says where the setting belongs. From
system.toml, the same text starts with [image.<id>.build] cmake_args:.
| Argument | Why | Instead |
|---|---|---|
-G, -T, -A, --toolchain | the generator and the toolchain are the build’s and the board’s choice | change the image’s board |
-C, -P | they run a CMake script | — |
--preset, -S, -B | the build lays out its own source and build trees | — |
-DCONFIG_* | it sets a Zephyr Kconfig symbol around the Kconfig fragments and the knob ladder | the image’s conf = [..] fragment |
-DCMAKE_BUILD_TYPE | nros build passes it from the image’s profile | --profile=, or [image.<id>] profile |
-DNROS_IMAGE, -DCMAKE_TOOLCHAIN_FILE, and the other names nros build passes itself | the build sets them | the system.toml key the refusal names |
a nano-ros knob, in any spelling (-DNROS_MEMORY_APP_STACK_BYTES, its CONFIG_NROS_* or legacy name) | the image’s knob table is its one committed place, and every build road reads it | [image.<id>.knobs.<group>], named in the error |
cargo --release | the profile is a build setting | --profile=release, or [image.<id>] profile |
cargo --target | the target is the board’s | change the image’s board |
a feature the build derives, such as platform-posix or rmw-xrce | the RMW, platform and capability features follow from system.toml | the image’s rmw, board or capability in system.toml |
For example:
Error: --cmake-args: `-DCONFIG_FOO=y` is refused: a `-DCONFIG_*` sets a Kconfig symbol directly on the west road, around the Kconfig fragments and the knob ladder; put Zephyr-native Kconfig in the image's `conf = [..]` fragment
A knob that means something on one platform only, such as
[image.<id>.knobs.zenoh] socket_timeout_ms (Zephyr), is refused when an
image on another platform states it, with the reason it does nothing there.
The image’s [image.<id>.knobs.<group>] table, which
Configure an image describes: it is
the one spelling every board reads.
See also
- Build profiles: what each profile means, and the default per board.
- system.toml: every key of the bringup’s
system.toml. - CLI reference:
nros buildand its flags.
Rust API
The nano-ros Rust API is the nros crate. It re-exports every type a
user application needs: Executor, Node, Publisher<M>,
Subscription<M>, Service<S>, Client<S>, ActionServer<A>,
ActionClient<A>, Timer and GuardCondition, with nros::prelude as the
glob import. It is no_std, and its heap use is behind the alloc feature,
so the same node code builds for a host and for a board. Message types
are generated crates, one per interface package your node depends on
(Message Generation).
API reference
nrosrustdoc — start here.
The published rustdoc is built from the current main branch with the
alloc, log, env, rmw-cffi and ros-humble features on.
Where to start
- New to nano-ros? →
nros::prelude - Executor-driven app? →
nros::Executor - Polling or callbacks? → Two ways to receive, the two layers of the API and when to use each.
How to read the rustdoc
The published pages show the crate with the features listed above turned on.
A board build turns on only the features its image asks for, so an item
behind a feature your image does not enable is absent from that build even
though the published page shows it; the item’s source, linked from its page,
shows the #[cfg(feature = ...)] that gates it. Your own package documents
nros at the version and features it builds with: run cargo doc --open in
that package. That is also where your message crates are documented: they
are generated for your workspace, so the published site does not have them.
Porting only
These crates are not part of the user API. They surface only when you write a custom RMW backend or port nano-ros to a new platform; see Write a custom RMW backend and Add a platform.
nros_rmw: the RMW trait surface.nros_platform_api: the platform abstraction traits.nros-rmw-zenoh: the zenoh-pico backend, in the source tree.
C API
The nano-ros C API is rclc’s: the rclc_*, rcl_* and rcl_action_* calls
a micro-ROS or rclc application makes, over nano-ros’s executor and RMW. Its
headers sit at upstream’s paths (rclc/, rcl/, rcl_action/,
rclc_parameter/, rclc_lifecycle/) under the SDK’s C include directory, so
an #include you know from rclc names the same file here. rclc/detail/ is
internal. Message types are generated by the build from the packages your
node depends on (Message Generation).
API reference
C API Doxygen — start here.
The Doxygen site is generated from the current main branch. The umbrella
header rclc/rclc.h pulls in every public surface a
user application needs.
Where to start
rclc/rclc.h— convenience umbrella includerclc/init.h—rclc_support_init,rclc_support_finirclc/node.h—rcl_node_get_default_options,rcl_node_finirclc/executor.h— spin loop, executor lifecycle,rclc_executor_node_init(a node bound to the executor)rclc/publisher.h/subscription.h— pub/subrclc/service.h/client.h— servicesrclc/action.h— actionsrclc_parameter/rclc_parameter.h— parameter servicesrclc_lifecycle/rclc_lifecycle.h— REP-2002 lifecycle statesrclc_set_trace_sink/rclc_trace_marker(id, arg)— the callback trace sink, and an application event (ids 1-15) through it; see Trace callbacks
Two-layer API. Every entity exposes two parallel C entry-point sets:
rclc_*_init_default(Layer 1, caller polls) andrclc_executor_add_*(Layer 2, executor callback). Layer 1 grew an_init_polling+take_*_raw/send_*_rawfamily for inline-storage callers (no executor arena). Layer 2 pairs the samerclc_*_init_defaultwith the executor-add call, which is where the callback is supplied (rclc’s binding site). See Two ways to receive for the verb discipline and per-layer trade-offs.
Event-driven wake callbacks. Each L1 polling entity supports
nros_*_set_wake_callback(entity, &state, cb, ctx)for event- driven RTOS / embassy callers. State is a caller-ownedrclc_wake_state_tPOD; the backend firescb(ctx)on rx / reply / request arrival. Per-channel for actions (set_{goal,cancel,get_result}_wake_callbackon the server,set_{goal_response,cancel_response,result,feedback}_wake_callbackon the client). See the Doxygen for signatures.
How to read the Doxygen site
Each header has a page named after its path (rclc/executor.h is
executor_8h.html), listing its functions with their return codes. A call that can fail returns
an rcl_ret_t; the codes, with the RCLC_RET_* ones nano-ros adds
(RCLC_RET_FULL for a full static pool, RCLC_RET_REENTRANT for a blocking
call made from inside a callback), are on the
error codes page.
Where it differs from rclc
| Behaviour | rclc | nano-ros |
|---|---|---|
| A goal arriving with every goal handle in use | queued | rejected |
| An accepted goal | waits for the client to ask for its result | executes at once, so a result may be sent before the client asks for it |
| Taking an entity off a running executor | rclc_executor_remove_* | the same calls; each frees its slot and arena bytes, and fini without one leaves the entity dispatched into |
| Reading a message’s metadata (timestamps, sequence numbers, publisher GID) | no subscription callback receives it | rclc_executor_add_subscription_with_message_info: the callback gets a const rmw_message_info_t *, NULL when the backend reports none. The older rclc_executor_add_subscription_with_info and ..._raw_with_info are deprecated: despite the name, their callback gets the wire attachment and no metadata |
Linking from CMake
A CMake project links the NanoRos::NanoRos target and generates C bindings
with nano_ros_generate_interfaces(<pkg> LANGUAGE C). The function defaults
to LANGUAGE CPP; Message Generation
has the table of spellings.
Porting only
The rmw-cffi and platform-cffi Doxygen sites are not part of the
user API. They document the C vtables for porters writing a custom RMW backend
or platform port. See Platform and RMW APIs.
Design background
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI. The paired examples as image rows of behaviour bringups in the language workspaces.
C++ API
The nano-ros C++ API is a freestanding C++14 interface for ROS 2 nodes on embedded and host targets. It needs no standard library, no exceptions and no RTTI, so the same code builds for Zephyr, FreeRTOS, NuttX, ThreadX, bare metal and Linux.
- Upstream’s names, in upstream’s namespaces.
rclcpp::Node,Publisher<M>,Subscription<M>,Service<S>,Client<S>,Timer,GuardCondition,Executor, andrclcpp_action::Server<A>/Client<A>. Every user-facing name is inrclcpp::,rclcpp_action::orrclcpp_lifecycle::; there is nonros::namespace. The extensions with no upstream counterpart (thePoll*types, the*Storagetypes,FixedString, …) are inrclcpp::too. - Errors are values. Every fallible call returns
rclcpp::Result, andRCLCPP_TRYreturns early on failure. Nothing throws. - Generated message types.
std_msgs::msg::Int32,example_interfaces::srv::AddTwoIntsand so on, generated by the build from the packages your node depends on (see Message Generation). - An opt-in std surface for ported code. Defining
NROS_CPP_STDadds thestd::string/std::function/std::chronooverloads and thestd::shared_ptr-returningrclcpp::Nodefactories. The build requests it; it is never detected from the toolchain. See Two surfaces.
The headers live in the SDK’s C++ include directory at upstream’s paths:
rclcpp/, rclcpp_action/ and rclcpp_lifecycle/. rclcpp/detail/ is
internal.
To build and run a first C++ node, start with the Tutorial, whose every step has a C++ tab; to grow it into a workspace, see Organize a larger workspace. To bring an existing ROS 2 node across, see Porting a ROS 2 C++ node. This page is the API itself.
API reference
C++ API Doxygen — start here.
The Doxygen site is generated from the current main branch. The umbrella
header rclcpp/rclcpp.hpp pulls in every
public surface a user application needs.
Where to start
rclcpp/rclcpp.hpp— convenience umbrella includerclcpp::init_in/rclcpp::shutdown— session lifetimerclcpp::Node— node + create_publisher/subscription/service/client/action_*rclcpp::Publisher<M>/Subscription<M>. A subscription callback may also take upstream’sconst rclcpp::MessageInfo&as its second argument, freestanding too when the message isconst M&(see rclcpp compatibility)rclcpp::Service<S>/Client<S>— the DISPATCH service server and client. A handler is registered into the executor arena, which owns the entity.Service<S>::SharedPtrisrclcpp::ServiceHandle<S>, a two-word keep-alive with nothing to dereference;Client<S>::SharedPtrisrclcpp::ClientHandle<S>, the same two words with one verb,async_send_request. Neither has anoperator->.rclcpp::PollService<S>— L1 polling service server. The caller owns the server and drains it withtake_request/send_responsefrom its own spin loop.node.create_service<S>(name)with no handler hands one back.rclcpp::PollClient<S>— L1 future-style service client, the client half of the same split. The caller owns the client and drains the reply itself:send_requestreturns arclcpp::Future<T>(on a hosted buildasync_send_request(shared_ptr)returns upstream’sFutureAndRequestId—.future,.request_id,share()),callblocks while driving the executor,call_pollingblocks without driving it, andwait_for_service/service_is_readyprobe the server.node.create_client<S>(name)with no handler hands one back.rclcpp_action::Server<A>/Client<A>— L2 callback model (executor-arena registered).rclcpp::ActionServer<A>/rclcpp::ActionClient<A>are the same two types. Hosted, upstream’s goal handles too (see rclcpp compatibility).rclcpp::PollingActionServer<A>/PollingActionClient<A>— L1 polling model. Caller drivestake_*/accept_goal/complete_goalfrom a spin loop.rclcpp::Future<T>— async result handlerclcpp::Executor,Timer,GuardConditionrclcpp::trace_marker(id, arg)— an application event (ids 1-15) through the installed trace sink, ordered with the executor’s callback events; see Trace callbacks- Parameters are methods ON the node —
declare_parameter<T>/get_parameter<T>/set_parameter<T>/has_parameter, upstream’s names, forwarding to the one store thercl_interfacesservices read.rclcpp::Seq<T, N>is the array VALUE a freestanding node declares with (std::vector<T>underNROS_CPP_STD). There is no standalonerclcpp::ParameterServer: a second store would be invisible toros2 param get. See How nano-ros differs from ROS 2 for what is intentionally smaller thanrclcpp, and Parameters and/parameter_events.
Two-layer API. The
rclcpp::ActionServer<A>/ActionClient<A>templates are L2 callback handles, dispatched by the executor. Therclcpp::PollingActionServer<A>/PollingActionClient<A>are L1 polling templates with the same typed serialization glue but caller-driven control flow. Subscriptions, services and service clients have both shapes too (Subscription/PollSubscription, and so on). See Two ways to receive for the per-layer rationale.
Event-driven wake callbacks.
PollingActionServer<A>andPollingActionClient<A>expose a nestedWakeStatePOD and typedset_{goal,cancel,get_result,goal_response, cancel_response,result,feedback}_wake_callback(state, cb, ctx)methods. Pair annros_cpp_wake_state_twith each entity / channel to wake on rx instead of polling.
Errors
Every fallible call returns an rclcpp::Result; RCLCPP_TRY returns early
when one fails, and ret.raw() is the rclcpp::ErrorCode. The codes, with
their meanings, are on the
rclcpp/result.hpp page of the Doxygen site.
A Full from a create_* usually means a build-time pool is too small;
Static Pool Inventory names the knob that sizes it.
How to read the Doxygen site
The site lists every header under its upstream path, so a page you know from
rclcpp’s documentation is at the same name: rclcpp/node.hpp,
rclcpp_action/client.hpp, rclcpp_lifecycle/lifecycle_node.hpp. Each class
page documents the freestanding surface first; members that exist only on a
hosted build say NROS_CPP_STD. The pages under rclcpp/detail/ are
internal and may change without notice.
See also
- rclcpp compatibility: what a ported rclcpp node gets, by the upstream spelling it uses, and the measured ROS 2 examples.
- Add a second node: a C++ node added to a workspace, built and run.
- A Zephyr app you build with west: a C++ node in a Zephyr application, under the nano-ros Zephyr module.
Design background
- RFC-0018: C++ API design — freestanding C++14, no exceptions, the
Resultchannel - RFC-0089: ROS 2 API adoption, and the compile-or-conform rule — upstream’s namespaces and names, the
_inrule, the hosted surface - RFC-0021: blocking API rules — why blocking calls drive the executor and refuse re-entry
rclcpp compatibility
What a ported rclcpp node gets, by the upstream spelling it uses. “Hosted
builds” means a target built with NROS_CPP_STD, which the ament verbs set
for a ported package. The porting steps are in
Port a C++ node.
| rclcpp surface | nano-ros | Notes |
|---|---|---|
class MyNode : public rclcpp::Node | rclcpp::Node — ours, and the same name. | Ctor takes (name), (name, options) or (name, ns, options). |
std::make_shared<MyNode>() | works | auto node = std::make_shared<MyNode>() and rclcpp::spin(std::make_shared<MyNode>()) are unchanged. rclcpp::Node::SharedPtr node = std::make_shared<…>(…) does not compile — write auto; see “Node::SharedPtr observes, it does not own” below. shared_from_this() works too, with the same caveat. |
rclcpp::Node::make_shared("name") | std::make_shared<rclcpp::Node>(…), the owning std::shared_ptr | Hosted builds. auto node = rclcpp::Node::make_shared("x"); is unchanged; assigning the temporary straight to a global rclcpp::Node::SharedPtr is not — keep it in a local first (auto node = …; g_node = node;). |
create_publisher<M>(topic, qos) | shared_ptr-returning wrapper | qos can be rclcpp::QoS(10) or an int. |
create_subscription<M>(topic, qos, callback) | registered on the executor arena; dispatched by any spin verb | Capturing lambdas + std::function + std::bind all work. The callback may take const M& (no allocation, every target) or, on hosted builds, upstream’s M::UniquePtr / M::SharedPtr / M::ConstSharedPtr / std::shared_ptr<const M>: each delivery is then copied into a fresh heap object the callback owns and may keep. A freestanding build refuses the pointer shapes at compile time, naming const M&. |
create_wall_timer(period, callback) | registered on the executor arena; dispatched by any spin verb | std::chrono::duration arg, capturing-lambda callback. Returns rclcpp::TimerBase::SharedPtr, which is rclcpp::Timer::SharedPtr — one flat type, two names. See below. |
rclcpp::create_timer(node, clock, period, cb) | the clock-taking verb; a RCL_ROS_TIME clock follows /clock | Humble’s only form. create_wall_timer stays on the steady clock. |
create_service<S>(name, handler) with upstream’s std::shared_ptr<Request> / std::shared_ptr<Response> handler (optionally with std::shared_ptr<rmw_request_id_t> first) | lent from the dispatch: the handler gets pointers to the request and response the dispatch decoded | Hosted builds; a plain function, a lambda with or without captures, or std::bind(&Node::on_request, this, _1, _2) (a handler’s state is copied into the service’s executor entry, and whatever it returns, such as Autoware’s bool, is ignored). The handler must not KEEP a pointer past its call: that aborts, naming why. The request header is zero-filled. |
rclcpp::executors::SingleThreadedExecutor + add_node + spin | the process executor every node already lives on | add_node checks rather than attaches. MultiThreadedExecutor is a compile error naming the alternative: an executor dispatches on one task, and parallelism is a tier, not a callback group. |
executor.spin_some() / rclcpp::spin_some(node) | drain what is ready, without waiting | The bound is milliseconds (spin_some(5)), not a std::chrono duration. |
client->wait_for_service(1s) / wait_for_action_server(10s) | the millisecond wait, converted | Hosted builds. The budget is still required; a negative duration is refused at the call. |
rclcpp::spin_until_future_complete(node, client->send_request(req)) | spins until the reply arrives | The timeout is milliseconds. |
auto fut = client->async_send_request(std::make_shared<S::Request>(…)) / fut.get() / fut.wait_for(1s) / client->remove_pending_request(fut) | the poll client’s rclcpp::Future, under upstream’s verbs | Hosted builds, except remove_pending_request. get() returns the reply as an owning std::shared_ptr<Response> but never blocks: call it after spin_until_future_complete returned SUCCESS (before the reply it logs a refusal and returns nullptr). wait_for returns std::future_status and spins the executor while it waits. Each future is keyed by its request’s sequence number, as upstream’s is: several may be in flight on one client, each gets its own reply, and a reply that arrives after remove_pending_request (or prune_pending_requests) is dropped. How many is capped by the transport’s own outstanding-request limit (NROS_ZENOH_MAX_PENDING_GETS on zenoh); a send past it returns an empty future (valid() false). What it returns is upstream’s FutureAndRequestId: the future as .future, the request’s sequence id as .request_id (auto [future, id] = … works), and share() hands back a SharedFutureAndRequestId whose future is a std::shared_future<SharedResponse> every copy of which gets the same response; remove_pending_request takes the id too. .future is an rclcpp::Future, not a std::future. A freestanding build has send_request(req) + fut.try_take(resp); get() and share() there are compile errors naming them. |
#include "rclcpp_action/rclcpp_action.hpp" | an umbrella over Server<A> / Client<A> and the two free factories | See Actions with upstream’s goal handles. |
rclcpp::init(argc, argv) / shutdown() / ok() / spin(n) / spin_some(n) | wraps rclcpp::init_in/shutdown_in/ok/spin_once | --ros-args -r from:=to is honoured, beneath any remap the launch file sets for the same name. -p [node:]name:=value and --params-file <file> are honoured in an image with a parameter store: the value replaces the default when the node declares the parameter (scalars only from a file; a value of the wrong type is logged and the default kept). Any other ROS argument (__node, log flags) aborts, naming it. |
RCLCPP_INFO / WARN / ERROR / DEBUG / FATAL | dispatched through the NROS_LOG_* family into nros_log | Carries the logger, so get_logger("x") selects a real per-logger level, and FATAL is a distinct severity. Reaches LOG_ERR/printk on embedded, where the legacy NROS_* sink is a no-op. _THROTTLE(logger, clock, ms, ...) measures its window on the clock you pass (steady, system, or ROS time), logs the first record and then at most one per ms; an invalid clock is reported once at runtime and the site is throttled on the platform’s monotonic clock instead. _ONCE, _SKIPFIRST and _SKIPFIRST_THROTTLE exist at every level. Their state is per call site, in function-local statics. |
RCLCPP_LOG_MIN_SEVERITY = RCLCPP_LOG_MIN_SEVERITY_{DEBUG,INFO,WARN,ERROR,FATAL,NONE} | the compile-time floor, upstream’s symbol and values | Set it as upstream does, with a compile definition (target_compile_definitions(<target> PRIVATE RCLCPP_LOG_MIN_SEVERITY=RCLCPP_LOG_MIN_SEVERITY_INFO), or zephyr_compile_definitions in a Zephyr app). Every RCLCPP_* macro below it (plain, _ONCE, _SKIPFIRST, _THROTTLE, _SKIPFIRST_THROTTLE, _STREAM) becomes an empty statement and its arguments are not evaluated; unset, nothing is compiled out. The run-time filters (set_level, the image’s log.max_level ceiling) still apply above it, but they act after the call site has computed its arguments. The C API’s twin is RCLC_LOG_MIN_SEVERITY (<rclc/log.h>, values RCLC_LOG_MIN_SEVERITY_{TRACE,...,NONE} numbered as log.max_level, so a Zephyr build can pass CONFIG_NROS_LOG_MAX_LEVEL); it gates RCLC_LOG_* and, as rcutils’ floor does upstream, RCLCPP_* too. _EXPRESSION and _FUNCTION are not provided. |
get_logger().get_child("sub") | a real child logger, <parent>.sub | Its level, when unset, follows the nearest ancestor’s, so set_level on the node logger reaches it. A full name over 48 bytes or a full runtime-logger arena emits through the PARENT and set_level on it is refused — never a silent move of the parent’s threshold. Iron/Jazzy images publish children on /rosout; Humble ones, as upstream, do not. |
executor.spin_once() / client->wait_for_service() / action_client->wait_for_action_server() | the budget is required | Upstream defaults all three to “block forever”, which nano-ros has no form of; the no-argument call is a compile error naming the alternative rather than a silently substituted 10 ms / 5 s budget. Write spin_once(10), wait_for_service(10000). |
rclcpp::QoS / KeepLast(n) / SystemDefaultsQoS() | one class with upstream’s implicit (depth) ctor | Chainable setters inherited. |
diagnostic_updater::Updater + DiagnosticStatusWrapper | nano-ros’s own diagnostic_updater | Publishes /diagnostics. |
rclcpp_action::Server<A> / Client<A> | ours, under upstream’s names | Hosted builds take upstream’s goal-handle shapes as written; freestanding builds key goals by id. See Actions with upstream’s goal handles. |
class MyNode : public rclcpp_lifecycle::LifecycleNode | ours, under upstream’s name (<rclcpp_lifecycle/lifecycle_node.hpp>) | It IS an rclcpp::Node. The on_configure(const State&) … on_shutdown overrides, CallbackReturn::SUCCESS, configure() / activate() / … and get_current_state() keep upstream’s signatures; the REP-2002 services are registered by the constructor. create_publisher<M>(topic, qos) returns a managed LifecyclePublisher<M>::SharedPtr that sends only while Active. One managed node per executor. |
RCLCPP_COMPONENTS_REGISTER_NODE(class) + rclcpp_components_register_node(lib PLUGIN "ns::Class" EXECUTABLE exe) | the macro defines the component’s factory in its own source file; the cmake verb emits a thin int main() per registration that declares the class and calls that factory | Single binary, no class_loader. The PLUGIN’s qualifiers must be namespaces (a class nested in a class cannot be forward-declared). A component library built SHARED is built static. |
plain CMake components: add_library(<c> SHARED …), ament_target_dependencies(<c> rclcpp …), rclcpp_components_register_nodes(<c> "ns::Class"), a hand-written main (add_executable + target_link_libraries) | each SHARED or MODULE library builds static, and the configure prints a line saying so; the plural verb and ament_environment_hooks are accepted and do nothing | One image is one binary with one runtime. ament_target_dependencies works beside a target_link_libraries in either signature (plain or PRIVATE). A hand-written main gets the link pass the ament verbs give theirs. IMPORTED libraries keep their type. A project that overrides add_library itself replaces this. |
a helper executable that is not an image (a test driver or host tool with its own main, linking none of the runtime) | nano_ros_add_plain_executable(<name> <sources>...), the builtin add_executable with the same arguments | On a board every add_executable becomes an image: the board’s entry calls the program’s renamed main. This verb opts one executable out, on every platform, and marks it NROS_PLAIN_EXECUTABLE. It takes no IMPORTED or ALIAS executable, which is never an image anyway. |
find_package(ament_cmake_auto / rclcpp / rclcpp_components / diagnostic_updater / std_msgs / …) | find modules in the SDK root’s cmake/find/ | ~28 of the most-cited ROS 2 packages; a message package not among them is found by the resolver from NROS_INTERFACE_SEARCH_PATH / AMENT_PREFIX_PATH. |
ament_auto_find_build_dependencies() + ament_auto_add_library / ament_auto_add_executable | reads package.xml; each target gets the package’s include/ and every dependency nano-ros has a module for | A dependency nano-ros does not provide (a project helper such as autoware_utils) is listed at configure and not looked up; a source that includes it fails on the include. |
a project’s own message packages (autoware_vehicle_msgs, tier4_control_msgs, …) installed under AMENT_PREFIX_PATH | generated by nano-ros codegen from the installed .msg / .srv | Never the installed package’s upstream C++. Source the project’s install first (below). |
create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive), SubscriptionOptions::callback_group, create_subscription<M>(topic, qos, cb, options) | accepted; an unnamed group runs on the node’s default context | One executor task already keeps every callback mutually exclusive, so Reentrant runs them one at a time too. A NAMED group (create_callback_group("name")) is the tier-mapped one. |
create_service<S>(name, cb, rmw_qos_profile_services_default, group) | upstream’s trailing QoS and group | rmw_qos_profile_t has upstream’s fields and enum values. A profile converts to rclcpp::QoS, QoS(QoSInitialization::from_rmw(p), p) builds one, and qos.get_rmw_qos_profile() reads it back. rmw_qos_profile_system_default is absent, because every field of it is a placeholder for the RMW to fill in, and the RMWs fill it in differently. A file that also includes <nros/rmw_entity.h> is refused, because that header defines the RMW backend’s own struct of the same name. |
pub_->publish(msg); as a statement | allowed on a ported (ament-built) target, even under -Wall -Werror; a failure is logged | Code written for nano-ros keeps the [[nodiscard]] Result. |
several packages in one workspace (a library package such as Nav2’s nav2_util, a cmake-only one such as nav2_common, and the node that finds them) | find_package(<sibling>) resolves to the sibling configured earlier in the same run: <pkg>::<pkg> over what it exported with ament_export_libraries / _targets / _dependencies, its include/, and its ament_package(CONFIG_EXTRAS …) files run | Add each package before the packages that find it; the configure refuses an out-of-order find by name. Every package configures in ONE CMake run, so ${CMAKE_SOURCE_DIR} is the workspace root, not the package: write ${PROJECT_SOURCE_DIR} (rare: 0 of 417 Autoware CMakeLists name it). |
find_package(<pkg>) for an upstream C++ library nano-ros does not ship (bondcpp, tf2_ros, …) | refused at configure, naming the package and the installed file CMake fell back to | Remove the dependency, or port the library into your workspace as a package of its own. |
rclcpp::Time(msg->header.stamp) | implicit, from any {sec, nanosec} message, on the ROS clock | |
msg.header.stamp = now();, stamp + rclcpp::Duration::from_seconds(0.1) | a {sec, nanosec} message converts from rclcpp::Time, and + / - a Duration | |
last_cmd_.twist == geometry_msgs::msg::Twist() | a generated message has field-wise operator== / operator!= | Messages only; a service’s or action’s own Request / Goal structs have none. |
rclcpp::Node::WeakPtr parent + parent.lock() | the same non-owning handle; lock() hands it back | lock() cannot tell a destroyed node from a live one, because the handle owns nothing; it answers null only for an unset handle. |
rclcpp::Clock::SharedPtr clock_ = get_clock(); | a pointer to the node’s clock | std::make_shared<rclcpp::Clock>(...) does not convert; hold a rclcpp::Clock by value. |
timer_->cancel(); / timer_->reset(); as a statement | allowed on a ported target under -Werror | As publish(): the result is still readable. |
descriptor.floating_point_range.resize(1) | a bounded sequence resizes within its bound | Past the bound it is refused and returns false, where rosidl throws. |
rclcpp::spin(node->get_node_base_interface()) | spins the node | |
get_node_base_interface()->get_context()->add_pre_shutdown_callback(f) | rclcpp::Context views the executor’s shutdown hooks; f runs on rclcpp::shutdown() | The hooks share the executor’s table (NROS_EXECUTOR_MAX_SHUTDOWN_CBS, default 2). A full table returns an invalid handle. |
a package that depends on rclcpp_lifecycle | its runtime carries lifecycle (with the stock param_services and rosout), and ros2 lifecycle get /<node> finds it | The same on a board. A Zephyr application states it in system.toml: [system] features = ["lifecycle"]. |
std::static_pointer_cast<Derived>(shared_from_this()) (Nav2’s nav2_util::LifecycleNode) | does not compile | The handle owns nothing, so there is no std::shared_ptr to cast. Drop the override; rclcpp_lifecycle::LifecycleNode::shared_from_this() returns its own type. |
pub_->get_subscription_count() | takes the executor and an out-parameter | See Publisher::get_subscription_count. Nav2 calls it only in its tests. |
declare_parameter(name, rclcpp::ParameterValue(...)[, descriptor]), get_parameter(name) as an rclcpp::Parameter, set_parameter(rclcpp::Parameter(...)) | the same store the typed declare_parameter<T> uses; the descriptor may be an rcl_interfaces::msg::ParameterDescriptor | Hosted builds. A byte or string array can be built but not declared. A wrong-type as_double() answers 0.0, not an exception. |
add_on_set_parameters_callback(std::bind(&C::cb, this, _1)) with cb(std::vector<rclcpp::Parameter>) returning SetParametersResult | runs on every write, local or ros2 param set; successful = false refuses it; the returned handle unregisters on destruction | One parameter per call, because writes are validated one at a time. The reason does not reach the remote caller. Keep the handle as a member of your node class, so it goes before the node does. |
node->get_node_parameters_interface() | has_parameter, declare_parameter, get_parameter and get_parameter_overrides() through -> | get_parameter_overrides() lists this node’s -p / --params-file values as a std::map<std::string, rclcpp::ParameterValue>, one copy per node, so Nav2’s declare_or_get_parameter compiles. |
pub_->publish(std::move(msg)) with a std::unique_ptr<M> | publishes *msg; the message is freed when the call returns | Hosted builds. Every publish serializes, so there is no intra-process hand-over to save a copy. A null pointer is refused and logged. |
rclcpp::Client<S>::SharedPtr client_ = create_client<S>(name); + client_->async_send_request(req, callback) with a void(Client<S>::SharedFuture) callback | the handle holds the poll client; the callback runs from the executor when the reply arrives, with a SharedFuture whose get() returns it | Hosted builds with std::promise. The client registers one 1 ms timer for its callbacks, cancelled while none is waiting. A removed request’s callback never runs. wait_for_service(1s) inside a callback waits without spinning, so on a polled backend it runs out its budget. On an RTOS toolchain (no std::promise) store the client as rclcpp::Owned<rclcpp::PollClient<S>>, keep the FutureAndRequestId that async_send_request(req) returns, and read it on a later callback with future.is_ready() and get(). |
diagnostic_updater::Updater updater_{this}; | publishes /diagnostics on its own timer, every period (setPeriod), as upstream’s does | update() still works and is no longer required. |
DiagnosticTask, FrequencyStatus, TimeStampStatus, Heartbeat, HeaderlessTopicDiagnostic, TopicDiagnostic | upstream’s classes, levels and messages; updater.add(task) | A clock argument is a const rclcpp::Clock*, so node->get_clock() still passes. The tasks take no lock, so a node that calls tick() from its own thread must keep that call from overlapping an update. DiagnosedPublisher is absent, because a nano-ros publisher handle can be moved but not copied. Keep the publisher and a TopicDiagnostic, and call tick(stamp) next to each publish. |
the six parameter services (ros2 param get/set/list) and /rosout | on by default, on every board: every node serves them, as upstream’s does | They cost six queryables per node and their RAM. A memory-tight image opts out: node_interfaces = "none" in its system.toml, or an empty NROS_FEATURES for an ament package (any NROS_FEATURES you set is taken as written). Values come from --ros-args --params-file <yaml> or -p. /rosout is VOLATILE, where rcl’s is TRANSIENT_LOCAL, and a node does not subscribe to /parameter_events. |
Measured: the stock rclcpp examples
Each file below, from ros2/examples (Humble and Jazzy), is compiled, linked and booted beside its port. The table is rendered from the record the test holds the counts to, so it cannot drift:
| Example | Edited lines | What the edits are |
|---|---|---|
rclcpp/topics/minimal_publisher/lambda.cpp | 0 | — |
rclcpp/topics/minimal_publisher/member_function.cpp | 0 | — |
rclcpp/topics/minimal_publisher/not_composable.cpp | 11 | exceptions: the try/catch around publish + spin_some is removed (-fno-exceptions; there is no rclcpp::exceptions::RCLError) |
rclcpp/topics/minimal_subscriber/lambda.cpp | 0 | — |
rclcpp/topics/minimal_subscriber/member_function.cpp | 0 | — |
rclcpp/topics/minimal_subscriber/not_composable.cpp | 3 | global Node::SharedPtr from a temporary: g_node = rclcpp::Node::make_shared(...) is refused because Node::SharedPtr does not own; keep the shared_ptr in a local (auto node = ...; g_node = node;) |
rclcpp/timers/minimal_timer/lambda.cpp | 0 | — |
rclcpp/timers/minimal_timer/member_function.cpp | 0 | — |
rclcpp/services/minimal_service/main.cpp | 3 | global Node::SharedPtr from a temporary (as minimal_subscriber_not_composable) |
rclcpp/services/minimal_client/main.cpp | 0 | — |
rclcpp/actions/minimal_action_server/member_functions.cpp | 6 | no hidden threads: the stock handle_accepted detaches a std::thread per goal, and a goal handle used from a thread the application started races the executor (no executor lock on a one-level image). The port runs execute(goal_handle) in the accepted callback and drops rclcpp::Rate::sleep, which would re-enter the executor from that callback |
rclcpp/actions/minimal_action_client/member_functions.cpp | 2 | generated sequences are FixedSequence/HeapSequence, not std::vector: .back() is spelled [length() - 1] (adding back() would move the codegen version surface, for one line) |
rclcpp/executors/multithreaded_executor/multithreaded_executor.cpp | 18 | MultiThreadedExecutor is refused (one task per executor, no hidden threads) — renamed to SingleThreadedExecutor; callback groups: create_callback_group(CallbackGroupType) / SubscriptionOptions::callback_group / CallbackGroup::SharedPtr have no counterpart (every group is mutually exclusive on one task); the group plumbing is deleted |
Two surfaces: freestanding, and NROS_CPP_STD
One set of headers ships two API shapes, and a build picks one.
The freestanding surface is the default and it is not a fallback. It is
plain C++14 with no standard library, no exceptions and no RTTI:
rclcpp::Node, create_* writing through an out-reference and returning an
rclcpp::Result, const char* for names, uint64_t period_ms for durations.
It is the surface for every node written for nano-ros, native host builds
included.
The std surface is an opt-in and it is reached only by defining
NROS_CPP_STD. Defining it turns on the six NROS_CPP_HAS_* capability
macros in rclcpp/detail/std_detect.hpp, and with them: the std::string /
std::function / std::chrono / std::vector convenience overloads in
nros/std_compat.hpp, the RCLCPP_*_STREAM logging macros, and — the piece
that actually motivates the flag — rclcpp::Node’s upstream-shaped
factories, which return std::shared_ptr and take const std::string&
names.
Do I need this flag?
The split is ported rclcpp code versus code written for nano-ros. It is not host versus embedded. A native Linux build does not want the flag any more than a Cortex-M3 build does; a ported node wants it on both.
| You are… | Flag | Why |
|---|---|---|
writing a new node against rclcpp::Node / rclcpp::Publisher<M> / rclcpp::Executor | no | The freestanding surface is the whole API you are using. This is the common case on every platform, native included. |
compiling an upstream ROS 2 .cpp unmodified — it says class MyNode : public rclcpp::Node, std::make_shared<MyNode>(), create_publisher<M>(...) returning a SharedPtr | yes | Those signatures are spelled in std::shared_ptr and std::string. Without the flag they do not exist and you get a compile error naming a missing overload. |
passing a std::string topic name or a std::chrono period into an otherwise nano-ros-native file | yes | Those are the std_compat.hpp overloads. |
building for Zephyr, FreeRTOS, NuttX, ThreadX, or any -ffreestanding toolchain | no | And here it is not merely unnecessary: asking for the std surface asks the headers to #include <string>, which on those toolchains is either absent or a hard #error. |
If you are unsure, build without it. The failure direction is loud: a missing overload at compile time, never a silent behaviour change.
Turning it on
Define it on the target, not per file:
target_compile_definitions(my_ported_node PRIVATE NROS_CPP_STD=1)
Per target rather than per #define-before-include, because the macro changes
the layout of rclcpp::Node (it carries hosted-only members and an
enable_shared_from_this base), so two translation units of one image that
disagree about it are an ODR/layout break rather than a missing function. An
image may set the flag on one module and not another, so keep the definition
at target granularity and give every translation unit of a target the same
answer.
A ported package usually needs none of this. nano-ros’s ament surface sets
NROS_CPP_STD=1 on every target its ament_* verbs create, and
find_package(rclcpp) sets it on whatever links rclcpp::rclcpp, so a ported
package already has the surface it needs; see
Porting a ROS 2 C++ node.
The ported shape
With the flag set, an upstream node’s own spelling compiles: std::make_shared,
SharedPtr returns, a std::string topic, a QoS depth, a capturing lambda and
a std::chrono period.
#include <rclcpp/rclcpp.hpp>
#include "std_msgs/std_msgs.hpp"
using namespace std::chrono_literals;
int main(int argc, char** argv) {
rclcpp::init(argc, argv);
auto node = std::make_shared<rclcpp::Node>("talker");
auto pub = node->create_publisher<std_msgs::msg::Int32>("chatter", 10);
int count = 0;
auto timer = node->create_wall_timer(1s, [&]() {
std_msgs::msg::Int32 msg;
msg.data = ++count;
pub->publish(msg);
});
rclcpp::spin(node);
rclcpp::shutdown();
}
A failed create_* here ABORTS, naming the call, because upstream throws and
nano-ros has no exceptions. To handle the failure instead, use the
Result-returning forms above.
Why it is not detected for you
Earlier releases discovered the capability macros from the include path with
__has_include, so a hosted compiler handed you the std-flavoured API whether
you asked for it or not. That was removed because no probe answers the
question correctly on both embedded toolchains:
__STDC_HOSTED__ | __has_include(<string>) | #include <string> | |
|---|---|---|---|
arm-none-eabi 13.2, -ffreestanding (FreeRTOS) | 0 | TRUE | hard #error |
Zephyr -nostdinc++, minimal libcpp | 1 | FALSE | absent |
| hosted g++ 12.3 | 1 | TRUE | works |
Each probe is right on exactly one embedded toolchain and wrong on the other:
libstdc++ 13 added bits/requires_hosted.h, so header presence stopped
implying usability. Only the request is right on both, because it is not a
probe — it is you saying which surface you want. The full measurement is in
the comments of rclcpp/detail/std_detect.hpp.
Hosted-only shapes
Subscriptions with MessageInfo
A dispatch subscription’s callback may take upstream’s
const rclcpp::MessageInfo& as a second argument, after the message. With
the message as const M& this works on every build, freestanding included:
the callable is copied into the executor arena, as a one-argument callback’s
is. The three pointer forms
(std::shared_ptr<const M>, std::shared_ptr<M>, std::unique_ptr<M>) need
a hosted build (NROS_CPP_STD), as their one-argument twins do:
auto sub = node->create_subscription<std_msgs::msg::Int32>(
"/chatter", 10,
[](const std_msgs::msg::Int32& msg, const rclcpp::MessageInfo& info) {
const auto& r = info.get_rmw_message_info();
printf("%d from seq %llu at %lld ns\n", msg.data,
(unsigned long long)r.publication_sequence_number,
(long long)r.source_timestamp);
});
get_rmw_message_info() carries source_timestamp, received_timestamp,
publication_sequence_number, reception_sequence_number and the 24-byte
publisher_gid, as the backend reported them. A backend that reports none
(XRCE, uORB) leaves every field zero. from_intra_process is always false.
SubscriptionOptions::message_info = true with a
callback that takes no MessageInfo aborts the create, because it would
otherwise configure nothing.
Actions with upstream’s goal handles (hosted)
On a hosted build (NROS_CPP_STD) the stock rclcpp_action spellings are
drop-ins over the two classes above:
using Fibonacci = example_interfaces::action::Fibonacci;
using GoalHandle = rclcpp_action::ServerGoalHandle<Fibonacci>;
using namespace std::placeholders;
// Server: free factory over the node interfaces, std::bind-ed members.
rclcpp_action::Server<Fibonacci>::SharedPtr server =
rclcpp_action::create_server<Fibonacci>(
get_node_base_interface(), get_node_clock_interface(),
get_node_logging_interface(), get_node_waitables_interface(),
"fibonacci",
// (const GoalUUID&, shared_ptr<const Goal>)
std::bind(&MyNode::handle_goal, this, _1, _2),
// (shared_ptr<GoalHandle>)
std::bind(&MyNode::handle_cancel, this, _1),
// (shared_ptr<GoalHandle>)
std::bind(&MyNode::handle_accepted, this, _1));
// in handle_accepted: goal_handle->get_goal(), ->publish_feedback(fb),
// ->is_canceling(), ->succeed(result) / ->abort(result) / ->canceled(result)
// Client: SendGoalOptions' upstream fields, bound per goal by async_send_goal.
auto client = rclcpp_action::create_client<Fibonacci>(this, "fibonacci");
auto opts = rclcpp_action::Client<Fibonacci>::SendGoalOptions();
opts.goal_response_callback =
[](rclcpp_action::ClientGoalHandle<Fibonacci>::SharedPtr h) {};
opts.feedback_callback =
[](auto h, const std::shared_ptr<const Fibonacci::Feedback> fb) {};
opts.result_callback =
[](const rclcpp_action::Client<Fibonacci>::WrappedResult& r) {
// r.code: rclcpp_action::ResultCode::SUCCEEDED / ABORTED / CANCELED;
// r.result
};
auto fut = client->async_send_goal(goal, opts); // rclcpp::Future<GoalAccept>
// The handle-taking calls return upstream's std::shared_future.
// shared_future<WrappedResult>
auto result = client->async_get_result(goal_handle);
// shared_future<CancelResponse::SharedPtr>
auto cancel = client->async_cancel_goal(goal_handle);
if (rclcpp::spin_until_future_complete(node, result) ==
rclcpp::FutureReturnCode::SUCCESS) {
const auto& wrapped = result.get();
}
// server, after handle_goal returned ACCEPT_AND_DEFER:
goal_handle->execute(); // ACCEPTED -> EXECUTING, status array published
X<A>::SharedPtr is rclcpp::Owned<X<A>> (the entity by value), and the
get_node_*_interface() handles name the node and do nothing else. A goal
handle is a heap token over the goal id: every call forwards to the server or
client keyed by it, and the goal’s state stays in the arena. Drive it from the
executor’s task only — not from a thread you started — and do not move the
server while a handle is in use. The callbacks run from the executor’s
dispatch, beside the client-wide set_callbacks ones. async_send_goal
returns the goal-keyed rclcpp::Future<GoalAccept>, not a
std::shared_future; get_goal_stamp is absent.
async_get_result / async_cancel_goal / async_cancel_all_goals /
async_cancel_goals_before return a
rclcpp_action::detail::DrivenSharedFuture<T>, which IS-A
std::shared_future<T>: its is_ready() (what spin_until_future_complete
polls), wait_for and get drive the client’s dispatch and executor while
they wait, since no other thread fulfils it. Converted to a bare
std::shared_future it still completes, but only when something else drives
the client. Every async_get_result for one goal returns the handle’s own
future; a result-aware goal’s handle is kept by the client until its result
arrives, as upstream’s pending request keeps it. Cancel replies are taken by
the executor’s spin, as upstream’s executor delivers them: the spin settles
the waiting async_cancel_* future and runs its cancel_callback, so a
caller that keeps only the callback needs no poll(). A nano-ros server acts on the zero-id cancel-all / cancel-before forms
as an rclcpp server does. A reply no future
claims is kept for try_recv_cancel_response, oldest first, up to
rclcpp_action::CANCEL_STASH_CAP (4) per client. These need std::promise,
so they are hosted-only twice over: a libstdc++ built without threads
(arm-none-eabi) refuses them as a freestanding build does.
ServerGoalHandle::execute() and Server<A>::execute(goal_id) move an
ACCEPTED goal to EXECUTING and publish the status array; the latter reports
NotFound / NotAllowed where upstream raises. create_server executes an
ACCEPT_AND_EXECUTE goal before handle_accepted; the goal-id API leaves it
ACCEPTED.
Goal slots. Each action sub-client holds at most MAX_CONCURRENT_GOALS (4)
requests in flight. A future dropped (or cancel()ed) before its reply frees
its request’s slot, unless something else still waits on that reply — a
client-wide set_callbacks hook, or an upstream goal (async_send_goal with
callbacks, async_get_result). A late reply for a freed slot is dropped. On a
freestanding build each of these shapes is a compile error
(NROS_RCLCPP_REFUSE_ACTION_GOAL_HANDLE) naming the goal-id-keyed form above;
create_client alone works there.
Action client futures
Future-based async. send_goal_future() / get_result_future() return a
Future<T> keyed by its goal: each future receives only its own goal’s
acceptance or result, whether the executor dispatched it during spin_once or
the future’s own poll took it, and a result for a goal nobody waits on is
dropped. At most MAX_CONCURRENT_GOALS of each may be pending per client;
past that the send is refused and the future is empty (valid() false):
auto fut = client.send_goal_future(goal);
typename decltype(client)::GoalAccept accept;
RCLCPP_TRY(fut.wait(executor.handle(), 5000, accept));
if (accept.accepted) {
auto rfut = client.get_result_future(accept.goal_id);
Fibonacci::Result result;
RCLCPP_TRY(rfut.wait(executor.handle(), 10000, result));
}
GoalAccept is a nested type on rclcpp_action::Client<A> (16-byte UUID +
bool accepted).
Parameters and /parameter_events
Parameters are methods on the node (declare_parameter<T>, get_parameter<T>,
set_parameter<T>, undeclare_parameter), over the executor’s one store.
node.start_parameter_services() serves them on the six rcl_interfaces
services, so ros2 param reaches them, and publishes /parameter_events
(rcl_interfaces/msg/ParameterEvent, rmw_qos_profile_parameter_events) as
rclcpp’s node does:
rclcpp::Node node;
RCLCPP_TRY(executor.create_node(node, "ctrl"));
node.declare_parameter<int64_t>("gain", 3); // before or after: both reported
// start-up event: new_parameters = [gain]
RCLCPP_TRY(node.start_parameter_services());
node.set_parameter<int64_t>("gain", 4); // changed_parameters = [gain]
node.undeclare_parameter("gain"); // deleted_parameters = [gain]
A launch or YAML value whose type is not the declared T (an integer
written for a double parameter) stops the boot at the declaration, as
upstream’s declare_parameter<T> throws: the node’s ok() turns false, and
the log line names the node, the parameter and the value to write.
Each event names the node’s fully qualified name in node; the events are
published on the next spin. The image needs the param_services capability,
which every image has unless it states node_interfaces = "none".
One publisher per executor serves every node. It is on for every served node
unless the node was built with
rclcpp::NodeOptions().start_parameter_event_publisher(false), which opts
that one node out; the other nodes keep publishing.
To react to OTHER nodes’ changes, a hosted build has
rclcpp::ParameterEventHandler. It subscribes to /parameter_events once, on
the node you give it:
auto handler = std::make_shared<rclcpp::ParameterEventHandler>(node);
auto h = handler->add_parameter_callback(
"gain", [](const rclcpp::Parameter& p) { use(p.as_int()); }, "/controller");
auto e = handler->add_parameter_event_callback(
[](const rcl_interfaces::msg::ParameterEvent& ev) { /* every event */ });
Keep the handles: dropping one unregisters it, as upstream’s do. An empty node
name means this node, and a relative one resolves against this node’s
namespace. A parameter callback sees new and changed values, never deletions.
An event callback receives the type it takes, so rcl_interfaces must be
generated for the image. The per-parameter handle is
rclcpp::ParameterCallbackHandle, as upstream (the handler’s nested
ParameterEventHandler::ParameterCallbackHandle names the same type). A
freestanding build refuses the handler at compile time; there, subscribe to
/parameter_events with create_subscription yourself.
Design background
- RFC-0089: ROS 2 API adoption, and the compile-or-conform rule — upstream’s namespaces and names, the
_inrule, the hosted surface - RFC-0018: C++ API design — freestanding C++14, no exceptions, the
Resultchannel
Platform and RMW APIs
nano-ros has two porting boundaries, and this page is the reference for both. The platform API sits between nano-ros and a concrete OS, RTOS or bare-metal target: each platform provides a clock, and optionally a heap, threading and networking. The RMW API sits between nano-ros and a concrete pub/sub transport (The RMW API, below). Both are internal: user applications use the Rust, C and C++ APIs, not either vtable directly.
nano-ros separates the platform layer (clock, sleep, allocator,
threading, critical section, network, timer, …) from the rest of the
code via a single canonical C ABI of free extern "C" symbols.
Every supported port — POSIX, FreeRTOS, NuttX, ThreadX, Zephyr,
bare-metal Cortex-M, bare-metal RISC-V — implements the
same symbols against its host kernel. RMW backends, codegen output, and the
nros-node runtime all link against the ABI; nobody links against a
specific port’s Rust crate.
Canonical reference
The SSoT C headers in
packages/platform/nros-platform-api/include/nros/ (platform.h +
platform_net.h, platform_timer.h, platform_zephyr.h, platform_freertos.h; Rust consumes committed bindgen output from them) are the source of
truth. Every symbol’s brief, parameter docs, ownership rules,
blocking / non-blocking classification, and ISR-safe contract live in
the Doxygen compiled from those headers.
Regenerating the Doxygen in the tree: see Internals → Build Commands.
This page does not duplicate the interface specification — read the Doxygen for that.
Surface
Three hand-written headers under
packages/platform/nros-platform-cffi/include/nros/:
| Header | Purpose |
|---|---|
platform.h | Core kernel surface: clock, sleep, alloc + heap stats, threading, scheduler, time, yield, random, critical section, opaque wake primitive. |
platform_net.h | Network surface: TCP/UDP/multicast socket helpers, endpoint resolution, IVC. |
platform_timer.h | Periodic timer surface (nros_platform_timer_*). |
Every symbol has the prefix nros_platform_. A drift gate
(scripts/check-platform-abi-mirror.sh) walks each header and asserts
that the unsafe extern "C" {} mirror block in
packages/platform/nros-platform-cffi/src/lib.rs declares the same set —
no symbol can land in C without its Rust mirror, no Rust mirror can
declare a symbol without a C header decl. CI runs the gate on every
build.
Capability groups
Within platform.h, the symbols are grouped by trait. Each group is
exported by one Rust trait + one C-port section + one drift-gate
match. Adding a capability means adding a row to every column.
| Capability | Rust trait | C section | Symbols |
|---|---|---|---|
| Clock | PlatformClock | clock_ns | nros_platform_clock_ns |
| Sleep | PlatformSleep | sleep_ms | nros_platform_sleep_ms |
| Alloc | PlatformAlloc | malloc/realloc/free | nros_platform_alloc{,_realloc,_free} |
| Threading | PlatformThreading | mutex/condvar/task | nros_platform_{mutex,condvar,task}_* |
| Critical section | PlatformCriticalSection | per-CPU interrupt mask | nros_platform_critical_section_{acquire,release} |
| Scheduler | PlatformScheduler | task hints | nros_platform_scheduler_* |
| Time | PlatformTime | wall-clock, and what it means (synced, which source, steps since boot) | nros_platform_time_now_ns, nros_platform_wall_clock_state |
| Yield | PlatformYield | cooperative yield | nros_platform_yield_now |
| Random | PlatformRandom | best-effort RNG | nros_platform_random_* |
| Wake | PlatformThreading (wake methods) | opaque binary-semaphore | nros_platform_wake_{init,drop,wait_ms,signal,signal_from_isr,storage_size,storage_align} |
platform_net.h covers TCP/UDP/multicast/IVC, and platform_timer.h
covers periodic timers. The shapes follow the same pattern: trait →
macro → header → drift gate.
How a port is built
A port can be written in either of two ways. The choice is per-port and not visible to consumers — both shapes resolve to the same symbols.
Path A — Rust trait + macro export
The Rust crate implements PlatformClock, PlatformAlloc,
PlatformThreading, … on a marker type, then invokes one of the
export macros:
#![allow(unused)]
fn main() {
use nros_platform_api::{
PlatformClock, PlatformSleep, PlatformAlloc, PlatformThreading,
PlatformCriticalSection,
nros_platform_export, nros_platform_export_net, nros_platform_export_timer,
};
pub struct PosixPlatform;
impl PlatformClock for PosixPlatform { /* … */ }
impl PlatformSleep for PosixPlatform { /* … */ }
// … etc.
nros_platform_export!(PosixPlatform);
nros_platform_export_net!(PosixPlatform);
nros_platform_export_timer!(PosixPlatform);
}
The macros expand to the full set of #[unsafe(no_mangle)] pub extern "C" fn nros_platform_* bodies forwarding to the trait calls.
This is what nros-platform-posix does today. It is also what the
bare-metal board crates (nros-platform-mps2-an385,
nros-platform-stm32f4)
use: there is no host kernel to write idiomatic C against, so the
single-task stub impls are written in Rust and exported via the macro.
Path B — pure C port
The kernel-side ports (FreeRTOS, NuttX, ThreadX, Zephyr) write the
bodies directly in src/platform.c, src/net.c, src/timer.c
inside each packages/platform/nros-platform-<rtos>/ directory. The Rust
side has no implementation file — the build script (or parent build
system: NuttX make, Zephyr west module) compiles the C
sources against the kernel’s headers.
Pure-C bodies are the more natural fit when the kernel already speaks
C and ships C headers (xSemaphoreCreate*, k_sem_*, tx_thread_*):
the impl is one-to-one with the kernel call, no FFI dance through
Rust’s calling convention. The shared crate
nros-platform-critical-section is the canonical example for a
single-symbol shim: the Rust side just calls the externs and registers
the result with critical_section::set_impl!.
Design
Why the ABI is free symbols rather than a vtable, and why threading and sockets stay per-RTOS while the scalar services are unified, is in Internals → Platform API design.
Reference implementations
Each row is a complete worked example. The crate’s README.md
walks the implementation; the source is the worked solution to
copy.
| Crate | Target | Source |
|---|---|---|
nros-platform-posix | Linux / *BSD | packages/platform/nros-platform-posix |
nros-platform-nuttx | NuttX RTOS | packages/platform/nros-platform-nuttx |
nros-platform-freertos | FreeRTOS | packages/platform/nros-platform-freertos |
nros-platform-threadx | Azure RTOS / ThreadX | packages/platform/nros-platform-threadx |
nros-platform-zephyr | Zephyr RTOS | packages/platform/nros-platform-zephyr |
nros-platform-mps2-an385 | Cortex-M3 (QEMU) | packages/platform/nros-platform-mps2-an385 |
nros-platform-stm32f4 | STM32F4 | packages/platform/nros-platform-stm32f4 |
The POSIX implementation is the canonical reference port.
Writing a custom platform
- The task, step by step: Add a platform.
- Per-platform behaviour matrix: Platform Differences.
The RMW API
The RMW (ROS middleware) vtable is the porting boundary between nano-ros and a concrete pub/sub transport. The backends in nano-ros’s tree are listed below; a backend in your own workspace is selected the same way.
The vtable
The C vtable nros_rmw_vtable_t is the source of truth. Each function
pointer’s brief, its parameters, its ownership rules (a borrowed buffer or a
caller-owned one), whether it blocks, its return codes and the lifetime of
loaned slots are in the Doxygen output, compiled from the header.
To regenerate the Doxygen in the tree, see Internals → Build Commands. This page does not duplicate the interface specification: read the Doxygen for that.
Backends in the tree
A backend is a package whose package.xml announces
<nano_ros_provides kind="rmw" name="..."/>, with an nros-rmw.toml beside
it. The build finds backends by that announcement, in nano-ros’s tree and in
your workspace alike, so this table is generated from the tree’s
announcements rather than typed. Each package’s README.md walks its
implementation, and the source is the worked example to copy.
rmw = | Package | About | Links through |
|---|---|---|---|
cyclonedds or rmw-cyclonedds | nros_rmw_cyclonedds | The Cyclone DDS RMW backend for nano-ros — full DDS/RTPS, used where a nano-ros node must speak natively to stock ROS 2 peers. | cargo crate nros-rmw-cyclonedds-sys, CMake target nros_rmw_cyclonedds |
uorb or rmw-uorb | nros_rmw_uorb | The uORB RMW backend for nano-ros — PX4’s in-process message bus. | CMake target nros_rmw_uorb |
xrce or rmw-xrce | nros_rmw_xrce | The Micro XRCE-DDS RMW backend for nano-ros — client/agent transport for constrained targets that cannot host a full DDS stack. | cargo crate nros-rmw-xrce-cffi, CMake target nros_rmw_xrce |
zenoh or rmw-zenoh | nros_rmw_zenoh | The zenoh RMW backend for nano-ros (zenoh-pico on embedded targets). | cargo crate nros-rmw-zenoh |
The zenoh-pico shim is the canonical reference port.
Writing a custom backend
- The task, step by step: Write a custom RMW backend.
- Coming from upstream
rmw.h: Internals → RMW API vs upstream. - Coverage against upstream
rmw.h:docs/research/rmw-c-abi-coverage.md.
Design background
- RFC-0054: C header ABI single source of truth — why the C headers are canonical and Rust uses generated bindings
- RFC-0034: platform layer split — the scalar / opaque-struct boundary (D2) and the allocation gate (D8)
nros CLI reference
The help of every user-tier nros command, exactly as the CLI prints it:
nros --help, then each verb in the groups nros --help lists, then each
subcommand a verb lists. The page is generated from the CLI’s own help, so
it reads the same as nros <command> --help on the release it documents.
nros help --all adds the build-system tier, which is not part of this page,
and the extension commands your workspace’s packages provide.
Where each verb is explained
| Command | Page |
|---|---|
nros setup | Install |
nros setup, pin | Install options, pinning, working offline |
nros new | Run a talker on an emulated board |
nros build, list | Organize a larger workspace |
nros configure, config | Configure an image |
nros run, flash, monitor, bench | Deploy to production |
nros interface | Message generation |
nros doctor | Troubleshoot |
nros locate | Build inside an existing CMake or vendor tree |
nros toolchain | Move a ROS 2 project over |
nros
nros — command-line tool for nano-ros (a lightweight ROS 2 client for embedded RTOS).
Quick start:
nros setup <board> provision a board's toolchains + sources (board-scoped)
nros new <name> scaffold a project
nros configure generate msg bindings, models and build settings
nros plan resolve a launch topology
nros check check a package, a plan or a workspace
nros doctor check SDK paths / toolchains / env
Run `nros setup --list` to see available packages, and `nros help --all` for the build-system tier as well.
Usage: nros [OPTIONS] [COMMAND]
Start:
new Scaffold a new nano-ros package (`--template`: talker, listener, server, client, action-server, action-client), workspace, image or component
template List the node roles `nros new --template` scaffolds, or show one
setup Resolve + fetch a board's toolchain/SDK packages
Build:
build Build a nano-ros workspace
configure Configure a project: generate message bindings and the cargo patch config, then resolve and generate every image's build inputs
fix Apply the mechanical remedies the build's refusals name; prints the change, and writes it with --apply
clean Remove the generated bindings and the managed patch block from each Rust package. Leaves user-written sections alone
materialize Take ownership of a generated entry package
Run on a target:
run Run an image on its target: a host process or an emulator. Builds it if stale, starts the router it needs, streams its console and stops everything on exit. `--expect` grades the console; `--dry-run [--why]` prints the resolved plan instead. A hardware image is `nros flash --monitor`
flash Flash an image onto a real board: builds it if stale, runs the board's human steps, flashes, and with `--monitor` watches the console on the same port. `--expect` grades it; `--dry-run [--why]` prints the plan instead
monitor Attach to a running board's console: `--expect` grades it, `--send` writes to it. In a workspace the image's board states the port and baud; elsewhere `--port` names the device
bench This machine's boards: `scan` records which attached USB device is which board in `$NROS_HOME/bench.toml`, `list` prints it with what is attached now. It supplies ports and probes, never test scope
debug Debug an image on its target (reserved: not available yet)
Workspace:
list List the workspace's packages: kind, name and directory per row
image List the workspace's images, or show one: what it declares and what the build resolves for it
graph Print the workspace's packages in dependency order, each with the workspace packages it depends on
Interfaces:
interface Generate message bindings, list the interfaces the workspace can reach, or show one interface's definition
Inspect:
doctor Health-check the workspace (SDK paths, toolchains, env)
board Inspect supported boards
platform List the platforms boards build on, or show one: its boards and capabilities
rmw List the RMW backends, or show one: its host side and its boards
runner List the runners and extension commands this workspace reaches, or show one
knob List the knobs a project can state, or show one: where to state it, the values it takes and its default
code List the diagnostic codes a refusal prints, or show one: what it reports and how to fix it
config Inspect or validate the current project's resolved configuration
plan Resolve launch files, manifests, and metadata into nros-plan.json
check Check a runner, command or board package, a plan, a system.toml or a workspace
explain Explain a diagnostic code, or render a generated nros-plan.json
Toolchain:
toolchain List, remove and garbage-collect installed toolchains and SDK packages
pin Report this project's `nros-toolchain.toml`, or move it
update Move one pin, leaving one diff to review
locate Print where a resource is, and with `--why`, which rung answered
Other:
version Print toolchain + library versions
completions Generate shell completions (bash | zsh | fish | powershell)
help Print this message or the help of the given subcommand(s)
Options:
--codegen-version
Print the codegen version this binary emits, and exit.
The compatibility token between this binary's emitted code and the nano-ros runtime that compiles it — deliberately not a release version. A codegen-version refusal asks you to compare this number against the runtime's accepted range.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Start
nros new
Scaffold a new nano-ros package (`--template`: talker, listener, server, client, action-server, action-client), workspace, image or component
Usage: nros new [OPTIONS] [NAME] [SYSTEM_NAME]
Arguments:
[NAME]
Project directory to create, or a mode keyword.
The literal keyword `system` enters bringup-scaffold mode: `nros new system <name>_bringup --components <pkg1,pkg2,...>`.
[SYSTEM_NAME]
The bringup package directory, or the package name in a package-scaffold mode.
The bringup directory when the first positional is the literal `system`; the <name> when it is the literal `platform` or `board`.
Options:
--for-platform <FOR_PLATFORM>
The platform a `nros new board <name>` targets.
A platform directory name, e.g. `zephyr`, `bare-metal`, or one scaffolded via `nros new platform`.
--inherits <INHERITS>
The built-in platform family a `nros new platform <name>` builds as, written as its `nros-platform.toml` `inherits` (e.g. `bare-metal`, `freertos`).
A board naming the platform builds as the first built-in platform this chain reaches. Without it the line is written commented out, and a board naming the platform is refused until it is set.
--components <COMPONENTS>
Comma-separated component package names for `nros new system <bringup> --components <list>`
--component-name <COMPONENT_NAME>
One component package name; repeatable.
An alternative to `--components <a,b,c>` when commas in the shell are awkward. Merged with `--components`.
--workspace-root <WORKSPACE_ROOT>
Workspace root holding the cargo `Cargo.toml` to update.
Defaults to the parent of the bringup dir.
--into <INTO>
Parent dir under which the bringup package is created.
Defaults to the current working directory.
--no-config
Skip the optional `config/` sub-dir
--no-readme
Skip the optional `README.md`
--platform <PLATFORM>
Target platform. In project mode give this or `--board`.
`--board` alone reads the platform from the board. `linux` is the host board. `esp32` is not offered: ESP32 support is dormant.
[possible values: linux, freertos, nuttx, threadx, zephyr, baremetal]
--rmw <RMW>
RMW backend, as `nros rmw list` names it. Defaults per mode: `zenoh` for project/component scaffolds (matches the tracked examples), `cyclonedds` for `--workspace` (needs no router — the quick-start default)
--ros-edition <ROS_EDITION>
ROS edition (drives the `ros-<edition>` cargo feature). Defaults to the sourced ROS 2 (`$ROS_DISTRO`) when it is one of these, else humble
[possible values: humble, iron, jazzy]
--lang <LANG>
Source language. Defaults per mode: `rust` for project/component scaffolds, `cpp` for `--workspace` (the quick-start language)
[possible values: rust, c, cpp]
--template <TEMPLATE>
The node the package holds: a talker (std_msgs/String on /chatter), a listener, an AddTwoInts `server` / `client`, or a Fibonacci `action-server` / `action-client` — the roles of the ROS demos, under the demos' own interfaces. Default: `talker`
[possible values: talker, listener, server, client, action-server, action-client]
--node-name <NODE_NAME>
The node's ROS name (as `ros2 pkg create --node-name`). Default: the package name (`-` spelled `_`); for `--component`, the role's demo node name (`talker`, `add_two_ints_server`, …)
--dependencies <DEPENDENCIES>...
Extra `<depend>` packages for package.xml, after the template's own interface package (as `ros2 pkg create --dependencies`). Space- or comma-separated
--license <LICENSE>
package.xml `<license>` (as `ros2 pkg create --license`). Default: `Apache-2.0`
--description <DESCRIPTION>
package.xml `<description>` (as `ros2 pkg create --description`)
--maintainer-name <MAINTAINER_NAME>
package.xml maintainer name (as `ros2 pkg create --maintainer-name`). Default: `git config user.name`
--maintainer-email <MAINTAINER_EMAIL>
package.xml maintainer email (as `ros2 pkg create --maintainer-email`). Default: `git config user.email`
--destination-directory <DESTINATION_DIRECTORY>
Directory to create the package in (as `ros2 pkg create --destination-directory`). Default: the current directory
--component
Scaffold a planned-mode component instead of a direct-mode binary project.
A component is a reusable library node with an `nros::Component` and a folded `[component]` `nros.toml`. It is platform-agnostic (platform and RMW are chosen at deploy time), so `--platform` is not needed.
--image <IMAGE>
Scaffold an `[image.<name>]` — a buildable image — into the bringup package's `system.toml` instead of a project
--host <HOST>
Scaffold a `[host.<name>]` — a machine nodes run on — into the bringup package's `system.toml`
--deploy <DEPLOY>
Deprecated: use `--image` or `--host`.
`[deploy.*]` split into `[image.*]` (what is built) and `[host.*]` (where it runs). Still accepted, and dispatched by `--kind`: `self` scaffolds a host, anything else an image.
--workspace
Scaffold a minimal multi-node workspace instead of a standalone project.
The workspace holds node packages, a bringup and an entry: the canonical copy-out template with the RMW choice baked into every file that spells it. Defaults: `--lang cpp --rmw cyclonedds`.
--from <PACKAGE>
With `--workspace`: grow this single package into a workspace.
Takes a package made by `nros new <name> --board <board>`. Its node moves to `<name>/src/<package>/` unchanged, and its `system.toml` moves to the bringup `<name>/src/<package>_bringup/`. `nros new node <name>` inside the workspace then adds a second node.
--kind <KIND>
`runner` or `command`: scaffold a runner or command package.
The package holds its `package.xml`, its descriptor and a stub on `nros-extension` (`--lang rust`, the default) or a CMake executable that speaks the protocol JSON itself (`--lang cpp`). Inside a workspace it lands in `src/<name>/`. Check it with `nros check <name>`.
--target <TARGET>
Deprecated: accepted and ignored.
The rustc triple comes from the board descriptor, so an image carries none.
--board <BOARD>
The board the new workspace's bringup image runs on (`nros new <name> --board <board>`: the platform is the board's), or the board an `--image` is built for. With `--platform` instead, a project defaults to the platform's own board from the board catalog (`freertos` -> `mps2-an385-freertos`) and refuses, naming the candidates, when the platform has several (`threadx`)
--bringup <BRINGUP>
Deploy mode: pick the bringup package whose `system.toml` to edit when the workspace exposes more than one
--to <BRINGUP>
Inside a workspace: the bringup that runs the new node package.
`nros new <node> --to <bringup>` adds the package under `src/`, a `[[component]]` row for it in the bringup's `system.toml` and an `<exec_depend>` in its `package.xml`. Without `--to` no bringup is touched.
--from-launch <FROM_LAUNCH>
Deploy mode: also set the bringup `[system].default_launch` (bootstrap)
--from-profile <FROM_PROFILE>
Fork an existing block of the same table (`[image.<name>]` with `--image`, `[host.<name>]` with `--host`)
--force
Overwrite an existing directory / `[image.<name>]` or `[host.<name>]` table
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros template
List the node roles `nros new --template` scaffolds, or show one
Usage: nros template <COMMAND>
Commands:
list List the node roles `nros new --template` scaffolds
show Show one role: what it does, its interface and its languages
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros template list
List the node roles `nros new --template` scaffolds
Usage: nros template list [OPTIONS]
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros template show
Show one role: what it does, its interface and its languages
Usage: nros template show [OPTIONS] <ROLE>
Arguments:
<ROLE> The role, as `nros new --template` takes it (`talker`)
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros setup
Resolve + fetch a board's toolchain/SDK packages
Usage: nros setup [OPTIONS] [BOARD]
nros setup <COMMAND>
Commands:
board Provision a downstream Zephyr consumer's tree for a nano-ros board
presets Write a project `CMakePresets.json` that includes the per-board presets `nros setup <board>` wrote. Then `cmake --preset <board>` works
help Print this message or the help of the given subcommand(s)
Arguments:
[BOARD]
Board to set up (resolves its toolchain/SDK package set from the index `[board.*]` table)
Options:
--list
List every package in the index + its version
--licenses
Show the license-gated packages + how to install them
--offline-dirs
Print the directories an air-gapped copy of this host's setup needs, one per line: the nros store, then the rustup and cargo homes the builds use (nros leaves Rust in rustup's own homes). Feed it to `tar`
--tool <NAME>
Install tools by name (instead of a board's whole set), e.g. `--tool qemu`. Repeatable, like `--source`: `--tool ninja --tool make` is ONE plan — one system-package ask for the union, one lock write. The `just <module> setup` recipes call this
--by-need
With `--tool`: install each named tool as its own plan, and let its index row's `need` decide what a failure means -- a `required` tool fails the run, an `opt-in` one prints a warning and the rest go on. What `just workspace cargo-tools` runs, so the recipe never states a tool's need a second time
--source <SOURCES>
Provision a single `[source.*]` package by name from the index.
E.g. `--source freertos-kernel`. Repeatable. The index is the SSOT — `dest`/`ref`/`submodule` come from data, never a hardcoded path. The `just <module> setup` recipes call this instead of inlining `git submodule update <path>`.
--build-sources
Provision the whole build-stage source union the repo's tests need.
That is what `just test` / `build-test-fixtures` need (every RMW's `-sys` source + the platform sources the workspace graph path-deps), independent of the per-board `nros setup <board>` slice. The index's top-level `build_sources` is the SSOT. With `--check`, only VERIFY they are present and name `nros setup --source <name>` per missing — the preflight the two recipes run.
--prefix <PREFIX>
Install prefix override (only with `--tool`): place the tool here instead of the shared store, e.g. `--prefix build/qemu` so the test harness finds it where it already looks. Layout is identical (`<prefix>/bin/…`)
--index <INDEX>
Path to the SDK index
[default: nros-sdk-index.toml]
--rmw <RMW>
RMW backend whose host daemon/tool to also provision.
Orthogonal to the board: `zenoh` | `xrce` | `cyclonedds`. Defaults to `zenoh`. Resolves `board.packages ∪ rmw.packages`.
--dry-run
Resolve + print the plan without fetching/building anything
--full
Provision full git history instead of the per-source shallow default (`--depth 1`). Use when you want `git log` / `blame` / branching in a provisioned source or submodule. Overrides the index `shallow` for this invocation only — no shared-file edit. (An already-shallow checkout is deepened in place with `git -C <path> fetch --unshallow`.)
--shallow
Force shallow (`--depth 1`) even for sources that set `shallow = false` in the index. The inverse of `--full`
--system
Print the native install command for the `[system.*]` OS packages.
Resolves the `[system.*]` OS-package closure for the detected package manager and prints the one native install command (never runs it without `--sudo`). With `--check`, run each entry's presence probe instead and exit non-zero if anything is missing (the doctor surface).
--workspace [<PATH>]
Provision from what this workspace declares.
Reads every `package.xml` under the path and answers three questions the tree already states: what the code depends on (`<depend>`), which builder must exist (`<build_type>` / `<buildtool_depend>`), and where it deploys (the `[image.<id>] board` of the `system.toml` beside a package.xml).
Prints the plan, then installs it: every image's board and RMW in one store plan, then the OS-package closure — installed with `--sudo`, otherwise printed as the command to run. `--check` stops after the plan. Plain `nros setup` inside a workspace means `--workspace .`.
--role <ROLE>
Narrow `--system` to keys of these roles (repeatable).
A scope's setup wants the HOST facts — `package` and `workspace` roles — and not `infra`: reporting every cross toolchain and emulator to someone provisioning `native` is noise, and noise is how a real missing package gets scrolled past.
--check
Run presence probes and report present/missing/unknown instead of installing/printing; exits 1 when anything is missing. With `--system`, probes only the `[system.*]` class; alone, walks EVERY declared class — `[system.*]`, `[rust.*]`, `[python.*]` — printing a remedy computed from each entry
--sudo
Execute the composed native install command instead of printing it.
With `--system`, runs the native install command (which invokes sudo where the manager needs it). With `--tool`, a tool declaring its own `[tool.<name>] system = [..]` build deps installs them instead of printing a line to copy. With `<board>` and `--workspace`, the board plan's one system ask (its tools' and `[source.*]`s' `system = [..]`) is installed before any download. Any other use is refused.
-j, --jobs <N>
How many packages to install at once.
Default: this host's CPU count; `NROS_SETUP_JOBS` overrides the default, and this overrides both.
Expect less than N times faster: the link saturates long before the cores do, and a tool built from source already uses the whole machine, so source builds run one at a time and the overlap that pays is one package's build or unpack beside another's download. Output stays per package and in plan order whatever the value.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros setup board
Provision a downstream Zephyr consumer's tree for a nano-ros board.
Fetches the board's RMW source, applies the zephyr-line patch set, adds the rust targets, and checks the `zephyr-lang-rust` pin — driven by the board's provisioning contract (`board.cmake` / `[package.metadata.nros.board]`).
Usage: nros setup board [OPTIONS] --zephyr-workspace <ZEPHYR_WORKSPACE> <NAME>
Arguments:
<NAME>
Board crate suffix (after `nros-board-`), e.g. `fvp-aemv8r-smp`
Options:
--zephyr-workspace <ZEPHYR_WORKSPACE>
The downstream consumer's Zephyr workspace dir (the tree containing `zephyr/` + `modules/lang/rust/`). The patch set is applied here
--workspace <WORKSPACE>
nano-ros SDK root (where the board crate, `scripts/zephyr/`, and `nros-sdk-index.toml` live). Default: `$NROS_WORKSPACE_ROOT`, a checkout enclosing cwd, then this `nros` binary's own SDK root
--index <INDEX>
Path to the SDK index (relative paths resolve against the nano-ros workspace root). The RMW source's `dest` is index-driven
[default: nros-sdk-index.toml]
--dry-run
Resolve + print the provisioning plan without fetching/patching
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros setup presets
Write a project `CMakePresets.json` that includes the per-board presets `nros setup <board>` wrote. Then `cmake --preset <board>` works
Usage: nros setup presets [DIR]
Arguments:
[DIR] Project directory to write `CMakePresets.json` into (default: current dir) [default: .]
Options:
-h, --help Print help
-V, --version Print version
Build
nros build
Build a nano-ros workspace.
Discovers packages, resolves the image, runs preflight, generates the root, and hands off to the native tool. The final stage is an `exec`, so compiler diagnostics are byte-identical to running cargo/cmake/west directly.
Usage: nros build [OPTIONS] [IMAGES]... [-- <NATIVE_ARGS>...]
Arguments:
[IMAGES]...
Image(s) to build — `linux`, or `<bringup>:linux` when two bringups declare the same id. Empty uses `[system] default_images`
[NATIVE_ARGS]...
Arguments after `--` go to the native tool verbatim
Options:
--workspace <WORKSPACE>
Workspace root. Defaults to the current directory
--nano-ros-path <NANO_ROS_PATH>
nano-ros SDK root holding `packages/boards`. Defaults to a walk-up from the workspace, then this `nros` binary's own SDK root
--zephyr-workspace <DIR>
The west workspace holding Zephyr — the directory that contains `zephyr/`. Zephyr images only.
The explicit rung of the resolution ladder, above `$ZEPHYR_BASE`, `$NROS_ZEPHYR_WORKSPACE`, the west workspace the project sits in (a `.west/` at or above it whose manifest names `zephyr`) and the store's workspace. An environment variable is ambient state that a user has to remember to set and cannot see in the command they ran; this makes the same fact reviewable in a script and in shell history.
Pointing it at the `zephyr/` directory itself also works — that is the commonest way to get this wrong, and both spellings name one place.
--all
Build every declared image
--board <BOARD>
Build the image whose `[image.*] board` is this board.
Matches the authored word (any case), any alias of the same board descriptor, or the `nros setup` index key the board provisions through (`nros build --board mps2-an385-baremetal` finds a `baremetal` image). One match builds exactly that image, as if it were named; several or none is refused, listing them — the image id stays the unit. Not with image arguments or `--all`.
--dry-run
Print the stages and the command that would run, then stop.
Safe by construction: a `Handoff` performs no I/O until `exec`. It still GENERATES (stage 4 writes each image's generated files), which regenerates an application without building it.
-v, --verbose
Also print the explanation behind each configure note.
That is: why a pass re-runs, why a size was not derived. Sets `NROS_VERBOSE=1` for every native command; a correct build without it prints one line per fact.
--explain-sizing
Print, in full, every sizing input the image leaves to a default.
A build prints them as one summary line; this names each one, why it was not derived, and what declaring it would take. `NROS_EXPLAIN_SIZING=1` asks the same of any road (a cmake or west configure).
--offline
Do not fetch anything; fail naming what is missing.
Note this is a SCOPED guarantee: stages 1–4 touch no network, and stage 5 gets the native tool's own offline spelling. It cannot promise an arbitrary user `CMakeLists.txt` refrains from fetching.
--packages-select <PKG>...
Only these packages — no dependencies, no dependents.
colcon's flag, with two differences: a name matching no package is an error, not a warning, and a selection that leaves out a package a selected one depends on is refused, since there is no install prefix for it to come from. That holds for every selection flag.
--packages-up-to <PKG>...
These packages and everything they depend on, transitively.
The selection flags compose as an INTERSECTION, which is colcon's composition too: each deselects independently, so adding one can only ever narrow the set.
--packages-above <PKG>...
These packages and everything that depends on them, transitively.
A package here that depends on a workspace package left out is refused, as for every selection flag; add `--packages-up-to` for its dependencies. A cargo member with no `package.xml` is refused here: its dependents name it only in their `Cargo.toml`, which the selection does not read.
--packages-skip <PKG>...
Leave these packages out
--base-paths <PATH>...
The workspace's source roots, relative to the workspace (default: `.`, plus `nros.toml` `package_paths`).
They replace the workspace and its `package_paths`, and nothing else: the nano-ros packages and `NROS_PACKAGE_PATH` stay on the search path. As in colcon, the roots are peers searched recursively, their order does not matter, a path repeated or inside another counts once, and a package name found in two of them is an error. A path that does not exist is an error; one that holds no package is a warning.
--continue-on-error
Keep building the other packages when one fails.
A package that depends on a failed one is skipped, as with colcon, and the command still exits non-zero, with the first failure's status. In a workspace with images, the unit is the image: each image is one merged build, so a failure inside it fails the whole image, and the next image is still attempted.
--cmake-args=<ARGS>
Arguments for every CMake configure: a cmake image's, a west image's, and a cmake package's. A cargo image runs no CMake configure and ignores them.
The `=` is required. The value is split with plain POSIX quoting (no expansion), so one flag can carry many arguments: `--cmake-args="-DA=1 -DB='x y'"`. The flag is repeatable, and the values add up in order. `--cmake-args=@<file>` reads one argument per line, with `#` comments. Allowed: `-D`, `-U`, `-W*`, `--log-level`, `--log-context`, `--debug-find`. A name `nros build` passes itself, or `-DCONFIG_*` (Zephyr Kconfig, which goes in the image's `conf`), is refused, saying where the setting goes. An image states its own in `[image.<id>.build] cmake_args`; these come after them.
--cargo-args=<ARGS>
Arguments for every cargo command of a cargo image. A CMake or west image ignores them.
Split and repeated like `--cmake-args=`, and `@<file>` works too. Allowed: `--features`, `--no-default-features`, `--all-features`, `-v`, `-q`, `--timings`, `--locked`, `--offline`, `--frozen`. In a workspace, name a feature with its package (`--features=<pkg>/<feat>`). A feature the build chooses itself (the RMW, the platform, a board or capability feature) is refused: choose those in `system.toml`.
--profile=<NAME>
Build with this profile instead of the image's `profile`.
It takes exactly what `[image.<id>] profile` takes: a cargo profile (`dev`, `release`, …) or a CMake build type (`Debug`, `Release`, …). It is a command-line spelling of that key for one build, not a new kind of profile.
-j, --jobs <N>
Run at most N jobs at once, in total. Default: the number of CPUs.
Every tool below `nros build` (cargo, make, ninja, west's cmake) shares one GNU make jobserver of N tokens, so packages compiling side by side still run N jobs in total, not N each. A package starts once every package it depends on has finished; images build one at a time, each drawing on the same N. Under a `make -jN` that already provides a jobserver, `nros build` joins it instead. Ninja older than 1.13 does not read a jobserver and runs at its own width; a warning names it.
--build-base <DIR>
Where each package's build directory goes: `<DIR>/<package>/`. Default: `build`, under the workspace.
Only for a workspace with no bringup. An image's generated tree has a fixed place under `build/`, which the cmake module and the image's other readers all expect, so moving it for one build would split them; it is refused there.
--check[=<TOOL>]
Type-check the image instead of building it: `cargo check`, or `cargo clippy` with `--check=clippy`.
Everything before the cargo command is the same as a build — the generated message crates, the `<pkg>_nros_selection` crate, the image's settings file and its lock — because none of it is optional for a check either: a leaf whose manifest names the selection crate cannot even be LOADED until sync has written it, so a bare `cargo check` in a fresh checkout fails at manifest parse with an error that never says why. Only the final verb changes, so a check here and a build here see one dependency graph.
Cargo images only; a cmake or west image is refused, since neither tool has a check that is not a build.
Possible values:
- check: `cargo check`
- clippy: `cargo clippy`. Lint flags go after a second `--`: `nros build --check=clippy -- -- -D warnings`
--allow-overriding <NAME>...
Let a package replace another provider of this name, for this build only.
colcon's flag. A replacement of the nano-ros provider nobody declared is refused for a runner or a command, and the same name in two source trees (the workspace and a `package_paths` entry) is refused for every kind; with this flag the later root wins. To make a choice permanent, add `<name> = "<package path>"` under `[workspace.overrides]` in `nros.toml` instead.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros configure
Configure a project: generate message bindings and the cargo patch config, then resolve and generate every image's build inputs.
The message bindings and patch config, then the stages `nros build` runs before it builds (discover, preflight, census, resolve, generate), under a per-project lock. Runs no target build tool. Records a stamp per image, so a rerun with nothing changed is a no-op. An image this host cannot build is skipped unless named.
Usage: nros configure [OPTIONS] [WORKSPACE]
Arguments:
[WORKSPACE]
Workspace root (the dir containing `src/`). Defaults to cwd
Options:
--generated-base <DIR>
Output dir for the generated message crates, relative to the workspace. Models and other sync output stay under `build/`
[default: generated]
--ros-edition <ROS_EDITION>
ROS 2 edition (`humble` | `iron` | `jazzy`).
When omitted, inherits `[system].ros_edition` from a `system.toml` at the workspace root, else `humble`.
--image <ID>
Single-package leaf only: sync for this `[image.<id>]`.
Covers its selection package, its `build/<id>/nros-cargo.toml`, and message codegen for its ROS edition. A leaf may declare one image per RMW and edition; without this flag the leaf's own rule applies (one image, or `[system] default_images`).
--dry-run
Don't write — just print what would happen
--check
Exit non-zero if any patch block is missing or stale (CI hook; also used by `nros ws status`)
-v, --verbose
Verbose codegen output
--nano-ros-root <DIR>
nano-ros source tree to scan as the FIRST provider search root.
The same root every provider lookup reads, so the provider index this writes is the one later commands read.
--base-paths <PATH>...
The workspace's source roots, relative to the workspace (default: `.`, plus `nros.toml` `package_paths`).
They replace the workspace and its `package_paths`, and nothing else: the nano-ros packages and `NROS_PACKAGE_PATH` stay on the search path. As in colcon, the roots are peers searched recursively, their order does not matter, a path repeated or inside another counts once, and a package name found in two of them is an error. A path that does not exist is an error; one that holds no package is a warning.
--no-provider-index
Skip the provider index entirely (`<ws>/build/nros/providers.json`).
The index is a CACHE for later commands, not an input to this sync, so a caller that will not read it can skip the scan outright. Same shape as `--no-metadata` above: name the expensive optional step and let the caller decline it.
--model-dir <MODEL_DIR>
Write resolved SystemModels here instead of into each bringup's `config/`.
This makes them build output rather than committed source. Consumers find them through the same search order (`nros_orchestration_ir::model_location`): export `NROS_MODEL_DIR` to the same path for the build.
--no-metadata
Skip the source-metadata refresh.
The refresh compiles a host probe per Node pkg, which is the slow part of a cold sync; skipping it leaves any existing sidecars untouched and makes bakes fall back to the SystemModel's entity lower bound.
--nano-ros-path <NANO_ROS_PATH>
The nano-ros SDK root the probes and board lookups read.
Defaults to a walk-up from the workspace, then this `nros` binary's own SDK root. It adds nothing to the patch block: the canonical shape carries nros-* runtime crates as path-deps in the user's own `[dependencies]`, so duplicating them there triggers cargo's "patch unused" warnings.
--offline
Never touch the network. Passed to the `cargo update --workspace` that prunes a single-package leaf's freshly seeded `Cargo.lock`, the one step of a sync that resolves crates
--force
Configure even when every image's stamp is current
--census [<BRINGUP:IMAGE>]
Take the entity census first: build the native image generated from the same launch file, run it, and record what it registers. Every image this configure covers, or only `BRINGUP:IMAGE`: the image whose build checks the census, usually a cross image, as in `nros build BRINGUP:IMAGE`. A plain configure only reports a census that is missing or stale, because taking one builds and runs a program
--migrate
Apply the known, reversible migrations first, printing every file moved and every key rewritten: a `system.toml` beside a package's code moves into a bringup package, and the project's contracts (`*.contract.yaml`) and `system.toml` files are rewritten from spellings the contract checker no longer reads to the current ones. A rewrite changes only the renamed keys; comments and layout stay. With an installed SDK, the project's `nros-sdk.lock` also accepts this release's pin for each vendored source and host tool it pinned differently, as `nros update --source` / `--tool` would
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros fix
Apply the mechanical remedies the build's refusals name; prints the change, and writes it with --apply
Usage: nros fix [OPTIONS] [PATH]
Arguments:
[PATH] The workspace (default: the current directory)
Options:
--apply Write the change; without it, only the diff prints
-h, --help Print help
-V, --version Print version
nros clean
Remove the generated bindings and the managed patch block from each Rust package. Leaves user-written sections alone
Usage: nros clean [OPTIONS] [WORKSPACE]
Arguments:
[WORKSPACE]
Options:
--build-dir <BUILD_DIR> [default: generated]
--dry-run Don't write — just print what would be removed
-h, --help Print help
-V, --version Print version
nros materialize
Take ownership of a generated entry package.
The last resort: `panic` and `profile` are declarations on the image and need no materialising. One way — `nros build` stops regenerating it.
Usage: nros materialize [OPTIONS] <IMAGE>
Arguments:
<IMAGE>
Image whose entry to materialise — `linux`, or `<bringup>:linux`
Options:
--workspace <WORKSPACE>
Workspace root. Defaults to the current directory
--nano-ros-path <NANO_ROS_PATH>
nano-ros checkout holding `packages/boards`
--force
Overwrite an entry that was already materialised.
Off by default: the whole point is that the builder stops touching it, and so should this verb. A second `materialize` without `--force` would otherwise silently discard the edits the first one existed to enable.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Run on a target
nros run
Run an image on its target: a host process or an emulator. Builds it if stale, starts the router it needs, streams its console and stops everything on exit. `--expect` grades the console; `--dry-run [--why]` prints the resolved plan instead. A hardware image is `nros flash --monitor`
Usage: nros run [OPTIONS] [IMAGE] [-- <PASSTHROUGH>...]
Arguments:
[IMAGE]
The image to run (`<image>` or `<bringup>:<image>`), as `nros build` names it. Omitted: the workspace's one image
[PASSTHROUGH]...
Arguments for the target, after `--`
Options:
--workspace <WORKSPACE>
Workspace root (auto-detected from cwd if omitted)
--nano-ros-path <NANO_ROS_PATH>
nano-ros checkout (auto-detected if omitted)
--dry-run
Print the resolved plan and run nothing
--why
Add the ladder rung that supplied each field
-v, --verbose
Also print the build's detail: the notes a correct build keeps quiet (as `nros build -v`)
--port <PORT>
The console device
--json
Print the plan as the JSON a runner is handed (`--plan`), not TOML
--exec <NAME>
The program to run, when the image's entry builds several, as in `ros2 run <pkg> <exe>`. Omitted: the one the bringup's launch file names for the entry package, or the entry's only program
--zephyr-workspace <DIR>
The Zephyr workspace the implicit `nros build` of a stale image uses, as `nros build --zephyr-workspace` takes it (and resolves it: the flag, then `$NROS_ZEPHYR_WORKSPACE`, then the project's and the store's)
--expect <TEXT>
Stop with exit 0 as soon as a console line contains TEXT; exit 1 if the target ends, or `--timeout` passes, first. Given more than once, every TEXT must appear, each on some line and in any order, and the run stops on the line that completes the set
--expect-regex <REGEX>
As `--expect`, with a regular expression over one console line. It may be repeated, and mixed with `--expect`: every pattern must match
--forbid <TEXT>
Fail with exit 1 as soon as a console line contains TEXT, before or after the expectation is met (a crash after the success line). Repeatable: any one of them fails the run
--forbid-regex <REGEX>
As `--forbid`, with a regular expression over one console line. Repeatable, and mixed with `--forbid`
--settle <SECONDS>
Once the expectation is met, keep watching for SECONDS before stopping with exit 0: a `--forbid` line or a failing exit inside the window still fails the run, and `console.log` holds the rest of the output. `--timeout` bounds the time to the match only, so the run can take up to `--timeout` + `--settle`
--timeout <SECONDS>
Stop the target after SECONDS
--router <auto|none|LOCATOR>
What serves the image's link on this host: `auto` starts the zenoh router or the XRCE agent when the link needs one here (reusing a zenoh router already listening there), `none` starts nothing, a locator names a router that is already running
[default: auto]
--prefix <CMD>
Run a host image under this command (`--prefix 'valgrind -q'`)
--plan <FILE>
Execute this plan file as written: resolve nothing, build nothing
--allow-overriding <NAME>...
Let a workspace package replace the nano-ros runner of this name, for this run only. A replacement nobody declared is refused; to make it permanent, add `[overrides] <name> = "<package path>"` to `system.toml` instead
--base-paths <PATH>...
The workspace's source roots, relative to the workspace (default: `.`, plus `nros.toml` `package_paths`).
They replace the workspace and its `package_paths`, and nothing else: the nano-ros packages and `NROS_PACKAGE_PATH` stay on the search path. As in colcon, the roots are peers searched recursively, their order does not matter, a path repeated or inside another counts once, and a package name found in two of them is an error. A path that does not exist is an error; one that holds no package is a warning.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros flash
Flash an image onto a real board: builds it if stale, runs the board's human steps, flashes, and with `--monitor` watches the console on the same port. `--expect` grades it; `--dry-run [--why]` prints the plan instead
Usage: nros flash [OPTIONS] [IMAGE] [-- <PASSTHROUGH>...]
Arguments:
[IMAGE]
The image to flash (`<image>` or `<bringup>:<image>`), as `nros build` names it. Omitted: the workspace's one image
[PASSTHROUGH]...
Arguments for the flasher, after `--`
Options:
--workspace <WORKSPACE>
Workspace root (auto-detected from cwd if omitted)
--nano-ros-path <NANO_ROS_PATH>
nano-ros checkout (auto-detected if omitted)
--dry-run
Print the resolved plan(s) and do nothing
--why
Add the ladder rung that supplied each field
--json
Print the plan as the JSON a runner is handed, not TOML
--port <PORT>
The board's serial device (else `NROS_PORT`, the bench file, or the one attached device matching the board)
--probe <PROBE>
The debug probe's serial number
--runner <RUNNER>
The flash method's own runner (`west flash --runner jlink`)
--no-prompt
Never wait for a person: a step that needs one fails instead
--monitor
After flashing, watch the board's console on the same port
--expect <TEXT>
Stop with exit 0 as soon as a console line contains TEXT; exit 1 if the target ends, or `--timeout` passes, first. Given more than once, every TEXT must appear, each on some line and in any order, and the run stops on the line that completes the set
--expect-regex <REGEX>
As `--expect`, with a regular expression over one console line. It may be repeated, and mixed with `--expect`: every pattern must match
--forbid <TEXT>
Fail with exit 1 as soon as a console line contains TEXT, before or after the expectation is met (a crash after the success line). Repeatable: any one of them fails the run
--forbid-regex <REGEX>
As `--forbid`, with a regular expression over one console line. Repeatable, and mixed with `--forbid`
--settle <SECONDS>
Once the expectation is met, keep watching for SECONDS before stopping with exit 0: a `--forbid` line or a failing exit inside the window still fails the run, and `console.log` holds the rest of the output. `--timeout` bounds the time to the match only, so the run can take up to `--timeout` + `--settle`
--zephyr-workspace <DIR>
The Zephyr workspace the implicit `nros build` of a stale image uses, as `nros build --zephyr-workspace` takes it
--timeout <SECONDS>
Stop after SECONDS: the console with `--monitor`, and any wait a prepare step makes
--router <auto|none|LOCATOR>
With `--monitor`: what serves the image's link on this host (`auto`, `none`, or a running router's locator)
[default: auto]
--plan <FILE>
Flash this plan file as written: resolve nothing, build nothing
--base-paths <PATH>...
The workspace's source roots, relative to the workspace (default: `.`, plus `nros.toml` `package_paths`).
They replace the workspace and its `package_paths`, and nothing else: the nano-ros packages and `NROS_PACKAGE_PATH` stay on the search path. As in colcon, the roots are peers searched recursively, their order does not matter, a path repeated or inside another counts once, and a package name found in two of them is an error. A path that does not exist is an error; one that holds no package is a warning.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros monitor
Attach to a running board's console: `--expect` grades it, `--send` writes to it. In a workspace the image's board states the port and baud; elsewhere `--port` names the device
Usage: nros monitor [OPTIONS] [IMAGE]
Arguments:
[IMAGE]
The image whose board to watch (`<image>` or `<bringup>:<image>`). Omitted: the workspace's one image, or none with `--port`
Options:
--workspace <WORKSPACE>
Workspace root (auto-detected from cwd if omitted)
--nano-ros-path <NANO_ROS_PATH>
nano-ros checkout (auto-detected if omitted)
--port <PORT>
The board's serial device (else `NROS_PORT`, the bench file, or the one attached device matching the board)
--baud <BAUD>
The serial baud rate (else the board's)
--expect <TEXT>
Stop with exit 0 as soon as a console line contains TEXT; exit 1 if the target ends, or `--timeout` passes, first. Given more than once, every TEXT must appear, each on some line and in any order, and the run stops on the line that completes the set
--expect-regex <REGEX>
As `--expect`, with a regular expression over one console line. It may be repeated, and mixed with `--expect`: every pattern must match
--forbid <TEXT>
Fail with exit 1 as soon as a console line contains TEXT, before or after the expectation is met (a crash after the success line). Repeatable: any one of them fails the run
--forbid-regex <REGEX>
As `--forbid`, with a regular expression over one console line. Repeatable, and mixed with `--forbid`
--settle <SECONDS>
Once the expectation is met, keep watching for SECONDS before stopping with exit 0: a `--forbid` line or a failing exit inside the window still fails the run, and `console.log` holds the rest of the output. `--timeout` bounds the time to the match only, so the run can take up to `--timeout` + `--settle`
--timeout <SECONDS>
Stop after SECONDS
--send <LINE>
Send LINE to the board once the console is open (repeatable)
--dry-run
Print the resolved plan and open nothing
--why
Add the ladder rung that supplied each field
--json
Print the plan as the JSON a runner is handed, not TOML
--base-paths <PATH>...
The workspace's source roots, relative to the workspace (default: `.`, plus `nros.toml` `package_paths`).
They replace the workspace and its `package_paths`, and nothing else: the nano-ros packages and `NROS_PACKAGE_PATH` stay on the search path. As in colcon, the roots are peers searched recursively, their order does not matter, a path repeated or inside another counts once, and a package name found in two of them is an error. A path that does not exist is an error; one that holds no package is a warning.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros bench
This machine's boards: `scan` records which attached USB device is which board in `$NROS_HOME/bench.toml`, `list` prints it with what is attached now. It supplies ports and probes, never test scope
Usage: nros bench <COMMAND>
Commands:
scan Record the attached devices whose USB id a board's `[board.console] usb` states, in `$NROS_HOME/bench.toml`
list Print the bench file and whether each device is attached now
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros bench scan
Record the attached devices whose USB id a board's `[board.console] usb` states, in `$NROS_HOME/bench.toml`
Usage: nros bench scan [OPTIONS]
Options:
--nano-ros-path <NANO_ROS_PATH> nano-ros checkout (auto-detected if omitted): whose board descriptors to match against
--dry-run Print what would be recorded and write nothing
-h, --help Print help
-V, --version Print version
nros bench list
Print the bench file and whether each device is attached now
Usage: nros bench list
Options:
-h, --help Print help
-V, --version Print version
nros debug
Debug an image on its target (reserved: not available yet)
Usage: nros debug
Options:
-h, --help Print help
-V, --version Print version
Workspace
nros list
List the workspace's packages: kind, name and directory per row
Usage: nros list [OPTIONS] [WORKSPACE]
Arguments:
[WORKSPACE]
Workspace root (cwd or first ancestor containing `src/`). Defaults to cwd
Options:
-t, --topological-order
List in build order, as `colcon list -t`. Default: sorted.
This and every flag below switch the listing to `colcon list`'s: one `name<TAB>path<TAB>(type)` line per package, found the way `nros build` finds them.
-n, --names-only
Print only each package's name, as `colcon list -n`
-p, --paths-only
Print only each package's path, as `colcon list -p`
--packages-select <PKG>...
Only these packages — no dependencies, no dependents.
colcon's flag, with two differences: a name matching no package is an error, not a warning, and a selection that leaves out a package a selected one depends on is refused, since there is no install prefix for it to come from. That holds for every selection flag.
--packages-up-to <PKG>...
These packages and everything they depend on, transitively.
The selection flags compose as an INTERSECTION, which is colcon's composition too: each deselects independently, so adding one can only ever narrow the set.
--packages-above <PKG>...
These packages and everything that depends on them, transitively.
A package here that depends on a workspace package left out is refused, as for every selection flag; add `--packages-up-to` for its dependencies. A cargo member with no `package.xml` is refused here: its dependents name it only in their `Cargo.toml`, which the selection does not read.
--packages-skip <PKG>...
Leave these packages out
--base-paths <PATH>...
The workspace's source roots, relative to the workspace (default: `.`, plus `nros.toml` `package_paths`).
They replace the workspace and its `package_paths`, and nothing else: the nano-ros packages and `NROS_PACKAGE_PATH` stay on the search path. As in colcon, the roots are peers searched recursively, their order does not matter, a path repeated or inside another counts once, and a package name found in two of them is an error. A path that does not exist is an error; one that holds no package is a warning.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros image
List the workspace's images, or show one: what it declares and what the build resolves for it
Usage: nros image <COMMAND>
Commands:
list List the workspace's images, as its bringups declare them
show Show one image: what it declares, and what the build resolves for it
check Check a built image. `--no-alloc` reports every allocation symbol it links, and exits 1 when there is one
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros image list
List the workspace's images, as its bringups declare them
Usage: nros image list [OPTIONS]
Options:
--workspace <WORKSPACE> Workspace root. Default: the workspace the current directory is in
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros image show
Show one image: what it declares, and what the build resolves for it
Usage: nros image show [OPTIONS] <IMAGE>
Arguments:
<IMAGE> The image, as `nros build` names it (`linux`, or `<bringup>:linux` when two bringups declare the same id)
Options:
--workspace <WORKSPACE> Workspace root. Default: the workspace the current directory is in
--json Print one JSON object instead of text
--nodes Print the nodes the image's plan will start
--topics Print the topics, services and actions the image's plan will create, and those its sizing descriptor records
--derived Print what the build derived for the image: its target, entity and type counts, each with the reason recorded for it
-h, --help Print help
-V, --version Print version
nros image check
Check a built image. `--no-alloc` reports every allocation symbol it links, and exits 1 when there is one
Usage: nros image check [OPTIONS] --no-alloc [IMAGE]
Arguments:
[IMAGE]
The image, as `nros build` names it. Default: the workspace's only image
Options:
--no-alloc
Report every allocation symbol the image links, by family: the C heap, the Rust allocator, C++ `operator new`, an RTOS heap
--tier <TIER>
What the image is held to
Possible values:
- heap-free: No allocation symbol at all, defined or referenced
- unified: Allocation only through the platform's allocator. Reads the build's objects, since a linked image no longer says who called `malloc`
[default: heap-free]
--elf <PATH>
Read this linked image instead of the one `nros build` made. May be given more than once
--objects <PATH>
With `--tier unified`: the objects, archives or build directories to read. Default: the image's build directory
--allow <SYMBOL=REASON>
Permit one symbol, with the reason: `--allow 'malloc=<why>'`
--workspace <WORKSPACE>
Workspace root. Default: the workspace the current directory is in
--json
Print one JSON object instead of text
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros graph
Print the workspace's packages in dependency order, each with the workspace packages it depends on
Usage: nros graph [OPTIONS]
Options:
--workspace <WORKSPACE> Workspace to scan. Defaults to the current directory
-h, --help Print help
-V, --version Print version
Interfaces
nros interface
Generate message bindings, list the interfaces the workspace can reach, or show one interface's definition
Usage: nros interface <COMMAND>
Commands:
generate Generate Rust / C / C++ message bindings from `package.xml`
list List the interface types the search path reaches
show Show an interface type's definition, nested types expanded
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros interface generate
Generate Rust / C / C++ message bindings from `package.xml`
Usage: nros interface generate [OPTIONS] <LANG>
Arguments:
<LANG>
Target language
Possible values:
- rust
- c
- cpp
- all: Generate Rust + C + C++ in one shot
Options:
--manifest <MANIFEST>
Path to `package.xml`
[default: package.xml]
-o, --output <OUTPUT>
Output directory for generated bindings
[default: generated]
--ros-edition <ROS_EDITION>
ROS 2 edition (`humble` | `iron` | `jazzy`)
[default: humble]
--codegen-config <CODEGEN_CONFIG>
Explicit per-field capacity config (`nros-codegen.toml`).
Wins over any file discovered by walking up from the manifest dir.
--force
Overwrite existing bindings
-v, --verbose
Verbose output
--generate-config
Generate `.cargo/config.toml` with `[patch.crates-io]` entries (Rust only)
--nano-ros-path <NANO_ROS_PATH>
Path to nros crates directory for generated Cargo config patches (Rust only)
--nano-ros-git
Use nros git repository for generated Cargo config patches (Rust only)
--rename <RENAME>
Rename a generated package: --rename old_pkg=new_crate_name (Rust only)
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros interface list
List the interface types the search path reaches
Usage: nros interface list [OPTIONS]
Options:
-m, --only-msgs Print only messages
-s, --only-srvs Print only services
-a, --only-actions Print only actions
--workspace <WORKSPACE> Workspace whose `src/` is searched first. Defaults to the current directory
-h, --help Print help
-V, --version Print version
nros interface show
Show an interface type's definition, nested types expanded
Usage: nros interface show [OPTIONS] <TYPE>
Arguments:
<TYPE> The type, as `<package>/<msg|srv|action>/<Name>`
Options:
--workspace <WORKSPACE> Workspace whose `src/` is searched first. Defaults to the current directory
-h, --help Print help
-V, --version Print version
Inspect
nros doctor
Health-check the workspace (SDK paths, toolchains, env)
Usage: nros doctor [OPTIONS]
Options:
--platform <PLATFORM>
Restrict the check to one module (e.g. `nuttx`, `zephyr`, `freertos`). Forwarded as `just <platform> doctor`
--board <BOARD>
Restrict the license-gate check to one board's package set.
When set, only `[gated.*]` entries listed in `[board.<name>].packages` are checked — keeps unrelated gated SDKs out of the report for board-scoped runs. The board's `board.cmake` `NROS_BOARD_GATED_PKGS` is the SSoT; `nros-sdk-index.toml` `[board.<name>].packages` mirrors it.
--workspace <WORKSPACE>
Path to the nano-ros workspace root (auto-detected if omitted)
--config <CONFIG>
Bringup `system.toml` (or a directory containing one) whose `[image.<id>]` and `[host.<name>]` blocks to health-check (a retired table is reported as a problem). When omitted, the cwd's `system.toml` is used if present
--report
Print the support status of every board the bringup's images name, and stop.
Reads the board support registry: a read-only report an adopter can file. Uses `--config`, else the cwd's `system.toml`.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros board
Inspect supported boards
Usage: nros board <COMMAND>
Commands:
list List every board key, with its crate, platform, support status and cadence
show Show one board: its support evidence and every table of its descriptor
info Print a board's resolved descriptor as JSON
new Scaffold a new board package
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros board list
List every board key, with its crate, platform, support status and cadence
Usage: nros board list [OPTIONS]
Options:
--workspace <WORKSPACE> nano-ros SDK root holding the board catalog. Default: `$NROS_WORKSPACE_ROOT`, a checkout enclosing cwd, then this `nros` binary's own SDK root (the installed track needs no flag)
--json Print one JSON object instead of a table
-h, --help Print help
-V, --version Print version
nros board show
Show one board: its support evidence and every table of its descriptor
Usage: nros board show [OPTIONS] <NAME>
Arguments:
<NAME> Board: a board key (`mps2-an385-freertos`), a package (`nros-board-zephyr`), a registry key (`nros-board-zephyr@Fvp`) or an evidence page name (`fvp`)
Options:
--workspace <WORKSPACE> nano-ros SDK root holding the board catalog. Default: `$NROS_WORKSPACE_ROOT`, a checkout enclosing cwd, then this `nros` binary's own SDK root
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros board info
Print a board's resolved descriptor as JSON
Usage: nros board info [OPTIONS] <NAME>
Arguments:
<NAME>
Board key.
Resolves to a board CRATE (`packages/boards/nros-board-<name>/`) or to a conf BUNDLE under a family crate (`packages/boards/nros-board-<family>/boards/<name>/`) — e.g. `fvp-aemv8r-smp` is `nros-board-zephyr/boards/fvp-aemv8r-smp/`.
Options:
--workspace <WORKSPACE>
nano-ros SDK root holding the board catalog. Default: `$NROS_WORKSPACE_ROOT`, a checkout enclosing cwd, then this `nros` binary's own SDK root
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros board new
Scaffold a new board package
Usage: nros board new [OPTIONS] --platform <PLATFORM> <NAME>
Arguments:
<NAME> Board key, kebab-case. Becomes the directory name, the canonical `names` entry and the announcement
Options:
--platform <PLATFORM> Platform this board runs on (`zephyr`, `freertos`, `nuttx`, `threadx`, `bare-metal`, `posix`, `esp32`)
--west-board <WEST_BOARD> Zephyr board id (`<board>/<soc>/<variant>`). Required for, and only meaningful on, `--platform zephyr`
--out-of-tree <OUT_OF_TREE> Write the package outside the nano-ros tree. The board is then reached through `$NROS_EXTRA_BOARD_PATH`, which this prints
--workspace <WORKSPACE> nano-ros checkout to write the in-tree board into (auto-detected from cwd if omitted). Not read with `--out-of-tree`, which needs no checkout
--dry-run Print what would be written and write nothing
-h, --help Print help
-V, --version Print version
nros platform
List the platforms boards build on, or show one: its boards and capabilities
Usage: nros platform <COMMAND>
Commands:
list List the platforms on the descriptor search path
show Show one platform: its names, parent, boards and capabilities
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros platform list
List the platforms on the descriptor search path
Usage: nros platform list [OPTIONS]
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros platform show
Show one platform: its names, parent, boards and capabilities
Usage: nros platform show [OPTIONS] <PLATFORM>
Arguments:
<PLATFORM> The platform, by its name or an alias (`freertos`, `bare-metal`)
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros rmw
List the RMW backends, or show one: its host side and its boards
Usage: nros rmw <COMMAND>
Commands:
list List every RMW backend and the boards it is verified on
show Show one RMW backend: its names, what it needs on the host, and its boards
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros rmw list
List every RMW backend and the boards it is verified on
Usage: nros rmw list [OPTIONS]
Options:
--json Print one JSON object instead of a table
--workspace <DIR> Workspace whose own RMW providers are listed too (default: the one the current directory is in, else the SDK's backends alone)
-h, --help Print help
-V, --version Print version
nros rmw show
Show one RMW backend: its names, what it needs on the host, and its boards
Usage: nros rmw show [OPTIONS] <NAME>
Arguments:
<NAME> The RMW name, as `rmw = "…"` spells it (e.g. `zenoh`)
Options:
--json Print one JSON object instead of text
--workspace <DIR> Workspace whose own RMW providers are searched too
-h, --help Print help
-V, --version Print version
nros runner
List the runners and extension commands this workspace reaches, or show one
Usage: nros runner <COMMAND>
Commands:
list List the runners and extension commands this workspace reaches
show Show one runner or extension command: its package, verbs and needs
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros runner list
List the runners and extension commands this workspace reaches
Usage: nros runner list [OPTIONS]
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros runner show
Show one runner or extension command: its package, verbs and needs
Usage: nros runner show [OPTIONS] <NAME>
Arguments:
<NAME> A runner (`qemu`), or a command as it is typed (`router`)
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros knob
List the knobs a project can state, or show one: where to state it, the values it takes and its default
Usage: nros knob <COMMAND>
Commands:
list List every knob a project can state: its name, scope, default and what it is for
show Show one knob: where to state it, the values it takes, its default and its help
render Render a package's rows as a view it commits: `--kconfig`, the Kconfig of a package that is its own Zephyr module
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros knob list
List every knob a project can state: its name, scope, default and what it is for
Usage: nros knob list [OPTIONS]
Options:
--json Print one JSON object instead of a table
--platform <PLATFORM> Resolve each knob's value for this platform, and say which rung of the platform/board ladder set it (`builtin`, `platform`, `board`, `env`)
--board-toml <FILE> With `--platform`: the board's `nros-board.toml`, for its rung
--workspace <DIR> The workspace whose packages are searched for their knobs (and, with `--platform`, its platform packages). Default: the current directory
-h, --help Print help
-V, --version Print version
nros knob show
Show one knob: where to state it, the values it takes, its default and its help
Usage: nros knob show [OPTIONS] <NAME>
Arguments:
<NAME> The knob, as `nros knob list` names it (e.g. `net.max_sockets`)
Options:
--json Print one JSON object instead of text
--workspace <DIR> The workspace whose packages are searched for their knobs (default: the current directory)
-h, --help Print help
-V, --version Print version
nros knob render
Render a package's rows as a view it commits: `--kconfig`, the Kconfig of a package that is its own Zephyr module
Usage: nros knob render [OPTIONS] --kconfig <PACKAGE>
Options:
--kconfig <PACKAGE> The package: a directory holding its `nros-knobs.toml`, or its `package.xml` name in the workspace's provider scan
--workspace <DIR> The workspace whose packages are searched (default: the current directory)
--out <FILE> Write here instead of stdout
-h, --help Print help
-V, --version Print version
nros code
List the diagnostic codes a refusal prints, or show one: what it reports and how to fix it
Usage: nros code <COMMAND>
Commands:
list List every diagnostic code with what it reports
show Show one code: what it reports, where it is raised, and how to fix it
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros code list
List every diagnostic code with what it reports
Usage: nros code list [OPTIONS]
Options:
--all List retired codes too
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros code show
Show one code: what it reports, where it is raised, and how to fix it
Usage: nros code show [OPTIONS] <CODE>
Arguments:
<CODE> The code, as a refusal prints it (`NROS-0001`)
Options:
--json Print one JSON object instead of text
-h, --help Print help
-V, --version Print version
nros config
Inspect or validate the current project's resolved configuration
Usage: nros config <COMMAND>
Commands:
show Print the resolved effective config for a bringup system (from its typed `system.toml`) with per-value provenance
explain Print the resolved BUILD-time knob ladder for a platform
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros config show
Print the resolved effective config for a bringup system (from its typed `system.toml`) with per-value provenance
Usage: nros config show [OPTIONS]
Options:
--system [<SYSTEM>]
The bringup pkg to resolve.
Omit (or pass with no value) to default to the workspace's `default_system` (or the sole bringup).
--format <FORMAT>
Output shape. `human` (default) is the provenance report; `cmake` emits a single `set(NROS_FEATURES ...)` line for `include()` from `nano_ros_workspace()` BEFORE nano-ros is imported
[default: human]
[possible values: human, cmake]
--image <ID>
`--format cmake`: the `[image.<id>]` being built (`-DNROS_IMAGE`). Its own `features` and `node_interfaces` join the system's, as on every other road. Absent, the `[system]` list answers
--workspace <WORKSPACE>
Workspace root for resolution (default: cwd)
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros config explain
Print the resolved BUILD-time knob ladder for a platform.
Shows every knob's final value plus the rung that set it (builtin / platform / board / env).
Usage: nros config explain [OPTIONS] --platform <PLATFORM>
Options:
--platform <PLATFORM>
Platform name (a directory under the platforms root, e.g. `zephyr`, `bare-metal`, `freertos-lwip`)
--board-toml <BOARD_TOML>
Optional board package `nros-board.toml` supplying `[knobs]` deltas (the ladder's board rung). Explicit path; registry-name resolution is a follow-up
--platforms-dir <PLATFORMS_DIR>
Platforms root. Pins the search to this one directory.
Default: `$NROS_PLATFORMS_DIR`, then the platform packages in the workspace, then the SDK's own platforms.
--workspace <WORKSPACE>
Workspace whose platform packages are searched (default: the current directory)
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros plan
Resolve launch files, manifests, and metadata into nros-plan.json
Usage: nros plan [OPTIONS] <SYSTEM_PKG> [LAUNCH_FILE] [LAUNCH_ARGS]...
Arguments:
<SYSTEM_PKG>
System package name used for build/<system_pkg>/nros output. A directory here, with no `<launch_file>`, is the bringup directory and names the package
[LAUNCH_FILE]
ROS 2 launch file to parse, or a package directory to resolve.
A directory is the discovery root for its resolved SystemModel. When omitted (`nros plan <bringup-dir>`), defaults to the `<system_pkg>` argument, treated as a directory path.
[default: ""]
[LAUNCH_ARGS]...
Launch arguments forwarded as name:=value or name=value
Options:
--record <RECORD>
Precomputed play_launch record.json to use instead of parsing launch_file
--model <system_model.yaml>
Plan from a resolved SystemModel (canonical). With a package-dir input, a committed `<dir>/config/system_model.yaml` is discovered automatically; this flag overrides with an explicit path
--workspace <WORKSPACE>
Workspace root containing colcon-like src/* packages
--out-dir <OUT_DIR>
Output root for orchestration artifacts
--metadata <METADATA>
Existing source metadata JSON artifact
--manifest <MANIFESTS>
ROS launch manifest YAML artifact
--rmw <RMW>
RMW override, the top of the precedence ladder.
`--rmw` > `[image.<t>].rmw` > `[system].rmw` > `zenoh`. Sets `plan.build.rmw` regardless of `system.toml` / the `[build].rmw` overlay.
--image <IMAGE>
Select the `[image.<id>]` the planner resolves per-target values against.
Those values are the RMW override, build tuning and the rustc triple. Omitted → the sole image `default_images` picks → target-agnostic.
--nano-ros-path <NANO_ROS_PATH>
nano-ros checkout holding `packages/boards`, used to derive the selected image's rustc triple from its board descriptor. Defaults to a walk-up from the workspace, then this `nros` binary's own SDK root — the same ladder `nros build` uses
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros check
Check a runner, command or board package, a plan, a system.toml or a workspace
Usage: nros check [OPTIONS] [PLAN]
Arguments:
[PLAN]
Path to nros-plan.json, a bringup `system.toml` (or a directory containing one), or a `<bringup>` pkg directory when `--bringup` is set. Or the name of a runner, command or board package.
A bare name (letters, digits, `_` and `-`) with no file or directory of that name here is a package: the check that package's kind needs runs. A runner or command is built, located and asked whether it speaks this nros's protocol; a board's descriptor is resolved through the board catalog, its announcement compared and its network and Zephyr projection resolved.
[default: build/nros/nros-plan.json]
Options:
--package-xml-drift <PACKAGE_XML_DRIFT>
Also check a package directory for generated `package.xml` drift (a generator-marked file edited by hand).
May be passed multiple times.
--bringup
Lint the `plan` argument as a `<bringup>` package directory.
Rejects `Cargo.toml`, `CMakeLists.txt`, `src/`, or any nested `add_executable(`. The bringup package must be pure declarative.
--workspace [<DIR>]
Walk a workspace root and run the workspace layout checks.
Checks `<pkg>::<Class>` enforcement on every `[[component]]` row, a stray `system.toml` next to a component pkg, and a per-pkg `.cargo/config.toml` carrying `[patch.crates-io]` (warn-only). When the flag is passed with no value the workspace defaults to the current directory.
--image <IMAGE>
Package form: the image whose run plan a runner check resolves. Omitted: the workspace's one image, if it has one
--allow-overriding <NAME>
Package form: approve an override of a nano-ros runner or command by this name
--no-build
Package form: check what is already built; do not run `nros build`
--nano-ros-path <NANO_ROS_PATH>
Package form: nano-ros checkout (auto-detected if omitted)
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros explain
Explain a diagnostic code, or render a generated nros-plan.json
Usage: nros explain [CODE_OR_PLAN]
Arguments:
[CODE_OR_PLAN] A diagnostic code (`NROS-NNNN`) or a plan path (an nros-plan.json) [default: build/nros/nros-plan.json]
Options:
-h, --help Print help
-V, --version Print version
Toolchain
nros toolchain
List, remove and garbage-collect installed toolchains and SDK packages
Usage: nros toolchain <COMMAND>
Commands:
list What the store holds: name, version, size, when it was last read
remove Remove one nano-ros toolchain from the store. Refuses while a known pin names the version — or while no pin file could be consulted at all
gc Propose (and, with `--delete`, perform) removal of unused store entries. Dry-run by default
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
nros toolchain list
What the store holds: name, version, size, when it was last read
Usage: nros toolchain list [OPTIONS]
Options:
--root <ROOT> Store root. Defaults to `$NROS_HOME`, else `~/.nros`
-h, --help Print help
-V, --version Print version
nros toolchain remove
Remove one nano-ros toolchain from the store. Refuses while a known pin names the version — or while no pin file could be consulted at all
Usage: nros toolchain remove [OPTIONS] <VERSION>
Arguments:
<VERSION> The toolchain version, exactly as `toolchains/<version>` spells it
Options:
--pin-file <PATH> An extra file whose contents pin versions. Repeatable
--ignore-pins Uninstall without consulting any pin file. You are asserting no project pins this version
--dry-run Report what would happen and remove nothing
--root <ROOT> Store root. Defaults to `$NROS_HOME`, else `~/.nros`
-h, --help Print help
-V, --version Print version
nros toolchain gc
Propose (and, with `--delete`, perform) removal of unused store entries. Dry-run by default
Usage: nros toolchain gc [OPTIONS] --older-than <DURATION>
Options:
--older-than <DURATION> Remove entries not read for at least this long: `90d`, `12h`, `2w`. A bare number is refused — say the unit
--delete Actually remove. Without it this only reports (the default)
--dry-run Report only. The default; accept it so the safe intent can be SPELLED rather than only implied, and so it can conflict with `--delete` instead of one of them silently winning
--pin-file <PATH> An extra file whose contents pin versions. Repeatable. Any string value in it protects an entry with that version
--ignore-pins Delete without consulting any pin file. You are asserting no project needs these
--root <ROOT> Store root (see `list --root`)
-h, --help Print help
-V, --version Print version
nros pin
Report this project's `nros-toolchain.toml`, or move it.
A bump reports the codegen delta between the two toolchains' declared `share/nros/manifest.toml` first, so an upgrade that would invalidate already-generated code warns before anything is written.
Usage: nros pin [OPTIONS] [VERSION]
Arguments:
[VERSION]
The store version to pin to, exactly as `toolchains/<version>` spells it (`0.7.9-nros1`) — not the crate version `nros --version` prints. Omit to report the current pin and change nothing
Options:
--rev <SHA>
Pin one commit instead: the full 40-hex sha. A branch, a tag or a short sha is refused, since none of them is sure to name the same commit tomorrow
--git <URL>
The repository `--rev` is a commit of. Default: the pin's current `git`, else the nano-ros repository
--path <DIR>
Pin a nano-ros checkout on this machine instead: the root of a clone. The pin records it relative to the pin file
--dir <PATH>
The project directory. Defaults to the working directory; the pin is searched for at or above it, the way cargo finds a workspace root
--root <PATH>
Store root. Defaults to `$NROS_HOME`, else `~/.nros`
--dry-run
Report the delta and write nothing
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros update
Move one pin, leaving one diff to review.
A pin is a registry crate (`--crate`), a vendored source (`--source`), a host tool (`--tool`) or a west project (`--west`).
With an installed SDK, the SDK's pins are the release and do not move: the project's own `nros-sdk.lock` does. `--source <name>` and `--tool <name>` accept this SDK's pin after an upgrade (no `--ref` or `--to-version`); `nros configure --migrate` accepts every one at once. `--crate <name>` records a project override. In a nano-ros checkout, each flag edits the checkout's pin set instead.
Usage: nros update [OPTIONS] <--pins|--crate <NAME>|--source <NAME>|--tool <NAME>|--west <MODULE>>
Options:
--pins
Regenerate the registry pin set from the locked roots as they stand — after a `cargo update` or a manifest edit in one root. Disagreements between roots are settled upward first
--prune
With `--pins`: also DROP every pinned range no locked root resolves and `locks/leaf-only-pins.toml` does not keep. Regeneration alone never drops a range, so a bump leaves the old one pinned
--crate <NAME>
A Rust registry crate. In a checkout: every locked root that uses it is re-resolved with `cargo update`, the roots are brought into agreement, and the pin set is regenerated from them. With an installed SDK: it is re-resolved in this project and recorded as a project override
--precise <VERSION>
The exact version to move to. Without it, cargo picks the newest semver-compatible one. A different MAJOR is a manifest edit first
--source <NAME>
A vendored source (`[source.<name>]`). With an installed SDK: the project's lock accepts this SDK's commit. In a checkout: with `--ref`, its submodule is checked out there and the index `ref` rewritten, forward only
--ref <SHA>
The commit for `--source` (a checkout only)
--allow-rewind
Let `--source` move a pin BACKWARDS (the submodule-pin rule forbids it otherwise; say why in the commit)
--tool <NAME>
A host tool (`[tool.<name>]`). With an installed SDK: the project's lock accepts this SDK's version. In a checkout: with `--to-version`, the row's version strings are rewritten and every dist artifact is downloaded to recompute its sha256
--to-version <VERSION>
The version for `--tool` (a checkout only)
--west <MODULE>
Move a Zephyr west project's revision in every manifest that lists it
--revision <REV>
The revision for `--west`
--nano-ros-path <NANO_ROS_PATH>
The nano-ros checkout whose pin set to edit (else the usual ladder)
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
nros locate
Print where a resource is, and with `--why`, which rung answered.
The cmake/just/shell front door to `nros_build_paths::locate`.
Usage: nros locate [OPTIONS] [NAMES]...
Arguments:
[NAMES]...
Resources to locate: a `[source.<name>]` of the index, or `store` / `nano-ros` for the two roots. `artifact <name>…` instead locates a cargo-built artifact (`c-archive`, `cpp-archive`, `c-include`, `cpp-include`, `c-config-header`, `cpp-config-header`); `tool <name>` a host binary (`nros-launch-resolve`, `renode`, or `qemu-system-<arch>` through the one QEMU ladder), the install directory of an SDK tool `nros setup <board>` provisioned (`tool zephyr-sdk`), `configured` where `nros configure` put an image's answer (with `--project` and `--image`), or `nuttx-cargo-config`, the cargo settings a NuttX make build with no project takes from its board (with `--target`, `--nuttx-board`, `--target-dir` and `--out`)
Options:
--all
Every `[source.*]` row. A row that resolves nowhere is skipped in batch output (and named on stderr), never invented
--why
Print every rung and what it saw
--format <FORMAT>
Possible values:
- path: The path alone (one name) or `name<TAB>path` lines
- sh: `NROS_LOCATE_<NAME>=<path>` lines, shell-quoted
- cmake: `set(NROS_LOCATE_<NAME> "<path>")` lines — normal variables, never CACHE
[default: path]
--index <INDEX>
Path to the SDK index
[default: nros-sdk-index.toml]
--target <TARGET>
`artifact` mode: the target triple the artifact was built for. Omit for a host build cargo ran without `--target`
--profile <PROFILE>
`artifact` mode: the cargo PROFILE (`dev`, `release`, a custom one)
[default: release]
--target-dir <TARGET_DIR>
`artifact` mode: the cargo target dir. Default: cargo's own answer for the nano-ros workspace (`CARGO_TARGET_DIR`, `[build] target-dir`, else `<root>/target`)
--placed-dir <PLACED_DIR>
`artifact` mode: the directory a build PLACED its config headers in.
REQUIRED for the header artifacts, which live only in cargo's `$OUT_DIR`; an archive is never placed, so naming one with this is refused.
--image <IMAGE>
`configured` mode: the image, by its configure key (an image id for a single-package leaf, `<bringup>:<id>` for a workspace)
--project <PROJECT>
The project whose `system.toml` `[sources]` is rung 3.
Default: `$NROS_WORKSPACE_ROOT`, else the nearest ancestor of the working directory that holds a `system.toml`.
--nuttx-board <NUTTX_BOARD>
`nuttx-cargo-config` mode: the kernel's `CONFIG_ARCH_BOARD`, which picks between boards that build for the same target
--out <OUT>
`nuttx-cargo-config` mode: the file to write. Its grandparent is the directory cargo resolves the file's relative paths against
--rmw <RMW>
`nuttx-cargo-config` mode (required): the RMW the kernel's Kconfig selects. Refused unless the NuttX make road can build it (a backend the image crate bundles); with `--project`, also checked against the project's image
--ros-edition <ROS_EDITION>
`nuttx-cargo-config` mode, with `--project`: the ROS edition the kernel's Kconfig selects, checked against the project's image
--kconfig <KCONFIG>
`nuttx-cargo-config` mode: the kernel's `.config`, named when its choices are refused or disagree with the image
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Other
nros version
Print toolchain + library versions
Usage: nros version
Options:
-h, --help Print help
-V, --version Print version
nros completions
Generate shell completions (bash | zsh | fish | powershell)
Usage: nros completions [OPTIONS] [SHELL]
Arguments:
[SHELL] The shell. Default: the one `$SHELL` names [possible values: bash, zsh, fish, powershell]
Options:
--static Print a generated script instead of the registration line: verbs and flags complete, names do not
-h, --help Print help
-V, --version Print version
Message Binding Generation
nros uses generated Rust bindings for ROS 2 message types. nros build generates no_std compatible bindings from each package’s package.xml dependencies before it builds (nros configure does that step alone, and nros interface generate rust the codegen alone).
Overview
The binding generator is part of the nros CLI and provides:
- Pure Rust,
no_stdcompatible output usingheaplesstypes - Automatic dependency resolution through your ROS 2 install’s ament index
- the
[patch.crates-io]rows that point the nano-ros runtime crates at the SDK root, written into the image’s generated build settings
Prerequisites
-
package.xml in each node package - Declares ROS interface dependencies
<?xml version="1.0"?> <package format="3"> <name>my_package</name> <version>0.1.0</version> <description>My nros package</description> <maintainer email="dev@example.com">Developer</maintainer> <license>Apache-2.0</license> <depend>std_msgs</depend> <depend>geometry_msgs</depend> <export> <build_type>ament_cargo</build_type> </export> </package> -
nros tool built + on PATH
Install a release;
install.shputsnrosin~/.nros/bin:curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh | sh export PATH="$HOME/.nros/bin:$PATH"See Installation for the full walkthrough.
-
A ROS 2 install, sourced for the first build
The bindings are generated from the message definitions of your ROS 2 install,
std_msgsincluded, so the generated layouts and type hashes match the ROS 2 nodes you talk to. Source it before the firstnros build,nros runornros configureof a project:source /opt/ros/humble/setup.bashThat configure records the prefix (
AMENT_PREFIX_PATH) in the project, and later configures reuse it, so later shells need not source ROS. With neither, configure refuses and names this step. A project whose packages depend on no message package at all needs no ROS 2.
What nros build does with message packages
Your own message, Tutorial 5, walks
through adding a message package to a workspace and using it from a node.
What follows is what the build does with each <depend>.
Before it builds, this will:
- Parse
package.xmlto find dependencies - Resolve transitive dependencies through the ament index
- Filter to interface packages (those with msg/srv/action)
- Generate bindings into the workspace’s
generated/directory - Resolve the bringup’s launch file into the system model
- Write each image’s build settings under
build/, carrying the board’s triple and flags, the resolved pool budgets, and the[patch.crates-io]rows for the nano-ros runtime crates
Each step is redone only when its inputs changed. To run them without building
(before opening the workspace in an IDE, for instance), use nros configure.
nros interface generate rust is the
codegen-only step underneath — steps 1–4 and nothing else — and is useful when
you want bindings without a workspace.
package.xml is the dependency list
A generated message crate is a path dependency on its own directory, and
nros build writes that row for you, before it plans: one
per <depend> / <build_depend> / <exec_depend> that names a message
package, tagged # nros-managed:
[dependencies]
std_msgs = { path = "../../generated/std_msgs", default-features = false } # nros-managed
example_interfaces = { path = "../../generated/example_interfaces", default-features = false } # nros-managed
So adding a message package is one edit — the <depend> — exactly as on the
C/C++ road, and deleting the <depend> deletes the row on the next build. A
row without the tag is yours: the build never edits or removes it, so deleting the
tag is how you take a row over. The nros row is not
managed — it carries a feature choice that is yours to make.
Never name a message crate by registry version (std_msgs = "*"): those
crates are generated per host from your ament install, they are not
published, and a bare name resolves against the public crates.io instead.
The nano-ros runtime crates are the other case — nros,
nros-board-<board>, the backends — and they are registry-named with
version = "*", because the build writes the [patch.crates-io] rows
that redirect them into the nano-ros SDK root.
Why msg crates are RMW-agnostic
Generated msg crates carry only the wire-format data type — no backend-specific code, no per-RMW Cargo feature. A user manifest is the plain pair:
[dependencies]
std_msgs = { path = "../../generated/std_msgs", default-features = false } # nros-managed
nros = { version = "*" }
Transport choice and message schema are orthogonal concerns and the
manifest reflects that. (Which backend you actually get is
[system] rmw in the bringup’s system.toml, not a feature you pick here — see
Switch the RMW per image.) This matches upstream rclcpp + rclrs, which
both ship msg packages RMW-agnostic and let the RMW pick which
descriptor representation it wants at runtime.
For DDS-based backends that need a per-type descriptor on the wire
(Cyclone DDS today), the nros-rmw-cyclonedds shim builds those
descriptors lazily on first pub/sub for a given message type,
walks the static field schema exposed by nros-serdes (the
Message trait with const TYPE_NAME + const FIELDS), and caches
the result in a bounded no_std registry. No per-msg-pkg backend
code is required.
The registry is bounded by the NROS_CYCLONEDDS_MAX_TYPES sizing knob.
Where the nano-ros sources come from
A project uses the SDK root the nros binary belongs to — a release’s
own share/nano-ros — so a plain nros build
works anywhere. To name a different SDK root, pass it:
nros build --nano-ros-path <sdk-root>
The build then writes the [patch.crates-io] rows into each image’s
generated settings, pointing each nros* requirement at a directory
in the SDK root. Nothing about the location is baked into a tracked file,
so moving the workspace, or installing another release, needs no edit: the
next build re-points it.
Use in code
#![allow(unused)]
fn main() {
use std_msgs::msg::Int32;
use example_interfaces::srv::{AddTwoInts, AddTwoIntsRequest, AddTwoIntsResponse};
let msg = Int32 { data: 42 };
}
Command Options
nros interface generate rust is the codegen step alone — it writes
bindings and nothing else:
nros interface generate rust [OPTIONS]
Options:
--manifest <PATH> Path to package.xml [default: package.xml]
-o, --output <DIR> Output directory [default: generated]
--ros-edition <EDITION> humble | iron | jazzy [default: humble]
--codegen-config <PATH> Explicit per-field capacity config (nros-codegen.toml)
--rename <OLD=NEW> Rename a generated package
--force Overwrite existing bindings
-v, --verbose Enable verbose output
It also still accepts --generate-config / --nano-ros-path /
--nano-ros-git, which write a .cargo/config.toml beside a package by hand.
Those are the old shape and are not the path to use: nros build writes the
patches into the generated settings instead, where they are regenerated
rather than committed.
Generated Output Structure
my_ws/
├── src/
│ ├── my_node/
│ │ ├── package.xml # Your dependency declarations
│ │ ├── Cargo.toml # Your package manifest (a library)
│ │ └── src/lib.rs # Your code using generated types
│ └── my_node_bringup/
│ ├── package.xml
│ └── system.toml # Board, RMW, components
├── generated/ # Generated bindings (do not edit)
│ ├── std_msgs/
│ │ ├── Cargo.toml
│ │ └── src/
│ │ ├── lib.rs # #![no_std]
│ │ └── msg/
│ │ ├── mod.rs
│ │ └── int32.rs
│ └── builtin_interfaces/ # Transitive dependency
│ └── ...
└── build/ # Build output (do not commit)
└── …/<image>_entry/ # each image's generated entry and
# its cargo settings, incl. the patches
Generated Code Features
no_std by default:
#![allow(unused)]
#![no_std]
fn main() {
pub mod msg;
}
std feature for optional std support:
[features]
default = []
std = ["nros-core/std", "nros-serdes/std"]
heapless types for embedded:
#![allow(unused)]
fn main() {
pub struct String {
pub data: heapless::String<256>,
}
pub struct Arrays {
pub data: heapless::Vec<i32, 64>,
}
}
Service types with Request/Response:
#![allow(unused)]
fn main() {
pub struct AddTwoInts;
pub struct AddTwoIntsRequest { pub a: i64, pub b: i64 }
pub struct AddTwoIntsResponse { pub sum: i64 }
impl RosService for AddTwoInts {
type Request = AddTwoIntsRequest;
type Reply = AddTwoIntsResponse;
}
}
A timestamp message gets SecNanosecMsg, so Time::to_ros_msg() can return
it:
#![allow(unused)]
fn main() {
impl nros_core::SecNanosecMsg for Time {
fn from_sec_nanosec(sec: i32, nanosec: u32) -> Self { Self { sec, nanosec } }
}
}
Emitted for every message whose field set is exactly { int32 sec, uint32 nanosec } — builtin_interfaces/msg/Time, its Duration twin, and any message
of yours with that shape. It is what makes the call a publisher writes work:
#![allow(unused)]
fn main() {
msg.header.stamp = node.now().to_ros_msg();
}
nros-core cannot name a message type — every generated crate depends on it, and
your message crates are generated from your packages — so the conversion is
implemented on the generated side and the trait is the seam. The C++ side spells
the same thing as a template (node.now().to_msg(msg.header.stamp)); Rust has no
structural bound, so it needs the named trait. There is no Result: nros’s
Time already is { sec, nanosec }, so nothing can fail. (rclrs returns
Result<_, TryFromIntError> because its Time is i64 nanoseconds; a ported
t.to_ros_msg()? will not compile here, and deleting the ? is the fix.)
Examples
Each example on GitHub is a workspace that carries its own bringup and resolves on its own, so it builds wherever it lives. Build each from its own root:
cd my_talker_ws && nros build
cd my_service_client_ws && nros build
Regenerating Bindings
To regenerate after ROS package updates or dependency changes:
nros interface generate rust --force
Where the definitions come from
nros build reads message definitions from the ROS 2 install you sourced
(or the one the project’s first configure recorded), through
AMENT_PREFIX_PATH. The release carries copies of a few standard packages,
but they only fill gaps under a ROS 2 install, never stand in for one: with
no prefix set and none recorded, configure refuses rather than build from
them, because they would silently fix a ROS 2 distro and the types would
stop matching a peer on another one. A message package in your own
workspace shadows the installed one of the same name.
A CMake or plain west application never runs nros configure, and it
follows the same rule. find_package(<pkg>) and nros_generate_interfaces
stop when neither NROS_INTERFACE_SEARCH_PATH nor AMENT_PREFIX_PATH names
the package. To build such an application from the bundled copies on
purpose, add their directory to NROS_INTERFACE_SEARCH_PATH (the error names
it: packages/cli/interfaces in the SDK root). A sourced ROS 2 install is
still read first.
Troubleshooting
“error[NROS-0001]: AMENT_PREFIX_PATH is unset, and … has no earlier configure that recorded one”
- This shell has not sourced ROS 2, and this project has never been
configured from one that had. Run
source /opt/ros/humble/setup.bash(or your overlay’sinstall/setup.bash), then build again.nros explain NROS-0001says the same offline.
“the message package X is on neither NROS_INTERFACE_SEARCH_PATH nor AMENT_PREFIX_PATH”
- A CMake or
westconfigure foundXonly in nano-ros’s bundled copies. Source ROS 2 (source /opt/ros/humble/setup.bash) and configure again, or opt in to the bundled copies by adding the directory the error names toNROS_INTERFACE_SEARCH_PATH.
“Package ‘X’ not found in ament index or bundled interfaces”
- Source the ROS 2 environment:
source /opt/ros/humble/setup.bash - Check package is installed:
ros2 pkg list | grep X - Install if missing:
sudo apt install ros-humble-X
Build errors with generated code
- Regenerate with
--forceflag - Check nros crate compatibility
Which CMake spelling (one table)
Five codegen entry points exist in the CMake surface. They are NOT interchangeable spellings of one thing — each serves one audience, and two are back-compat only. Pick by what you are doing:
| You are… | Use | Notes |
|---|---|---|
| Consuming an existing msg package from an app/node pkg | find_package(<pkg> REQUIRED) | The recommended default. The smart Find-stub resolves the package through the 3-layer search (workspace → ament → bundled) and generates bindings on the fly. Zero codegen calls in your file. |
| Defining msgs in a message package | rosidl_generate_interfaces(${PROJECT_NAME} msg/… DEPENDENCIES …) | Recommended — the stock ROS shape, intercepted by nano-ros. Your msg pkg carries zero nano-ros-specific lines and cross-builds under colcon unchanged. |
| Defining msgs and you want the nano-ros verb explicitly (or C bindings) | nano_ros_generate_interfaces(<name> <files…> [LANGUAGE C|CPP] [DEPENDENCIES …]) | The ament-shape alias. Defaults to LANGUAGE CPP like rosidl — pass LANGUAGE C for C. |
| Building a workspace root with several msg pkgs | nros_workspace_interfaces() after set(NROS_INTERFACE_SEARCH_PATH …/src) | Bulk-builds every workspace msg pkg in topological order; one line, no per-pkg add_subdirectory. |
Generating this pkg’s package.xml dependencies (no find_package flow) | nros_find_interfaces([LANGUAGE C|CPP] [SKIP_INSTALL]) | Consume-by-manifest: resolves the transitive interface closure of your own package.xml. Used by the workspace node pkgs. Defaults LANGUAGE CPP. |
| — | nros_generate_interfaces(<target> <files…>) | Deprecated for new code. The low-level generator everything above routes through; direct calls are back-compat only. |
C Code Generation (CMake)
nano_ros_generate_interfaces(… LANGUAGE C) generates C bindings for .msg, .srv,
and .action files (the function defaults to C++ — the LANGUAGE C
argument is what makes it the C generator). It uses a bundled codegen library — no external nros binary needed.
Prerequisites
nano_ros_generate_interfaces() becomes available automatically once
the consumer’s CMakeLists.txt invokes add_subdirectory(nano-ros).
The codegen tool ships inside the in-tree nros CLI binary
(packages/cli/target/release/nros; the old nros-codegen
submodule is retired); cmake auto-resolves it from
PATH / packages/cli/target/release/ / the transitional
${NROS_HOME:-~/.nros}/bin/. No separate build step.
Usage
For a complete example, see the features workspace,
examples/workspaces/features:
its custom_msgs package defines a message, and c_reading_talker_pkg and
c_reading_listener_pkg use the generated C bindings. The custom-message
feature demo is a node package there, with its own image row.
Design background
- RFC-0067: environment-invariant message dependency identity
- RFC-0130: one ROS 2 CMake build (supersedes RFC-0048)
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI. Feature demos as node packages of the features workspace.
What nros build Produces
nros build ends at an artifact and stops. It discovers your packages,
resolves the image, checks the toolchain, generates the root build file and the
entry, and then hands off to the native tool — cargo, cmake or west. The
tool runs as nros build’s child, with its output on your terminal as it
prints it, so the artifact is exactly the one that tool would have produced had
you run it yourself.
This page answers the question the build does not: what are you holding, and where is it?
Running it: nros run and nros flash
nros run starts an image whose board is a host process or an emulator: it
builds the image if it is stale, starts the router the image’s link needs,
streams the console and stops everything when it ends (--expect <text>
grades the console, --dry-run --why prints the plan it would execute). How a
board is launched is stated once, in its descriptor’s [board.run], so the
command nros build prints as its next step is the one nros run executes.
Real silicon is flashed, not run: nros run refuses a hardware image and
names nros flash --monitor. nros flash builds the image if stale, runs the
board’s human steps ([board.flash] prepare), flashes through the method its
descriptor’s [board.flash] names (west, or a command template), and
with --monitor watches the console on the same port; --expect <text>
grades it as nros run does. nros monitor opens the console of a board
that is already running. The port comes from --port, NROS_PORT, the bench
file (nros bench scan) or the one attached device that matches the board.
The commands quoted below are the board tooling’s, reproduced here as a reference for a board no flash method covers yet.
There is also no install step: nros build never runs cmake --install, writes
no install/ prefix and stages nothing. Whatever the native tool wrote in its
own build tree is the deliverable.
Where it lands
Which tool builds an image is decided by its platform and by whether the workspace crosses languages:
| platform / shape | driver | the artifact |
|---|---|---|
| Rust-only workspace, any non-Zephyr board | cargo | <ws>/build/<coordinate>/<image>_entry/target/[<triple>/]<profile>/<image>_entry |
| any workspace containing C or C++ | cmake | <ws>/build/<coordinate>/cmake/<image>_entry |
a zephyr board | west | <ws>/build/<coordinate>/<bringup>__<image>_west/zephyr/zephyr.{elf,bin,exe} |
The coordinate is the platform and the RMW — posix-zenoh,
freertos-cyclonedds — plus, for CMake, the board, because CMake pins one
compiler per configure and two boards on one platform would otherwise share a
cache: posix-zenoh-linux, freertos-zenoh-mps2-an385-freertos.
Everything above is under build/, and that is the rule rather than a
coincidence: a workspace has no root Cargo.toml and no root
CMakeLists.txt. It is a directory of packages, like a
colcon workspace, and every generated thing — the entry, the root build
file, the cargo settings, the compiled output — lives in build/.
After a successful build nros build prints the artifact itself, and the
board’s own command that runs or flashes it — never running either:
nros build: next for `c_talker_node_bringup:linux`:
artifact: /home/you/c_talker_ws/build/posix-zenoh-linux-c_talker_node_bringup-linux/cmake/linux_entry
run:
/home/you/c_talker_ws/build/posix-zenoh-linux-c_talker_node_bringup-linux/cmake/linux_entry
What the run: (or flash) line is depends on the board: the binary for a
host board, the board’s QEMU runner with the provisioned qemu-system-* for an
emulated one, nros run <image> / nros flash <image> for Zephyr, followed by
the same through west.
--dry-run and --check build nothing, so they print no such block.
One path the build also prints is easy to mistake for the binary:
nros build: entry → …/build/posix-zenoh/linux_entry
That is the generated entry package — source that nano-ros wrote for you,
under build/ because it is build output. The compiled program is elsewhere;
see below.
cargo
Every image gets its own cargo settings file,
build/<coordinate>/<entry>/nros-cargo.toml, and nros build points cargo at
it:
cargo build --manifest-path build/posix-zenoh/linux_entry/Cargo.toml \
--config build/posix-zenoh/linux_entry/nros-cargo.toml
That file states the image’s target-dir, so each image compiles into its
own tree rather than sharing one target/. It also carries the board’s
triple, linker flags and cross compiler, the resolved pool budgets as
[env], the in-repo [patch.crates-io] rows, and the nros-* build
profiles. It is generated on every build — read it, never edit it.
The artifact is the generated entry’s binary, inside that entry’s own target dir:
<ws>/build/<coordinate>/<image>_entry/target/[<triple>/]<profile-dir>/<image>_entry
The triple level appears whenever the board pins one — which it does in the
generated [build] target, not on your command line.
A Linux image on Cyclone DDS, for instance, is
build/posix-cyclonedds/linux_entry/target/debug/linux_entry.
<profile-dir> is debug unless the image declares
[image.<id>] profile = …, in which case it is that profile’s directory
(cargo’s rule: a profile builds into the directory of its own name, and dev
into debug).
Next step: on a host board, run it. It is an ordinary executable.
./build/linux/target/debug/talker
For a QEMU board, the generated settings file also carries that board’s
runner, so cargo run through the same --config boots the image —
see Build Profiles for driving cargo yourself.
A multi-process zenoh example also needs a router; that is ROS’s rmw_zenohd,
not something nano-ros ships — see
Deployment Workflow and
ROS 2 and the Zenoh router.
C, C++ and mixed workspaces (cmake)
CMake is chosen whenever the package graph contains anything that is not Rust,
on the host and when cross-compiling alike. The generated root is <ws>/build/<coordinate>/CMakeLists.txt,
it is configured into <ws>/build/<coordinate>/cmake/, and each image’s
executable lands at the top of that directory:
<ws>/build/<coordinate>/cmake/<image>_entry
The coordinate is <platform>-<rmw>, then the board when it is not the
platform, then a -cfg<hash> when the image states configuration, then the
bringup, and last the image. Each image gets its own directory and its own
Rust runtime, built and sized for exactly what that image declares: an image
that opts out of the stock node interfaces (node_interfaces = "none") does
not pay for them because another image beside it keeps them. The price is one
CMake configure and one runtime build per image.
For example, examples/workspaces/c builds [image.linux] to
build/posix-zenoh-linux-demo_bringup-linux/cmake/linux_entry and its FreeRTOS image to
build/freertos-zenoh-mps2-an385-freertos-demo_bringup-freertos/cmake/freertos_entry. (Node packages
also build their own executables, under cmake/pkg/<pkg>/<pkg>; the image is
the one at the top level.)
The file has no extension in either case. On the host it is a host executable;
for a cross board it is a statically linked ELF for that architecture — the
FreeRTOS one above is ELF 32-bit LSB executable, ARM, EABI5, statically linked.
Next step:
- host — run it directly.
- QEMU — the ELF is what
-kerneltakes, with the machine and CPU your board’s guide names. - hardware — hand the ELF to your flasher (
probe-rs, OpenOCD, a vendor tool). nano-ros has no opinion about which.
Zephyr (west)
nros build resolves your application and its overlays and runs west build
from the workspace root with each image’s OWN build directory,
<ws>/build/<coordinate>/<bringup>__<image>_west (west’s default,
build/ under the cwd, would put every image of a workspace in one tree and
refuse the second). Pass -- -d <dir> to choose another. Zephyr writes its image under
zephyr/ inside it; for demo_bringup:zephyr on zenoh:
<ws>/build/zephyr-zenoh/demo_bringup__zephyr_west/zephyr/zephyr.elf # always
<ws>/build/zephyr-zenoh/demo_bringup__zephyr_west/zephyr/zephyr.exe # native_sim — a host executable
<ws>/build/zephyr-zenoh/demo_bringup__zephyr_west/zephyr/zephyr.bin # cross targets — the raw image
<ws>/build/zephyr-zenoh/demo_bringup__zephyr_west/zephyr/zephyr.map # the link map
Which of .exe and .bin appears is Zephyr’s choice, not nano-ros’s: a
native_sim build produces zephyr.exe, a Cortex-M build produces
zephyr.bin.
Next step. nros build prints whichever of these the board supports.
nros run and nros flash work from the image’s workspace as printed.
Zephyr’s own verbs do the same against the image’s build directory, but west build and west flash are commands of the Zephyr west workspace: outside it
west refuses them (unknown command "build") unless ZEPHYR_BASE names that
workspace’s zephyr/, so nros build prints them with the ZEPHYR_BASE it
found.
# emulated boards
nros run demo_bringup:zephyr
ZEPHYR_BASE=~/.nros/workspaces/zephyr/3.7/zephyr west build -d build/zephyr-zenoh/demo_bringup__zephyr_west -t run
# hardware: the board's flash runner
nros flash demo_bringup:zephyr
ZEPHYR_BASE=~/.nros/workspaces/zephyr/3.7/zephyr west flash -d build/zephyr-zenoh/demo_bringup__zephyr_west
# native_sim: the executable itself
./build/zephyr-zenoh/demo_bringup__zephyr_west/zephyr/zephyr.exe
The -d is not optional here: without it west uses build/ under the
current directory, which is not where nros build put the image. west flash
picks its runner from the board’s own board.cmake; nano-ros adds nothing to
it.
Finding it yourself
When in doubt, ask the build what it is about to do. --dry-run prints the
stages and the exact command, and performs no I/O:
nros build <image> --dry-run
The tool named in that command owns the output location, and its own documentation is the authority — which is the whole point of handing off rather than wrapping.
For the generation side of this — which root file is written, why the entry is derived rather than hand-written, and what the coordinate directory holds — see How a build becomes an image.
The build’s log
Every build that reaches the native tool keeps what the tool printed, in
<tool>.log inside the image’s own build directory:
| driver | the log |
|---|---|
cargo | <ws>/build/<coordinate>/<image>_entry/target/cargo.log |
cmake | <ws>/build/<coordinate>/cmake/cmake.log |
west | <ws>/build/<coordinate>/<bringup>__<image>_west/west.log |
Each build replaces the file, so it always holds the last build. It is written in a terminal and in CI alike, where nothing is attached to a terminal.
nros build exits with the tool’s own status: a failing cmake --build
exits 2 under nros build as it does on its own. Ctrl-C stops the tool and
everything it started, and nros build exits 130.
When the link fails because the image does not fit a memory region, the build reads its log and ends with what the image reserves there. Troubleshoot shows that message and what to change.
The generated entry
| Part of the entry | Derived from |
|---|---|
the no_std / no_main shell | the board’s entry_kind |
board boilerplate (use panic_semihosting as _;, esp_app_desc!()) | the board descriptor’s entry.crate_root_extra |
nros::main!(launch = …, args = …) | the image |
nros::main! form | Meaning |
|---|---|
nros::main!(launch = "demo_bringup") | the bringup’s default launch file |
nros::main!(launch = "demo_bringup:sim.launch.xml") | a named launch file |
nros::main!(launch = "…:multihost.launch.xml", args = [("host", "robot1")]) | one host’s slice, by launch argument |
nros::main!(model = "demo_bringup") | deprecated: names the resolved model instead of its input |
nros::main!(board = X) | retired: a compile error |
On the CMake driver, the generated root holds one
nano_ros_add_executable(<name> BOARD … BRINGUP … LAUNCH … LANG … TYPED DEPLOY …)
per image, with no SOURCES: the verb generates the translation unit that
carries main. nano_ros_entry(NAME … LANG … BRINGUP … LAUNCH …) is the
hand-written spelling, in an entry taken over with nros materialize.
Measured footprint
Per (platform, transport, backend, profile), built from the in-tree
examples. RAM is data + bss, after --gc-sections. The release profile is
cargo’s default; the size profile is opt-level s, fat LTO and strip.
| Platform | Transport | Backend | Profile | text | data | bss | RAM |
|---|---|---|---|---|---|---|---|
| mps2-an385-baremetal (Cortex-M3) | ethernet (smoltcp) | zenoh-pico | release | 177.4 KB | 67.0 KB | 91.7 KB | 158.7 KB |
| mps2-an385-baremetal | ethernet | zenoh-pico | size | 158.3 KB | 67.0 KB | 91.7 KB | 158.7 KB |
| mps2-an385-baremetal | serial (no IP stack) | zenoh-pico | release | 128.6 KB | 25.2 KB | 75.8 KB | 101.0 KB |
| mps2-an385-baremetal | serial | zenoh-pico | size, with the size knobs | 116.1 KB | 25.2 KB | 75.8 KB | 101.0 KB |
| stm32f4 (Cortex-M4F) ¹ | ethernet | zenoh-pico | release | 186.9 KB | 13.7 KB | 123.0 KB | 136.7 KB |
| stm32f4 ¹ | ethernet | zenoh-pico | size | 138.1 KB | 13.7 KB | 123.0 KB | 136.7 KB |
| mps2-an385-freertos (lwIP) | ethernet | zenoh-pico | release | 240.6 KB | 10.7 KB | 3.3 MB ² | 3.3 MB |
| mps2-an385-baremetal | serial (custom transport) | XRCE-DDS | size, 24 KB heap, tight XRCE pools ³ | 60.3 KB | 25.2 KB | 8.8 KB | ~34 KB |
¹ Historical: the stm32f4 board crates have left the tree, so nothing in the
tree reproduces these rows.
² lwIP’s heap and the FreeRTOS task stacks: configured headroom, not nano-ros.
³ NROS_XRCE_STREAM_HISTORY=4, NROS_XRCE_CUSTOM_TRANSPORT_MTU=512,
NROS_XRCE_MAX_SUBSCRIBERS=1, NROS_XRCE_MAX_SERVICE_SERVERS=1,
NROS_XRCE_MAX_SERVICE_CLIENTS=1, NROS_XRCE_SUBSCRIBER_RING_DEPTH=1,
NROS_XRCE_BUFFER_BYTES=256.
Static heap (NROS_HEAP_SIZE, bare metal) | Peak working set | Recommended |
|---|---|---|
| zenoh-pico over TCP | ~16 KB | 24–32 KB |
| zenoh-pico over serial | below TCP | 16–24 KB |
| XRCE-DDS | ~3 KB | ~8 KB |
These are direct-mode figures. A nros::main! image needs the board’s
default heap, because its executor backing is one large allocation.
Static pool inventory
Every build-time sizing knob nano-ros reads, with the default it uses when you do not set it. Set them as environment variables at BUILD time.
This page exists because knowing a knob exists is the hard part. An audit of a 256 KB image found it already tuned nine of these and still carried ~145 KB of defaults it did not know to change — every knob it needed was already there. Four separate features had each added a static pool with a knob, silently.
Pools with a computed size
Bytes are at the DEFAULTS below, computed from the pool’s own declared
arithmetic (// nros-pool: in the source). Change a knob and the figure
moves with it.
| pool | bytes at default | formula | declared in |
|---|---|---|---|
LARGE_PAYLOADS | 131,072 (builtin — an image that declares its entities derives its own) | NROS_ZENOH_MAX_LARGE_SUBSCRIBERS * NROS_ZENOH_SUBSCRIBER_RING_DEPTH * NROS_ZENOH_SUBSCRIBER_LARGE_BYTES | packages/rmw/zenoh/nros-rmw-zenoh/src/shim/subscriber.rs:231 |
SLOTS | 8,192 (builtin — an image that declares its entities derives its own) | NROS_RMW_SUBSCRIBER_SLOTS * NROS_RMW_SUBSCRIBER_SLOT_BYTES | packages/rmw/cffi/src/rust_adapter.rs:128 |
SMALL_PAYLOADS | — (knob NROS_ZENOH_MAX_SUBSCRIBERS has a computed default) | NROS_ZENOH_MAX_SUBSCRIBERS * NROS_ZENOH_SUBSCRIBER_RING_DEPTH * NROS_SUBSCRIBER_BUFFER_BYTES | packages/rmw/zenoh/nros-rmw-zenoh/src/shim/subscriber.rs:230 |
SOCKET_RX_BUFFERS | — (knob NROS_NET_MAX_SOCKETS has a computed default) | NROS_NET_MAX_SOCKETS * NROS_NET_BUFFER_BYTES | packages/drivers/net/nros-smoltcp/src/bridge.rs:265 |
SOCKET_TX_BUFFERS | — (knob NROS_NET_MAX_SOCKETS has a computed default) | NROS_NET_MAX_SOCKETS * NROS_NET_BUFFER_BYTES | packages/drivers/net/nros-smoltcp/src/bridge.rs:266 |
UDP_SOCKET_RX_BUFFERS | — (knob NROS_NET_MAX_UDP_SOCKETS has a computed default) | NROS_NET_MAX_UDP_SOCKETS * NROS_NET_BUFFER_BYTES | packages/drivers/net/nros-smoltcp/src/bridge.rs:322 |
UDP_SOCKET_TX_BUFFERS | — (knob NROS_NET_MAX_UDP_SOCKETS has a computed default) | NROS_NET_MAX_UDP_SOCKETS * NROS_NET_BUFFER_BYTES | packages/drivers/net/nros-smoltcp/src/bridge.rs:323 |
Pools sized by a knob, measured per image
These statics move with the knobs beside them, but their element is a struct (or the region is a heap), so no formula over defaults can state their size exactly — and a guessed multiplier is the defect this page exists to avoid. The memory report (Static memory) gives each one’s exact bytes in the image you built, beside the knobs listed here.
| symbol | kind | sized by |
|---|---|---|
byte_pool_storage | heap | NROS_THREADX_BYTE_POOL_BYTES |
g_sessions | pool | NROS_ZENOH_GRAPH_CACHE_BYTES, NROS_ZENOH_MAX_LIVELINESS, NROS_ZENOH_MAX_PENDING_GETS, NROS_ZENOH_MAX_PUBLISHERS, NROS_ZENOH_MAX_QUERYABLES, NROS_ZENOH_MAX_SESSIONS, NROS_ZENOH_MAX_SUBSCRIBERS |
nros_log::early::SLOTS | pool | NROS_LOG_EARLY_RECORDS |
nros_log::pool::NAMES | pool | NROS_LOG_DYNAMIC_LOGGERS |
nros_log::pool::POOL | pool | NROS_LOG_DYNAMIC_LOGGERS |
nros_log::rosout::SLOTS | pool | NROS_LOG_ROSOUT_RECORDS |
nros_node::boot_report::NROS_BOOT_REPORT | pool | NROS_BOOT_REPORT |
nros_node::parameter_services::PARAM_INBOX | pool | NROS_PARAMS_SERVICE_INBOX_BYTES, NROS_PARAMS_SERVICE_INBOX_DEPTH |
nros_platform::zephyr_heap::HEAP | heap | NROS_MEMORY_HEAP_BYTES |
nros_rmw_cffi::MESSAGE_INFO_TABLE | pool | NROS_RMW_MESSAGE_INFO_SLOTS |
nros_rmw_cffi::NODE_TABLE | pool | NROS_RMW_MAX_NODES |
nros_rmw_cffi::REGISTRY | pool | NROS_RMW_MAX_BACKENDS |
nros_rmw_zenoh::shim::publisher::transient_local::TL_SLOTS | pool | NROS_ZENOH_MAX_TL_PUBLISHERS, NROS_ZENOH_TL_RETAIN_BYTES, NROS_ZENOH_TL_RETAIN_DEPTH |
nros_rmw_zenoh::shim::service::ACTION_INBOX | pool | NROS_ACTION_INBOX_BYTES, NROS_ACTION_INBOX_DEPTH |
nros_rmw_zenoh::shim::service::SERVICE_BUFFERS | pool | NROS_ZENOH_MAX_QUERYABLES, NROS_ZENOH_MAX_SESSIONS, NROS_ZENOH_SERVICE_BUFFER_BYTES |
nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX | pool | NROS_SERVICE_INBOX_BYTES, NROS_SERVICE_INBOX_DEPTH, NROS_ZENOH_MAX_QUERYABLES, NROS_ZENOH_MAX_SESSIONS |
nros_rmw_zenoh::shim::subscriber::SMALL_PAYLOADS | pool | NROS_SUBSCRIBER_BUFFER_BYTES |
nros_rmw_zenoh::shim::subscriber::SUBSCRIBER_BUFFERS | pool | NROS_ZENOH_MAX_SUBSCRIBERS |
nros_smoltcp::bridge::SOCKET_RX_BUFFERS | pool | NROS_NET_BUFFER_BYTES, NROS_NET_MAX_SOCKETS |
nros_smoltcp::bridge::SOCKET_TABLE | pool | NROS_NET_MAX_SOCKETS |
nros_smoltcp::bridge::SOCKET_TX_BUFFERS | pool | NROS_NET_BUFFER_BYTES, NROS_NET_MAX_SOCKETS |
nros_smoltcp::bridge::UDP_SOCKET_RX_BUFFERS | pool | NROS_NET_BUFFER_BYTES, NROS_NET_MAX_UDP_SOCKETS |
nros_smoltcp::bridge::UDP_SOCKET_TABLE | pool | NROS_NET_MAX_UDP_SOCKETS |
nros_smoltcp::bridge::UDP_SOCKET_TX_BUFFERS | pool | NROS_NET_BUFFER_BYTES, NROS_NET_MAX_UDP_SOCKETS |
ucHeap | heap | NROS_MEMORY_HEAP_BYTES |
Every sizing knob
Every knob says what it costs: a byte figure where a formula prices it, otherwise WHERE its bytes go and why no static figure exists. Nothing in this column is blank, and nothing here is free unless it says so.
| knob | default | read by | cost |
|---|---|---|---|
NROS_ACTION_INBOX_BYTES | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:169 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::service::ACTION_INBOX: slot bytes of each action-family inbox ring; the element is an InboxStorage struct (ring header + slots), so only the compiler knows the product |
NROS_ACTION_INBOX_DEPTH | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:175 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::service::ACTION_INBOX: ring depth of each action-family inbox; same InboxStorage element |
NROS_BOOT_REPORT | computed — see packages/core/nros-node/build.rs:405 | packages/core/nros-node | pool nros_node::boot_report::NROS_BOOT_REPORT: a switch, not a count: on (the native_sim default, and wherever CONFIG_NROS_BOOT_REPORT=y) it links the one boot-record static, measured per image by mem-report; off, it links nothing |
NROS_CAPABILITY_PARAM_SERVICES | computed — see packages/core/nros-params/build.rs:331 | packages/core/nros-params | executor: a switch: the bringup declares param_services (Zephyr Kconfig); like NROS_PARAM_STORE it makes the executor’s storage carve the parameter store; whether the six services’ sets and request/reply pair are carved too is the param-services cargo feature |
NROS_CLOCK_EPOCH_FAILURE | computed — see packages/tooling/nros-zephyr-build/src/clock_selection.rs:101 | packages/tooling/nros-zephyr-build | not-a-size: a choice: unstamped or halt when no wall-clock source answers; the posix and freertos ports’ builds read it for their resolution policy |
NROS_CLOCK_FALLBACK_SETTLE_MS | computed — see packages/tooling/nros-zephyr-build/src/clock_selection.rs:85 | packages/tooling/nros-zephyr-build | not-a-size: a time: how long each wall-clock source (here board) gets to answer; the posix and freertos ports’ builds read it for their resolution policy |
NROS_CLOCK_SOURCE | computed — see packages/platform/nros-platform/build.rs:110 | packages/platform/nros-platform | not-a-size: a choice: which wall-clock source(s) the image resolves at boot; nros-platform’s build script reads it only to refuse a source the port cannot resolve |
NROS_CLOCK_UPGRADE | computed — see packages/tooling/nros-zephyr-build/src/clock_selection.rs:100 | packages/tooling/nros-zephyr-build | not-a-size: a choice: whether an earlier listed wall-clock source may take over after boot; the posix and freertos ports’ builds read it for their resolution policy |
NROS_EXECUTOR_ACTION_CLIENTS | computed — see packages/tooling/nros-zephyr-build/knobs.toml:320 | packages/tooling/nros-zephyr-build | executor: action-client entries the executor arena is sized for |
NROS_EXECUTOR_ARENA_BYTES | computed — see packages/core/nros-node/build.rs:1240 | packages/core/nros-node | executor: the executor arena itself; the backing is EXECUTOR_BACKING (Rust) or the entry’s __nros_executor_storage / sched_task table (C/C++) |
NROS_EXECUTOR_BACKING_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:396 | packages/tooling/nros-zephyr-build | executor: STATES the boot executor’s backing size in words; EXECUTOR_BACKING is exactly 8x this |
NROS_EXECUTOR_EXTRA_SESSIONS | computed — see packages/core/nros-node/build.rs:685 | packages/core/nros-node | executor: extra-session slots (a session plus its id, 696 B each on thumbv7em with zenoh) carved from the executor backing, at most one per node: backend_count - 1 from the sizing descriptor, else one per node |
NROS_EXECUTOR_MAX_CBS | computed — see packages/tooling/nros-zephyr-build/src/lib.rs:1581 | packages/tooling/nros-zephyr-build | executor: callback slots inside the executor |
NROS_EXECUTOR_MAX_NODES | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:402 | packages/rmw/zenoh/nros-rmw-zenoh | executor: node slots inside the executor; the zenoh backend also sizes its per-node liveliness cap from it |
NROS_EXECUTOR_MAX_SC | computed — see packages/tooling/nros-zephyr-build/src/lib.rs:1592 | packages/tooling/nros-zephyr-build | executor: sched-context slots inside the executor |
NROS_EXECUTOR_MAX_SHUTDOWN_CBS | 2 | packages/core/nros-node | executor: shutdown-callback slots inside the executor |
NROS_EXECUTOR_MAX_VIOLATIONS | 8 | packages/core/nros-node | executor: violation-ring slots carved from the executor backing (24 B each on a 32-bit target); with the boot report it also sizes the NROS_VIOLATION_RECORD static (40 B + 28 B a slot), measured per image by mem-report |
NROS_EXECUTOR_PARAM_SERVICE_BUFFER_BYTES | computed — see packages/core/nros-node/build.rs:551 | packages/core/nros-node | executor: request/reply buffers of the builtin parameter and lifecycle services, held in the executor’s value |
NROS_EXECUTOR_RUNTIME_REMAPS | computed — see packages/core/nros-node/build.rs:700 | packages/core/nros-node | executor: runtime remap-table slots carved from the executor backing (404 B each on a 32-bit target): --ros-args -r and hand-declared rules; 16 with process arguments, 0 on bare metal; the launch’s rules are a flash table |
NROS_EXECUTOR_SUBSCRIPTION_BUFFER_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:712 | packages/tooling/nros-zephyr-build | executor: each subscription’s receive buffer inside the executor arena (DEFAULT_RX_BUF_SIZE) |
NROS_LOG_BUFFER_BYTES | computed — see packages/core/nros-log/build.rs:101 | packages/core/nros-log | stack: the per-call Rust FormatBuffer is a stack frame in the logging caller; it is also the message element of nros_log::early::SLOTS and nros_log::rosout::SLOTS |
NROS_LOG_DYNAMIC_LOGGERS | computed — see packages/core/nros-log/build.rs:95 | packages/core/nros-log | pool nros_log::pool::POOL, nros_log::pool::NAMES: runtime-logger slots: POOL holds a Logger per slot, a struct whose size moves with its fields; NAMES is exactly 24 bytes per slot, so mem-report reads the image’s CAPACITY back out of its size |
NROS_LOG_EARLY_RECORDS | computed — see packages/core/nros-log/build.rs:108 | packages/core/nros-log | pool nros_log::early::SLOTS: records held before init: each slot holds a formatted message of NROS_LOG_BUFFER_BYTES bytes plus a logger name, so SLOTS moves with both knobs; 0 declines the ring |
NROS_LOG_MAX_LEVEL | computed — see packages/core/nros-log/build.rs:124 | packages/core/nros-log | not-a-size: the compile-time severity CEILING: a threshold, not a count; a lower ceiling can only REMOVE code (Rust call sites below it fold away), never add storage |
NROS_LOG_ROSOUT_RECORDS | computed — see packages/core/nros-log/build.rs:115 | packages/core/nros-log | pool nros_log::rosout::SLOTS: the /rosout queue, linked only with nros-node/rosout: each slot holds a message of NROS_LOG_BUFFER_BYTES bytes plus a logger name |
NROS_MEMORY_APP_STACK_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:877 | packages/tooling/nros-zephyr-build | stack: the application task’s stack, which FreeRTOS allocates out of ucHeap and ThreadX out of its byte pool — inside that heap’s or pool’s figure, never a symbol of its own |
NROS_MEMORY_HEAP_BYTES | computed — see packages/platform/nros-platform/build.rs:67 | packages/platform/nros-platform | heap nros_platform::zephyr_heap::HEAP, ucHeap: the platform heap: on Zephyr the rlsf arena both zenoh-pico’s z_malloc and Rust’s allocator draw from, on FreeRTOS heap_4’s ucHeap[configTOTAL_HEAP_SIZE]; the symbol IS the region, measured per image |
NROS_MONITOR_ARM_GRACE_MS | 0 | packages/core/nros-node | not-a-size: a time: arm the contract monitors this long after the first spin |
NROS_MONITOR_ARM_ON_CALL | computed — see packages/core/nros-node/build.rs:728 | packages/core/nros-node | not-a-size: a switch: whether contract monitors wait for the application’s arm call |
NROS_MULTIGOAL_GOALS | computed — see packages/testing/nros-tests/bins/action-client-multigoal/src/action-client-multigoal/src/main.rs:132 | packages/testing/nros-tests/bins/action-client-multigoal/src/action-client-multigoal | test-only: action-client-multigoal test binary |
NROS_MULTIGOAL_SOAK_MS | 0 | packages/testing/nros-tests/bins/action-client-multigoal/src/action-client-multigoal | test-only: action-client-multigoal test binary |
NROS_NET_BUFFER_BYTES | computed — see packages/drivers/net/nros-smoltcp/build.rs:54 | packages/drivers/net/nros-smoltcp | sizes SOCKET_RX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_SOCKETS has a computed default); sizes SOCKET_TX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_SOCKETS has a computed default); sizes UDP_SOCKET_RX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_UDP_SOCKETS has a computed default); sizes UDP_SOCKET_TX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_UDP_SOCKETS has a computed default); pool nros_smoltcp::bridge::SOCKET_RX_BUFFERS, nros_smoltcp::bridge::SOCKET_TX_BUFFERS, nros_smoltcp::bridge::UDP_SOCKET_RX_BUFFERS, nros_smoltcp::bridge::UDP_SOCKET_TX_BUFFERS: per-socket buffer bytes; formula-priced, but the default is computed per platform |
NROS_NET_CONNECT_TIMEOUT_MS | computed — see packages/drivers/net/nros-smoltcp/build.rs:57 | packages/drivers/net/nros-smoltcp | not-a-size: milliseconds |
NROS_NET_MAX_SOCKETS | computed — see packages/drivers/net/nros-smoltcp/build.rs:45 | packages/drivers/net/nros-smoltcp | sizes SOCKET_RX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_SOCKETS has a computed default); sizes SOCKET_TX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_SOCKETS has a computed default); pool nros_smoltcp::bridge::SOCKET_RX_BUFFERS, nros_smoltcp::bridge::SOCKET_TX_BUFFERS, nros_smoltcp::bridge::SOCKET_TABLE: TCP socket count; the byte buffers carry nros-pool: formulas, the socket table’s element is a struct |
NROS_NET_MAX_UDP_SOCKETS | computed — see packages/drivers/net/nros-smoltcp/build.rs:51 | packages/drivers/net/nros-smoltcp | sizes UDP_SOCKET_RX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_UDP_SOCKETS has a computed default); sizes UDP_SOCKET_TX_BUFFERS — not priceable at defaults (knob NROS_NET_MAX_UDP_SOCKETS has a computed default); pool nros_smoltcp::bridge::UDP_SOCKET_RX_BUFFERS, nros_smoltcp::bridge::UDP_SOCKET_TX_BUFFERS, nros_smoltcp::bridge::UDP_SOCKET_TABLE: UDP socket count; byte buffers formula-priced, the table’s element is a struct |
NROS_NET_SOCKET_TIMEOUT_MS | computed — see packages/drivers/net/nros-smoltcp/build.rs:60 | packages/drivers/net/nros-smoltcp | not-a-size: milliseconds |
NROS_PARAMS_EVENTS_DEPTH | computed — see packages/core/nros-params/build.rs:174 | packages/core/nros-params | not-a-size: a QoS history depth handed to the RMW when the /parameter_events publisher is created; what it costs is the backend’s (a reliable DDS writer’s history), not a nano-ros pool |
NROS_PARAMS_MAX_ARRAY_LEN | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1117 | packages/tooling/nros-zephyr-build | element: bounds an array parameter value; paid by every ParameterValue, i.e. every slot |
NROS_PARAMS_MAX_BYTE_ARRAY_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1143 | packages/tooling/nros-zephyr-build | element: bounds a byte-array parameter value; paid by every ParameterValue, i.e. every slot |
NROS_PARAMS_MAX_CONSTRAINTS_BYTES | computed — see packages/core/nros-params/build.rs:158 | packages/core/nros-params | element: bounds a parameter descriptor’s constraints text inside every ParameterStorage slot |
NROS_PARAMS_MAX_DESCRIPTION_BYTES | computed — see packages/core/nros-params/build.rs:132 | packages/core/nros-params | element: bounds a parameter descriptor’s description inside every ParameterStorage slot |
NROS_PARAMS_MAX_NAME_BYTES | computed — see packages/core/nros-params/build.rs:67 | packages/core/nros-params | element: bounds a parameter NAME inside every parameter-store slot (executor storage or heap, see NROS_PARAMS_MAX_PARAMETERS) |
NROS_PARAMS_MAX_PARAMETERS | computed — see packages/core/nros-params/build.rs:59 | packages/core/nros-params | executor: slots of the parameter store. CARVED into the executor’s storage when the build implies a store (NROS_PARAM_STORE / NROS_CAPABILITY_PARAM_SERVICES / a contract params:), so mem-report’s [executor storage] prices it; otherwise boxed on the heap once per executor that declares |
NROS_PARAMS_MAX_STRING_ARRAY_LEN | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1284 | packages/tooling/nros-zephyr-build | element: bounds a string-array parameter value (elements; each a MAX_STRING_VALUE_LEN string); paid by every ParameterValue, i.e. every slot |
NROS_PARAMS_MAX_STRING_VALUE_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1313 | packages/tooling/nros-zephyr-build | element: bounds a string parameter VALUE — ParameterValue is sized by its largest variant, so this is paid by every slot |
NROS_PARAMS_SERVICE_INBOX_BYTES | 0 | packages/rmw/xrce | pool nros_node::parameter_services::PARAM_INBOX: slot bytes of the parameter-service inbox ring (CallerInboxStorage element) |
NROS_PARAMS_SERVICE_INBOX_DEPTH | 1 | packages/core/nros-node | pool nros_node::parameter_services::PARAM_INBOX: ring depth of the parameter-service inbox (CallerInboxStorage element) |
NROS_PARAM_STORE | computed — see packages/core/nros-params/build.rs:332 | packages/core/nros-params | executor: a switch: the image builds a parameter store, so the executor’s storage carves NROS_PARAMS_MAX_PARAMETERS slots of it; off, the store costs the backing nothing |
NROS_PUBSUB_QOS_DEPTH | computed — see packages/core/nros-node/build.rs:995 | packages/core/nros-node | executor: the per-subscription receive queue depth the arena budgets for; derived from the declared QoS where an image states one |
NROS_RMW_MAX_BACKENDS | 8 | packages/rmw/cffi | pool nros_rmw_cffi::REGISTRY: backend slots in the RMW registry; the element is a BackendSlot struct |
NROS_RMW_MAX_NODES | 4 | packages/rmw/cffi | pool nros_rmw_cffi::NODE_TABLE: node slots in the RMW node table; the element is a NodeSlot struct |
NROS_RMW_MESSAGE_INFO_SLOTS | 64 | packages/rmw/cffi | pool nros_rmw_cffi::MESSAGE_INFO_TABLE: message-info slots; the MessageInfoSlot element gains fields under alloc + safety-e2e, so a constant would be right for one build |
NROS_RMW_SUBSCRIBER_SLOTS | 8 | packages/rmw/cffi | prices SLOTS (8,192 B at defaults); default DERIVED per image when it declares its entities |
NROS_RMW_SUBSCRIBER_SLOT_BYTES | 1024 | packages/rmw/cffi | prices SLOTS (8,192 B at defaults) |
NROS_RT_SCHED_CPU | 0 | packages/testing/nros-tests | test-only: rt_sched_levels_e2e: the CPU its pinned runs use (default 0) |
NROS_RUNTIME_COMPONENT_SLOT_BYTES | 512 | packages/api/nros | component: byte budget of each component slot (TypedSlot<C>) |
NROS_RUNTIME_MAX_CELL_ENTITIES | 8 | packages/api/nros | component: entity-registry slots per component cell |
NROS_RUNTIME_MAX_CLASS_INSTANCES | 2 | packages/api/nros | component: instances one component class’s macro-emitted store (__NROS_COMPONENT_<pkg>_SLOT_STORE) holds |
NROS_RUNTIME_MAX_COMPONENTS | 4 | packages/api/nros | component: component slots of the runtime’s type-erased pool |
NROS_SERVICE_INBOX_BYTES | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:162 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX: slot bytes of each user-service inbox ring (InboxStorage element); its default is DERIVED from the declared request types, so no static figure exists either |
NROS_SERVICE_INBOX_DEPTH | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:168 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX: ring depth of each user-service inbox (InboxStorage element) |
NROS_SERVICE_TIMEOUT_MS | computed — see packages/tooling/nros-platform-config/src/platform_config.rs:1943 | packages/tooling/nros-platform-config | not-a-size: milliseconds |
NROS_SUBSCRIBER_BUFFER_BYTES | computed — see packages/core/nros-node/build.rs:925 | packages/core/nros-node (conflicting defaults — see below) | sizes SMALL_PAYLOADS — not priceable at defaults (knob NROS_ZENOH_MAX_SUBSCRIBERS has a computed default); pool nros_rmw_zenoh::shim::subscriber::SMALL_PAYLOADS: the small payload class (formula-priced); read by two crates with two defaults — the page flags that; default DERIVED per image when it declares its entities |
NROS_THREADX_BYTE_POOL_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | heap byte_pool_storage: ThreadX’s byte pool, the port’s whole allocator (byte_pool_storage[BYTE_POOL_SIZE] in threadx_hooks.c); derived as the app stack plus the RMW’s measured working set unless stated; the symbol IS the region, measured per image |
NROS_TRACE_TAKES | computed — see packages/core/nros-node/build.rs:737 | packages/core/nros-node | not-a-size: a switch: whether the callback trace emits a take event per subscription sample |
NROS_TRACE_TIMER_EVERY | 1 | packages/core/nros-node | not-a-size: a ratio: one timer tick in N keeps its callback-trace start/end pair |
NROS_VIOLATION_DRAIN_REPORT | computed — see packages/core/nros-node/build.rs:719 | packages/core/nros-node | not-a-size: a switch: whether a new executor drains its violation ring every spin and logs each entry |
NROS_XRCE_BUFFER_BYTES | 1024 | packages/rmw/xrce | heap: the default the three XRCE buffer sizes above alias to |
NROS_XRCE_BUILTIN_SERVICE_REQUEST_BUFFER_BYTES | 1024 | packages/rmw/xrce | heap: request buffer of each builtin-family server slot inside xrce_session_state_t |
NROS_XRCE_BUILTIN_SERVICE_SERVERS | 0 | packages/rmw/xrce | heap: how many service-server slots inside xrce_session_state_t are the parameter / lifecycle family’s, each with its own request ring |
NROS_XRCE_CUSTOM_TRANSPORT_MTU | 4096 | packages/rmw/xrce | heap: the custom-transport twin of NROS_XRCE_TRANSPORT_MTU |
NROS_XRCE_GRAPH_RESYNC_MS | 5000 | packages/rmw/xrce | not-a-size: a time: how often an XRCE session re-creates its ros_discovery_info reader |
NROS_XRCE_MAX_SERVICE_CLIENTS | 4 | packages/rmw/xrce | heap: service-client slots inside xrce_session_state_t |
NROS_XRCE_MAX_SERVICE_SERVERS | 4 | packages/rmw/xrce | heap: service-server slots inside xrce_session_state_t |
NROS_XRCE_MAX_SUBSCRIBERS | 8 | packages/rmw/xrce | heap: subscriber slots inside xrce_session_state_t, which the XRCE backend allocates from the platform heap (nros_xrce_calloc) when a session opens — no named static, so mem-report cannot see it |
NROS_XRCE_SERVICE_REPLY_BUFFER_BYTES | 1024 | packages/rmw/xrce | heap: per-client reply buffer inside xrce_session_state_t |
NROS_XRCE_SERVICE_REQUEST_BUFFER_BYTES | 1024 | packages/rmw/xrce | heap: per-APPLICATION-server request buffer inside xrce_session_state_t |
NROS_XRCE_STREAM_HISTORY | 16 | packages/rmw/xrce | heap: reliable-stream history depth; multiplies the stream buffers inside the session state |
NROS_XRCE_SUBSCRIBER_BUFFER_BYTES | 1024 | packages/rmw/xrce | heap: bytes per XRCE subscriber ring entry inside xrce_session_state_t |
NROS_XRCE_SUBSCRIBER_RING_DEPTH | 32 | packages/rmw/xrce | heap: ring depth of each XRCE subscriber slot inside xrce_session_state_t |
NROS_XRCE_TRANSPORT_MTU | 4096 | packages/rmw/xrce | heap: Micro-XRCE-DDS-Client transport MTU (UDP/TCP): sizes the transport’s buffer inside its transport struct |
NROS_ZENOH_BATCH_MULTICAST_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | heap: the multicast twin of the unicast batch buffers — heap at session open, no symbol |
NROS_ZENOH_BATCH_UNICAST_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | heap: zenoh-pico allocates its unicast TX/RX batch buffers (_z_wbuf_make/_z_zbuf_make) when a session opens — heap bytes, no symbol |
NROS_ZENOH_CONNECT_FOREVER | computed — see packages/tooling/nros-platform-config/src/platform_config.rs:1912 | packages/tooling/nros-platform-config | not-a-size: a switch |
NROS_ZENOH_CONNECT_TIMEOUT_MS | computed — see packages/tooling/nros-platform-config/src/platform_config.rs:1918 | packages/tooling/nros-platform-config | not-a-size: milliseconds |
NROS_ZENOH_FRAG_MAX_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | heap: zenoh-pico’s defragmentation buffer, _z_wbuf_make(Z_FRAG_MAX_SIZE) on first fragment — heap, no symbol |
NROS_ZENOH_GET_POLL_INTERVAL_MS | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | not-a-size: milliseconds |
NROS_ZENOH_GET_REPLY_BUFFER_BYTES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | stack: the blocking z_get reply context is stack-allocated per call (zpico.c), so it costs stack in the caller, never static RAM |
NROS_ZENOH_GRAPH_CACHE_BYTES | computed — see packages/rmw/zenoh/nros-zpico-build/src/runner.rs:1585 | packages/rmw/zenoh/nros-zpico-build | pool g_sessions: the graph cache’s byte buffer, embedded in each struct zpico_session beside its mutex and subscriber handle |
NROS_ZENOH_GRAPH_DISCOVERY | computed — see packages/rmw/zenoh/nros-zpico-build/src/runner.rs:1600 | packages/rmw/zenoh/nros-zpico-build | not-a-size: switches the graph cache on; its bytes are ZPICO_GRAPH_CACHE_SIZE |
NROS_ZENOH_GRAPH_MAX_ENTITIES | 0 | packages/rmw/zenoh/nros-zpico-build | input: the entity count ZPICO_GRAPH_CACHE_SIZE is derived from; storage is that knob’s |
NROS_ZENOH_KEYEXPR_STRING_BYTES | 256 | packages/rmw/zenoh/nros-rmw-zenoh | element: the key-expression buffer inside each subscriber/service shim entry; lands in SUBSCRIBER_BUFFERS/SERVICE_BUFFERS |
NROS_ZENOH_MAX_LARGE_SUBSCRIBERS | 2 | packages/rmw/zenoh/nros-rmw-zenoh | prices LARGE_PAYLOADS (131,072 B at defaults) |
NROS_ZENOH_MAX_LIVELINESS | computed — see packages/rmw/zenoh/nros-zpico-build/src/runner.rs:1395 | packages/rmw/zenoh/nros-zpico-build | pool g_sessions: liveliness-token entries inside each struct zpico_session |
NROS_ZENOH_MAX_PENDING_GETS | 4 | packages/rmw/zenoh/nros-zpico-build | pool g_sessions: pending-get slots inside each struct zpico_session |
NROS_ZENOH_MAX_PUBLISHERS | computed — see packages/rmw/zenoh/nros-zpico-build/src/runner.rs:1381 | packages/rmw/zenoh/nros-zpico-build | pool g_sessions: publisher entries inside each struct zpico_session; default derived per image from the entity inventory |
NROS_ZENOH_MAX_QUERYABLES | computed — see packages/rmw/zenoh/nros-zpico-build/src/runner.rs:1365 | packages/rmw/zenoh/nros-zpico-build | pool g_sessions, nros_rmw_zenoh::shim::service::SERVICE_BUFFERS, nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX: queryable entries inside each struct zpico_session and the per-queryable shim pools; default derived per image (a service server, a TRANSIENT_LOCAL publisher and the builtin param/lifecycle services each take one) |
NROS_ZENOH_MAX_SESSIONS | 1 | packages/rmw/zenoh/nros-zpico-build | pool g_sessions, nros_rmw_zenoh::shim::service::SERVICE_BUFFERS, nros_rmw_zenoh::shim::service::USER_SERVICE_INBOX: session count: the outer dimension of the zpico session table and of every per-session shim pool; the session element is the struct zpico_session C struct |
NROS_ZENOH_MAX_SUBSCRIBERS | computed — see packages/rmw/zenoh/nros-zpico-build/src/runner.rs:1385 | packages/rmw/zenoh/nros-zpico-build | sizes SMALL_PAYLOADS — not priceable at defaults (knob NROS_ZENOH_MAX_SUBSCRIBERS has a computed default); pool g_sessions, nros_rmw_zenoh::shim::subscriber::SUBSCRIBER_BUFFERS: subscriber entries inside each struct zpico_session and the shim’s SubscriberBuffer table (also priced through SMALL_PAYLOADS); default derived per image |
NROS_ZENOH_MAX_TL_PUBLISHERS | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:976 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::publisher::transient_local::TL_SLOTS: retention slots for TRANSIENT_LOCAL publishers; the element is a RetainSlot struct and the count is derived per image |
NROS_ZENOH_PUBLISHER_TX_BUFFER_BYTES | 1024 | packages/rmw/zenoh/nros-rmw-zenoh | element: each publisher’s zero-copy lend arena (ZENOH_TX_BUF), inside the publisher entry wherever that is stored |
NROS_ZENOH_READ_PRIORITY | 16 | packages/rmw/zenoh/nros-zpico-build | not-a-size: a task priority |
NROS_ZENOH_RX_TASK_BUDGET_FRAMES | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | not-a-size: a frame COUNT the read task processes before it rests; sizes no storage |
NROS_ZENOH_RX_TASK_BUDGET_REST_US | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | not-a-size: microseconds |
NROS_ZENOH_SERVICE_BUFFER_BYTES | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:137 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::service::SERVICE_BUFFERS: payload bytes inside each ServiceBuffer struct; also the default for the two inbox slot sizes above |
NROS_ZENOH_SUBSCRIBER_LARGE_BYTES | 16384 | packages/rmw/zenoh/nros-rmw-zenoh | prices LARGE_PAYLOADS (131,072 B at defaults) |
NROS_ZENOH_SUBSCRIBER_LARGE_THRESHOLD_BYTES | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:104 | packages/rmw/zenoh/nros-rmw-zenoh | not-a-size: the hint above which a subscription routes to the LARGE payload class — a routing threshold, not storage |
NROS_ZENOH_SUBSCRIBER_RING_DEPTH | 4 | packages/rmw/zenoh/nros-rmw-zenoh | prices LARGE_PAYLOADS (131,072 B at defaults); sizes SMALL_PAYLOADS — not priceable at defaults (knob NROS_ZENOH_MAX_SUBSCRIBERS has a computed default); default DERIVED per image when it declares its entities |
NROS_ZENOH_TL_RETAIN_BYTES | computed — see packages/rmw/zenoh/nros-rmw-zenoh/build.rs:424 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::publisher::transient_local::TL_SLOTS: bytes retained inside each RetainSlot |
NROS_ZENOH_TL_RETAIN_DEPTH | 1 | packages/rmw/zenoh/nros-rmw-zenoh | pool nros_rmw_zenoh::shim::publisher::transient_local::TL_SLOTS: samples each RetainSlot retains: multiplies the slot’s retained bytes and attachment, derived per image from the deepest declared transient-local KEEP_LAST; default DERIVED per image when it declares its entities |
NROS_ZENOH_TX_BATCH | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | not-a-size: a switch: whether zenoh-pico batches outgoing messages |
NROS_ZENOH_TX_BATCH_FLUSH_MS | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | not-a-size: a time: the longest a batched message waits before it is flushed |
NROS_ZENOH_TX_SPLIT_LOCK | computed — see packages/tooling/nros-zephyr-build/knobs.toml:1 | packages/tooling/nros-zephyr-build | not-a-size: a switch: whether the TX path takes its own lock instead of the session’s |
ROSOUT_PROBE_PERIOD_MS | 250 | packages/testing/nros-tests/bins/rosout-talker/src/rosout-talker | test-only: rosout-talker test binary |
ROSOUT_PROBE_RECORDS | 60 | packages/testing/nros-tests/bins/rosout-talker/src/rosout-talker | test-only: rosout-talker test binary |
Conflicting defaults
These knobs are read in more than one place with DIFFERENT defaults, so setting one moves only part of the tree: one setting, two values in the same image.
NROS_SUBSCRIBER_BUFFER_BYTES
Supported Boards
Procurement-grade compatibility matrix, in two parts.
Board packages nano-ros ships come first. Those rows are generated from the board support registry, so each status there is derived from evidence (where the board runs, how often, and when it last did) and links to the board’s evidence page. Board Support Levels explains each status word.
| Board package | Status | Runs on | Evidence |
|---|---|---|---|
nros-board-linux (Linux) | Verified on host (daily) | host executable | evidence |
nros-board-zephyr (ZephyrNativeSim) | Verified on host (daily) | host executable | evidence |
nros-board-mps3-an536-freertos | Builds | qemu:mps3-an536 (twin) | evidence |
nros-board-mps2-an385-freertos (FreertosMps2) | Verified in emulator (daily) | qemu:mps2-an385 | evidence |
nros-board-s32z270-freertos (s32z270-freertos) | Builds | s32z270 (target) | evidence |
nros-board-s32z270-freertos (s32z270-freertos-rtd) | Not supported | s32z270 (target) | evidence |
nros-board-nuttx-qemu (NuttxArm) | Verified in emulator (daily) | qemu:virt-armv7a | evidence |
nros-board-threadx-linux (ThreadxLinux) | Verified on host (daily) | host executable | evidence |
nros-board-freertos-posix (FreertosPosix) | Verified on host (daily) | host executable | evidence |
nros-board-threadx-qemu-riscv64 (ThreadxRiscv64) | Verified in emulator (daily) | qemu:rv-virt | evidence |
nros-board-mps2-an385 (QemuBaremetal) | Verified in emulator (daily) | qemu:mps2-an385 | evidence |
nros-board-mps2-an385-zephyr (ZephyrQemuCortexM) | Verified in emulator (daily) | qemu:mps2-an385 | evidence |
nros-board-nuttx-qemu (NuttxRiscv) | Verified in emulator (daily) | qemu:rv-virt | evidence |
nros-board-zephyr (Fvp) | Boots, manual (2026-11-21); reads Builds from 2027-03-22 | fvp:FVP_BaseR_AEMv8R | evidence |
nros-board-zephyr (s32z270-rtu0-zephyr) | Builds | s32z270 (target) | evidence |
s32k344-safety-island | Boots on hardware, manual (2026-10-26); reads Builds from 2027-02-24 | mr-canhubk344 | evidence |
nros-board-nucleo-f767zi-zephyr (ZephyrNucleoF767zi) | Boots, manual (2026-11-01); reads Builds from 2027-03-02 | renode:nucleo_f767zi, nucleo-f767zi (target) | evidence |
nros-board-rpi-pico-w-zephyr | Not supported | rpi-pico-w (target) | evidence |
px4-sitl (Px4) | Boots, manual (2026-11-03); reads Builds from 2027-03-04 | host executable | evidence |
Other boards and how you would approach them
The parts below have no board package in nano-ros, so the registry says nothing about them and this page claims no status for them. Each row names the path you would take to bring nano-ros up on it.
| Vendor | Board | MCU / SoC | Arch | RTOS to start from | How to approach it |
|---|---|---|---|---|---|
| STMicro | STM32F4-Discovery | STM32F407 | Cortex-M4F | bare | Worked example, an out-of-tree board package |
| STMicro | STM32H7-Nucleo | STM32H743 | Cortex-M7F | FreeRTOS / Zephyr | FreeRTOS or Zephyr starter, with an overlay on nros-board-freertos |
| STMicro | Pixhawk 4 (FMUv5) | STM32F765 | Cortex-M7F | NuttX (PX4) | The PX4 module template: PX4 Autopilot |
| STMicro | Pixhawk 6X / 6C | STM32H753 | Cortex-M7F | NuttX (PX4) | The PX4 module template: PX4 Autopilot |
| Nordic | nRF52840-DK | Cortex-M4F | Armv7E-M | Zephyr | Zephyr starter with -b nrf52840dk_nrf52840 |
| Nordic | nRF5340-DK | Cortex-M33 (dual) | Armv8-M | Zephyr | Zephyr starter with -b nrf5340dk_nrf5340_cpuapp |
| NXP | LPC55S69-EVK | Cortex-M33 | Armv8-M | Zephyr | Zephyr starter with -b lpcxpresso55s69_cpu0 |
| NXP | MIMXRT1170-EVK | Cortex-M7 + M4 | Armv7-M | FreeRTOS / Zephyr | FreeRTOS starter plus the vendor BSP |
| TI | LP-CC1352P7 | Cortex-M4F | Armv7E-M | FreeRTOS / TI-RTOS | FreeRTOS starter plus a TI driver overlay |
| RP2040 | Raspberry Pi Pico | Cortex-M0+ | Armv6-M | bare / FreeRTOS | The bare-metal Cortex-M path; see the Cortex-M0+ caveat below |
| QEMU | Cortex-A9 (Versatile) | Cortex-A9 | Armv7-A | Zephyr | Zephyr starter with -b qemu_cortex_a9 |
| NVIDIA | Jetson Orin SPE | Cortex-R5 | Armv7-R | FreeRTOS (NVIDIA FSP) | No board package, and no work on one is planned. The IVC driver (nvidia-ivc) and the zenoh-pico IVC link remain in nano-ros |
The ESP32 boards (ESP-IDF component and esp-hal bare-metal) are retired: ESP32 — retired.
To add a board, as a package of your own or contributed to nano-ros, see Add a board.
Caveats by chip family
- Cortex-M0+ (RP2040, STM32F0, nRF51): only 4 NVIC priority levels. Per-callback OS-priority dispatch (a research scheduler shape originally proposed by Choi et al. as PiCAS, RTAS ’21) is disqualified on this class; nano-ros’s user-space EDF / FIFO scheduler is the only option. Pub/sub works fine.
- Xtensa (ESP32, ESP32-S2, ESP32-S3): not supported. nano-ros has no Xtensa board, and the RISC-V ESP32 boards are retired (ESP32 — retired).
- Cortex-A9 / A53: hosted-RTOS only (NuttX, Zephyr). Heap + libc required; bare-metal Cortex-A is not in the coverage matrix.
- PX4 boards: NuttX is the underlying kernel; the PX4 module template is the canonical entry path — see PX4 Autopilot.
See also
- Board Support Levels — what each status word means.
- Embedded Starters — per-RTOS walkthrough.
- Platform Differences — per-platform capability deltas.
Support Status
What you get, at which version, tested how hard — the analogue of
Rust’s platform-support page. Version strings on this page are
parsed from nros-sdk-index.toml and rust-toolchain.toml (the
pinning SSoTs), so they cannot drift from what nros setup
actually installs.
This page and your release
This page is generated from the tree the book is published from,
main. A release pins its own versions, so a release older than
main may provision older ones than the tables below show. For the
release you installed, run nros doctor --report in your bringup
package: it prints, dated, the nros version, each image’s board and
that board’s support status, and every tool and source the image pins.
That output is the record to attach to a review.
Release support
- Only the newest release is supported. nano-ros is pre-1.0, and each release supersedes the one before it.
- Fixes reach you in the next release. A fix lands on
mainand ships with the release after it; nothing is backported to an older release. To take a fix, move your pin to the release that has it. - Release assets stay published. A release’s tag is never deleted or moved, and its assets stay on GitHub Releases, so a pinned version installs the same bytes later.
- No long-term support before 1.0. A release reaches end of life when the next one is published; there is no LTS line to stay on.
- Security. Report a vulnerability privately at https://github.com/NEWSLabNTU/nano-ros/security/advisories/new, not in a public issue. A fixed one is published as a GitHub Security Advisory naming the affected releases and the release with the fix.
- SBOM. Each release publishes
nros-linux-x86_64.cdx.jsonbeside its asset and installs it asshare/nros/sbom.cdx.json: a CycloneDX list of every crate compiled into the toolchain. What one firmware image is built from is in your project’snros-sdk.lock.
CI tiers — what “supported” means
| Tier | Lane | Runs | Guarantee |
|---|---|---|---|
| 1 | ci tier1 (CI: daily) | Host-executable boards (Linux, Zephyr native_sim, ThreadX Linux): builds + fixtures, all gates | The logic and the seams are sound. Says nothing about cross-built targets. |
| 2 | ci matrix (CI: daily; run it locally when core, codegen or cmake move) | 1-wise cover: every platform, language, RMW, and kind appears at least once (~28 % of the coordinate space) | Each axis value builds and runs somewhere — but pairings are NOT covered. |
| 2-nightly | ci matrix-nightly (CI: daily) | Pairwise cover (~70 %) | Platform×language and RMW×language interactions surface here, within a day. |
| 3 | ci full (pre-release, on demand) | The whole matrix | Everything the tree claims, verified together. |
What CI runs on every change is the compile smoke and the source gates
on a pull request, plus the unit tests in the merge queue. Runtime tests
run daily: no board’s runtime is tested on every change. The merge-queue
candidate set (ci merge: the zenoh behaviour pairs in Rust, C and C++ on
Linux, Zephyr native_sim and ThreadX Linux) can be run on demand to measure
what a per-change cadence would cost.
Per-board support levels are generated on their own page: Board Support Levels. The procurement view, including parts with no board package, is Supported Boards.
RTOS / platform source pins
nros setup <board> fetches exactly these (shared store
${NROS_HOME:-~/.nros}/sdk):
| Component | Pinned version | Used by |
|---|---|---|
| FreeRTOS kernel | 10.6.2 | FreeRTOS boards (QEMU MPS2-AN385, overlays) |
| lwIP | 2.2.0 | FreeRTOS networking |
| ThreadX | 6.4.1 | ThreadX (Linux sim + QEMU RISC-V64) |
| NetX Duo | 6.4.x | ThreadX networking |
| NuttX kernel | 12.13.0 | NuttX (QEMU armv7a / rv32) |
| Zephyr SDK | 0.16.9 (+ 1.0.1 for the 4.4 rolling line); its macOS host build needs macOS 14+ (nano-ros hosts: Linux only) | Zephyr module builds |
| mbedTLS | 3.x | zenoh TLS transport |
These pins are decisions, not lags — they move only with a reason, tested together (see Build inside an existing CMake or vendor tree).
RMW backends — versions and interop pairing
| Backend | Client side (pinned) | Host side | Pairing rule |
|---|---|---|---|
| Zenoh | zenoh-pico 1.10.1 (vendored submodule) | Router = the one ROS ships: ros2 run rmw_zenoh_cpp rmw_zenohd — nano-ros deliberately vendors no router | zenoh-pico’s wire protocol is stable across zenoh 1.x, so the pinned client interops with a newer ROS-shipped router |
| XRCE-DDS | Micro-XRCE-DDS client 3.0.1 + Micro-CDR 2.0.2 | Agent 2.4.3-nros1 (installed by nros setup … --rmw xrce) | Client and agent are pinned independently and are NOT the same upstream release; they meet at the DDS-XRCE wire protocol |
| Cyclone DDS | fork 0.10.5-nros1 — upstream 0.10.5 + carried patches (fork delta) | Talks RTPS directly to rmw_cyclonedds_cpp | Pinned to the Cyclone ROS ships (ros-humble-cyclonedds 0.10.5) — upstream 11.x is deliberately NOT a rebase target until a distro migration |
Per-feature coverage across the backends: Per-RMW Feature Matrix.
ROS 2 editions
| Edition | Feature / flag | Status | Notes |
|---|---|---|---|
| Humble | ros-humble (default) | Supported | TypeHashNotSupported key expressions, XCDR1. Ubuntu 22.04 only; ships ros-humble-rmw-zenoh-cpp. |
| Jazzy | ros-jazzy | Supported | RIHS01; Ubuntu 24.04; ships ros-jazzy-rmw-zenoh-cpp. Interop with a Jazzy peer runs weekly in weekly.yml job ros-editions (publish/subscribe, services and actions, both directions, over Cyclone DDS, XRCE and zenoh); generated code is also checked against committed golden files. A default Jazzy peer encodes XCDR1/FINAL, which nano-ros speaks; per-type XCDR2 (@appendable) is not enabled. |
Pick the edition of the ROS system you interop with — mismatched
editions discover nothing (different key expressions).
Iron (end of life) is not claimed. The ros-iron flag still
builds, and nothing tests it.
Supported means WIRE interop, not API parity. nano-ros’s API is
compared against Humble and Jazzy — Jazzy from pinned upstream
sources, since it cannot be installed beside Humble
(how the comparison runs). Iron is not compared on its own; what it added and Jazzy kept is
covered there. Jazzy’s additions over Humble are each RULED, not each implemented:
matched/incompatible-type events, timer call info,
the small rclcpp accessors,
count_clients/count_services, the client GID and
event_type_is_supported are implemented;
BEST_AVAILABLE QoS is implemented,
resolved at creation against the discovered graph;
dynamic typesupport, service introspection and the
~/get_type_description service are declined on RAM/flash grounds;
rmw_discovery_options_t is answered by the session locator and
localhost_only. Type hashes (RIHS01) are on the wire today.
Toolchains
| Tool | Pinned version |
|---|---|
| Rust | 1.99.0 channel (rust-toolchain.toml); pinned cross targets: thumbv7m-none-eabi, thumbv7em-none-eabihf, armv7r-none-eabi, armv7r-none-eabihf, armv8r-none-eabihf, riscv32imc-unknown-none-elf, riscv64gc-unknown-none-elf, aarch64-unknown-none, armv7a-none-eabi, armv7a-none-eabihf, thumbv7em-none-eabi, thumbv8m.main-none-eabi, thumbv8m.main-none-eabihf, i686-unknown-linux-gnu, x86_64-unknown-none, thumbv6m-none-eabi. rustfmt runs on nightly (nightly-only options). |
Arm GCC (arm-none-eabi) | 13.2-nros5 |
RISC-V GCC (riscv-none-elf) | 14.2-nros1 |
| QEMU (patched, Arm) | 11.0.0-nros8 |
| Corrosion (CMake↔Cargo) | 0.6.1-nros1 (≥ 0.6.0 required — older versions share one build dir across workspace roots and break the mixed link) |
| OpenOCD | 0.12.0-nros2 |
| sccache | 0.17.0-nros1 |
-nros<N> suffixes mark builds re-packaged (or patched) for the SDK
store; the base version is the upstream release.
Related
- Install — how these get onto
a machine (
nros setup, prebuilt-vs-source rules) - Per-RMW Feature Matrix
- Board Support Levels (generated) · Supported Boards (procurement view)
- Build inside an existing CMake or vendor tree — pinning and upgrading these from a company tree
Board Support Levels
What nano-ros can show for each board it knows about. Each level is derived from evidence, never typed: where the board’s image runs (on a host, in an emulator, on hardware, or nowhere yet), how often that run happens (every merge, daily, weekly, or by hand on a date) and which board’s test matrix stands for its breadth.
| Status | What it means |
|---|---|
| Verified on host / in emulator / on hardware (cadence) | an automated lane boots it and asserts a message, at that cadence |
| Boots, manual (date) | a maintainer booted it by hand on that date; after 120 days it reads Builds until booted again |
| Builds | a lane builds it; nothing boots it |
| Not supported | nothing builds or boots it |
A witness board runs its platform family’s test matrix; a board that inherits shares the witness’s code path and adds its own smoke evidence.
Boards
Pick a board for its evidence: what runs it, how often, what its tests cover and which pages of this book it runs in.
| Board | Status | Runs on |
|---|---|---|
nros-board-linux (Linux) | Verified on host (daily) | host executable |
nros-board-zephyr (ZephyrNativeSim) | Verified on host (daily) | host executable |
nros-board-mps3-an536-freertos | Builds | qemu:mps3-an536 (twin) |
nros-board-mps2-an385-freertos (FreertosMps2) | Verified in emulator (daily) | qemu:mps2-an385 |
nros-board-s32z270-freertos (s32z270-freertos) | Builds | s32z270 (target) |
nros-board-s32z270-freertos (s32z270-freertos-rtd) | Not supported | s32z270 (target) |
nros-board-nuttx-qemu (NuttxArm) | Verified in emulator (daily) | qemu:virt-armv7a |
nros-board-threadx-linux (ThreadxLinux) | Verified on host (daily) | host executable |
nros-board-freertos-posix (FreertosPosix) | Verified on host (daily) | host executable |
nros-board-threadx-qemu-riscv64 (ThreadxRiscv64) | Verified in emulator (daily) | qemu:rv-virt |
nros-board-mps2-an385 (QemuBaremetal) | Verified in emulator (daily) | qemu:mps2-an385 |
nros-board-mps2-an385-zephyr (ZephyrQemuCortexM) | Verified in emulator (daily) | qemu:mps2-an385 |
nros-board-nuttx-qemu (NuttxRiscv) | Verified in emulator (daily) | qemu:rv-virt |
nros-board-zephyr (Fvp) | Boots, manual (2026-11-21); reads Builds from 2027-03-22 | fvp:FVP_BaseR_AEMv8R |
nros-board-zephyr (s32z270-rtu0-zephyr) | Builds | s32z270 (target) |
s32k344-safety-island | Boots on hardware, manual (2026-10-26); reads Builds from 2027-02-24 | mr-canhubk344 |
nros-board-nucleo-f767zi-zephyr (ZephyrNucleoF767zi) | Boots, manual (2026-11-01); reads Builds from 2027-03-02 | renode:nucleo_f767zi, nucleo-f767zi (target) |
nros-board-rpi-pico-w-zephyr | Not supported | rpi-pico-w (target) |
px4-sitl (Px4) | Boots, manual (2026-11-03); reads Builds from 2027-03-04 | host executable |
nros-board-linux (Linux)
Status: Verified on host (daily)
| Package | nros-board-linux |
| Test-matrix platform | Linux |
| Runs on | host executable |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, ExecutorBoundNode, CustomLink, Service, Action, Port, PortSmoke, PortMonitor, PortWorkspace, Params, Qos, CustomMsg, Safety, Logging, EntryPubsub, Lifecycle, Remap, BeforeBoot, RealtimeSchedTasks, Multihost in Rust, C, C++, Mixed over zenoh, cyclonedds, XRCE-DDS |
| Book | Run: linux host |
| Book probe tracks | linux (weekly), linux-rust (weekly), linux-c (weekly), platform-linux, custom-rmw |
The reference platform: the densest Runtime coverage of any target, all three RMWs. One board crate covers both the Linux host and the POSIX family driver.
nros-board-zephyr (ZephyrNativeSim)
Status: Verified on host (daily)
| Package | nros-board-zephyr |
| Test-matrix platform | ZephyrNativeSim |
| Runs on | host executable |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, Service, Action, ConnectBudget, Logging, EntryPubsub, Params, Lifecycle, Qos, Safety, RealtimeSchedTasks, Multihost in Rust, C, C++, Mixed over zenoh, cyclonedds, XRCE-DDS |
| Book | Run: zephyr native sim |
| Book probe tracks | zephyr (weekly), zephyr-cpp (weekly), zephyr-rust (weekly), platform-zephyr-native-sim, zephyr-west-app (weekly), zephyr-west-app-cpp (weekly), zephyr-west-app-rust (weekly) |
CAVEAT: only ever built for native_sim/native/64. No real Zephyr hardware board is built by anything.
nros-board-mps3-an536-freertos
Status: Builds
| Package | nros-board-mps3-an536-freertos |
| Test-matrix platform | — |
| Runs on | qemu:mps3-an536 (twin) |
| Cadence | — |
| Breadth | inherited from FreertosMps2 — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds |
| Book | — |
| Book probe tracks | — |
nros-board-mps2-an385-freertos (FreertosMps2)
Status: Verified in emulator (daily)
| Package | nros-board-mps2-an385-freertos |
| Test-matrix platform | FreertosMps2 |
| Runs on | qemu:mps2-an385 |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds |
| Book | Run: mps2 an385 freertos |
| Book probe tracks | first-project, tutorial-2, tutorial-3, tutorial-4, tutorial-5, tutorial-6, tutorial-7, tutorial-8, tutorial-9, tutorial-10, tutorial-c (weekly), tutorial-cpp (weekly), lab-qos (weekly), lab-qos-c (weekly), lab-qos-cpp (weekly), lab-tiers (weekly), lab-tiers-c (weekly), lab-tiers-cpp (weekly), freertos (weekly), freertos-c (weekly), freertos-cpp (weekly), platform-freertos, own-library |
nros-board-s32z270-freertos (s32z270-freertos)
Status: Builds
| Package | nros-board-s32z270-freertos |
| Test-matrix platform | — |
| Runs on | s32z270 (target) |
| Cadence | — |
| Breadth | inherited from FreertosMps2 — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds |
| Book | — |
| Book probe tracks | — |
S32Z270 RTU Cortex-R52 (ASI phase-4 W5.b consumer). No matrix_platform: no witness exists for this board, and borrowing FreertosMps2’s would claim its Runtime cells. Link-completeness is proven by the workspace cmake lane with the CRx_No_GIC default port.
nros-board-s32z270-freertos (s32z270-freertos-rtd)
Status: Not supported
| Package | nros-board-s32z270-freertos |
| Test-matrix platform | — |
| Runs on | s32z270 (target) |
| Cadence | — |
| Breadth | inherited from FreertosMps2 — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds |
| Book | — |
| Book probe tracks | — |
S32Z270 RTU Cortex-R52 on NXP’s ARM_CR52_GIC FreeRTOS port, built against a provisioned NXP kernel (NXP_FREERTOS_S32ZE_DIR) and RTD (S32_RTD_PATH). No CI lane and no hardware run: the NXP pieces are license-gated. The NETC network glue is not part of it yet.
nros-board-nuttx-qemu (NuttxArm)
Status: Verified in emulator (daily)
| Package | nros-board-nuttx-qemu |
| Test-matrix platform | NuttxArm |
| Runs on | qemu:virt-armv7a |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, TypedCarrier, Service, Action, Params, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++ over zenoh |
| Build roads | workspace (the daily lane); guest-make (nightly.yml:nuttx-make-road) |
| Book | Run: nuttx arm |
| Book probe tracks | nuttx-arm (weekly), nuttx-arm-cpp (weekly), nuttx-arm-rust (weekly), platform-nuttx |
nros-board-threadx-linux (ThreadxLinux)
Status: Verified on host (daily)
| Package | nros-board-threadx-linux |
| Test-matrix platform | ThreadxLinux |
| Runs on | host executable |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds |
| Book | Run: threadx linux |
| Book probe tracks | threadx-linux (weekly), threadx-linux-c (weekly), threadx-linux-cpp (weekly), platform-threadx-linux |
nros-board-freertos-posix (FreertosPosix)
Status: Verified on host (daily)
| Package | nros-board-freertos-posix |
| Test-matrix platform | FreertosPosix |
| Runs on | host executable |
| Cadence | daily |
| Breadth | inherited from FreertosMps2 — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds. Board-specific: Runtime: EntryPubsub in C, C++ over cyclonedds, zenoh; build-only: Port |
| Book | Run: freertos posix |
| Book probe tracks | freertos-posix (weekly), freertos-posix-rust (weekly), freertos-posix-cpp (weekly), freertos-posix-zenoh-rust (weekly), freertos-posix-zenoh (weekly), freertos-posix-zenoh-cpp (weekly), platform-freertos-posix |
nros-board-threadx-qemu-riscv64 (ThreadxRiscv64)
Status: Verified in emulator (daily)
| Package | nros-board-threadx-qemu-riscv64 |
| Test-matrix platform | ThreadxRiscv64 |
| Runs on | qemu:rv-virt |
| Cadence | daily |
| Breadth | inherited from ThreadxLinux — Runtime: Pubsub, Service, Action, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++, Mixed over zenoh, cyclonedds. Board-specific: Runtime: Pubsub, Service, Errno, TypedCarrier, Params, Logging, EntryPubsub in Rust, C, C++ over zenoh, cyclonedds; build-only: Action |
| Book | Run: threadx riscv64 |
| Book probe tracks | threadx-riscv64 (weekly), threadx-riscv64-c (weekly), threadx-riscv64-cpp (weekly), platform-threadx-riscv64 |
All three Action rows are BuildOnly by a deliberate wall-clock choice (182.5), not by breakage.
nros-board-mps2-an385 (QemuBaremetal)
Status: Verified in emulator (daily)
| Package | nros-board-mps2-an385 |
| Test-matrix platform | QemuBaremetal |
| Runs on | qemu:mps2-an385 |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, Service, Action, RealtimeSchedTasks, Logging, BoardEntryBoot in Rust, C, C++ over zenoh, XRCE-DDS |
| Book | Run: mps2 an385 bare metal |
| Book probe tracks | baremetal (weekly), baremetal-c (weekly), baremetal-cpp (weekly), offline (weekly), platform-baremetal |
One crate; the book’s entry shape is direct execution (the board-entry feature).
nros-board-mps2-an385-zephyr (ZephyrQemuCortexM)
Status: Verified in emulator (daily)
| Package | nros-board-mps2-an385-zephyr |
| Test-matrix platform | ZephyrQemuCortexM |
| Runs on | qemu:mps2-an385 |
| Cadence | daily |
| Breadth | witness — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, BootReport, IdleWake, Lifecycle, ViolationChannel in C, C++, Rust over zenoh, XRCE-DDS; build-only: Service, Action |
| Book | Run: mps2 an385 zephyr |
| Book probe tracks | zephyr-mps2 (weekly), zephyr-mps2-c (weekly), zephyr-mps2-cpp (weekly), platform-zephyr-mps2 |
C, C++ and Rust pubsub are Runtime; service and action are BuildOnly until the runner’s peer half lands. It carries a live-peer interop cell against a host peer over zenoh. Daily rather than per merge, because the merge lane is host-only and this board needs QEMU.
nros-board-nuttx-qemu (NuttxRiscv)
Status: Verified in emulator (daily)
| Package | nros-board-nuttx-qemu |
| Test-matrix platform | NuttxRiscv |
| Runs on | qemu:rv-virt |
| Cadence | daily |
| Breadth | inherited from NuttxArm — Runtime: Pubsub, TypedCarrier, Service, Action, Params, Logging, EntryPubsub, RealtimeSchedTasks in Rust, C, C++ over zenoh. Board-specific: Runtime: Pubsub, RealtimeSchedTasks in C, C++, Rust over zenoh; build-only: EntryPubsub |
| Build roads | workspace (the daily lane); guest-make (nightly.yml:nuttx-make-road) |
| Book | Run: nuttx riscv |
| Book probe tracks | nuttx-riscv (weekly), nuttx-riscv-cpp (weekly), nuttx-riscv-rust (weekly) |
HONEST LABEL: C runtime-proven; Rust and C++ Pubsub are explicit CarveOuts and every EntryPubsub row is BuildOnly.
nros-board-zephyr (Fvp)
Status: Boots, manual (2026-11-21); reads Builds from 2027-03-22
| Package | nros-board-zephyr |
| Test-matrix platform | Fvp |
| Runs on | fvp:FVP_BaseR_AEMv8R |
| Cadence | manual, last run 2026-11-21 |
| Breadth | inherited from ZephyrQemuCortexM — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, BootReport, IdleWake, Lifecycle, ViolationChannel in C, C++, Rust over zenoh, XRCE-DDS; build-only: Service, Action. Board-specific: build-only: Pubsub |
| Book | — |
| Book probe tracks | — |
Runtime is run by a maintainer, hence cadence = "manual". The model is user-provided: install the AEMv8-R FVP from Arm, then set ARMFVP_BIN_PATH (or ARM_FVP_DIR); it needs libatomic1 at runtime. CI does not run it because of cost and x86_64-only hosting. It is the target of simple-autoware-safety-island, a reference consumer outside this tree.
nros-board-zephyr (s32z270-rtu0-zephyr)
Status: Builds
| Package | nros-board-zephyr |
| Test-matrix platform | — |
| Runs on | s32z270 (target) |
| Cadence | — |
| Breadth | inherited from ZephyrQemuCortexM — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, BootReport, IdleWake, Lifecycle, ViolationChannel in C, C++, Rust over zenoh, XRCE-DDS; build-only: Service, Action |
| Book | — |
| Book probe tracks | — |
S32Z270 RTU0 Cortex-R52 (board revision D) on Zephyr, with Zephyr’s NXP NETC ethernet driver. A C++ Cyclone image for it links in CI, in a job that fetches hal_nxp for itself. No emulator models the SoC and no hardware run is recorded.
s32k344-safety-island
Status: Boots on hardware, manual (2026-10-26); reads Builds from 2027-02-24
| Package | s32k344-safety-island (in simple-autoware-safety-island, outside this tree) |
| Test-matrix platform | — |
| Runs on | mr-canhubk344 |
| Cadence | manual, last run 2026-10-26 |
| Breadth | inherited from ZephyrQemuCortexM — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, BootReport, IdleWake, Lifecycle, ViolationChannel in C, C++, Rust over zenoh, XRCE-DDS; build-only: Service, Action |
| Book | — |
| Book probe tracks | — |
NXP S32K344 (Cortex-M7) on the MR-CANHUBK344, Zephyr, behind a 921,600-baud UART zenoh link to an island gateway router. Verified on hardware on 2026-10-26. The board package belongs to the downstream island project.
nros-board-nucleo-f767zi-zephyr (ZephyrNucleoF767zi)
Status: Boots, manual (2026-11-01); reads Builds from 2027-03-02
| Package | nros-board-nucleo-f767zi-zephyr |
| Test-matrix platform | ZephyrNucleoF767zi |
| Runs on | renode:nucleo_f767zi, nucleo-f767zi (target) |
| Cadence | manual, last run 2026-11-01 |
| Breadth | inherited from ZephyrQemuCortexM — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, BootReport, IdleWake, Lifecycle, ViolationChannel in C, C++, Rust over zenoh, XRCE-DDS; build-only: Service, Action. Board-specific: Runtime: Pubsub in C over zenoh |
| Book | Run: nucleo f767zi; Flash: nucleo f767zi |
| Book probe tracks | flash-a-real-board, flash-a-real-board-bench, zephyr-west-app-flash (weekly), renode-nucleo (weekly), renode-nucleo-rust (weekly), renode-nucleo-cpp (weekly), nucleo-f767zi-bench |
ST Nucleo-F767ZI (STM32F767ZI, Cortex-M7F, 384 KiB sram0) on Zephyr 3.7. Its Renode twin boots the C talker over serial (USART3, the ST-LINK VCP) and over ethernet. Its RAM budget, max_large_subscribers = 0, is the board descriptor’s [knobs.zenoh], which every image inherits; the ethernet image adds its own knobs (see the descriptor header).
nros-board-rpi-pico-w-zephyr
Status: Not supported
| Package | nros-board-rpi-pico-w-zephyr |
| Test-matrix platform | — |
| Runs on | rpi-pico-w (target) |
| Cadence | — |
| Breadth | inherited from ZephyrQemuCortexM — Runtime: Pubsub, Port, PortSmoke, PortMonitor, PortWorkspace, BootReport, IdleWake, Lifecycle, ViolationChannel in C, C++, Rust over zenoh, XRCE-DDS; build-only: Service, Action |
| Book | — |
| Book probe tracks | — |
Raspberry Pi Pico W (RP2040, Cortex-M0+, 264 KiB SRAM) on Zephyr 3.7, serial only: zenoh over UART0, with the console on UART1, so the bench needs a USB-to-UART adapter. It is a real board with no emulator twin, flashed by UF2 with nros flash. Nothing has booted it on hardware yet, so nano-ros has no evidence it runs today. The image needs CONFIG_TICKLESS_KERNEL=n (in the board’s prj.conf) and five RAM knobs, which are the descriptor’s [knobs] and every image inherits.
px4-sitl (Px4)
Status: Boots, manual (2026-11-03); reads Builds from 2027-03-04
| Package | px4-sitl (in PX4-Autopilot, outside this tree) |
| Test-matrix platform | Px4 |
| Runs on | host executable |
| Cadence | manual, last run 2026-11-03 |
| Breadth | witness — Runtime: Pubsub in C++ over uORB |
| Book | Run: px4 |
| Book probe tracks | px4 (weekly) |
PX4’s own SITL board, px4_sitl_default, built from PX4-Autopilot with the nano-ros uORB example as an external module. A maintainer ran it on the date shown: a stock PX4 listener read a nano-ros publication over uORB, and each work-queue tier ran only for its deadlines and arrivals (arrival to dispatch 14 to 29 µs). The nightly CI job that runs the same tests is not yet passing, so the cadence stays manual. Real PX4 flight controllers build from the same module, but nano-ros has no run on one.
Infrastructure
Packages under packages/boards/ that are not boards: shared traits, family drivers, ABI mirrors, PACs and descriptor directories.
nros-board-common, nros-board-cffi, nros-board-freertos, nros-board-nuttx, nros-board-threadx, nros-board-threadx-port-riscv64, mps2-an385-pac, linux, zephyr, nros-board-qemu-cortex-a53
Per-RMW Feature Matrix
One table per question the capability pages used to answer in
contradictory prose. Derived from the backend sources — the C
vtables (vtable.c (XRCE-DDS), vtable.cpp (Cyclone DDS), vtable.cpp (uORB)) and the zenoh shim’s trait
overrides — so a backend gaining or losing a slot moves this page in
the same commit or fails the gate.
wired = the backend implements it. — = not wired: the runtime
surfaces UNSUPPORTED or falls back where a fallback exists (the
vtable comments name which). A slot filled with a function that only
returns UNSUPPORTED (uORB’s service stubs) is —, not wired.
Status events count as wired whether the backend calls back
(*_event_init) or the runtime polls it (*_take_event). The rows
below the parity marker are slots declared in the ABI whose backend
wiring is still landing; all-dash
rows there mean declared, not yet wired anywhere, and they flip
automatically as backends land implementations.
Session / entity capabilities
| Capability | Zenoh | XRCE-DDS | Cyclone DDS | uORB |
|---|---|---|---|---|
| Publish / subscribe | wired | wired | wired | wired |
| Services (server side) | wired | wired | wired | — |
| Service clients | wired | wired | wired | — |
| Server-availability probe | wired | — | wired | — |
| Status events (deadline / liveliness / lost) | wired | wired | wired | — |
| Matched / incompatible-type events (Iron+) | wired | — | wired | — |
| Manual liveliness assert | — | — | wired | — |
Event-driven wake (set_wake_callback) | wired | wired | wired | wired |
Deadline hint (next_deadline_ms) | wired | wired | — | — |
| Zero-copy loan API | wired | — | — | — |
Batch receive (take_sequence) | wired | — | wired | — |
| Streamed publish | wired | wired | — | — |
| Connectivity ping | wired | wired | — | — |
| Identity / feature probe | — | — | — | — |
| Publisher GID | wired | wired | wired | — |
| Matched-endpoint counts | — | — | wired | — |
| Actual-QoS read-back | wired | wired | wired | wired |
| Wait-for-acked | — | — | — | — |
| Take-with-info | wired | wired | wired | — |
| Entity new-data callbacks | wired | wired | wired | — |
| Graph introspection (names/types/counts) | wired | — | wired | — |
Service-graph counts (count_clients / count_services) | wired | — | wired | — |
| Client GID | wired | wired | wired | — |
Event-kind probe (event_type_is_supported) | wired | wired | wired | — |
Node-layer features
These live in nros-node on top of pub/sub + services — they are
not backend slots, so a backend has them exactly when it has those.
tested = at least one Runtime cell for that backend and workload
in matrix::CELLS or interop::CELLS (packages/testing/nros-tests/src/);
untested = available, but no runtime cell runs it; — = the
backend lacks pub/sub or services, so the feature cannot exist there.
| Feature | Zenoh | XRCE-DDS | Cyclone DDS | uORB | Rule |
|---|---|---|---|---|---|
| Actions | tested | tested | tested | — | Built in nros-node on pub/sub + services (goal / cancel / result services + feedback / status topics). |
| Parameters (+ param services) | tested | tested | tested | — | Node-layer services; available wherever services are. |
| Lifecycle (REP-2002) | tested | tested | tested | — | Node-layer state machine + services (lifecycle-services feature). |
QoS policies
A backend advertises the policies it can enforce via
supported_qos_policies(); requesting an unadvertised policy fails
entity creation loudly (INCOMPATIBLE_QOS) — no silent
downgrade. Each column is that backend’s OWN answer: the zenoh
shim’s Session::supported_qos_policies, and for a C backend the
function its vtable puts in the supported_qos_policies slot.
Per-policy semantics: RMW vs upstream §7.
| Policy | Zenoh | XRCE-DDS | Cyclone DDS | uORB |
|---|---|---|---|---|
RELIABILITY | ✓ | ✓ | ✓ | ✓ |
DURABILITY_VOLATILE | ✓ | ✓ | ✓ | ✓ |
DURABILITY_TRANSIENT_LOCAL | ✓ | ✓ | ✓ | — |
HISTORY | ✓ | ✓ | ✓ | ✓ |
DEPTH | ✓ | ✓ | ✓ | ✓ |
DEADLINE | ✓ | ✓ | ✓ | — |
LIFESPAN | ✓ | — | ✓ | — |
LIVELINESS_AUTOMATIC | ✓ | — | ✓ | — |
LIVELINESS_MANUAL_BY_TOPIC | ✓ | — | ✓ | — |
LIVELINESS_MANUAL_BY_NODE | — | — | — | — |
LIVELINESS_LEASE | ✓ | — | ✓ | — |
AVOID_ROS_NAMESPACE_CONVENTIONS | — | ✓ | — | — |
Related
- Choosing an RMW Backend — the decision tree, and how each backend works
- Support Status — versions, pins, and CI tiers
Scheduling Wiring Matrix
Which scheduling capabilities nano-ros delivers per platform,
and which portable executor classes are live in dispatch —
derived from the two artifacts the runtime executes, not from
prose. The per-platform rows are parsed from sched_caps_for()
(nros-orchestration-ir), the exact function the workload realizer
calls to decide Native-vs-Degrade for a deployment; its rule, quoted
from the source: caps describe what nano-ros DELIVERS, not what
the OS could do.
Kernel capabilities per platform
| Platform | Kernel EDF | Reservation / sporadic server | Preemption threshold | SMP affinity | Priority levels | Low number = high priority |
|---|---|---|---|---|---|---|
| Linux host | — | — | — | ✓ | 99 | — |
| Zephyr | ✓ | — | — | ✓ | 32 | ✓ |
| FreeRTOS | — | — | — | ✓ | 16 | — |
| ThreadX | — | — | ✓ | ✓ | 32 | ✓ |
| NuttX | — | ✓ | — | ✓ | 255 | — |
| Bare-metal (NVIC) | — | — | — | — | 8 | — |
Notes carried from the source arms: the Linux row is deliberately
conservative — no SCHED_DEADLINE consumer exists, so edf is
false even though Linux could; its affinity is sched_setaffinity,
which is Linux and not POSIX (absent from libc’s apple module), so the
row’s reach is linux while the platform layer beneath it stays
posix; Zephyr’s EDF is
CONFIG_SCHED_DEADLINE; NuttX’s reservation is POSIX
SCHED_SPORADIC; ThreadX’s preemption threshold is native; the
bare-metal row is NVIC hardware priorities,
single core. These are PLATFORM DEFAULTS and there is no per-image
override today. ([deploy.<board>] edf / cores, documented in older
releases, never took effect and is retired.)
Portable executor classes (SchedClass)
These run inside the executor on every platform — they need no
kernel support, which is what makes them portable; where the kernel
HAS the native capability (table above), the realizer places the
workload natively instead. “Dispatch sites” counts
SchedClass::<X> references in the executor’s spin path — a class
with zero sites is a type, not a behavior.
| Class | Dispatch sites in spin.rs | Status |
|---|---|---|
Fifo | 3 | Live — the default class; bucketed FIFO ready-set. |
Edf | 2 | Live — earliest-deadline-first ready-set ordering. |
Sporadic | 6 | Live — budget/period enforcement in dispatch. |
Related
- Scheduling Models — the narrative: how sched tasks, transport priorities, and these classes land on each kernel
- The execution model — spin-loop shapes, levels and the kernels underneath
- Support Status · Per-RMW Feature Matrix
Platform Differences
This page covers OS-port differences (clock, allocator, threading, sockets). For per-RMW feature coverage — services, events, QoS — see the Per-RMW Feature Matrix.
Per-platform behaviour comparison. The Doxygen reference defines what each vtable entry must do; this page covers how each shipped platform crate fulfils that contract and which optional capabilities each platform exposes.
At a glance
| Platform | Clock source | Allocator | Threading | Networking | UDP multicast | Wall-clock | Notes |
|---|---|---|---|---|---|---|---|
| POSIX | clock_gettime(CLOCK_MONOTONIC) | libc malloc | pthreads | libc BSD sockets (Rust) | Yes | clock_gettime(CLOCK_REALTIME) | Canonical reference port. |
| NuttX | POSIX alias | libc malloc | pthreads | zenoh-pico unix/network.c (C) | Yes | POSIX | Most paths inherit POSIX behaviour. |
| FreeRTOS | xTaskGetTickCount | pvPortMalloc | FreeRTOS tasks | lwIP via freertos-lwip-sys (Rust) | — | Tick-based, no RTC | Multicast gated on lwIP LWIP_IGMP=1 (untested). |
| Zephyr | k_uptime_get | k_malloc | Zephyr POSIX pthreads | Zephyr POSIX sockets (Rust) | Yes (native_sim via NSOS) | clock_gettime(CLOCK_REALTIME) | native_sim multicast routes through the NSOS IPPROTO_IP patch. |
| ThreadX | tx_time_get | tx_byte_allocate | ThreadX threads | NetX Duo BSD network.c (C) | — | tx_time_get fallback | Multicast gated on NetX Duo nx_igmp_* (untested). |
| Bare-metal (MPS2-AN385) | CMSDK Timer0 | bump allocator | single-threaded | nros-smoltcp (Rust) | Yes (smoltcp 0.12 IGMP) | monotonic fallback | Cortex-M3 QEMU. |
| Bare-metal (STM32F4) | DWT cycle counter | bump allocator | single-threaded | nros-smoltcp (Rust) | Yes | monotonic fallback | Cortex-M4F. |
Canonical interface contract. What “Yes” / “—” / specific functions mean — buffer ownership, blocking allowance, valid value ranges — is in the platform-cffi Doxygen reference. This page is a comparison table, not a spec.
Behaviour notes by trait group
Time (PlatformClock)
All ports surface a monotonic clock. Resolution varies:
- POSIX / NuttX: nanosecond-resolution
clock_gettime, exposed at ms + µs. - FreeRTOS:
xTaskGetTickCountticks (typically 1 ms).clock_us=clock_ms × 1000— the resolution lie is documented. - Zephyr:
k_uptime_getms +k_cyc_to_us_floor64(k_cycle_get_64())µs. - ThreadX:
tx_time_getticks (default 100 Hz; bump viaTX_TIMER_TICKS_PER_SECONDfor finer resolution). - Bare-metal (Cortex-M): hardware timer counter (CMSDK Timer0, DWT cycle counter). µs is the native resolution; ms is
µs / 1000.
The clock is monotonic and wraparound-free from init to shutdown. Platforms with 32-bit timers run a software extender on overflow.
Memory (PlatformAlloc)
Only zenoh-pico calls PlatformAlloc::{alloc, realloc, free}. XRCE-DDS does not allocate. Recommended heap budget: 64 KB minimum for zenoh-pico’s working set; bare-metal ports typically allocate 128 KB+ via a bump allocator (linked-list-allocator or embedded-alloc).
The RTOS allocators (pvPortMalloc, tx_byte_allocate, k_malloc, libc malloc) honour their respective heap-region configurations. On bare-metal the heap region is defined in the linker script and consumed at startup by the bump allocator.
Threading (PlatformThreading)
Multi-threaded ports (POSIX, NuttX, FreeRTOS, Zephyr, ThreadX) expose real tasks, mutexes, and condition variables. zenoh-pico’s lease task and read task spawn into these. Single-threaded bare-metal ports stub task_init to return -1 so the spawn fails gracefully; the application drives spin_once from a single context.
Recursive mutexes are required by zenoh-pico. FreeRTOS uses xSemaphoreCreateRecursiveMutex; ThreadX uses tx_mutex_create(..., TX_INHERIT, ...); POSIX uses PTHREAD_MUTEX_RECURSIVE.
Sleep / Random / Wall-time (PlatformSleep, PlatformRandom, PlatformTime)
PlatformSleep on RTOS ports uses the kernel’s tickless sleep (vTaskDelay, tx_thread_sleep, k_msleep, libc usleep). On bare-metal with smoltcp, the sleep helper also runs network_poll() in a busy loop — packets must keep flowing during otherwise-idle waits or the zenoh lease times out.
PlatformRandom is a 32-bit xorshift PRNG seeded with hardware entropy (getrandom, RNG peripheral) or a build-time constant on platforms without entropy. Used for session IDs and protocol nonces; not cryptographic.
PlatformTime returns wall-clock for log timestamps. Bare-metal platforms with no RTC fall back to the monotonic clock — log timestamps then count from boot, not Unix epoch.
Networking (PlatformTcp, PlatformUdp, PlatformSocketHelpers, PlatformUdpMulticast, PlatformNetworkPoll)
The split into four traits maps directly onto zenoh-pico’s unix/network.c interface. Each port wires the four traits independently:
- C-backed networking (NuttX, ThreadX): the platform shim forwards into zenoh-pico’s bundled
unix/network.c(NuttX) or a NetX-Duo equivalent (ThreadX) — the C code talks to BSD-shape sockets directly. - Rust-backed networking (POSIX, FreeRTOS, Zephyr, bare-metal): the platform crate implements TCP / UDP in Rust. POSIX wraps libc, FreeRTOS wraps lwIP via
freertos-lwip-sys, Zephyr wraps the POSIX layer, bare-metal goes throughnros-smoltcp.
PlatformUdpMulticast (RTPS SPDP, zenoh scouting) ships fully wired on POSIX, NuttX, Zephyr, and bare-metal (smoltcp 0.12 IGMP group join). FreeRTOS and ThreadX have no multicast yet — gated by lwIP’s IGMP=1 (untested) and NetX Duo’s nx_igmp_* (untested).
PlatformNetworkPoll is bare-metal only. The implementation advances the smoltcp state machine; without it, smoltcp would only receive when the application explicitly asked. PlatformSleep and the wait_event helper both run network_poll() while waiting so packets continue flowing.
Libc (PlatformLibc)
zenoh-pico uses strlen, memcpy, errno, etc. directly. Bare-metal targets that link picolibc or newlib-nano satisfy these for free; the trait exists for no_std targets without a C runtime, which forward to Rust implementations.
Logging (nros-log)
Where a log record goes, by the platform linked into the image:
| Target | Delivery |
|---|---|
| POSIX | fprintf(stderr, "[<LEVEL>] <name>: <msg>\n") |
| Zephyr | LOG_INF, LOG_WRN and so on, in module nros (printk if CONFIG_LOG=n) |
| NuttX | syslog(priority, "%s", buf) |
| FreeRTOS, ThreadX | a UART writer the board registers with nros_platform_register_log_writer at run() |
| Bare metal (MPS2-AN385) | QEMU semihosting, hstderr |
| Bare metal (STM32F4) | defmt::info!("{=str}", msg) |
Severities, as the nros_platform_log_write ABI numbers them. They are not
rcutils_log_severity_t’s numbers, and there is no Unset level in Rust
(Logger::unset_level() is the “no level of its own” state). The C surface’s
rcl_log_severity_t uses rcutils’s numbers, UNSET included.
| Severity | Value | Use |
|---|---|---|
Trace | 0 | per-instruction detail; compiled out unless the ceiling allows it |
Debug | 1 | diagnostics while developing |
Info | 2 | normal events worth one line; the process default |
Warn | 3 | unexpected but recoverable |
Error | 4 | errors the caller surfaces; the system continues |
Fatal | 5 | unrecoverable; the system is about to stop |
The log crate bridge (nros-log/log-compat) maps Trace, Debug, Info, Warn
and Error both ways, and Fatal to log’s Error one way.
Common pitfalls
For platform-specific gotchas (DMA buffer placement, ephemeral port conflicts, picolibc errno TLS, QEMU clock synchronization, Z_FEATURE_INTEREST mutex exhaustion, etc.), see Platform Porting Pitfalls.
For the design rationale (why these trait groups, why split PlatformNetworkPoll), see Platform API Design.
For writing a new port, see Add a platform. For the canonical interface spec, see the Doxygen reference.
Troubleshooting — First 10 Minutes
Every first build of a project needs ROS 2 sourced, because the messages are
generated from it (A10). The
Run a talker on an emulated board runs a talker in QEMU over Zenoh, so it
also needs ROS 2 for the router; its Linux section runs on Cyclone DDS,
where no router exists, so “no output” there is never a router problem. The
First Node pages run on Linux over Zenoh and assume nros setup linux --rmw zenoh has run and the ROS 2 router (ros2 run rmw_zenoh_cpp rmw_zenohd) is
reachable. When something goes wrong in the first ten minutes, the
error you see usually points at one of the predictable misses below.
Each branch quotes the real stderr you can grep against — not a paraphrase. If your error text matches, the fix on the right is the one to try.
A refusal that starts error[NROS-NNNN] carries a diagnostic code. Its last
line, explain: nros explain NROS-NNNN, is a command that prints what
happened and how to fix it, with no network; Diagnostic
codes lists every code.
A. Build failures (cargo / cmake)
A1. Cargo cannot find nros
error: no matching package named `nros` found
A node package’s Cargo.toml declares nano-ros crates registry-style
(nros = { version = "*" } — they are not published to crates.io); the
[patch.crates-io] block that resolves them into the nano-ros SDK is
GENERATED, under build/, and nros build hands it to cargo with
--config. nros build and nros run write it themselves, so this error
means cargo ran without it: a plain cargo build in a package, or an IDE
that opened the workspace before anything was generated. Fix:
cd <the workspace root>
nros build # or, to prepare without building: nros configure
nros configure writes the generated
settings without building; nros build --dry-run prints the cargo line that
uses them. Either is also what ties a copied-out workspace to an SDK (the
nros binary’s own, or the one --nano-ros-path names), and runs again by
itself on the next build after you move the directory.
This is not an nros setup issue — nros setup only fetches
the SDK / source-package payload (zenoh-pico, mbedtls, cyclonedds,
…); it does not synthesise missing Cargo dependencies.
A2. nros CLI not found
nros (codegen tool) not found on PATH or in packages/cli/target/release/
or ${NROS_HOME:-~/.nros}/bin. …
(The rest of the message names how a contributor builds the CLI from a checkout; as a user you install it instead.)
The nros binary is not installed, or not on PATH. Install a release
and put ~/.nros/bin on PATH:
curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh | sh
export PATH="$HOME/.nros/bin:$PATH"
If ~/.nros/bin/nros exists but PATH doesn’t see it — that’s the
[PATH] doctor status (D2 below), not this branch.
The nros binary ships the codegen — there is no separate
nros-codegen build step. CMake projects auto-resolve nros from
PATH / ${NROS_HOME:-~/.nros}/bin/;
-D_NANO_ROS_CODEGEN_TOOL=<path> is an override, not a requirement.
A3. Rust target not installed
error: could not compile … due to previous error
the target `thumbv7m-none-eabi` is not installed
Add it:
rustup target add thumbv7m-none-eabi
The triple is the board’s, not the example’s — you will not find it in any
file you wrote. Read it back from the [build] target line of the generated
nros-cargo.toml under build/, which nros build writes from the board
your bringup’s system.toml names.
A4. Cross linker not found
error: linker `arm-none-eabi-gcc` not found
The cross toolchain wasn’t provisioned. Run nros setup for your board (it ships a prebuilt arm-none-eabi-gcc):
nros setup mps2-an385-freertos # or qemu-armv7a-nuttx / mps2-an385-baremetal / …
A5. Cyclone DDS runtime missing
ld: cannot find -lddsc
ld: cannot find -lcyclonedds-ddsc
The Cyclone DDS runtime wasn’t provisioned:
nros setup linux --rmw cyclonedds
A6. cargo build --features rmw-cyclonedds can’t link
undefined reference to `nros_rmw_cyclonedds_register`
undefined reference to `dds_create_participant`
rmw-cyclonedds cannot link from cargo alone — the Cyclone backend
is C++ + CMake, registered via nros_rmw_cffi_register_named from a
CMake-built target — wired through CMakeLists.txt +
Corrosion. Use the cmake build path instead, and choose the backend where
backends are chosen: [system] rmw in the bringup’s system.toml.
[system]
rmw = "cyclonedds"
cd my_ws # a workspace with C or C++ node packages
nros build
There is no -DNROS_RMW= to pass: a backend selected on
the command line disagrees with the one the rest of the build resolves from
system.toml.
A Rust node package does not take --features rmw-cyclonedds at all: its RMW
is its image’s. A bringup that declares a linux_cyclonedds
image (as
examples/linux/rust/talker
does) builds it with nros build linux_cyclonedds — the board crate’s rmw-cyclonedds builds Cyclone
through nros-rmw-cyclonedds-sys.
A7. The board name is a typo
error[NROS-0002]: `[image.linux] board = "mps2-an358"` matches no board
help: check the spelling; the known boards are an536, bare-metal, baremetal, … Out-of-tree boards are added through `$NROS_EXTRA_BOARD_PATH`
explain: nros explain NROS-0002
[image.<id>] board is where a bringup names its board, and a typo there is
refused by name rather than guessed at. The legal spellings are the
names = [...] arrays of the board descriptors, one per board crate at
packages/boards/*/nros-board.toml; several are aliases for the same board
(mps2-an385-baremetal, baremetal and bare-metal all name one
descriptor).
The neighbouring refusals, when the image is missing rather than misspelt:
error[NROS-0003]: this workspace declares no `[image.*]`, and an image is the buildable unit
help: add `[image.<id>] board = "<board>"` to the bringup package's system.toml
explain: nros explain NROS-0003
error[NROS-0004]: …/system.toml: `[image.linux]` names no `board`
help: add `board = "<board>"` to the `[image.<id>]` table in system.toml
explain: nros explain NROS-0004
The first means no bringup in the workspace has a system.toml with an
image, so there is nothing for nros build to plan. The second means the file is
there and its [image.<id>] table has no board key.
A8. system.toml next to code
nros build refuses a system.toml in a directory that also holds a
Cargo.toml or a CMakeLists.txt. A system.toml belongs to a bringup
package, never to the package with the code, because it says where that code
runs and the code itself must not.
To fix it, give the configuration its own package:
- Make
src/<pkg>_bringup/beside your node package, with apackage.xml. - Move
system.tomlinto it. - Delete any
mainthat only starts the node; the entry is generated.
nros new <ws> --board <board> --template talker writes this shape, so a
scaffolded project never hits it.
A9. direnv allow reminder
NROS_PLATFORM_CFFI_INCLUDE not set (direnv allow, or build via just)
FREERTOS_PORT not set
(The quoted message is emitted by the build script; “direnv allow” and
“build via just” in it refer to a contributor checkout.) nros build
passes these to cargo from the board’s settings, so a build driven by
nros build — or by cargo with the generated --config file — does not
hit it. If a cargo command you drive yourself does, you skipped the
--config build/<image>/nros-cargo.toml argument.
A10. AMENT_PREFIX_PATH is unset
nros build, nros run or nros configure stops before building anything.
The message names the command you ran; from nros build:
error[NROS-0001]: `AMENT_PREFIX_PATH` is unset, and `/home/you/sensor_ws` has no earlier configure that recorded one
help: source ROS 2 in this shell (`source /opt/ros/<distro>/setup.bash`, or your overlay's `install/setup.bash`) and run `nros build` again; later shells need not source it
explain: nros explain NROS-0001
The project has messages to generate (every talker uses std_msgs), and
nano-ros generates them from the message definitions of your ROS 2 install,
so the types and their hashes match your ROS 2 peers. This shell has not
sourced ROS 2, and no earlier configure of the project ran in one that had.
It happens on every board and every RMW, Linux and Cyclone DDS included.
Source ROS 2 once, in this shell, and run the same command again:
source /opt/ros/humble/setup.bash # or your overlay's install/setup.bash
nros build
That configure records the prefix in the project. Later builds and runs of the same project reuse it, from any shell, an IDE or a CI step. A new project records its own, so its first build needs a sourced shell again.
A11. The stack is below the image’s floor
nros-stack-floor: ERROR: the OPEN stack is 26624 B, below the measured floor 56368 B. Raise it: NROS_BAREMETAL_STACK_KB=56
Every build of an embedded image works out a stack floor for the thread that opens nano-ros and runs its executor. It walks the compiled code for the deepest call path, counts every indirect call as able to reach every function it could reach, and adds a margin. That makes it a heuristic floor: it usually sits well above the stack the image really uses, because no run takes every path the walk allows, and it is not a proof that a larger stack never overflows. An exact search that would tighten it is not done yet.
An image template whose real peak has been observed on a run is measured.
For a measured image, a stack below the floor fails the build, and the
message names the setting to raise and the value that clears it:
NROS_BAREMETAL_STACK_KB on bare metal, NROS_MEMORY_APP_STACK_BYTES on
FreeRTOS, CONFIG_MAIN_STACK_SIZE in a Zephyr image’s os_config. Raise it
to that value and build again. nros new writes a stack that holds the floor
into the projects it scaffolds. A FreeRTOS image can instead state
stack_floor = "raise" under [image.<id>] in system.toml, and the build
rebuilds it once at the floor (system.toml reference).
For an image nobody has measured, the floor is only printed, as a WARNING
that names the same setting. Nothing is refused, and if the image overflows
that setting is the first thing to try.
A12. The stack check finds no llc for the toolchain
nros-stack-floor: the bitcode was written by rustc 1.99.0, whose toolchain has no `llc`: run `rustup component add llvm-tools --toolchain 1.99.0`, or pass --llvm-bin
The stack check (A11) reads the
compiled Rust code with the LLVM tools of the toolchain that built it. A
project with its own rust-toolchain.toml builds with that pinned toolchain,
and rustup installs it without those tools. Run the command the message
names, rustup component add llvm-tools --toolchain 1.99.0 with the version
it names, then nros build again.
The same fix holds when the message says the only llc it found is of
another LLVM version: the check never reads the code with a tool of the
wrong version. For a measured image the missing tool fails the build; for an
unmeasured one it is a WARNING and the build goes on.
B. Binary runs but no output
B1. Rust: RMW session open failed — Transport(ConnectionFailed)
[ERROR nros] RMW session open failed — Transport(ConnectionFailed)
The zenoh router isn’t running, or isn’t reachable on the locator the talker is pointed at. The router comes from ROS 2 (nano-ros no longer ships one) — start it in another terminal:
ZENOH_CONFIG_OVERRIDE='listen/endpoints=["tcp/127.0.0.1:7447"];scouting/multicast/enabled=false' \
ros2 run rmw_zenoh_cpp rmw_zenohd
Default ports: tcp/127.0.0.1:7447 on POSIX,
tcp/10.0.2.2:7451 on QEMU FreeRTOS (Slirp forwards to host),
7452 NuttX, 7453 ThreadX-RV, 7454 ESP32, 7455
ThreadX-Linux, 7447 Zephyr.
B2. C: RCLC_CHECK failed: rclc_support_init(...) -> -4
RCLC_CHECK failed at src/main.c:92: rclc_support_init(&app.support, argc, argv, &allocator) -> -4
Process exits 1 (the retval passed to RCLC_CHECK_RET).
-4 = RCLC_RET_NOT_FOUND — the locator was unreachable (zenohd
not running, or wrong port). Same fix as B1 above.
The C API entry point is rclc_support_init (rclc’s
(&support, argc, argv, &allocator)) or, with an explicit locator,
rclc_support_init_with_locator — not nros_init or nros::init,
which don’t exist in the C API.
B3. C++: process exits 156 after a rclcpp::init_in failure
nros::init returned NROS_CPP_RET_TRANSPORT_ERROR (-100)
Same root cause as B1/B2 — zenohd not reachable.
NROS_CPP_RET_TRANSPORT_ERROR = -100 is the C++ result code that
RCLCPP_TRY_RET propagates from main(); on POSIX this becomes
(unsigned char)-100 = 156 as the process exit code. Treat
“exited 156 after starting” as the C++ equivalent of B1.
B4. Override the locator at runtime
When a native talker can’t reach the daemon, override the locator with the canonical env var:
NROS_LOCATOR=tcp/192.168.1.50:7447 ./build/c_talker
ROS_DOMAIN_ID=7 ./build/c_talker # also overridable
The native Rust / C / C++ talkers all read NROS_LOCATOR, then fall back
to the build-time default. The retired ZENOH_LOCATOR / ZENOH_MODE are
REFUSED at startup with an error naming NROS_LOCATOR / NROS_SESSION_MODE
— unset them. Embedded
targets have no runtime env — their locator is compile-baked from
system.toml ([image.<id>] locator, or [system] locator for an image that
does not state one), so editing that file and rebuilding is the override.
B5. Binary exits immediately, no error printed
Buffering: setvbuf(stdout, NULL, _IOLBF, 0) if you piped the run.
POSIX terminals flush on newline; piped stdout full-buffers and
may eat short outputs. Add a RUST_LOG=info (Rust) or unbuffer
the C / C++ output (stdbuf -oL).
C. ROS 2 side sees nothing
C1. RMW mismatch
# On the ROS 2 side, default rmw_fastrtps_cpp will NOT see nano-ros:
export RMW_IMPLEMENTATION=rmw_zenoh_cpp # for Zenoh
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp # for Cyclone
C2. QoS mismatch — echo silent, list sees the topic
ros2 topic list # /chatter shown
ros2 topic echo /chatter # … nothing
nano-ros publishers default to BEST_EFFORT; stock
ros2 topic echo defaults to RELIABLE. The QoS-mismatched
subscriber is created but receives no data. Force best-effort on
the echo:
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
D. Doctor + last-resort
D1. Run the doctor first
nros doctor
It prints fixit hints for the toolchain you actually need. (A just-free platform-scoped doctor spelling does not exist today; contributors with an in-tree checkout can scope via the platform recipes.)
D2. [PATH] nros built but not on PATH
The doctor reports this distinct from [MISSING] when the binary is
installed at ${NROS_HOME:-~/.nros}/bin/nros but PATH doesn’t see it.
Put the directory on PATH (and in your shell’s startup file):
export PATH="$HOME/.nros/bin:$PATH"
D3. Full sweep (slow)
nros doctor
nros setup --check
Only run this when you’re standing up every supported platform in one go. It walks the provisioning checks and can take a few minutes.
D4. File an issue
When all else fails, include:
- the exact command you ran,
- the full stderr,
rustc --version,cmake --version,qemu-system-arm --version,nros --version.
E. zenoh-pico error codes
| Code | Name | Meaning |
|---|---|---|
| -102 | _Z_ERR_TRANSPORT_OPEN_FAILED | could not connect to the router |
| -73 | _Z_ERR_SESSION_CLOSED | the session closed after an earlier failure |
| -78 | _Z_ERR_SYSTEM_OUT_OF_MEMORY | an allocation did not fit |
| -100 | _Z_ERR_TRANSPORT_TX_FAILED | a transmission failed |
| -128 | _Z_ERR_GENERIC | a generic error |
The full list is zenoh-pico’s include/zenoh-pico/utils/result.h. Fixes by
symptom are in Troubleshoot.
What success looks like
A correctly-running Rust Linux talker
(examples/linux/rust/talker) prints something like this on
stderr (with RUST_LOG=info):
[INFO talker] Publishing: 'Hello World: 1'
[INFO talker] Publishing: 'Hello World: 2'
[INFO talker] Publishing: 'Hello World: 3'
(That is the full expected output — the talker logs one line per publish, nothing else.)
A correctly-running C talker (examples/linux/c/talker) prints
on stdout:
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
Publishing: 'Hello World: 3'
A correctly-running C++ talker prints the same
Publishing: 'Hello World: N' line once per second.
The ROS 2 side (ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort with
RMW_IMPLEMENTATION=rmw_zenoh_cpp) should see:
data: 'Hello World: 1'
---
data: 'Hello World: 2'
---
data: 'Hello World: 3'
---
If you see all three of these — talker logging, ROS 2 echo output, and matching counter values — interop is verified end-to-end.
See also
- Install + first build — full setup walkthrough
- Add a second node — the canonical Rust starter
- Troubleshooting — broader issue-by-issue reference for post-first-build problems
Diagnostic codes
Every refusal nano-ros prints carries a code, NROS- and four digits:
error[NROS-0004]: src/demo_bringup/system.toml: names no board
help: add `board = "<board>"` to the `[image.<id>]` table in system.toml
explain: nros explain NROS-0004
The explain: line is a command: nros explain NROS-0004 prints the
code’s section below without a network or a checkout. A code never
changes its meaning, and a retired code names the one that replaced it.
| Code | What went wrong |
|---|---|
| NROS-0001 | ROS 2 is not sourced, and the project has messages to generate |
| NROS-0002 | an image names a board that no board descriptor claims |
| NROS-0003 | the workspace declares no image |
| NROS-0004 | an image names no board |
| NROS-0005 | a board’s platform reaches no built-in family |
| NROS-0006 | no diagnostic has this code |
| NROS-0011 | a knob is spelled with its retired name |
NROS-0001: ROS 2 is not sourced, and the project has messages to generate
nros configure, nros build or nros run stopped before building anything,
because this shell has not sourced ROS 2 and the project has messages to
generate.
nano-ros generates every message type a project uses (a talker’s std_msgs,
for example) from the message definitions of your ROS 2 install, so the types
and their hashes match your ROS 2 peers. It finds that install through
AMENT_PREFIX_PATH, which sourcing ROS 2 sets. A configure that ran in a
sourced shell records the prefix in the project, so later commands do not
need it; this project has no such record yet.
It happens on every board and every RMW, Linux and Cyclone DDS included.
How to fix it
Source ROS 2 once, in this shell, and run the same command again:
source /opt/ros/humble/setup.bash # or your overlay's install/setup.bash
nros build
That configure records the prefix in the project. Later builds and runs of the same project reuse it, from any shell, an IDE or a CI step. A new project records its own, so its first build needs a sourced shell again.
The refusal’s help line, unless the site gives a more specific one:
source ROS 2 in this shell (
source /opt/ros/<distro>/setup.bash, or your overlay’sinstall/setup.bash) and run the command again; later shells need not source it
NROS-0002: an image names a board that no board descriptor claims
An image names a board that no board descriptor claims, so nano-ros does not know what to build it for.
[image.<id>] board in a bringup’s system.toml is where an image names its
board. Each board crate ships a descriptor whose names list says which
spellings it answers to, and several are aliases for one board
(mps2-an385-baremetal, baremetal and bare-metal all name one
descriptor). A name that none of them lists is refused by name rather than
guessed at, because a guess builds the wrong image and reports success.
How to fix it
Check the spelling in system.toml:
[image.demo]
board = "mps2-an385-freertos"
nros board list prints every board this SDK has. If the board is your own,
its board package must be on the board search path.
The refusal’s help line, unless the site gives a more specific one:
check the spelling of the image’s
board;nros board listnames every board this SDK has
NROS-0003: the workspace declares no image
nros build (or a verb that resolves images) found no [image.<id>] in any
bringup package of the workspace, so there is nothing to build.
An image is the buildable unit of nano-ros: one board, one RMW, and the
components that run on it. It is declared in a bringup package’s
system.toml (a directory holding package.xml and system.toml, and no
code). A workspace whose bringup declares no image, or that has no bringup
package at all, has nothing for nros build to plan.
How to fix it
Add an image to the bringup package’s system.toml:
[image.demo]
board = "linux"
If the workspace has no bringup package yet, nros new <ws> --board <board> --template talker shows the shape, and nros configure --migrate moves a
system.toml that sits beside a package’s code into one.
The refusal’s help line, unless the site gives a more specific one:
add
[image.<id>] board = "<board>"to the bringup package’s system.toml
NROS-0004: an image names no board
An [image.<id>] table in system.toml has no board key, so nano-ros does
not know what to build the image for.
Every image names exactly one board. The board decides the target triple, the RTOS, the toolchain and the network setup; nothing else in the project can stand in for it.
How to fix it
Add the board to the image’s table:
[image.demo]
board = "mps2-an385-freertos"
nros board list prints the boards this SDK has.
The refusal’s help line, unless the site gives a more specific one:
add
board = "<board>"to the[image.<id>]table in system.toml
NROS-0005: a board’s platform reaches no built-in family
A board names a platform that is not one of nano-ros’s built-in platforms, and
the platform’s inherits chain does not reach one, so nano-ros does not know
which family’s build rules the platform takes.
A platform you add yourself (nros new platform) is described by its
nros-platform.toml. Its inherits key names the built-in family it builds
like (freertos, zephyr, bare-metal, and so on), directly or through
another platform that does. The refusal names the chain it followed, and says
which of these went wrong:
- the chain ends at a platform that inherits nothing;
- a name in the chain is neither built in nor answered by any
nros-platform.tomlon the platform search path; - the chain loops back on itself.
How to fix it
Add inherits to the platform the refusal names, choosing the built-in family
it is closest to:
# nros-platform.toml
inherits = "freertos"
A platform that does not exist yet is scaffolded with
nros new platform <name> --inherits <family>.
The refusal’s help line, unless the site gives a more specific one:
add
inherits = "<family>"to the platform’s nros-platform.toml
NROS-0006: no diagnostic has this code
nros explain was given a code, spelled NROS- and four digits, that no
diagnostic has.
Every code nano-ros prints is compiled into the nros binary, so this one was
mistyped, or comes from a newer release than this binary. The refusal lists
the three codes nearest the one you gave.
How to fix it
Copy the code from the explain: line of the refusal that printed it. If it
came from a newer nano-ros, run that release’s nros explain.
A file that happens to be named like a code is reached as a path:
nros explain ./NROS-0412.
The refusal’s help line, unless the site gives a more specific one:
check the code against the refusal that printed it
NROS-0011: a knob is spelled with its retired name
A knob in system.toml is spelled with a name that has been retired. Each
knob has one current spelling; older spellings (ZPICO_MAX_QUERYABLES for
NROS_ZENOH_MAX_QUERYABLES, for example) are refused rather than read,
because two names for one setting is how a build ends up reading the one you
did not change.
The refusal points at the key in the file and names the current spelling.
How to fix it
Rename the key. nros fix does it for every retired spelling in the
workspace’s system.toml files: it prints the change first, and writes it
with --apply.
nros fix # show what would change
nros fix --apply # write it
A knob whose setting was removed outright, not renamed, has no current spelling. Its refusal names the reason instead, and the row has to be deleted by hand.
The refusal’s help line, unless the site gives a more specific one:
rename the key to the knob’s current spelling, which the refusal names;
nros fixdoes it
Add a board
Needs first: How a build becomes an image
You have a board that nano-ros does not ship, on a platform it already
supports. By the end of this page, nros board info resolves your board from
your own tree, and an image built for it runs. If nano-ros has no platform for
your RTOS yet, add the platform first.
Before you start
-
nano-ros is installed, and you have built and run an image on one of its own boards.
-
You know which platform the board runs:
zephyr,freertos,nuttx,threadx,bare-metalorposix. -
You know who owns your build. That decides what you write:
Your build What you write Zephyr, with westA board package: a descriptor, a package.xml, Kconfig and devicetree fragments. No Rust crate.FreeRTOS, ThreadX or NuttX, driven by nros buildA board package and a small board crate on the family crate ( nros-board-freertos,nros-board-threadx,nros-board-nuttx).Bare metal A board package and a board crate of your own. There is no family crate; nros-board-mps2-an385is the reference.A vendor IDE or CMake tree No board crate: build inside your tree.
Steps
-
Scaffold the board package outside nano-ros:
nros board new my-board --platform freertos --out-of-tree ./boards \ --workspace "$(nros locate nano-ros)"wrote ./boards/nros-board-my-board next: export NROS_EXTRA_BOARD_PATH=./boards # how this board is reachedThe command writes two files: the descriptor
nros-board.toml, which says what the board lowers to, and apackage.xmlwhose<nano_ros_provides kind="board" name="my-board"/>announces that the board exists. nano-ros needs both. For a Zephyr board, add--west-board <board>/<soc>/<variant>; the command then also writes an emptyprj.conf. Outside a nano-ros source tree,--workspaceis required even with--out-of-tree.The scaffold’s last line names a check for nano-ros’s own tree. It does not apply to an out-of-tree board.
-
Make the board reachable, and check that nano-ros finds it:
export NROS_EXTRA_BOARD_PATH="$PWD/boards" nros board info my-board{ "name": "my-board", "board_dir": ".../boards/nros-board-my-board", "descriptor": ".../boards/nros-board-my-board/nros-board.toml", "cmake_vars": null }NROS_EXTRA_BOARD_PATHtakes several directories, separated by:. Each has the layout of nano-ros’s own board directory: one package directory per board. For a Zephyr board,cmake_varsholds the variablesnano_ros_use_board()sets, so you can read what CMake will see without configuring anything. -
Fill in the descriptor. The scaffold sets
names,platform,toolchain,platform_feature,entry_kindand an emptysupported_netstacks. Add what your board needs:board_crate, the crate that holds the board’s code, andcargo_config, the target triple and link flags its images build with.chip, andsupported_netstacks: who brings up the network. An empty list is a statement, not an omission: an image that names a network stack the board does not list is refused.[board.entry] type, the board’s marker type thatnros::main!names ("::my_board::MyBoard"), for any board whose images have a Rust entry.nros buildhands it to the macro, and the generated entry depends on the crate it names. A Linux host board copied from the in-tree one keeps"::nros_board_linux::LinuxBoard".- The rest of
[board.entry], whenentry_kind = "board-run": themainsignature the generated entry calls. Copy the block from the in-tree board nearest yours.
Then say how the board runs. A board states this once, and
nros run,nros flashand the generated board pages read it:[board.run]holdsemulator = "<kind>:<machine>"(qemu,fvporrenode) orhost = true. A QEMU board adds[board.run.qemu]. An Arm FVP board adds[board.run.fvp] paramsfor the model parameters every image on it needs, each written as it would follow-C("bp.smsc_91c111.enabled=1"). Real silicon with no emulator twin leaves[board.run]out.[board.flash]names the flashermethod(west,probe-rs,openocd,picotool, …), thechipin that flasher’s spelling, and thepreparesteps a person does first. Each step issay,wait_for(an event such asusb:<vid>:<pid>) orrun.[board.console]gives the consolekind(stdio,serial,rttorsemihosting), and for serial the adapter’susbid andbaud.
Rerun
nros board info my-boardafter each edit. An unknown key fails the load and names the key, the file and every key that is allowed. -
Write the board crate (every platform but Zephyr). A board is a marker type that implements four traits from
nros_platform:Trait What your board does in it BoardInitinit_hardware(): clocks, pin mux and peripherals, once, before the executor opens.BoardPrintprintln(args): write one line wherever the board’s console is.BoardExitexit_success()andexit_failure(): halt, reset or end the emulator.BoardEntryrun(setup): bring the link up, open the executor, callsetup, spin. On FreeRTOS, ThreadX and NuttX, delegate to the family crate’srun_entry.BoardEntry::run_with_deploytakes the image’s network settings from itssystem.toml; implement it as well, so the board dials the locator the image names. The members and their contracts are in thenros_platformrustdoc.On FreeRTOS, the family crate brings up lwIP and calls two C hooks for the network interface,
nros_board_register_netifandnros_board_poll_netif. Its defaults are weak and report no Ethernet. Give strong definitions that attach your MAC driver to lwIP, or leave them out and reach the router over a serial locator. -
On Zephyr, consume the board from the application’s
CMakeLists.txt, with one call beforefind_package(Zephyr):nano_ros_use_board(my-board) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(my_app LANGUAGES CXX)The call sets
BOARDand the default RMW, and appends the board’sprj.conf, Kconfig fragments and devicetree overlay, ahead of your own. It comes from nano-ros’s Zephyr module, whichnros buildpasses for you; awest buildyou run yourself names it withZEPHYR_EXTRA_MODULES="$(nros locate nano-ros)". -
Build and run an image on the board:
nros new sensor_ws --board my-board --template talker cd sensor_ws nros run sensor_nodeOn hardware, use
nros flash --monitorinstead ofnros run. Check the talker against a stock ROS 2 peer, as in Talk to ROS 2.
Example
An STM32F429 with Ethernet, on bare metal, kept in its own repository. No nano-ros lane boots this chip, so its verification is yours: the board stays out of tree, and you upgrade nano-ros when you choose.
my-stm32f4-board/
Cargo.toml # depends on nros and the bare-metal platform
nros-board.toml # the descriptor
package.xml # announces kind="board" name="my-stm32f4"
build.rs # emits the memory map
memory.x # FLASH and RAM origin and length for the chip
src/lib.rs # the board marker type, its trait impls and its entry
The descriptor. nano-ros supplies both the MAC driver and the IP stack here
(smoltcp), so nothing outside the crate brings up the network:
[[board]]
names = ["my-stm32f4"]
platform = "bare-metal"
toolchain = "stable"
platform_feature = "platform-bare-metal"
link_kind = "none"
entry_kind = "board-run"
supported_netstacks = ["smoltcp"]
chip = "stm32f429"
board_crate = "my-stm32f4-board"
cargo_config = '''
[build]
target = "thumbv7em-none-eabihf"
[target.thumbv7em-none-eabihf]
rustflags = ["-C", "link-arg=-Tlink.x"]
'''
[board.entry]
type = "::my_stm32f4_board::MyStm32f4Board"
crate_name = "my_stm32f4_board"
signature = "#[my_stm32f4_board::entry]\nfn main() -> !"
[board.flash]
method = "probe-rs"
chip = "STM32F429ZITx"
prepare = [
{ say = "Set BOOT0 to 1, then press RESET", wait_for = "usb:0483:df11" },
]
[board.console]
kind = "serial"
usb = "0483:374b"
baud = 115200
The board’s Config composes the shared network fields rather than declaring
them again. BaseConfig carries the MAC, IP, netmask, gateway, locator and
domain, and applies the image’s settings, so your board stays in step with the
others when those fields change:
#![allow(unused)]
fn main() {
pub struct Config {
pub base: nros_board_common::BaseConfig,
pub phy_addr: u8,
}
}
The cost of this board is the network driver. On an RTOS board, the RTOS brings up the NIC and nano-ros asks it for a socket. Here nothing else does, so the MAC driver is part of your board. Budget for it first.
Get your board into this book
A board kept out of tree needs nothing more: it runs from its descriptor. It has no support status on the generated pages, because nano-ros holds no evidence for it.
For nano-ros to carry a status for your board, contribute the board package and the commands that build, flash and run it, by an issue or a pull request on GitHub. The maintainers add the board’s row to the board-support registry. The row records where the board’s image runs in evidence nano-ros holds (nowhere, on the host, in an emulator or on hardware) and how often that run happens. The status word on Supported boards is derived from those facts and never typed. A board gets a page in this book only when it has an emulator twin or a probe track that replays its chapter; Board support levels explains each word.
If it doesn’t work
has no sibling package.xml announcing a board. The descriptor has no announcement beside it. Write thepackage.xmlthe error prints, naming the descriptor’snames, canonical first.nros board newwrites it for you.no board named my-board.NROS_EXTRA_BOARD_PATHis unset in this shell, or names the package directory itself instead of the directory that holds it.- The Zephyr build ignores the board.
nano_ros_use_board()ran afterfind_package(Zephyr). Zephyr readsBOARDand the fragments during that call, so move it above. could not auto-detect nano-ros workspace root.nros board newran outside a nano-ros source tree without--workspace. Pass--workspace "$(nros locate nano-ros)".
See also
- Add a platform, for an RTOS nano-ros has no platform for.
- Add a transport, for a link that is not Ethernet, serial or WiFi.
- Supported boards and the generated board pages.
- The in-tree boards, as working code to copy:
nros-board-mps2-an385-freertos(FreeRTOS with its own Ethernet driver) andnros-board-mps2-an385(bare metal).
Design background
- RFC-0064: board support organization: board packages, family crates and why an unverified board stays out of tree
- RFC-0114: board support registry primitives: the evidence a registry row records and the derived status word
- RFC-0115: emulator-first board policy: which boards the user book admits (D4)
- RFC-0118: target execution model:
[board.run],[board.flash]and[board.console](D4)
Add a platform
Needs first: How a build becomes an image
You have an RTOS or a bare-metal environment that nano-ros has no platform
for. A platform is the layer under the RMW backend: the clock, sleep, heap,
threads and sockets, exposed as free C functions named nros_platform_*. By
the end of this page your port implements those functions, a board names the
platform, and an image runs on it.
Today a platform is registered inside nano-ros itself, so the last part of this task is a contribution to nano-ros, not a package you keep on your own. Step 5 says what that contribution touches.
Before you start
- Check that you need a platform. If your RTOS is one nano-ros supports (FreeRTOS, Zephyr, NuttX, ThreadX, bare metal, POSIX), you need a board instead: Add a board.
- Know what your RMW backend asks of the platform. XRCE-DDS needs a clock and its transport. zenoh-pico needs the whole surface: a heap of about 64 KB, threads (or single-thread stubs), sockets, a random source and wall time. Cyclone DDS binds the platform’s own socket stack rather than these functions.
- Have the headers that specify the ABI at hand. They live in
packages/platform/nros-platform-api/include/nros/of nano-ros:platform.h(clock, sleep, heap, threads, random, time, critical section),platform_net.h(sockets) andplatform_timer.h(periodic timers). The Platform API and C ABI reference links their rendered documentation.
Steps
-
Scaffold the platform package:
nros new platform myoscreated .../nros-platform-myos/Cargo.toml created .../nros-platform-myos/src/lib.rs created .../nros-platform-myos/nros-platform.toml platform package `myos` scaffolded — next: fill in clock/sleep, then a board package: `nros new board <board> --for-platform myos`src/lib.rsholds stubs for the first three functions a port needs, a monotonicclock_ns, itsclock_resolution_ns, andsleep_ms. -
Choose how you implement the ABI. Both ways produce the same symbols, and the code above the platform cannot tell them apart.
- In C. Write the bodies against your kernel’s own API, as the
FreeRTOS, NuttX, ThreadX, Zephyr and POSIX ports do, in
src/platform.c,src/net.candsrc/timer.c. This is the natural fit when the kernel ships C headers and you build with its C toolchain. - In Rust. Implement the traits of
nros-platform-api(PlatformClock,PlatformAlloc,PlatformSleep,PlatformThreading, …) on a marker type, then export them with the macros ofnros-platform-cffi:nros_platform_export!(MyOsPlatform), andnros_platform_export_net!andnros_platform_export_timer!for the network and timer headers. The bare-metal ports do this, because there is no kernel to write C against.
- In C. Write the bodies against your kernel’s own API, as the
FreeRTOS, NuttX, ThreadX, Zephyr and POSIX ports do, in
-
Implement every function the three headers declare. A port that leaves one out fails to link. When your kernel lacks a primitive, return the value the header documents for it:
nros_platform_task_initreturnsNROS_PLATFORM_RET_UNSUPPORTEDon a port with no tasks, andnros_platform_epoch_usreturns0with no wall clock. Four rules catch most ports:- The clock reads a hardware timer or the kernel tick, never a counter that only moves when something polls it.
- Both mutex kinds inherit priority, as every supported port’s do. The recursive kind lets the same thread lock again: zenoh-pico needs it.
- The random source is seeded from something that differs between two boards (entropy, an address, the wall clock), not from a constant.
- Nothing panics or throws across the C boundary. Return the error codes the header names.
-
State the platform’s facts in
nros-platform.toml.[capabilities]holds what the software stack can do (ip_stack,serial,threads, …): a transport that needs a capability the platform declaresfalseis refused when the image is configured. Settings any C build on the platform needs go at the top of the file, before any table:arch_profiles,compileandrequired_env. Leave the[knobs.*]defaults alone until you have measured a reason to change one. An empty file is valid. -
Register the platform in nano-ros. This is the part that changes nano-ros, and it is a pull request, built as Contributing describes. It touches:
nros-platform: aplatform-myosfeature that pulls in your crate, and its entry in the list that resolvesConcretePlatform. A port that ships only C can use the existingplatform-cffifeature, which takes the symbols from whatever library the image links.- zenoh-pico, when the platform carries it: an ABI marker feature on
zpico-sys(myos = []), and a[port.myos]row in the zenoh backend’snros-rmw.tomlthat says which zenoh-pico system sources, defines and include paths build there. Start from the nearest platform’s row. XRCE-DDS needs no row: it selects its sources by target. - CMake, for C and C++ images:
cmake/platform/nano-ros-myos.cmake, which defines theNanoRos::Platformalias, thenros_platform_<plat>_ifacetarget behind it, thenros_platform_link_app(target)function for per-image link fixups, and theNROS_PLATFORM_LINK_FEATURESdefault.
-
Add a board that names the platform, as Add a board describes, with
platform = "myos"in its descriptor. -
Build and run the talker on that board, and check it against a stock ROS 2 peer:
nros new sensor_ws --board my-board --template talker cd sensor_ws nros run sensor_nodeOn hardware, use
nros flash --monitorinstead ofnros run.
Example
The first functions of a C port, for a kernel called MyOS. Each body is one kernel call; the opaque storage the runtime passes in holds the kernel’s own handle:
#include <nros/platform.h>
#include "myos.h"
uint64_t nros_platform_clock_ns(void) {
return (uint64_t)myos_tick_count() * 1000000u; /* 1 kHz tick */
}
uint64_t nros_platform_clock_resolution_ns(void) {
return 1000000u; /* say the tick honestly */
}
uint64_t nros_platform_epoch_us(void) {
return 0; /* no wall clock */
}
void *nros_platform_alloc(size_t size) { return myos_malloc(size); }
void *nros_platform_realloc(void *ptr, size_t size) {
return myos_realloc(ptr, size);
}
void nros_platform_dealloc(void *ptr) { myos_free(ptr); }
void nros_platform_sleep_ms(size_t ms) { myos_task_delay(ms); }
int8_t nros_platform_mutex_rec_init(void *m) {
myos_mutex_t *mx = (myos_mutex_t *)m;
*mx = myos_mutex_create_recursive();
return *mx ? NROS_PLATFORM_RET_OK : NROS_PLATFORM_RET_ERROR;
}
/* ... every other function declared in platform.h, platform_net.h and
* platform_timer.h ... */
The complete ports are the working examples. The POSIX port,
nros-platform-posix,
is the reference C port. The FreeRTOS port,
nros-platform-freertos,
shows tasks, recursive mutexes and condition variables on an RTOS, and
nros-platform-mps2-an385
is a Rust port for bare metal.
If it doesn’t work
- Timeouts never fire, or fire all at once. The clock advances only when something polls it. Read a free-running hardware timer.
- The session opens, then deadlocks. A mutex zenoh-pico takes twice is not recursive.
- Two boards on one network cannot talk. Both seeded the random source with the same constant, so they opened sessions with the same id.
- Silent memory corruption on an RTOS. A task stack is too small; an RTOS has no guard page. Size it from a measured overflow, not by copying a number.
- Duplicate
z_*symbols at link. The RTOS vendor’s own zenoh-pico system layer already defines them, and so does nano-ros’s alias layer. Turn theplatform-aliasesfeature ofzpico-sysoff for that platform. - Under QEMU, timeouts fire before packets arrive. Run the machine with
-icount shift=auto, so virtual time keeps wall-clock pace while the guest sleeps.
Internals keeps the longer list of lessons from the in-tree ports: Platform porting pitfalls.
See also
- Platform API and C ABI: the headers, the capability groups and the ports to copy.
- Platform differences: the clock, allocator, threading and network of each supported platform.
- Add a transport: for a link that needs no platform of its own.
- Internals → Platform API design: why the ABI is free symbols, and why threads and sockets stay per kernel.
Design background
- RFC-0034: platform layer split: the scalar and opaque-struct services
- RFC-0049: hierarchical platform and board config:
nros-platform.tomland its resolution ladder - RFC-0054: C header ABI single source of truth: why the headers are canonical
- RFC-0073: platform clock in nanoseconds:
clock_nsand its resolution
Add a transport
Needs first: How a build becomes an image
Your link is not one nano-ros carries itself: a USB CDC device, BLE GATT,
RS-485 with your own framing, a semihosting or RTT bridge, a ring buffer for a
test. You can plug it in from application code, without a new board or
platform. You give nano-ros four C functions (open, close, write and read) and
point the image’s locator at the custom scheme. By the end of this page the
RMW session runs over your link.
This is nano-ros’s counterpart of micro-ROS’s
rmw_uros_set_custom_transport. When a link nano-ros builds in (Ethernet,
serial, WiFi) fits, use that instead: a built-in link is smaller.
Before you start
- You have an image that builds and runs on its board, and the RMW is zenoh-pico or XRCE-DDS. Cyclone DDS binds the platform’s socket stack and does not use this hook.
- You have a driver for your link with an open, a close, a blocking write and a read that takes a timeout.
Steps
1. Write the four callbacks
Each callback takes the user_data pointer you register, so per-link state
travels through it:
| Callback | Returns |
|---|---|
open(user_data, params) | 0 on success, a negative rmw_ret_t on failure |
close(user_data) | nothing; teardown is best effort |
write(user_data, buf, len) | 0 on success, a negative rmw_ret_t on failure |
read(user_data, buf, len, timeout_ms) | the byte count, which may be less than len or 0; a negative rmw_ret_t on error |
The callbacks never run from an interrupt: wrap an interrupt-driven device in
a queue that read drains. write should not block beyond a short hardware
retry. user_data must live until close returns.
2. Register them, for zenoh-pico
Register before the executor or support object opens the session. The backend reads the registration once, at open; a later call is not refused, but the session may never see it.
#![allow(unused)]
fn main() {
use nros_rmw::{
NrosTransportOps, NROS_TRANSPORT_OPS_ABI_VERSION_V1, set_custom_transport,
};
unsafe {
set_custom_transport(Some(NrosTransportOps {
abi_version: NROS_TRANSPORT_OPS_ABI_VERSION_V1,
_reserved: 0,
user_data: core::ptr::addr_of_mut!(MY_LINK).cast(),
open: my_open,
close: my_close,
write: my_write,
read: my_read,
}))
.expect("abi_version matches this nano-ros");
}
}
A version other than NROS_TRANSPORT_OPS_ABI_VERSION_V1 returns
TransportError::IncompatibleAbi, and the previous registration stays.
#include <rclc/rclc.h>
const nros_transport_ops_t ops = {
.abi_version = NROS_TRANSPORT_OPS_ABI_VERSION_V1,
._reserved = 0,
.user_data = &my_link,
.open = my_open,
.close = my_close,
.write = my_write,
.read = my_read,
};
if (rclc_set_custom_transport(&ops) != RCL_RET_OK) {
/* a version other than NROS_TRANSPORT_OPS_ABI_VERSION_V1 */
}
rclc_set_custom_transport(NULL) clears the registration.
#include <rclcpp/transport.hpp>
rclcpp::TransportOps ops;
ops.user_data = &my_link;
ops.open = [](void* ud, const void*) -> nros_cpp_transport_ret_t {
return my_open(ud);
};
ops.close = [](void* ud) { my_close(ud); };
ops.write = [](void* ud, const uint8_t* buf, size_t len) -> nros_cpp_transport_ret_t {
return my_write(ud, buf, len);
};
ops.read = [](void* ud, uint8_t* buf, size_t len, uint32_t to) -> int32_t {
return my_read(ud, buf, len, to);
};
rclcpp::set_custom_transport(ops);
The fields are plain function pointers, so only lambdas with no captures
convert to them. set_custom_transport fills in the ABI version and refuses
a null field.
zenoh-pico frames its own wire protocol, so the bytes your callbacks carry
need no framing. The image also needs zenoh-pico’s custom link compiled in.
Stating the locator in the image (step 4) does that for Rust, C and C++
alike. A Rust image that opens its session on a custom/… locator in code,
without stating it, turns on the backend’s link-custom option instead,
beside its other dependencies:
[dependencies.nros-rmw-zenoh]
version = "*"
default-features = false
features = ["link-custom"]
3. Or register them, for XRCE-DDS
XRCE-DDS takes its own registration, with the same four callbacks and a
framing choice: framing on for a byte stream (a UART, USB CDC), off for a
packet link (UDP, BLE GATT). Call
nros_rmw_xrce_cffi::set_custom_transport_ops(&ops, framing) from Rust, or
nros_rmw_xrce_set_custom_transport_ops(&ops, framing) from C
(nros_rmw_xrce.h), before the backend registers. XRCE-DDS never calls
read and write at the same time. A board usually makes this call in its
entry, as the bare-metal MPS2-AN385 board does for its UART.
4. Point the image at the custom link
The locator’s scheme is the link. In the bringup’s system.toml, for
zenoh:
[image.my_image]
board = "my-board"
locator = "custom/uart"
and for XRCE-DDS, locator = "custom://uart". The two backends spell the
scheme differently: zenoh reads custom://uart as a scheme named custom:,
which it does not know.
On a custom link the build leaves the IP transports out of the image, and for zenoh it compiles in the custom link. What follows the scheme is a label for your own logs and must not be empty.
The far end of your link has to speak the protocol back: for zenoh, a router
or a peer that answers the session’s handshake. A loop that only returns the
image’s own bytes cannot, and the session refuses right after open.
5. Run the image
The session opens over your link: your open runs once, every publish
reaches write, and the executor’s spin calls read.
Example
A host image whose zenoh session runs over a TCP connection the application
opens itself, with no zenoh TCP link. The factory in nros-transport-callbacks
returns the four callbacks for a TCP bridge, and the session’s locator is the
custom scheme:
use nros::prelude::*;
fn main() {
let ops = nros_transport_callbacks::tcp_transport_ops("127.0.0.1:7447")
.expect("connect to the router");
unsafe { nros_rmw::set_custom_transport(Some(ops)).expect("abi_version v1") };
let config = ExecutorConfig::new("custom/loopback").node_name("talker");
let mut executor: Executor = Executor::open(&config).expect("open the session");
let mut node = executor.create_node("talker").expect("create the node");
let publisher = node
.create_publisher::<std_msgs::msg::String>("/chatter")
.expect("create the publisher");
// publish and spin as in any talker
}
The full image is
examples/linux/rust/custom-transport-talker,
which also registers its backend first and logs each message. A C image that
carries the bytes over a TCP connection it opens itself, and exits non-zero
unless all four callbacks ran, is
examples/linux/c/custom-transport-loopback.
On a board, the Rust workspace’s
baremetal_talker_xrce_serial image
runs XRCE-DDS over the mps2-an385 UART through locator = "custom://uart".
If it doesn’t work
- The session never opens, and
opennever ran. The transport was registered after the session opened, or zenoh-pico’s custom link is not in the image: the image states nocustom/…locator (step 4) and, in Rust, names nolink-custom, or the locator is spelledcustom://…. zenoh then treats the scheme as unknown. openran, then the session refused. Nothing on the far end answered the handshake (step 4).- Registration fails.
abi_versionis notNROS_TRANSPORT_OPS_ABI_VERSION_V1, or the struct was built without setting it. - An XRCE-DDS session ignores the transport. It was registered through
set_custom_transport, which only zenoh-pico reads. Use the XRCE call of step 3. - The session declares, then deadlocks. On a threaded platform,
zenoh-pico reads in its own task while your application writes. A transport
that holds one lock across a blocking
readstarveswrite. Keep the two directions independent, as a full-duplex UART or a TCP stream is.
See also
nros_rmw::custom_transport, the callbacks’ contract, in the Rust API reference.- Add a board, when the link needs a board of its own.
- Write a custom RMW backend, when the protocol itself is new.
Design background
- RFC-0006: portable RMW and platform interface: the C ABI the transport hook is part of
- RFC-0109: network config layers: the link as the locator’s scheme (D6)
Write a custom RMW backend
Needs first: How a build becomes an image
nano-ros’s own backends are listed in the
RMW API reference.
When your middleware is none of them (MQTT, a proprietary bus, a vendor’s
DDS), you write a backend: the code that turns publish, take, request and
reply into your protocol. The backend is a package in your own workspace,
found by its package.xml announcement the way nano-ros’s own backends are,
so nothing in nano-ros changes. By the end of this page an image selects
your backend by name and publishes through it.
If the protocol is zenoh or XRCE-DDS and only the wire is new, add a transport instead: four functions, not a backend.
Before you start
- You know how nano-ros’s RMW layer differs from ROS 2’s: the caller owns
the I/O buffers, one call drives I/O instead of wait sets, and the backend
binds when the image links. Internals → RMW API design
argues these against ROS 2’s
rmw.h. - You have chosen the backend’s language. A Rust backend implements the
traits of
nros-rmw. A C or C++ backend fills the C tablenros_rmw_vtable_tfrom<nros/rmw_vtable.h>. Either way the runtime calls the backend through that one C table. - For the worked example below: a Linux host with nano-ros
installed, and ROS 2 Humble (on Jazzy, replace
humblein each command).
Steps
-
Implement the session and its four entity kinds. In Rust, these are the traits and the methods each must provide; the rest have defaults:
Trait Required methods Rmwopen(self, &RmwConfig), which returns the sessionSessioncreate_publisher,create_subscription,create_service,create_client,close,drive_ioPublisherpublish_raw,buffer_error,serialization_errorSubscriptiontake_serialized,deserialization_errorServiceTraittake_request,send_responseClientTraitsend_request_raw,take_response_rawA C backend fills the matching slots of
nros_rmw_vtable_t(create_session,drive_io,create_publisher,publish,create_subscription,take, and the service and client slots). The header states each slot’s signature, ownership and blocking rules; the RMW API reference links its rendered form. A slot the backend leavesNULLis reported as unsupported. -
Keep to the I/O model. The buffers are the caller’s:
publish_rawgets a byte slice andtake_serializeda slice to fill, both already CDR. Every take is non-blocking and answers “no data” when nothing is ready. All waiting happens indrive_io(timeout_ms), which the executor calls from its own thread to move your protocol’s I/O; it may block up to the timeout. A client sends withsend_request_rawand polls withtake_response_raw, matching a reply to its request by the sequence id. -
Return specific errors. The runtime maps each
TransportErrorvariant to a namedrmw_ret_tat the C boundary, so a caller can act on it:Timeoutwhen a bounded wait elapses,NoDatafor an empty queue,WouldBlockwhen a resource is busy,BufferTooSmallwhen the caller’s slice is short,MessageTooLargewhen a message exceeds the backend’s capacity,Unsupportedfor an operation your middleware cannot do, andIncompatibleQoswhen two endpoints cannot be reconciled. KeepBackendfor what fits none of them. -
Register the backend under its name, in one function the image calls before the first session opens:
- A Rust backend wraps its
Rmwtype in the adapter ofnros-rmw-cffi:RustBackendAdapter::<MyRmw>::register_named(c"myproto".as_ptr()). - A C or C++ backend calls
nros_rmw_cffi_register_named("myproto", &MY_VTABLE).
- A Rust backend wraps its
-
Announce it. Put the backend in a package of its own in your workspace, whose
package.xmlexports<nano_ros_provides kind="rmw" name="myproto"/>, with annros-rmw.tomlbeside it. The descriptor states what the name cannot:[rmw] cpp_define, the define C++ code tests for the backend, and how the backend reaches the link. A Rust backend names its crate and its register function under[rmw.provides.cargo]; a CMake one names itsdirandtargetunder[rmw.provides.cmake]. Then[rmw.link], and[rmw.host] peer: whatnros runstarts beside the image. Start from the descriptor of the backend nearest yours. -
Select it. An image names the backend in its bringup’s
system.toml(rmw = "myproto"). The build looks the name up among the announcements in your workspace and in nano-ros, so a misspelt name fails with the names it found. A Rust image links the backend’s crate and calls its register function itself; a C or C++ image’s CMake configure resolves the name through the same lookup. Run a talker and a listener, then check the pair against a stock ROS 2 node, as What ROS 2 tools expect describes.
Worked example: a backend in your workspace
The backend here, acme, is the smallest that runs: zenoh’s table under
its own name, with two slots of its own. One reports its name; the other
wraps publish and logs a line on the first message, so you can see the
image chose it. A real backend fills every slot with its own protocol.
Install the zenoh router ROS 2 ships and provision the host:
sudo apt-get install -y ros-humble-rmw-zenoh-cpp
nros setup linux --rmw zenoh
Scaffold a Rust talker workspace for the Linux host. Source ROS 2 first:
nros new takes the ROS 2 edition from it.
source /opt/ros/humble/setup.bash
nros new acme_ws --board linux --template talker --lang rust --rmw zenoh
cd acme_ws
mkdir -p src/acme_rmw/src
The backend’s package. The nano_ros_provides line is what the build finds:
src/acme_rmw/package.xml<?xml version="1.0"?>
<package format="3">
<name>acme_rmw</name>
<version>0.1.0</version>
<description>The acme RMW backend.</description>
<maintainer email="dev@example.com">Developer</maintainer>
<license>Apache-2.0</license>
<export>
<build_type>nros_cargo</build_type>
<nano_ros_provides kind="rmw" name="acme"/>
</export>
</package>
Its descriptor. The image links the crate acme-rmw and calls its
register(); the linux board’s platform-posix feature and the ROS edition
pass through to it. acme speaks zenoh, so it needs a zenoh router:
src/acme_rmw/nros-rmw.toml[rmw]
cpp_define = "NROS_RMW_ACME"
[rmw.host]
peer = "zenoh-router"
[rmw.provides.cargo]
crate = "acme-rmw"
register = "register"
[rmw.provides.cargo.platform_features]
platform-posix = "platform-posix"
[rmw.link]
rlib_dep = "acme-rmw"
edition_feature = "ros-{edition}"
needs_cxx_linker = false
Its crate. It names nano-ros’s crates by version, as any third-party crate would; the build points each one at the nano-ros it builds against:
src/acme_rmw/Cargo.toml[package]
name = "acme-rmw"
version = "0.1.0"
edition = "2024"
[lib]
name = "acme_rmw"
[dependencies]
nros-rmw-cffi = { version = "*", default-features = false, features = ["alloc"] }
nros-rmw-zenoh = { version = "*", default-features = false }
nros-log = { version = "*", default-features = false }
[features]
platform-posix = ["nros-rmw-zenoh/platform-posix"]
ros-humble = ["nros-rmw-zenoh/ros-humble"]
ros-iron = ["nros-rmw-zenoh/ros-iron"]
ros-jazzy = ["nros-rmw-zenoh/ros-jazzy"]
src/acme_rmw/src/lib.rs#![allow(unused)]
#![no_std]
fn main() {
use core::{
ffi::c_char,
sync::atomic::{AtomicBool, Ordering},
};
use nros_rmw_cffi::{
NROS_RMW_RET_OK, NrosRmwRet, NrosRmwVtable, RustBackendAdapter,
nros_rmw_cffi_register_named, rmw_byte_span_t, rmw_publisher_t, rmw_ret_t,
};
use nros_rmw_zenoh::ZenohRmw;
const ZENOH: NrosRmwVtable = RustBackendAdapter::<ZenohRmw>::VTABLE;
static ACME_VTABLE: NrosRmwVtable = NrosRmwVtable {
get_implementation_identifier: Some(acme_identifier),
publish: Some(acme_publish),
..ZENOH
};
static ANNOUNCED: AtomicBool = AtomicBool::new(false);
unsafe extern "C" fn acme_identifier() -> *const c_char {
c"acme".as_ptr()
}
unsafe extern "C" fn acme_publish(
publisher: *const rmw_publisher_t,
payload: rmw_byte_span_t,
) -> rmw_ret_t {
if !ANNOUNCED.swap(true, Ordering::AcqRel) {
nros_log::log_info!(
nros_log::get_logger("acme_rmw"),
"publishing through backend acme"
);
}
match ZENOH.publish {
Some(inner) => unsafe { inner(publisher, payload) },
None => nros_rmw_cffi::NROS_RMW_RET_ERROR,
}
}
pub struct RegisterError(pub NrosRmwRet);
pub fn register() -> Result<(), RegisterError> {
let rc =
unsafe { nros_rmw_cffi_register_named(c"acme".as_ptr(), &ACME_VTABLE) };
if rc == NROS_RMW_RET_OK { Ok(()) } else { Err(RegisterError(rc)) }
}
}
Select it in the bringup:
sed -i 's/^rmw = "zenoh"/rmw = "acme"/' src/acme_node_bringup/system.toml
grep -n '^rmw' src/acme_node_bringup/system.toml
7:rmw = "acme"
Build and run the talker. nros run reads the descriptor’s peer, starts
the router, then the talker:
source /opt/ros/humble/setup.bash
nros run acme_node
publishing through backend acme
Publishing: 'Hello World: …'
The first line is your backend’s: every message goes through acme_publish.
What ROS 2 tools expect
A backend that implements the traits passes messages between nano-ros nodes.
To appear in ros2 topic list and to talk to rmw_zenoh_cpp or a DDS
node, it must also carry what the traits do not state:
- Discovery. ROS 2 tools find endpoints through discovery traffic. A
zenoh-flavoured backend publishes a liveliness token per endpoint, under
@ros2_lv/<domain>/<zid>/…; a DDS-flavoured one sends the ROS 2 user data in its participant discovery. A new protocol needs some discovery channel, emitted as a side effect of eachcreate_*. - Per-message metadata. Each message carries a sequence number, a source
timestamp and a publisher id that subscribers read as
MessageInfo. On zenoh it travels as an attachment; on DDS it is the sample info. A backend that drops it leaves everyMessageInfoat its default. - Type hashes.
TopicInfo::type_hasharrives filled in for the selected ROS edition: the literalTypeHashNotSupportedon Humble, anRIHS01_…hash from Iron on. Your backend puts it where your wire carries it; a peer that disagrees about the hash never matches. - QoS. Honour reliability, durability, history and depth, or refuse the ones you cannot. Report a mismatch (a best-effort publisher with a reliable subscriber) rather than lose messages.
Actions need nothing more: the runtime composes each action from three services and two topics.
Example: the traits
A backend that loops each published message back to its subscribers. Only publish and take are shown; services and clients follow the same pattern:
#![allow(unused)]
#![no_std]
fn main() {
use nros_rmw::*;
static mut ECHO_BUF: [u8; 1024] = [0; 1024];
static mut ECHO_LEN: usize = 0;
pub struct EchoPub;
impl Publisher for EchoPub {
type Error = TransportError;
fn publish_raw(&self, data: &[u8]) -> Result<(), TransportError> {
unsafe {
let len = data.len().min(ECHO_BUF.len());
ECHO_BUF[..len].copy_from_slice(&data[..len]);
ECHO_LEN = len;
}
Ok(())
}
fn buffer_error(&self) -> TransportError {
TransportError::BufferTooSmall
}
fn serialization_error(&self) -> TransportError {
TransportError::SerializationError
}
}
pub struct EchoSub;
impl Subscription for EchoSub {
type Error = TransportError;
fn take_serialized(
&mut self,
buf: &mut [u8],
) -> Result<Option<usize>, TransportError> {
unsafe {
if ECHO_LEN == 0 {
return Ok(None);
}
let len = ECHO_LEN;
buf[..len].copy_from_slice(&ECHO_BUF[..len]);
ECHO_LEN = 0;
Ok(Some(len))
}
}
fn deserialization_error(&self) -> TransportError {
TransportError::DeserializationError
}
}
}
EchoSession::create_publisher returns Ok(EchoPub), create_subscription
returns Ok(EchoSub), drive_io returns Ok(()), and EchoRmw::open
returns the session.
Complete examples:
nros-rmw-metadata,
a small Rust backend registered through RustBackendAdapter, and
nros-rmw-uorb,
a C++ backend with its package.xml and nros-rmw.toml.
If it doesn’t work
no package provides rmwmyproto``, fromnros build. Nopackage.xmlannounces that name. Check the spelling on both sides against the names the message lists, and that the package sits undersrc/.nros runsays the descriptor does not say what it needs on the host. Add[rmw.host] peer:"zenoh-router","xrce-agent"or"none".- The build refuses a backend with no
[rmw.provides.cargo]. A Rust image links the backend through its crate, so a backend with only a CMake table cannot serve one. - The executor opens no session. The backend registered under a different name from the one the image selects.
- Services or actions time out while topics work.
take_requestortake_response_rawblocks instead of answering “no data”, so the executor never reachesdrive_io. - A second session in one process fails. Session state lives in a
staticinstead of in theSessionthatopenreturns. ros2 topic listdoes not show your endpoints. The backend emits no discovery traffic; see “What ROS 2 tools expect”.
See also
- RMW API: the C table and the backends in the tree.
- Internals → RMW API vs upstream:
every difference from
rmw.h, for a porter coming from a ROS 2 backend. - Internals → RMW Zenoh protocol: the key expressions and attachments a zenoh-compatible backend must produce.
Design background
- RFC-0054: C headers as the ABI single source of truth: why every backend is reached through the C table
- RFC-0071: RMW backend descriptor:
nros-rmw.toml, and how the build finds and links a backend in your workspace
Runner and command packages
Needs first: Organize a larger workspace
You want nros to do something it does not ship: run an image on a launcher
or flasher nano-ros has no runner for, or add a verb of your own, such as a
generator your team runs on every workspace. Both are ordinary packages in
your workspace, built for the host by nros build, with no change to
nano-ros. By the end of this page, nros run drives your runner, or
nros <verb> runs your command.
Before you start
- You have a workspace with a
src/directory thatnros buildbuilds. - The Rust scaffolds build with the host’s Rust toolchain. A C++ package
speaks the same protocol through its own CMake executable: pass
--lang cpptonros new.
Runner packages
A runner teaches nros run, nros flash and nros monitor to drive a
launcher, a flasher or a console: an emulator nano-ros does not know, a
vendor flash tool, a remote board farm.
-
Scaffold the runner, from the workspace root:
nros new my_runner --kind runnernros new: scaffolded runner package `my_runner` at src/my_runnerThe package holds:
package.xml, whose<nano_ros_provides kind="runner" name="my_runner"/>announces the runner;nros-runner.toml, whatnrosreads when this runner is selected:protocol, theverbsit serves (run,flash,monitor), what itneedsfrom the build (elf, …) and thebinthe build produces;src/main.rs, a stub on thenros-extensioncrate that answersdescribeand runs the plan’selfas a host process, as the built-in native runner does. A test in it holdsdescribeequal tonros-runner.toml.
-
Replace
runinsrc/main.rswith what your target needs.nros runresolves a plan and executes your binary as<bin> run --plan <plan.json>;nros-extensionreads the plan, checks the verb and hands you its artifacts and arguments. -
Build it:
nros build --packages-select my_runner -
Select it for an image in the bringup’s
system.toml, then run the image:[image.my_image.run] method = "my_runner"nros run my_imageA runner that serves
flashis selected the same way, with[image.<id>.flash] method. A board can name it once for every image, in its descriptor’s[board.flash] method: which method words exist is the answer of the installed runners, sonroschecks only their shape.
Command packages
A command adds a verb to nros. A verb nros does not know is looked up as
an announced command package.
-
Scaffold the command, from the workspace root:
nros new my_cmd --kind commandnros new: scaffolded command package `my_cmd` at src/my_cmdThe package holds a
package.xmlannouncing<nano_ros_provides kind="command" name="my_cmd"/>, annros-command.tomlwith the command’sprotocol,summary,tierandbin, and asrc/main.rsthat prints its arguments and environment.tier = "user"lists the verb innros help --all. -
Write the command in
src/main.rs.nros my_cmd <args>runs your binary with the arguments unchanged, and with three variables set:NROS_WS_ROOT(the workspace),NROS_TOOLCHAIN(the toolchain’s version) andNROS_CLI(the runningnros). Ask"$NROS_CLI"for facts rather than deriving them again. Your exit status isnros’s. -
Build it, and run it:
nros build --packages-select my_cmd nros my_cmd hello worldnros my_cmd: hello world workspace /home/me/my_ws toolchain 0.6.0 (/home/me/.nros/bin/nros) -
Check that
nroslists it. Put a real sentence insummaryfirst:nros help --allExtension commands (from packages): nros my_cmd TODO: say what `nros my_cmd` does (package my_cmd)A package that announces a built-in verb, such as
build, is refused.
Example
nano-ros’s own extension commands are command packages, and their help is in the CLI reference:
nros px4 msgs, from the packagenros_px4_tools, generatespx4_msgsbindings from a PX4 message tree (PX4).nros router config, from the packagenros_zenoh_tools, prints the zenoh router configuration a bringup’s router runs (Configure zenoh).
If it doesn’t work
nros my_cmdreports that the command is not built. The package is announced but its binary is missing. Runnros build --packages-select my_cmd.nros runcannot use the runner. The image’s[image.<id>.run] methodnames a word no built runner announces, or the runner’snros-runner.tomldoes not list the verb (run,flash,monitor).- The runner fails on a missing artifact. The plan carries only what
needslists. Add the artifact (elf,bin,hex, …) toneeds.
See also
- CLI reference: every built-in verb, so you can pick a name that does not collide.
- Add a board:
[board.run]and[board.flash], which name a runner for every image of a board.
Design background
- RFC-0119: CLI extension packages: runner and command packages
- RFC-0118: target execution model: the plan a runner receives (D5)
Migrating from older releases
Needs first: Build inside an existing CMake or vendor tree
You have a project written against an older nano-ros release, and something it relies on is gone: the installed CMake prefix, a configuration file, or a board. Each section below is one such change: what was removed, what replaces it, and the edit that moves your project over. A single renamed variable, board or command needs no page: nano-ros refuses the old name and the refusal names what to write instead.
Before you start
- Install the current release (Install), and keep the old project’s build directory out of the way: a cache an older release wrote can hold names that are now refused.
- Know how your project consumes nano-ros: a CMake tree, a
system.tomlworkspace, or a hand-writtenno_stdapplication.
Move off the install-local prefix
nano-ros no longer has a CMake install step. The install-local recipe, the
build/install/ prefix, its install(...) rules and Config.cmake.in
templates, and the find_package(NanoRos) path that consumed them are gone. A
CMake project adds the installed SDK root with add_subdirectory.
-
Replace the
find_packagecall. Before:cmake_minimum_required(VERSION 3.16) project(my_app C) find_package(NanoRos REQUIRED CONFIG) nano_ros_generate_interfaces(std_msgs SKIP_INSTALL) add_executable(my_app src/main.c) target_link_libraries(my_app PRIVATE std_msgs__nano_ros_c NanoRos::NanoRos)After:
cmake_minimum_required(VERSION 3.22) project(my_app C) set(NROS_PLATFORM posix) set(NROS_RMW zenoh) add_subdirectory("${NANO_ROS_SDK}" nano_ros) add_executable(my_app src/main.c) target_link_libraries(my_app PRIVATE NanoRos::NanoRos) nano_ros_generate_interfaces(std_msgs LANGUAGE C DEPENDENCIES builtin_interfaces) target_link_libraries(my_app PRIVATE std_msgs__nano_ros_c) -
Configure with the SDK root instead of an install prefix:
cmake -B build -DNANO_ROS_SDK="$(nros locate nano-ros)" cmake --build build
The other pieces of the old shape map as follows:
| Before | Now |
|---|---|
cmake -DCMAKE_PREFIX_PATH=<nano-ros>/build/install | -DNANO_ROS_SDK="$(nros locate nano-ros)" |
nano_ros_link_platform(target), nano_ros_link_rmw(target) | nothing: NanoRos::NanoRos links both |
nros_freertos_compose_platform(target), nros_threadx_compose_platform(target) | nros_platform_link_app(target), the one per-image link fixup |
find_package(NrosRmwCyclonedds CONFIG REQUIRED) | nothing: NROS_RMW=cyclonedds wires it |
cmake_minimum_required(VERSION 3.16) | 3.22, as nano-ros’s own CMake |
a prebuilt libnros_c.a under the prefix | none: each project builds the library in its own build tree |
A Zephyr application takes nano-ros as a Zephyr module instead (A Zephyr app you build with west). NuttX and PX4 have their own integration paths (NuttX, PX4).
Replace a retired configuration file
These files used to carry configuration and no longer do. If a guide, an old project or a blog post tells you to write one, its content belongs elsewhere:
| File | Now |
|---|---|
a workspace-root nros.toml | system.toml, an image’s settings under [image.<id>]. The CLI refuses a workspace-root nros.toml. Migrate it with the nros-v0.5.0 release’s nros migrate workspace; newer releases do not carry that command. |
a per-package nros.toml overlay | system.toml. The overlay is still read, as a deprecated fallback, and nros check reports it. |
config.toml with [network], [zenoh], [scheduling] or [[transport]] | system.toml, or for a hand-written no_std application with no code generation, the standalone config.toml of Configure an image. |
- Move each setting into the
[image.<id>]table it configures, keeping its key wheresystem.tomlhas the same key. Thesystem.tomlkeys reference lists them. - Delete the old file, and rebuild with
nros build.
ESP32 boards
nano-ros no longer supports the ESP32. Both ways it once ran there are gone:
- The ESP32-C3 bare-metal board, over
esp-hal, retired 2026-11-02. It ran under Espressif’s QEMU fork. nano-ros supports a board only where an executor can park until an arrival or its next deadline. On bare metal that needs a network receive interrupt and a one-shot timer behind the platform’s wake object, and this board had neither, so it could only poll. It was retired rather than served by polling. Every name it answered to is refused wherever a board is read, with that reason. - The ESP-IDF component and the
idf.pybuild driver, retired 2026-09. Nothing built the component, and it was never published to the Espressif Component Registry. With it gone,nros buildrefuses a C or C++ project for an ESP32 instead of runningidf.pywith no project to build.
The platform ABI and the C API are unchanged, so an out-of-tree port is possible. It has to bring what every supported board has: on bare metal, the receive interrupt and one-shot timer that signal the wake object; on ESP-IDF, a component, a way to carry nano-ros’s resolved settings into the ESP-IDF build, and a build that something runs. Add a board and Add a platform describe what a port provides.
What changed in each release
Each release has a page that says what it changes for a project: the edits a project may need, then the fixes. The same page is the release’s notes on GitHub. Newest first:
If it doesn’t work
- The configure stops on a
NANO_ROS_*variable. The variable is retired, or an older release wrote it into the build directory’s cache. The error prints thecmake -U …line that drops it and the name to write instead. find_package(NanoRos)fails. That package no longer exists. Follow Move off the install-local prefix.
See also
- Install options, pinning, working offline: pinning a project to a release.
0.6.0-nros12
Codegen is unchanged, so a project generated with 0.6.0-nros11 needs
nothing generated again. A project that nros new made with 0.6.0-nros11
does need one edit: its contract states each timer as rate_hz,
which this release refuses. Upgrade shows the command that
makes it. Beyond that,
a project that uses none of the renamed settings or contract spellings below
builds as it is. One that uses any of them stops, and the message names the
new spelling.
Upgrade
A project built with 0.6.0-nros11 keeps building with 0.6.0-nros11 until you
move its pin: its first nros build wrote the release it used to
nros-toolchain.toml. Installing 0.6.0-nros12 changes nothing by itself.
To move a project, run in its directory:
curl -fsSL https://raw.githubusercontent.com/NEWSLabNTU/nano-ros/main/scripts/install.sh \
| sh -s -- --version 0.6.0-nros12
nros pin 0.6.0-nros12
nros setup <board>
nros configure --migrate
nros build
nros configure --migrate rewrites the project’s contracts and
system.toml files from the spellings this release renamed, and accepts
this release’s sources into the project’s nros-sdk.lock. It prints every
key and source it changes. A project made with nros new in 0.6.0-nros11
needs it for its timers: its contract writes each one as rate_hz, one
line per timer its node starts with. To make that edit by hand instead, in
each src/<bringup>/system.contract.yaml:
# before
trigger: { timer: { rate_hz: 1 } }
# after
trigger: { timer: { rate: 1Hz } }
Pinning a version says what each step does.
What you will notice
- Many settings have new names. Every built-in setting is now
<owner>.<name>, and every memory size is in bytes. An old name is refused, and the message names the new one, with the factor to multiply by when the unit changed. Settings you write lists them. ros2 paramand/rosoutwork on every image, except/rosoutfrom a C node on threadx-linux (see Known issues). Each node serves the six parameter services and publishes/rosout, as an rclcpp node does. An image with no stated parameter count now holds 8 parameters, not 32.- String and array parameters need a stated size. The build stops and
names the lines to add to
system.toml. - Old contract spellings are refused, including the
rate_hztimers thatnros newwrote in 0.6.0-nros11.nros configure --migraterewrites them. - Each C or C++ image has a build directory of its own, named for the
image.
nros buildandnros runfind it themselves. - A Rust image on a board builds optimized by default, as C and C++ images already did: about half the flash.
- A
linuximage joins the domain and router itssystem.tomlstates, not domain 0 and the default router. nros buildkeeps the tool’s output in a log in the build directory, and shows it with its colours and progress bar.
Known issues
- On threadx-linux, a C node’s
/rosoutpublisher is not created. The image logs one line at boot,/rosout could not be created for node /<name> (Transport(PublisherCreationFailed)), and then runs and publishes normally, but its log records do not reach/rosout. This publisher is new in this release: in 0.6.0-nros11 a C node had none unless it calledrclc_rosout_publisher_init, so nothing that worked there stopped working. - On XRCE, a sample larger than 65,535 bytes is not delivered intact. The publish returns success, and the sample is then lost, or arrives cut to its size modulo 65,536, with no error on either side. The XRCE DATA submessage states its length in 16 bits. This is not new in this release. Keep XRCE samples at or below 65,535 bytes; a later release refuses a larger one at the publish.
- On Zephyr mps2/an385, a zenoh publish costs about 7 % more time than
in the builds of early November, about 50 µs a dispatch of three
publishes under QEMU with a fixed instruction count, mostly on a topic
the publishing node also subscribes to. Under QEMU’s default
-icount shift=auto, one dispatch can read anywhere from about 2 to 65 ms, and that spread is the emulator, not nano-ros.
Edits you may need to make
Settings you write
A setting is refused under its old name wherever it is written: in
system.toml ([image.<id>.knobs]), in a board’s or a platform’s [knobs]
table, in the build environment, in a Zephyr conf file or -DCONFIG_, and in
-DNROS_OVERRIDE_. The environment variable and the Kconfig symbol follow
the key: params.max_parameters is NROS_PARAMS_MAX_PARAMETERS and
CONFIG_NROS_PARAMS_MAX_PARAMETERS. nros knob list prints every setting
under its current name, and nros knob show <name> says where to state it.
An old name stops nros build with a message like this one:
Error: [image.linux.knobs]:
`[image.linux.knobs.executor] backing_u64s` is retired: write `[image.linux.knobs.executor] backing_bytes` instead (the value x 8: executor.backing_u64s was in 8-byte words)
-
Zenoh. The
[knobs.zenoh.wire],[knobs.zenoh.limits]and[knobs.zenoh.tx]tables are gone: their keys are plain[knobs.zenoh]keys, and the sizes end in_bytes.Old New wire.batch_multicast_sizebatch_multicast_byteswire.batch_unicast_sizebatch_unicast_byteswire.frag_max_sizefrag_max_byteswire.get_poll_interval_msget_poll_interval_mswire.get_reply_buf_sizeget_reply_buffer_byteswire.rx_task_budget_framesrx_task_budget_frameswire.rx_task_budget_rest_usrx_task_budget_rest_uslimits.keyexpr_string_sizekeyexpr_string_byteslimits.connect_foreverconnect_foreverlimits.connect_timeout_msconnect_timeout_mslimits.subscriber_ring_depthsubscriber_ring_depthlimits.service_timeout_ms[knobs.service] timeout_ms(variable unchanged:NROS_SERVICE_TIMEOUT_MS)tx.batchtx_batchtx.flush_mstx_batch_flush_mstx.split_locktx_split_lockservice_buffer_sizeservice_buffer_bytesgraph_cache_sizegraph_cache_bytespublisher_tx_buffer_sizepublisher_tx_buffer_bytessubscriber_large_sizesubscriber_large_bytessubscriber_size_thresholdsubscriber_large_threshold_bytes[knobs.graph] max_entities[knobs.zenoh] graph_max_entities -
Parameters. Every parameter setting is under
[knobs.params], and its variable startsNROS_PARAMS_:NROS_MAX_PARAMETERSis nowNROS_PARAMS_MAX_PARAMETERS.Old New params.max_param_name_lenparams.max_name_bytesparams.max_string_value_lenparams.max_string_value_bytesparams.max_byte_array_lenparams.max_byte_array_bytesparams.max_param_description_lenparams.max_description_bytesparams.max_param_constraints_lenparams.max_constraints_bytesparams.param_events_depthparams.events_depth[knobs.param] service_inbox_bytes,service_inbox_depth[knobs.params] service_inbox_bytes,service_inbox_depth -
Memory. The heap and the application task’s stack are one setting each, on every platform, in bytes.
Old New Value zephyr.heap_sizememory.heap_bytesthe same freertos.heap_kbmemory.heap_bytestimes 1024 freertos.app_stack_kb,threadx.app_stack_kbmemory.app_stack_bytestimes 1024 NROS_THREADX_BYTE_POOL_KBthreadx.byte_pool_bytestimes 1024 executor.backing_u64sexecutor.backing_bytestimes 8 A FreeRTOS heap or application stack must be a whole number of KiB. Any other value is refused, and the message names the nearest valid ones.
-
Other sizes end in
_bytes:executor.arena_size,executor.subscription_buffer_sizeandexecutor.param_service_buffer_size;log.buffer_size,subscriber.buffer_sizeandnet.buffer_size; and XRCE’sbuffer_size,builtin_service_request_buffer_size,service_reply_buffer_size,service_request_buffer_sizeandsubscriber_buffer_size. -
The network stack’s variables start
NROS_NET_:NROS_SMOLTCP_MAX_SOCKETS,_MAX_UDP_SOCKETS,_CONNECT_TIMEOUT_MS,_SOCKET_TIMEOUT_MSand_BUFFER_SIZEare nowNROS_NET_MAX_SOCKETS,NROS_NET_MAX_UDP_SOCKETS,NROS_NET_CONNECT_TIMEOUT_MS,NROS_NET_SOCKET_TIMEOUT_MSandNROS_NET_BUFFER_BYTES. The[knobs.net]keys keep their names, apart frombuffer_size. -
Zenoh build switches are settings now:
ZPICO_MULTICAST_TRANSPORTis[image.<id>.knobs.zenoh] multicast_transport = true,NROS_ZPICO_DEBUGisNROS_ZENOH_DEBUG, andZPICO_NO_SMOLTCPisNROS_ZENOH_NO_SMOLTCP, whichnrossets itself fromtransport = "serial". -
Zephyr Kconfig symbols:
Old New CONFIG_NROS_ZENOH_LOCATORCONFIG_NROS_LOCATORCONFIG_NROS_CYCLONE_DOMAIN_IDCONFIG_NROS_CYCLONEDDS_DOMAIN_IDCONFIG_NROS_CYCLONE_CONFIG_XMLCONFIG_NROS_CYCLONEDDS_CONFIG_XMLCONFIG_NROS_ZEPHYR_TASK_STACK_SIZECONFIG_NROS_ZEPHYR_TASK_STACK_BYTESCONFIG_NROS_ZEPHYR_SCHED_TASK_STACK_SIZE,CONFIG_NROS_ZEPHYR_TIER_STACK_SIZECONFIG_NROS_ZEPHYR_SCHED_TASK_STACK_BYTESCONFIG_NROS_ZEPHYR_LEVEL_WORKER_FRAMECONFIG_NROS_ZEPHYR_LEVEL_WORKER_FRAME_BYTESCONFIG_NROS_CONSOLE_WHOLE_LINES_BUFFERCONFIG_NROS_CONSOLE_WHOLE_LINES_BUFFER_BYTESCONFIG_NROS_EDMA_WARM_RESET_QUIESCECONFIG_NROS_ZEPHYR_EDMA_WARM_RESET_QUIESCECONFIG_NROS_PARAM_STORECONFIG_NROS_PARAMS_STORECONFIG_NROS_SERVICE_BUFFER_SIZECONFIG_NROS_ZENOH_SERVICE_BUFFER_BYTESCONFIG_NROS_TRANSPORT_SERIALtransport = "serial"insystem.toml, orCONFIG_NROS_ZENOH_LINK_SERIAL=ywithout oneA Zephyr project with no
system.tomlthat still sets an old symbol stops at configure, naming the new one. -
The wall-clock source on Zephyr is a setting of the image.
CONFIG_NROS_SNTP_EPOCHandCONFIG_NROS_EPOCH_FROM_ZENOHare retired with no alias. State the source instead:[image.<id>.knobs.clock] source = "sntp" # or "zenoh-hlc", or a fallback: "sntp,platform"CONFIG_NROS_EPOCH_FROM_ZENOH_INTERVAL_MSis nowclock.hlc_interval_ms.sntp.serverandsntp.timeout_mskeep their names. A package of your own that names its settingsclock.*must rename them:clockis now a built-in owner. -
A nano-ros setting passed as a CMake
-Dis refused, in any spelling (-DNROS_...,-DCONFIG_NROS_..., or an old name), whether through--cmake-args=, an@fileor[image.<id>.build] cmake_args. Move it to the image’s[image.<id>.knobs.<owner>]table; the error names the table and the key. On Zephyr,--cmake-args=-DNROS_OVERRIDE_<ID>=<value>is still the override for one build. -
A setting for one platform only is refused on an image of another platform. Today that is
[image.<id>.knobs.zenoh] socket_timeout_ms, which only Zephyr images read: remove it from the others. -
runtime.let_buffer_size(NROS_LET_BUFFER_SIZE) is gone: it sized nothing. Delete it.
The environment an image runs with
The domain, the router and the node name of an image come from its
system.toml (domain_id, locator). The build never reads them from its
own environment any more:
- A build with
NROS_DOMAIN_IDset stops, naming[system] domain_id. - A build that finds
NROS_LOCATORorNROS_NODE_NAMEset prints a note and goes on.
A hosted image reads these names when it runs, and they win over
system.toml:
| Variable | What it sets |
|---|---|
ROS_DOMAIN_ID | the ROS 2 domain |
NROS_LOCATOR | the router or peer to dial |
NROS_NODE_NAME, NROS_NODE_NAMESPACE | the node’s name and namespace |
A linux image now uses the domain_id and locator its system.toml
states when these are unset. Before, it joined domain 0 and dialled the
middleware’s default. When the environment overrides a stated value, the
image says so at boot, for example
ROS_DOMAIN_ID=5 overrides system.toml's domain_id=42.
Three run-time variables are renamed. A hosted image started with an old one set stops and names the new one:
| Old | New |
|---|---|
XRCE_SERIAL_BAUD | NROS_XRCE_SERIAL_BAUD |
NROS_CYCLONE_MATCH_TIMEOUT_MS | NROS_CYCLONEDDS_MATCH_TIMEOUT_MS |
NROS_RMW_CYCLONEDDS_SKIP_PREFIX | NROS_CYCLONEDDS_SKIP_PREFIX |
A build directory from the previous release
Build directories configured with 0.6.0-nros11 keep working:
nros buildandnros runfind a C or C++ image’s new directory, named for the image, and remove the old one’s build files. A small leftover directory holding the old configure’s resolve files may remain; you can delete it. A script that names the old path needs the new one:build/posix-zenoh-linux-demo_bringup/cmake/linux_entryis nowbuild/posix-zenoh-linux-demo_bringup-linux/cmake/linux_entry.- A Zephyr build directory remembers each
-DCONFIG_it was once given. When one of them is a retired name, the next configure drops it with a warning that names the value and what to set instead. - A retired name you still pass is refused, naming the new spelling.
- A program registered under an
EXECUTABLEgets a new name (see Images and packages): rebuild those directories. - A build directory for
fvp-aemv8r-smpconfigured before the Arm FVP was found cachesARMFVP-NOTFOUND. Configure it again once the model is found.
Contracts
-
A system contract written with the old spellings is refused. Each error names the line and its new spelling.
nros configure --migraterewrites a project’s contracts in one step, or edit each line by hand. The renames are:functions:is nowcapabilities:.- A hazard’s
enters:is nowleaves:. - A manifest-level
paths:is nowevent_chains:. min_rate_hz,max_rate_hzandrate_hzare nowmin_rate,max_rateandrate, written with a unit (100Hz).- A contract’s
supervision:moves to the target’s platform file. policy:is now the checker’s--deny <rule>.integrity_levels:is nowuse:of a profile.max_transporton an endpoint or a service is now a link.observes:written as a string is now{ input }.early.dropis nowearly.decrease.
The system model is now schema 6, and
contracts.scope_pathsis nowcontracts.event_chains. Older models still load. -
A contract’s QoS values and launch arguments are checked.
reliability,durability,historyandlivelinessmust name a ROS 2 value. A typo such astransient-localis refused, and the error names the key, the value and the values allowed.system_defaultandbest_availableare accepted. A contract whose arguments fail is now anerror[manifest-args]; before, the contract was dropped without a word. Arguments fail on a required argument not passed, a value outside itschoices:, or a QoS$(var …)outside the allowed set. Fix the value the error names.
Parameters
-
A string or array parameter needs its size stated, whether a node declares it in its code or the contract declares it under
params:. The build stops, naming the image, each missing line and a suggested floor. Add the lines to the image insystem.toml:[image.<id>.knobs.params] max_string_value_bytes = 16 # the longest string value max_array_len = 4 # the longest bool, integer or double array max_string_array_len = 4 # the longest string array max_byte_array_bytes = 256 # the longest byte array (only for a byte_array) service_inbox_bytes = 4096 # the largest set_parameters requestA board can state them in its own
[knobs.params]instead. When the image’s nodes state no parameter-service shapes, the build prints theservice_inbox_bytesline commented out, for you to fill in. -
A
string_arrayhas its own element bound,max_string_array_len.max_array_lennow bounds only bool, integer and double arrays. -
An image with no stated parameter count holds 8 parameters, not 32: every image that declares no
params:in its contract. The 32 slots took 285,696 bytes of RAM; 8 take 71,424. A ninth declaration stops the boot. -
A parameter the store has no room for stops the boot. Before, the node ran on its compiled default and the launch or YAML value was lost without a word. Now:
- In C++,
declare_parameter<T>(name, default)latchesNROS_CPP_RET_FULLon the node, and the entry halts boot. - In C,
rclc_add_parameterandrclc_parameter_declare_*returnRCLC_RET_FULLfor a full store, where they used to returnRCL_RET_ERROR. Code that compares againstRCL_RET_ERRORneeds the new value. - Every language logs a line naming the node, the parameter, the store’s size and the setting that sizes it.
To make room, declare the parameters under
params:in each node’s contract, which sizes the store from that count, or set[image.<id>.knobs.params] max_parameters. - In C++,
-
In C++, a parameter whose launch or YAML value has another type than its declaration stops the boot. Before,
declare_parameter<T>(name, default)returned the code default without a word, so the node ran on a value its launch file did not state. The usual case is an integer written for a double:kp: 1for a parameter declareddouble. The boot log names the node, the parameter, the value and the fix, for exampleparameter "kp" is declared double but the launch value is the integer 1; write 1.0 in the YAML.Before you upgrade, check your launch and YAML files for integers written where the code declares a double. Upstream rclcpp throws on the same mismatch. -
list_parametersfilters by prefix and depth as rclcpp does.- A prefix matches itself, or itself followed by
.:robotno longer selectsrobotics. depthcounts the separators after the prefix: with prefixrobot, depth 1 no longer returnsrobot.arm, and depth 2 does.- With no prefix, depth N returns names with fewer than N separators.
- Depth 0 still returns every name below the prefix.
- A prefix matches itself, or itself followed by
-
In Rust,
nros_params::ParameterDescriptorhas nonamefield. The store keeps the name once, in the parameter, which saves 64 bytes a slot.nros_node::parameter_services::to_rcl_descriptortakes the name as its first argument.ParameterDescriptor::new(name, type)is unchanged.
Images and packages
- Every image serves the stock ROS 2 node interfaces, on every board:
the six parameter services (
ros2 param list,get,set,describe), and/rosout. An image that cannot afford them setsnode_interfaces = "none"in[system],[image_defaults]or[image.<id>]. A board with room for one service only, such as the Raspberry Pi Pico W, must opt out: its build stops and names the switch. An ament package built through CMake gets them unless it setsNROS_FEATURESitself./rosoutis VOLATILE, where rclcpp’s is TRANSIENT_LOCAL, and a node does not subscribe to/parameter_events. - A registered component’s program is named for its
EXECUTABLE, not its package, asrclcpp_components_register_nodenames one executable per node.nros_components_register_node(... EXECUTABLE talker DEPLOY threadx)now buildstalker. Update the scripts, flash commands and run lines that load the old name. A package may now register several components under differentEXECUTABLEnames; two under the same name are refused. On Zephyr a package still builds one program. - A C or C++ component package whose
project()name differs from itspackage.xml<name>is refused at configure. The message names both values and both files. Rename one so they match, as ament expects. - A Rust image derives its sched tasks’
spin_periodas C and C++ images do: from the task’s tightest timer, instead of 1 ms. Aspin_periodlonger than that timer is refused at build time, naming the task, both periods and the[tasks.<name>] spin_periodto change. - A Rust image on a board builds optimized by default. Before, it built
cargo’s
devprofile when the image stated noprofile. It now buildsreleasewith fat LTO, as C and C++ images already did: the mps2-an385 FreeRTOS talker drops from 914,880 bytes of flash to about 500,000. A host image still buildsdev. For a debug build on a board, runnros build <image> --profile=dev, or setprofile = "dev"on the image. - A C or C++ FreeRTOS image on zenoh gets a 512 KiB default heap, derived
the way a Rust image’s is, instead of the old 3 MiB fallback. That is about
2.5 MiB less RAM per image. The C talker template peaks at about 90 KB. A
larger image prints its own peak on its
nros: heap peakboot line; one that needs more sets[image.<id>.knobs.memory] heap_bytes. - The ThreadX byte pool is derived, no longer a fixed 4 MiB: the
application thread’s stack plus the middleware’s measured working set
(about 0.8 MiB for zenoh and 1.6 MiB for Cyclone DDS on the RISC-V board).
An image that declares sched tasks states its pool with
[image.<id>.knobs.memory] heap_bytes; one that does not stops at boot, naming the setting and the bytes it was short. - A Zephyr zenoh image with
CONFIG_NROS_ZENOH_MULTI_THREAD=nis refused at configure. It used to build and then fail at boot. Leave the option on, as it is by default.
Platform ports and the C ABI
- A custom platform port defines
nros_platform_wall_clock_state()besidenros_platform_time_now_ns(), returning whether its wall clock is synced and which source answers it. A port without it fails to link, naming the symbol. A port with no real-time clock returns{ false, NROS_WALL_CLOCK_SOURCE_PLATFORM, 0 }; a Rust port implementsPlatformTime::wall_clock_state. - The RMW backend’s C enums are
int-sized on every target. On arm-none-eabi they used to be one byte in C and four in Rust. Rebuild a C or C++ RMW backend for an ARM EABI target against the new headers. Aswitchwith nodefault:over one of these enums needs a case for the new*_FORCE_INT_WIDTH_enumerator to stay-Wswitchclean. - An FD frame on a CAN handle whose
fd_activeis false returnsNROS_PLATFORM_CAN_ENOFD, where it returnedNROS_PLATFORM_CAN_EINVAL.
The Arm FVP
nano-ros no longer installs the Arm FVP (FVP_BaseR_AEMv8R): nros setup --tool arm-fvp is gone. Install the AEMv8-R FVP from Arm (x86_64 Linux) and
libatomic1, then set ARMFVP_BIN_PATH, set ARM_FVP_DIR, or put the model
on PATH. nros doctor says whether it is found, and through which setting.
Behaviour that changed
nros buildkeeps the tool’s output. The tool runs on a terminal thatnros buildholds, so its colours and cargo’s progress bar look as they do when you run it yourself. The output is also written tocargo.log,cmake.logorwest.login the image’s build directory, replaced on each build. Ctrl-C stops the tool and everything it started, andnros buildexits with the tool’s own status.- On Zephyr, the wall clock is resolved before anything spins. Every
sched task waits at its first spin until boot has resolved the clock, so no
message is stamped before it, and timers start counting when that wait
ends. A task that does not finish its setup within 30 s fails the boot,
naming it. Code that waits between its setup and its first spin calls
Executor::restart_timing(C:nros_cpp_executor_restart_timing). - On the freertos-posix board, the wall clock reads the host’s time by default. It read 0 unless a source was stated.
nros buildchecks a ThreadX-on-Linux image’s application stack against the peak it was measured at, and fails namingmemory.app_stack_byteswhen the stack is smaller.- A Rust Zephyr image with no measured stack row is held to its board’s measured main-stack floor instead of a fixed 32 KiB. The Nucleo-F767ZI’s default Rust main stack is 33,368 bytes.
nros buildsays where it found each Zephyros_configfragment of an image: the bringup’s board directory, the west application, or the bringup.
Code you can delete
- Logging to
/rosouttakes no extra code. In an image built with therosoutcapability, the executor creates one/rosoutpublisher per node and sends each log record from that node’s publisher, as rcl does. Rustnros::rosout::pumpand C++rclcpp::rosout::Publisherare deprecated: both still work, but they add a second publisher, so delete them. C’srclc_rosout_publisher_initandrclc_rosout_pumpstay, for a node made withrclc_node_init_default.
New commands and options
nros build --cmake-args=<args>passes arguments to every CMake configure of the build: a CMake image’s, a west image’s and a CMake package’s. The=is required. One value can hold several arguments, split with plain shell quoting (--cmake-args="-DA=1 -DB='x y'"), and the flag repeats.--cmake-args=@<file>reads one argument per line, with#comments. Allowed:-D,-U,-W*,--log-level,--log-contextand--debug-find. A namenros buildsets itself, and-DCONFIG_*(which goes in the image’sconf), are refused, and the error says where the setting goes. colcon’s spelling,--cmake-args -DA=1, is refused with your arguments shown rewritten.[image.<id>.build] cmake_args = [...]insystem.tomlstates an image’s own CMake arguments, checked the same way. They follow[image_defaults.build] cmake_args, and--cmake-args=comes after both.[image_defaults.build] cmake_argsalso reaches the metadata probe, which runs once for the whole workspace before any image builds. Put a path the probe needs there, such as-DEigen3_DIR=...for a library of your own:--cmake-args=and an image’s owncmake_argsdo not reach it. A change to the list probes again.nros build --cargo-args=<args>passes arguments to every cargo command of a cargo image, split, repeated and read from@<file>like--cmake-args=. Allowed:--features,--no-default-features,--all-features,-v,-q,--timings,--locked,--offlineand--frozen. In a workspace, name a feature with its package (--features=<pkg>/<feat>). A feature the build chooses itself (the RMW, the platform, a board or capability feature) is refused: choose those insystem.toml.nros build --profile=<name>builds with that profile instead of the image’sprofile, for one build. It takes the same values as[image.<id>] profile: a cargo profile or a CMake build type. A single-package cargo project now honoursprofiletoo; before, it was dropped without a word.- An application trace marker:
rclc_trace_marker(id, arg)in C,rclcpp::trace_markerin C++ andnros::trace_marker::emit_app_markerin Rust send an event through the installed callback trace sink, on the same clock as the executor’s callback events. Ids 1 to 15 are yours; 0 and the executor’s ids are refused with an error. On Zephyr the default sink writes the CTF stream; on FreeRTOS, POSIX, NuttX and ThreadX the event goes to a sink the application installs.
New boards
s32z270-rtu0-zephyr, a Zephyr board for the NXP S32Z270 RTU0 Cortex-R52. It builds and links; no emulator models it. A board’swest_boardmay now carry a board revision (board@rev/soc/variant), so no-DBOARD_REVISIONis needed.s32z270-freertos-rtd, the S32Z270 RTU on NXP’s FreeRTOS port, built from a provisioned NXP kernel (NXP_FREERTOS_S32ZE_DIR) and RTD (S32_RTD_PATH). Name the board instead of settingFREERTOS_DIRandFREERTOS_PORT. The network glue is not part of it yet.
Other new features
RCLCPP_<LEVEL>_THROTTLE(logger, clock, ms, ...)compiles and throttles, measuring its window on the clock you pass, as rclcpp does. That clock can be*get_clock(), a steady clock, a system clock, or a ROS time clock driven by/clock. The first record at a call site is logged, then at most one perms.RCLCPP_<LEVEL>_ONCE,_SKIPFIRSTand_SKIPFIRST_THROTTLEare new at every level. All of them work on freestanding targets and take no lock. The C throttle gainsrclc_log_throttle_admit_at, which takes the clock reading from the caller.- A C or C++ image carries only the parts of the API it calls. Before, every image kept the whole C and C++ API: a talker that only publishes still carried the action server and client. The mps2-an385 FreeRTOS C talker drops from 631,440 to about 424,000 bytes of flash.
- An image of C and Rust components, with no C++ source, configures on
the CMake road and on Zephyr. Before,
nros buildandnros configure --censusstopped with “node pkg...exec...is langrust(arustcomponent), notc”.
Fixes
- A list parameter from a launch
<param from>file, or written asvalue="[1, 2]", reaches the node as an array of doubles, integers, bools or strings, instead of one comma-joined string. A list that mixes types is refused at boot with a log line, as ROS refuses it.[]seeds nothing, so the declared default stands. ros2 param listandros2 param dumpsee every parameter of a node. Before,list_parametersstopped at 64 names without saying so, andget_parametersrefused a request for more than 64.- The C and C++ metadata probe holds 1,024 parameters, so a component that declares more than the 32-slot default (an Autoware controller declares about 150) is probed instead of running on compiled defaults.
- A board package inside your workspace (
src/<board>/nros-board.toml) is found by the west configure thatnros buildstarts, so a Zephyr image on that board builds withoutNROS_EXTRA_BOARD_PATH. - A build directory follows the
nrosthat builds it. Before, a directory first configured by anothernroskept running that binary and failed with “in-tree nros CLI is STALE”. A barecmakere-configure still uses the cached tool, but now stops at once, naming the tool and both versions, when that tool’s codegen version is one the tree does not accept. - A Zephyr C++ image built with newlib on a 64-bit Arm board, such as
fvp-aemv8r-smp, can callfabslandcopysignl, so code that reaches Eigen’s long-doubleabsbuilds without a-Dfabsldefine of its own. - A new C project from
nros newfor the nucleo-f767zi Zephyr board builds again: its main stack is now 118,424 bytes. - A Zephyr image whose nodes serve the parameter or lifecycle services
(several nodes, or two managed nodes on XRCE-DDS) no longer boots and then
stalls when its heap runs out. The heap is now derived from those node
counts instead of a fixed default. An image with one node keeps the heap
it had, and a heap stated with
[image.<id>.knobs.memory] heap_bytesstill wins. - A failed C or C++ metadata probe is reported as a failure, naming the
node, the first error line and the log. Before, the image was built on
default sizes without a word.
NROS_PROBE_FAILURE=warn(the default for an interactive build) finishes with a warning line, andNROS_PROBE_FAILURE=refusemakesnros syncandnros configurefail. Setrefusein CI. - A failed probe now reports its cause: the linker’s first
undefined referenceline instead ofld returned 1 exit status, and a CMake error’s message instead of its header alone. - A component that declares no publisher, subscription, timer, service, action or parameter is refused by the metadata probe with a sentence naming it, instead of a bare “exit 254”.
- A Zephyr configure with no seed from
nros configurefinishes in two passes, as its message says. Before, it failed twice first. - A FreeRTOS, NuttX or ThreadX C or C++ image writes
compile_commands.jsonwhen its stack floor is checked, so the stack walk is tighter: the new FreeRTOS C talker walks 130,424 bytes instead of 147,060. A project that setsCMAKE_EXPORT_COMPILE_COMMANDSkeeps its choice. - A Rust Zephyr image uses much less main-thread stack for a graph query (listing names and types: about 20 KB to 3.5 KB) and for a parameter declaration (about 25 KB to 8 KB). A graph query also no longer stops at 64 names, and returns names in sorted order, as the ROS 2 RMWs do.
- A Rust package in a workspace with no bringup builds after an
nros build --dry-runplan of it. Before, the build failed with “cannot update the lock file … because –frozen was passed”. - The API docs and C headers of the RMW layer, the zenoh RMW,
nros-board-commonandnros-orchestration-irstate facts in plain words instead of citing internal design numbers.
0.6.0-nros11
A project generated with 0.6.0-nros10 builds as it is: nothing needs to be generated again.
Edits you may need to make
-
An image’s
profilenow reaches a CMake build.nros buildsets the C and C++ build type and the Rust runtime’s cargo profile from it, in either spelling (nros-relwithdebinfoorRelWithDebInfo). Before, a CMake build was Release whatever the image said. A profile with no CMake build type is refused, and the message names-- -DCMAKE_BUILD_TYPE=<type>. A Zephyr image that statesprofileis refused: Zephyr takes its optimisation from Kconfig, so delete the line. -
A hand-written CMake configure that names its image gets that image’s settings.
nano_ros_workspace(SYSTEM <bringup>)with-DNROS_IMAGE=<id>applies the image’s knobs,envrows anddomain_id, and is refused when the bringup states such rows but no image is named.nano_ros_add_executable(… BRINGUP <dir> IMAGE <id>)uses the domain the image states instead of 0, and refuses a-DNROS_DOMAIN_IDthat names another. -
A Rust package in a mixed C, C++ and Rust image needs no CMake file. The build registers it from the bringup’s
[[component]]row, on a CMake build and in a generated Zephyr application alike, so the same Rust package builds unchanged in a Rust-only image and in a mixed one. You may delete aCMakeLists.txtthat only callsnano_ros_node_register(LANGUAGE RUST), with its<build_type>nros_cmake</build_type>; a package with a realCMakeLists.txtof its own keeps it. -
Create every C node with
rclc_executor_node_init. A node made withrclc_node_init_defaultis not bound to an executor, and a publisher, subscription, service, client, timer or action created on it is now refused withRCL_RET_INVALID_ARGUMENT: the executor would not know which node to announce it under. Replace eachrclc_node_init_default(&node, name, namespace, &support)withrclc_executor_node_init(&executor, &node, name, options), after the executor is set up. Code that already binds its nodes this way needs no change. -
Spell an RTIC image as the bare-metal board plus
framework = "rtic".board = "rtic-mps2-an385"still builds the RTIC entry, but that board name is going away. Writeboard = "mps2-an385-baremetal"withframework = "rtic"instead; the image builds the same entry.
New
- An image announces only the nodes it declares.
ros2 node listshows the nodes of the image’s launch file and no extra node for the image itself. An entity created on the executor rather than on a node is announced under the image’s first declared node; an image that declares no node keeps its one node as before. On zenoh a node appears with its first entity, as on Cyclone DDS. - The MPS2-AN385 bare-metal board runs RTIC per image. Add
framework = "rtic"to an[image.<id>]onboard = "mps2-an385-baremetal"to build the RTIC entry; without it the image builds the direct entry as before. - An XRCE node notices when its Agent restarts. About a second after the
Agent is back, every publish and spin returns a session-lost error and
Executor::session_lost()is true. Drop the executor and open it again to reconnect; the loop is in When the Agent restarts. - The Zephyr starter image has the C++ talker built too, beside the C and Rust ones, so the starter’s C++ tab needs no download.
Fixes
- A C or C++ image that opens its executor over its own storage no longer also reserves the Rust executor’s default storage. That reservation made such images run out of RAM on small boards.
- Editing a node’s parameter file, or anything else that makes the build
call a model stale, now makes
nros configureresolve the model again. Before, it saidup to date, the build kept the old values, and only deletingbuild/got out. nros configurereads the platform file for the target an image runs on, such as<stem>.system.zephyr.yaml, instead of always the POSIX one.- A Rust node in a mixed C++ and Rust image reads its launch
<param>values withctx.param(name). Before, every read returnedNone. - A launch parameter that a Rust node reads by name counts as read, so the contract check no longer reports it as declared but unused.
- A Zephyr image adds every workspace package it depends on, so a support
library’s own
CMakeLists.txtruns, and itszephyr/module.ymlKconfig symbols can be set from the image’s config fragment. It also finds the workspace’s own message packages withoutNROS_INTERFACE_SEARCH_PATH, and keeps those modules whennros buildadds nano-ros as an extra Zephyr module. - The stack check works on cross-built images whose crate names are long,
and on a project that pins its own Rust toolchain. If that toolchain lacks
its LLVM tools, the message names the
rustupcommand that adds them. - A C image built on a host without clang no longer fails its stack check.
Without clang the check cannot measure the image, so it now passes with
the warning
unmeasured: install clang to check this image's stack; install clang to have it checked. - A C or C++ app on ThreadX prints nano-ros’s own log lines, such as the one that says why a session did not open. Before, they were dropped.
- A Zephyr build no longer fails after the link step when a
.conffragment states a pool size above the one the image needs (for exampleCONFIG_NROS_MAX_PUBLISHERS=13where 11 is enough), or when the image subscribes to more than one message type. - A new Zephyr C talker for nucleo-f767zi builds again: its stamped stack was below the measured floor. The project’s name no longer changes the floor.
- With zenoh’s split-lock send path on, a message too large for one batch no longer reaches the wire ahead of the batch before it, and a publish no longer waits behind a slow batch write.
- The C and C++ API headers and the Rust API docs of
nrosandnros-nodestate facts in plain words instead of citing internal design numbers.
0.6.0-nros10
A project generated with 0.6.0-nros9 builds as it is: nothing needs to be generated again.
Edits you may need to make
framework = "zephyr"is refused. A Zephyr board already picks the Zephyr entry for every image on it. Delete theframeworkline from that[image.<id>]; the image builds the same. The frameworks an image can still name areowned-spin,rticandpx4.- C++ alias headers use the rosidl file name.
<pkg>/msg/<name>.hppnow matches what rclcpp code includes:float32_stamped.hppforFloat32Stamped,u_int8.hppforUInt8,tf_message.hppforTFMessage. An include of the old spelling (float32stamped.hpp,uint8.hpp) no longer resolves; switch it to the new one. - Launch contracts take new key names.
functions:iscapabilities:, a hazard’senters:isleaves:, a client names a mode withenters:, a manifest level’spaths:isevent_chains:, rates carry a unit (min_rate: 100Hz), andsupervision:moves to the platform file. The old names still read in this release;play_launch migraterewrites them. - The fault-tolerant time interval check covers every fallback level. A hazard whose fallback sequence misses its deadline at any level, not only the last one, now fails the build. The message names the level that misses and the total for each level.
Fixes
- A Rust node can use the constants a
.msg,.srvor.actionfile declares, as in rclrs:IslandMode::MODE_NOMINAL. nros configureandnros syncfind packages at any depth undersrc/, as in an Autoware layout (src/<group>/<pkg>), and under everypackage_pathsentry. Two packages with the same name are refused, and the message names both folders.- A package marked
COLCON_IGNORE,AMENT_IGNORE,NROS_IGNOREor.nros-ignoreis skipped by every command, so a package kept aside no longer breaks the whole workspace. - A Zephyr Rust project from
nros newbuilds on the toolchain itsrust-toolchain.tomlpins, so two hosts build the same code. The nucleo-f767zi Rust templates get a larger main stack to match. - A C++ component in a nested namespace (
autoware::foo::Bar) with noHEADERis found atautoware/foo/Bar.hpp.