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(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 four settings from the environment when it starts, so the same binary can join another domain or another router, or run under another name, without a rebuild:
ROS_DOMAIN_ID=0
NROS_LOCATOR=tcp/127.0.0.1:7447
NROS_NODE_NAME=my_talker
NROS_NODE_NAMESPACE=/robot1
The first two replace the image’s domain_id and locator. The other two
apply to the image’s nodes, including nodes named in code or by a launch
file:
NROS_NODE_NAMESPACEreplaces the namespace of every node. A node that stated a different namespace gets one warning at start.NROS_NODE_NAMErenames the node only when the image states that it creates exactly one.nros buildstates the count, as[image] node_countin the files it generates. The rename prints one warning that names the old and the new name.- With two or more nodes,
NROS_NODE_NAMEis ignored, since one name can’t name them all, and a notice says so. An image whose count is unstated, such as one built withoutnros build, ignores it with a notice too. Name each node insystem.toml, or with a launch remap, instead.
A launch file’s remaps keep applying to a renamed node.
An embedded image has no environment. Its domain and locator are compiled in
from its image’s domain_id and locator keys, and its nodes keep the names
the image gives them.
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.