Hi. Sorry for all mistakes, English is not my native language. I have a subscriber that looks like this
rclcpp::Subscription<minicar_control::msg::Feedback>::SharedPtr hw_feedback_sub;
...
hw_feedback_sub = this->create_subscription<minicar_control::msg::Feedback>("hw_feedback", 1000, std::bind(&STMRobotHW::feedbackCallback, this, _1));
As far as I know this should work, but this is how problem looks in VS Code:
operand types are: std::shared_ptr<rclcpp::Subscription<minicar_control::msg::Feedback, std::allocator, rclcpp::message_memory_strategy::MessageMemoryStrategy<minicar_control::msg::Feedback, std::allocator>>> = std::shared_ptr<rclcpp::Subscription<const minicar_control::msg::Feedback &, std::allocator, rclcpp::message_memory_strategy::MessageMemoryStrategy<const minicar_control::msg::Feedback &, std::allocator>>>
I think, that this can be solved by removing hw_feedback_sub from header and use auto like this
auto hw_feedback_sub = this->create_subscription<minicar_control::msg::Feedback>("hw_feedback", 1000, std::bind(&STMRobotHW::feedbackCallback, this, _1));
But I want to know where I overlook mistake. Appreciate any help.
Originally posted by Edvard on ROS Answers with karma: 95 on 2022-10-21
Post score: 0
Original comments
Comment by ravijoshi on 2022-10-21:
The rclcpp::Subscription
should be a class member. Removing it from header and using auto
(the way you suggested), may avoid the error, but the callback will not be executed. On the other hand, I can not reproduce the error, as the code is incomplete. I suggest creating a minimal reproducible example