Hi,
I’m trying to create a subscriber to the joystick topic like this:
sub_joy_ = this->create_subscription<sensor_msgs::msg::Joy>(“joy”, std::bind(&exampleNode::recvJoy, this, std::placeholders::_1));
with the handler as follows:
void exampleNode::recvJoy(const sensor_msgs::msg::SharedPtr msg)
{
}
However, I get this error:
CMakeFiles/example_node.dir/src/example_node.cpp.o: In function rclcpp::create_subscription_factory<sensor_msgs::msg::Joy_<std::allocator<void> >, std::_Bind<void (exampleNode::*(exampleNode*, std::_Placeholder<1>))(std::shared_ptr<sensor_msgs::msg::Joy_<std::allocator<void> > >)>, std::allocator<void>, sensor_msgs::msg::Joy_<std::allocator<void> >, rclcpp::Subscription<sensor_msgs::msg::Joy_<std::allocator<void> >, std::allocator<void> > >(std::_Bind<void (exampleNode::*(exampleNode*, std::_Placeholder<1>))(std::shared_ptr<sensor_msgs::msg::Joy_<std::allocator<void> > >)>&&, rclcpp::message_memory_strategy::MessageMemoryStrategy<sensor_msgs::msg::Joy_<std::allocator<void> >, std::allocator<void> >::SharedPtr, std::shared_ptr<std::allocator<void> >)::{lambda(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rcl_subscription_options_t&)#1}::operator()(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rcl_subscription_options_t&) const': example_node.cpp:(.text._ZZN6rclcpp27create_subscription_factoryIN11sensor_msgs3msg4Joy_ISaIvEEESt5_BindIFM24exampleNodeFvSt10shared_ptrIS5_EEPS7_St12_PlaceholderILi1EEEES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_NS_23message_memory_strategy21MessageMemoryStrategyIT2_T1_E9SharedPtrES8_ISP_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER26rcl_subscription_options_tE_clESV_S13_S15_[_ZZN6rclcpp27create_subscription_factoryIN11sensor_msgs3msg4Joy_ISaIvEEESt5_BindIFM24exampleNodeFvSt10shared_ptrIS5_EEPS7_St12_PlaceholderILi1EEEES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_NS_23message_memory_strategy21MessageMemoryStrategyIT2_T1_E9SharedPtrES8_ISP_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER26rcl_subscription_options_tE_clESV_S13_S15_]+0xa6): undefined reference to
rosidl_message_type_support_t const* rosidl_typesupport_cpp::get_message_type_support_handle<sensor_msgs::msg::Joy_<std::allocator > >()’
collect2: error: ld returned 1 exit status
It compiles if I substitute the joy message type to any other type.
I include the joystick message as follows: #include <sensor_msgs/msg/joy.hpp>
Let me know what might be the problem.
Thanks