subscription callback types ROS1 vs. ROS2
Hi everyone
I've been creating some subscriptions in ROS2 lately, and had a question regarding the callback signature of any subscription or service creation. In ROS1, the callback signature of any message type could've been any one of the MsgType, MsgTypePtr, MsgTypeConstPtr, and additional const qualification and references of all of the previous. However as far as I can tell in ROS2, there seems to only be a limited subset of the above which would constitute a compilable callback signature.
To give a couple of examples in ROS2:
create_subscription<std_msgs::msg::String>(
"/foo", 5, [this](std_msgs::msg::String::ConstSharedPtr msg) // this works
create_subscription<std_msgs::msg::String>(
"/foo", 5, [this](std_msgs::msg::String::UniquePtr msg) // also works
create_subscription<std_msgs::msg::String>(
"/foo", 5, [this](const std_msgs::msg::String::ConstSharedPtr msg) // doesn't seem to work
create_subscription<std_msgs::msg::String>(
"/foo", 5, [this](std_msgs::msg::String::ConstSharedPtr& msg) // doesn't work either
create_subscription<std_msgs::msg::String>(
"/foo", 5, [this](std_msgs::msg::String::ConstUniquePtr msg) // neither does this
It seems that the internal templates do not allow some of these patterns. Is it possible with the current design to perhaps extend subscription callback signatures so that it can accept some of the above signatures?