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.