Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Get started on the ThreadX Linux simulator

How-to · Level 1: First contact

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 nros is on your PATH.
  • 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 run stops at once and names the router: it could not find rmw_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 run stops at once and names AMENT_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 run names the router’s log when it stops.
  • Everything else: Troubleshooting - First 10 Minutes.

Next