Why is ROS2 Tutorials using SharedPtr for subscriber callbacks?
Hello,
when following the tutorial at https://docs.ros.org/en/foxy/Tutorial... I realized that void topic_callback(const std_msgs::msg::String::SharedPtr msg)
always takes the SharedPtr of the message as an argument. Why isn't it common to just take the message as an argument for the callback, this would look like this void topic_callback(const std_msgs::msg::String msg)
? When thinking about it I guess the difference is that one is call by reference and the other one call by value. Is using SharedPtr increasing memory efficiency?
Thanks.
This reads like a duplicate of #q363135.