ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The problem is with your subscription callback signature. In Foxy, std::function<void (const std::shared_ptr<const MessageT> &)>
(what you have) is not a supported signature for a subscription callback.
The list of supported subscription callbacks in Foxy is (reference: https://docs.ros2.org/foxy/api/rclcpp/classrclcpp_1_1AnySubscriptionCallback.html)
std::function<void (std::unique_ptr<MessageT, MessageDeleter>)>
std::function<void (std::unique_ptr<MessageT, MessageDeleter>, const rclcpp::MessageInfo &)>
std::function<void (const std::shared_ptr<const MessageT>)>
std::function<void (const std::shared_ptr<const MessageT>, const rclcpp::MessageInfo &)>
std::function<void (std::shared_ptr<MessageT>)>
std::function<void (std::shared_ptr<MessageT>, const rclcpp::MessageInfo &)>
The quick fix here would be to drop the reference to the message's constant shared_ptr, instead opting to just receive a constant shared_ptr in your subscription callback as such:
void cmd_dirCallback(const std_msgs::msg::String::SharedPtr msg);