ROS Node
This is like fundamental, I should spend more time on this. How are ROS nodes implemented under the hood?
Resources
Some questions I need to answer:
- What is
Node::SharePtr
? - Why is it that for the ROS Executor, we need to make this node a shared pointer?
Source code
This is an example ROS node, from ROS Examples
Notice that the subscription is a
SharedPtr
More generally, most of everything in ROS with
rclcpp
is usingSharedPtr
. This is because of the benefit of automatic memory management: https://answers.ros.org/question/363135/why-is-everything-a-shared_ptr-in-ros2/
Notice also that the callback is a private method.
Member fields:
Publisher
The this->create_publisher
returns a shared pointer, which is why we need SharedPtr
Subscriber
The this->create_subscription
also returns a shared pointer, which is why we need SharedPtr