Manual
Create a class
Now that the dependencies are set, we can create a class that inherits from the rclcpp::Node
class. We will call this class TurtleBot4FirstNode.
class TurtleBot4FirstNode : public rclcpp::Node
{
public:
TurtleBot4FirstNode()
: Node("turtlebot4_first_cpp_node")
{}
};
Notice that our class calls the Node constructor and passes it the name of our node,
turtlebot4_first_cpp_node.
We can now create our node in the main function and spin it. Since our node is empty, the node
will be created but it won't do anything.
int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<TurtleBot4FirstNode>());
rclcpp::shutdown();
return 0;
}