Lifecycle node ROS2

asked 2020-04-11 11:10:52 -0500

lorenzo gravatar image

Hi everybody. I'm using the lifecycle node to base interface to create a node object that suscribe and publish on some topic. The point is that I cannot create a subscriber with the class. Following the code pieces involved:

class I2c_Comm : public rclcpp_lifecycle::LifecycleNode{
...

And the method in which I am trying to create the subscriber

...  
auto qos =rclcpp::QoS(rclcpp::KeepLast(20));
vel_sub_ = rclcpp_lifecycle::LifecycleNode::create_subscription<geometry_msgs::msg::Twist>(speed_sub, 
qos,std::bind(&I2c_Comm::callback,this, std::placeholders::_1) );
...

The attribute vel_sub_ is defined as:

rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr vel_sub_;

Extract of compiler output:

In file included from /home/lorenzoteo/ros2_eloquent/install/rclcpp/include/rclcpp/node_interfaces/node_topics_interface.hpp:29:0,
                 from /home/lorenzoteo/ros2_eloquent/install/rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node.hpp:49,
                 from /home/lorenzoteo/ALBA_REPO/alba_v2_navigation/wheelchair_fake_node/include/i2c_comm.hpp:30,
                 from /home/lorenzoteo/ALBA_REPO/alba_v2_navigation/wheelchair_fake_node/src/i2c_comm.cpp:20:
/home/lorenzoteo/ros2_eloquent/install/rclcpp/include/rclcpp/subscription_factory.hpp: In instantiation of ‘rclcpp::SubscriptionFactory rclcpp::create_subscription_factory(CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; CallbackT = std::_Bind<void (I2c_Comm::*(I2c_Comm*, std::_Placeholder<1>))(geometry_msgs::msg::Twist_<std::allocator<void> >)>; AllocatorT = std::allocator<void>; CallbackMessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; SubscriptionT = rclcpp::Subscription<geometry_msgs::msg::Twist_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> >; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> > >]’:
/home/lorenzoteo/ros2_eloquent/install/rclcpp/include/rclcpp/create_subscription.hpp:67:63:   required from ‘std::shared_ptr<SubscriptionT> rclcpp::create_subscription(NodeT&&, const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; CallbackT = std::_Bind<void (I2c_Comm::*(I2c_Comm*, std::_Placeholder<1>))(geometry_msgs::msg::Twist_<std::allocator<void> >)>; AllocatorT = std::allocator<void>; CallbackMessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; SubscriptionT = rclcpp::Subscription<geometry_msgs::msg::Twist_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> >; NodeT = rclcpp_lifecycle::LifecycleNode&; std::__cxx11::string = std::__cxx11::basic_string<char>; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> > >]’
/home/lorenzoteo/ros2_eloquent/install/rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node_impl.hpp:73:47:   required from ‘std::shared_ptr<SubscriptionT> rclcpp_lifecycle::LifecycleNode::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; CallbackT = std::_Bind<void (I2c_Comm::*(I2c_Comm*, std::_Placeholder<1>))(geometry_msgs::msg::Twist_<std::allocator<void> >)>; AllocatorT = std::allocator<void>; CallbackMessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; SubscriptionT = rclcpp::Subscription<geometry_msgs::msg::Twist_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> > >]’
/home/lorenzoteo/ALBA_REPO/alba_v2_navigation/wheelchair_fake_node/src/i2c_comm.cpp:70:124:   required from here
/home/lorenzoteo/ros2_eloquent/install/rclcpp/include/rclcpp/subscription_factory.hpp:87:3: error: no matching function for call to ‘rclcpp::AnySubscriptionCallback<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> >::set(std::_Bind<void (I2c_Comm::*(I2c_Comm*, std::_Placeholder<1>))(geometry_msgs::msg::Twist_<std::allocator<void> >)>)’
   any_subscription_callback.set(std::forward<CallbackT>(callback));
   ^~~~~~~~~~~~~~~~~~~~~~~~~
edit retag flag offensive close merge delete