Intro
rclcpp is the ROS client library for C++.
Resources
- https://github.com/ros2/rclcpp
- https://docs.ros.org/en/rolling/p/rclcpp/generated/index.html#rclcpp-ros-client-library-for-c
- https://docs.ros.org/en/humble/Concepts/Intermediate/About-Executors.html
Usage
#include "rclcpp/rclcpp.hpp"
API
rclcpp::init(argc, argv)rclcpp::Noderclcpp::spinrclcpp::shutdown
ROS2 C++ Node
int main(int argc, char* argv[])
{
// Some initialization.
rclcpp::init(argc, argv);
...
// Instantiate a node.
rclcpp::Node::SharedPtr node = ...
// Run the executor.
rclcpp::spin(node);
// Shutdown and exit.
...
return 0;
}- Instantiate a ROS2 node using
std::make_shared<rclcpp::Node>(), which returns astd::shared_ptr<rclcpp::Node>.
explicit Node(const std::string &node_name, const NodeOptions &options = NodeOptions())


