‘decltype’ cannot resolve address of overloaded function
-
系统:ubuntu22.04 ros2 humble
大佬们,你们有没有遇到过这种问题,终端报告下面这样的错误:Starting >>> ros_ads_msgs Finished <<< ros_ads_msgs [0.45s] Starting >>> ros_ads_node --- stderr: ros_ads_node In file included from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_Interface.h:8, from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:9, from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const bool&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:14:38: warning: unused parameter ‘value’ [-Wunused-parameter] 14 | virtual void operator=(const bool& value){} | ~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const uint8_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:15:41: warning: unused parameter ‘value’ [-Wunused-parameter] 15 | virtual void operator=(const uint8_t& value){} | ~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const int8_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:16:40: warning: unused parameter ‘value’ [-Wunused-parameter] 16 | virtual void operator=(const int8_t& value){} | ~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const uint16_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:17:42: warning: unused parameter ‘value’ [-Wunused-parameter] 17 | virtual void operator=(const uint16_t& value){} | ~~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const int16_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:18:41: warning: unused parameter ‘value’ [-Wunused-parameter] 18 | virtual void operator=(const int16_t& value){} | ~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const uint32_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:19:42: warning: unused parameter ‘value’ [-Wunused-parameter] 19 | virtual void operator=(const uint32_t& value){} | ~~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const int32_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:20:41: warning: unused parameter ‘value’ [-Wunused-parameter] 20 | virtual void operator=(const int32_t& value){} | ~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const uint64_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:21:42: warning: unused parameter ‘value’ [-Wunused-parameter] 21 | virtual void operator=(const uint64_t& value){} | ~~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const int64_t&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:22:41: warning: unused parameter ‘value’ [-Wunused-parameter] 22 | virtual void operator=(const int64_t& value){} | ~~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const float&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:23:39: warning: unused parameter ‘value’ [-Wunused-parameter] 23 | virtual void operator=(const float& value){} | ~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::operator=(const double&)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:24:40: warning: unused parameter ‘value’ [-Wunused-parameter] 24 | virtual void operator=(const double& value){} | ~~~~~~~~~~~~~~^~~~~ /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h: In member function ‘virtual void IAdsVariable::ReadValue(void*)’: /home/user2/demo02_ws/src/ros_ads_node/include/../lib/ADS/AdsLib/AdsVariable.h:26:32: warning: unused parameter ‘res’ [-Wunused-parameter] 26 | virtual void ReadValue(void *res){} | ~~~~~~^~~ In file included from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:12, from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /home/user2/demo02_ws/src/ros_ads_node/include/ADSDecode.h: At global scope: /home/user2/demo02_ws/src/ros_ads_node/include/ADSDecode.h:28:84: warning: ‘ros_ads_msgs::msg::ADS_<std::allocator<void> >::ConstPtr’ is deprecated [-Wdeprecated-declarations] 28 | std::map<std::string, variant_t> decode(const ros_ads_msgs::msg::ADS::ConstPtr &msg); | ^ In file included from /home/user2/demo02_ws/install/ros_ads_msgs/include/ros_ads_msgs/ros_ads_msgs/msg/ads.hpp:7, from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:10, from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /home/user2/demo02_ws/install/ros_ads_msgs/include/ros_ads_msgs/ros_ads_msgs/msg/detail/ads__struct.hpp:129:5: note: declared here 129 | ConstPtr; | ^~~~~~~~ In file included from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:78:64: warning: ‘ros_ads_msgs::msg::ADS_<std::allocator<void> >::ConstPtr’ is deprecated [-Wdeprecated-declarations] 78 | bool Subscriber(const ros_ads_msgs::msg::ADS::ConstPtr& msg); | ^ In file included from /home/user2/demo02_ws/install/ros_ads_msgs/include/ros_ads_msgs/ros_ads_msgs/msg/ads.hpp:7, from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:10, from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /home/user2/demo02_ws/install/ros_ads_msgs/include/ros_ads_msgs/ros_ads_msgs/msg/detail/ads__struct.hpp:129:5: note: declared here 129 | ConstPtr; | ^~~~~~~~ /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp: In constructor ‘ads_node::ADSNode::ADSNode(rclcpp::NodeOptions)’: /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:114:24: warning: catching polymorphic type ‘struct AdsException’ by value [-Wcatch-value=] 114 | catch(AdsException e) | ^ /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp: At global scope: /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:389:69: warning: ‘ros_ads_msgs::msg::ADS_<std::allocator<void> >::ConstPtr’ is deprecated [-Wdeprecated-declarations] 389 | bool ADSNode::Subscriber(const ros_ads_msgs::msg::ADS::ConstPtr &msg) | ^ In file included from /home/user2/demo02_ws/install/ros_ads_msgs/include/ros_ads_msgs/ros_ads_msgs/msg/ads.hpp:7, from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:10, from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /home/user2/demo02_ws/install/ros_ads_msgs/include/ros_ads_msgs/ros_ads_msgs/msg/detail/ads__struct.hpp:129:5: note: declared here 129 | ConstPtr; | ^~~~~~~~ In file included from /opt/ros/humble/include/rclcpp/rclcpp/client.hpp:39, from /opt/ros/humble/include/rclcpp/rclcpp/callback_group.hpp:23, from /opt/ros/humble/include/rclcpp/rclcpp/any_executable.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategy.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategies.hpp:18, from /opt/ros/humble/include/rclcpp/rclcpp/executor_options.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:37, from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /home/user2/demo02_ws/src/ros_ads_node/include/Ads_node.h:7, from /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:1: /opt/ros/humble/include/rclcpp/rclcpp/function_traits.hpp: In instantiation of ‘struct rclcpp::function_traits::function_traits<boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > > >’: /opt/ros/humble/include/rclcpp/rclcpp/any_subscription_callback.hpp:380:10: recursively required by substitution of ‘template<class MessageT, class CallbackT> struct rclcpp::detail::SubscriptionCallbackTypeHelper<MessageT, CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>, const rclcpp::MessageInfo&)> >::value, void>::type> [with MessageT = ros_ads_msgs::msg::ADS_<std::allocator<void> >; CallbackT = boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > >]’ /opt/ros/humble/include/rclcpp/rclcpp/any_subscription_callback.hpp:380:10: required from ‘rclcpp::AnySubscriptionCallback<MessageT, AllocatorT> rclcpp::AnySubscriptionCallback<MessageT, AllocatorT>::set(CallbackT) [with CallbackT = boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > >; MessageT = ros_ads_msgs::msg::ADS_<std::allocator<void> >; AllocatorT = std::allocator<void>]’ /opt/ros/humble/include/rclcpp/rclcpp/subscription_factory.hpp:94:32: required from ‘rclcpp::SubscriptionFactory rclcpp::create_subscription_factory(CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr, std::shared_ptr<rclcpp::topic_statistics::SubscriptionTopicStatistics<ROSMessageType> >) [with MessageT = ros_ads_msgs::msg::ADS_<std::allocator<void> >; CallbackT = boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > >; AllocatorT = std::allocator<void>; SubscriptionT = rclcpp::Subscription<ros_ads_msgs::msg::ADS_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> >; ROSMessageType = ros_ads_msgs::msg::ADS_<std::allocator<void> >; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> > >]’ /opt/ros/humble/include/rclcpp/rclcpp/create_subscription.hpp:122:63: required from ‘std::shared_ptr<ROSMessageT> rclcpp::detail::create_subscription(NodeParametersT&, NodeTopicsT&, const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = ros_ads_msgs::msg::ADS_<std::allocator<void> >; CallbackT = boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > >; AllocatorT = std::allocator<void>; SubscriptionT = rclcpp::Subscription<ros_ads_msgs::msg::ADS_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> >; NodeParametersT = rclcpp::Node; NodeTopicsT = rclcpp::Node; ROSMessageType = ros_ads_msgs::msg::ADS_<std::allocator<void> >; std::string = std::__cxx11::basic_string<char>; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> > >]’ /opt/ros/humble/include/rclcpp/rclcpp/create_subscription.hpp:191:76: required from ‘std::shared_ptr<ROSMessageT> rclcpp::create_subscription(NodeT&, const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = ros_ads_msgs::msg::ADS_<std::allocator<void> >; CallbackT = boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > >; AllocatorT = std::allocator<void>; SubscriptionT = rclcpp::Subscription<ros_ads_msgs::msg::ADS_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> >; NodeT = rclcpp::Node; std::string = std::__cxx11::basic_string<char>; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> > >]’ /opt/ros/humble/include/rclcpp/rclcpp/node_impl.hpp:99:47: required from ‘std::shared_ptr<ROSMessageT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = ros_ads_msgs::msg::ADS_<std::allocator<void> >; CallbackT = boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, ads_node::ADSNode, const std::shared_ptr<const ros_ads_msgs::msg::ADS_<std::allocator<void> > >&>, boost::_bi::list2<boost::_bi::value<ads_node::ADSNode*>, boost::_bi::value<std::_Placeholder<1> > > >; AllocatorT = std::allocator<void>; SubscriptionT = rclcpp::Subscription<ros_ads_msgs::msg::ADS_<std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> >; std::string = std::__cxx11::basic_string<char>; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<ros_ads_msgs::msg::ADS_<std::allocator<void> >, std::allocator<void> > >]’ /home/user2/demo02_ws/src/ros_ads_node/src/Ads_node.cpp:123:73: required from here /opt/ros/humble/include/rclcpp/rclcpp/function_traits.hpp:51:9: error: ‘decltype’ cannot resolve address of overloaded function 51 | using arguments = typename tuple_tail< | ^~~~~~~~~ /opt/ros/humble/include/rclcpp/rclcpp/function_traits.hpp:57:9: error: ‘decltype’ cannot resolve address of overloaded function 57 | using argument_type = typename std::tuple_element<N, arguments>::type; | ^~~~~~~~~~~~~ /opt/ros/humble/include/rclcpp/rclcpp/function_traits.hpp:59:9: error: ‘decltype’ cannot resolve address of overloaded function 59 | using return_type = typename function_traits<decltype( &FunctionT::operator())>::return_type; | ^~~~~~~~~~~ gmake[2]: *** [CMakeFiles/ros_ads_node.dir/build.make:90:CMakeFiles/ros_ads_node.dir/src/Ads_node.cpp.o] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:154:CMakeFiles/ros_ads_node.dir/all] 错误 2 gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< ros_ads_node [5.20s, exited with code 2] Summary: 1 package finished [5.80s] 1 package failed: ros_ads_node 1 package had stderr output: ros_ads_node
前面的警告我觉得应该没有什么大的问题,初步猜测是定义订阅者对象和设置回调函数时可能出错,但是我看了看,和基础ROS2的设置教程没什么区别:
设置如下:try { m_subscriber = this->create_subscription<ros_ads_msgs::msg::ADS>("command", 10, boost::bind(&ADSNode::Subscriber, this, _1)); m_on_event_publisher = this->create_publisher<ros_ads_msgs::msg::ADS>("report_event", 10); m_on_timer_publisher = this->create_publisher<ros_ads_msgs::msg::ADS>("report_timer", 10); m_state_publisher = this->create_publisher<ros_ads_msgs::msg::State>("state", 10); /* m_subscriber = n.subscribe<ros_ads_msgs::msg::ADS>("command", 10, boost::bind(&ADSNode::Subscriber, this, _1)); m_on_event_publisher = n.advertise<ros_ads_msgs::msg::ADS>("report_event", 10); m_on_timer_publisher = n.advertise<ros_ads_msgs::msg::ADS>("report_timer", 10); m_state_publisher = n.advertise<ros_ads_msgs::msg::ADS>("state", 10); */ } catch (...) { RCLCPP_ERROR(rclcpp::get_logger("rclcpp"),"ERROR in creating subscriber"); /* return 0; */ } m_timer_thread = std::make_shared<boost::thread>(&ADSNode::publishOnTimer,this, m_rate_publish); m_update_thread = std::make_shared<boost::thread>(&ADSNode::update,this, m_rate_update); m_checker_thread = std::make_shared<boost::thread>(&ADSNode::publishOnEvent,this, m_rate_update); m_state_thread = std::make_shared<boost::thread>(&ADSNode::publishState,this, m_rate_state);
订阅者的回调函数如下:
bool ADSNode::Subscriber(const ros_ads_msgs::msg::ADS::ConstPtr &msg) { m_state_publisher->publish(m_state_msg); bool result = true; auto command = ros_ads_msgs::decode(msg); try { if(m_ADS.getState()) { for (auto &[name, value]: command) { m_ADS.adsWriteValue(name, value); } } } catch (...) { result = false; } return result; }
这个问题应该怎么处理呢?请大佬指教
-
-
@yudonghou123 建议多看看小鱼的话题实现代码。你写的订阅者的代码格式不符合要求
-
@Lorry 您好,非常感谢您的解答,这个程序其实是PLC倍福提供的关于ROS节点的,原本是ros1的,但是我目前把它迁移到ros2上,我改过程中按照教程进行修改并没有报错,但是终端始终输出上面的问题,您觉得是回调函数的问题吗
-
@yudonghou123 没有报错不代表能够正常编译。你上面的代码不全,我只能看出来你的回调函数不符合要求,建议你先学习一下ros2的用法。我把ros代码迁移到ros2,都是直接重写一遍,我不太了解你说的教程是哪种
-
@Lorry 好的,感谢,那我去看看,我看报错好像也是提醒这个
-
-
你好,我也遇到了一样的问题,请问你最后解决了吗,方便告知一下方法吗,感谢感谢
-
不用了,感谢解决了