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

Lightweight ROS 2 client library for embedded real-time systems — freestanding C++14 surface that mirrors rclcpp.

Quick Start

#include "std_msgs.hpp" // generated by nano_ros_generate_interfaces()
int main() {
// 1. Initialise the global session.
RCLCPP_TRY(rclcpp::init_in("tcp/127.0.0.1:7447"));
// 2. Create a node.
RCLCPP_TRY(rclcpp::create_node(node, "cpp_talker"));
// 3. Create a typed publisher.
RCLCPP_TRY(node.create_publisher(pub, "/chatter"));
// 4. Publish messages.
std_msgs::msg::Int32 msg{};
for (int i = 0; rclcpp::ok() && i < 10; ++i) {
msg.data = i;
pub.publish(msg);
}
return 0;
}
Definition client.hpp:129
Definition node.hpp:703
typename::rclcpp::Publisher< M >::SharedPtr create_publisher(const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
create_publisher<M>(topic, qos) — available on every target.
Result shutdown_in()
Definition node.hpp:2945
Result create_node(::rclcpp::Node &out, const char *name, const char *ns)
Definition node.hpp:3043
Result init_in(const char *locator=nullptr, uint8_t domain_id=0)
Definition node.hpp:2785
bool ok()
Definition node.hpp:3031
Result spin_in()
Definition rclcpp.hpp:192
#define RCLCPP_TRY(expr)
Definition result.hpp:258

See Getting Started for the full walkthrough.

API Modules

The C++ 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, global session, rclcpp::ok()
node Node creation and lifecycle (rclcpp::Node)
pubsub Publishers and subscriptions (rclcpp::Publisher<M>, rclcpp::Subscription<M>)
service Service servers and clients (rclcpp::Service<S>, rclcpp::Client<S>)
action Action servers and clients (rclcpp::ActionServer<A>, rclcpp::ActionClient<A>)
executor Callback dispatch, timers, guard conditions
clock Monotonic and wall-clock time
qos Quality-of-Service settings
errors Error codes, rclcpp::Result, RCLCPP_TRY
support Span, FixedString, FixedSequence, std_compat

Header Organisation

Include the umbrella header for the full surface:

Or include only the per-module headers you need (<rclcpp/publisher.hpp>, <rclcpp/subscription.hpp>, …) for faster compile times in large projects.

Concepts

Guides

Freestanding vs <tt>std</tt>

By default nros-cpp is freestanding C++14: no STL, no exceptions, no RTTI. Define NROS_CPP_STD before including <rclcpp/rclcpp.hpp> to enable std::string, std::function, and std::chrono convenience overloads on host platforms.