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: an image whose agent stops loses all connectivity until it comes back.
Before you start
- A workspace, such as the host one from Run a talker.
- ROS 2 Humble, 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_xrce --expect 'Publishing:' --timeout 120nros run: starting the XRCE agent (udp4 -p 2018) Publishing: 'Hello World: 1' nros run: matched after -
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
nros run posix_xrcewithout--expectin the first terminal so the talker keeps going. -
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 example
examples/mps2-an385-baremetal/rust/talker-xrcestateslocator = "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_size = 256 stream_history = 4stream_historymust be at least 4. A received sample larger thanbuffer_sizeis 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.
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.