Intro

rclcpp is the ROS client library for C++.

Resources

Usage

#include "rclcpp/rclcpp.hpp"

API

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 a std::shared_ptr<rclcpp::Node>.
 explicit Node(const std::string &node_name, const NodeOptions &options = NodeOptions())

Related