Litle problem with assigning subscriber.
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<void="">, rclcpp::message_memory_strategy::MessageMemoryStrategy<minicar_control::msg::feedback, std::allocator<void="">>>> = std::shared_ptr<rclcpp::subscription<const minicar_control::msg::feedback="" &,="" std::allocator<void="">, rclcpp::message_memory_strategy::MessageMemoryStrategy<const minicar_control::msg::feedback="" &,="" std::allocator<void="">>>>
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.
The
rclcpp::Subscription
should be a class member. Removing it from header and usingauto
(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