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

C API

Reference · Level 2: Building real applications

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

Two-layer API. Every entity exposes two parallel C entry-point sets: rclc_*_init_default (Layer 1, caller polls) and rclc_executor_add_* (Layer 2, executor callback). Layer 1 grew an _init_polling + take_*_raw / send_*_raw family for inline-storage callers (no executor arena). Layer 2 pairs the same rclc_*_init_default with 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-owned rclc_wake_state_t POD; the backend fires cb(ctx) on rx / reply / request arrival. Per-channel for actions (set_{goal,cancel,get_result}_wake_callback on the server, set_{goal_response,cancel_response,result,feedback}_wake_callback on 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

Behaviourrclcnano-ros
A goal arriving with every goal handle in usequeuedrejected
An accepted goalwaits for the client to ask for its resultexecutes at once, so a result may be sent before the client asks for it
Taking an entity off a running executorrclc_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 itrclc_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.