nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
nros C API

Lightweight ROS 2 client library for embedded real-time systems.

Quick Start

#include <rclc/rclc.h>
#include <std_msgs/msg/int32.h> /* generated by nano_ros_generate_interfaces() */
/* Initialise the support context (transport layer). The allocator is rcl's
* argument; nothing here allocates. */
rclc_support_init(&support, 0, NULL, &allocator);
/* Create a node. */
rclc_node_init_default(&node, "my_node", "", &support);
/* Create a publisher and publish. */
rclc_publisher_init_default(&pub, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
"chatter");
std_msgs__msg__Int32 msg = {.data = 42};
rcl_publish(&pub, &msg, NULL);
/* Tear down in reverse order. */
rcl_publisher_fini(&pub, &node);
rcl_ret_t rclc_support_init(struct rclc_support_t *support, int argc, const char *const *argv, const struct rcl_allocator_t *allocator)
rcl_ret_t rclc_publisher_init_default(struct rcl_publisher_t *publisher, const struct rcl_node_t *node, const struct rclc_message_type_t *type_info, const char *topic_name)
struct rcl_node_t rcl_get_zero_initialized_node(void)
struct rcl_publisher_t rcl_get_zero_initialized_publisher(void)
struct rclc_support_t rclc_support_get_zero_initialized(void)
rcl_ret_t rcl_node_fini(struct rcl_node_t *node)
rcl_ret_t rcl_publisher_fini(struct rcl_publisher_t *publisher, struct rcl_node_t *node)
struct rcl_allocator_t rcl_get_default_allocator(void)
rcl_ret_t rcl_publish(const struct rcl_publisher_t *publisher, const void *ros_message, struct rmw_publisher_allocation_t *allocation)
rcl_ret_t rclc_support_fini(struct rclc_support_t *support)
rcl_ret_t rclc_node_init_default(struct rcl_node_t *node, const char *name, const char *namespace_, const struct rclc_support_t *support)
Umbrella header for the nano-ros C API, at upstream's path.
Definition nros_generated.h:836
Definition nros_generated.h:1454
Definition nros_generated.h:2076
Definition nros_generated.h:1219

API Modules

The API is organised into the following module groups (see the Modules tab in the sidebar for each group's contents):

Group Description
init Library initialisation, support context
node Node creation and lifecycle
pubsub Topic publishers and subscriptions
service Service servers and clients
action Action servers and clients
executor Callback executor, timers, guard conditions
clock Clock and time types
parameter Parameter services
lifecycle Node lifecycle state machine (REP-2002)
cdr CDR serialisation helpers
qos Quality-of-Service settings
errors Return codes, see Error Codes
types Shared types

Header Organisation

Each per-module header above is the authoritative C API surface for its module, with hand-written Doxygen documentation. Include individual headers for what you need, or use <rclc/rclc.h> for everything.

Shared types (return codes, QoS, time) live in <rclc/types.h>, which all module headers include automatically.

An internal nros_generated.h (produced by cbindgen) is used for compile-time drift detection — it is not part of the public API.

Reference

  • Error Codes — rcl_ret_t reference with cause and recovery

Guides