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 <nros/nros.h>
#include "my_msg.h" /* generated by nano_ros_generate_interfaces() */
/* Initialise the support context (transport layer). */
nros_support_init(&support, NULL, 0);
/* Create a node. */
nros_node_init(&node, &support, "my_node", "");
/* Create a publisher (uses generated type info). */
nros_publisher_init(&pub, &node, &my_msg__type_info, "chatter");
/* Serialise and publish a message. */
uint8_t buf[256];
size_t len = my_msg__serialize(&msg, buf, sizeof(buf));
nros_publish_raw(&pub, buf, len);
/* Tear down in reverse order. */
Umbrella header for the nros C API.
nros_ret_t nros_publisher_fini(struct nros_publisher_t *publisher)
nros_ret_t nros_node_init(struct nros_node_t *node, const struct nros_support_t *support, const char *name, const char *namespace_)
nros_ret_t nros_publisher_init(struct nros_publisher_t *publisher, const struct nros_node_t *node, const struct nros_message_type_t *type_info, const char *topic_name)
nros_ret_t nros_support_fini(struct nros_support_t *support)
struct nros_node_t nros_node_get_zero_initialized(void)
struct nros_support_t nros_support_get_zero_initialized(void)
nros_ret_t nros_node_fini(struct nros_node_t *node)
nros_ret_t nros_publish_raw(const struct nros_publisher_t *publisher, const uint8_t *data, size_t len)
nros_ret_t nros_support_init(struct nros_support_t *support, const char *locator, uint8_t domain_id)
struct nros_publisher_t nros_publisher_get_zero_initialized(void)
Definition nros_generated.h:1143
Definition nros_generated.h:1742
Definition nros_generated.h:919

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 <nros/nros.h> for everything.

Shared types (return codes, QoS, time) live in <nros/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 Codesnros_ret_t reference with cause and recovery

Guides