关于“ROS2 Topic-Statistics-Tutorial编译出错”的思考2
Posted zhangrelay
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于“ROS2 Topic-Statistics-Tutorial编译出错”的思考2相关的知识,希望对你有一定的参考价值。
关于“ROS2 Topic-Statistics-Tutorial编译出错”的思考
复现了一下其中报错信息:
如果选foxy会有如上错误,如果选galactic则不会报错,顺利编译完成。
无需修改:set(CMAKE_CXX_STANDARD 17)
windows环境:
if(MSVC)
set(CMAKE_CXX_FLAGS "$CMAKE_CXX_FLAGS /std:c++17")
endif(MSVC)
详细记录:
Hello, ROS 1.0 or ROS 2.0? 1=noetic 2=foxy 3=galactic
2
foxy
ros@ros:~/RobCode/exam_ros2$ colcon build
Starting >>> examples_rclcpp_minimal_publisher
Starting >>> examples_rclcpp_minimal_subscriber
Starting >>> launch_testing_examples
Finished <<< launch_testing_examples [0.72s]
Finished <<< examples_rclcpp_minimal_publisher [11.4s]
--- stderr: examples_rclcpp_minimal_subscriber
In file included from /usr/include/c++/9/ext/alloc_traits.h:36,
from /usr/include/c++/9/bits/basic_string.h:40,
from /usr/include/c++/9/string:55,
from /usr/include/c++/9/stdexcept:39,
from /usr/include/c++/9/array:39,
from /usr/include/c++/9/tuple:39,
from /usr/include/c++/9/functional:54,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:15:
/usr/include/c++/9/bits/alloc_traits.h: In instantiation of ‘struct std::allocator_traits<std::allocator<const std_msgs::msg::String_<std::allocator<void> >&> >’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:47:9: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = std::_Bind<void (MinimalSubscriber::*(MinimalSubscriber*, std::_Placeholder<1>))(const std_msgs::msg::String_<std::allocator<void> >&) const>; AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: required from here
/usr/include/c++/9/bits/alloc_traits.h:400:13: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
400 | using pointer = _Tp*;
| ^~~~~~~
/usr/include/c++/9/bits/alloc_traits.h:403:13: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
403 | using const_pointer = const _Tp*;
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/9/memory:80,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:16:
/usr/include/c++/9/bits/unique_ptr.h: In instantiation of ‘struct std::default_delete<const std_msgs::msg::String_<std::allocator<void> >&>’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:119:18: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = std::_Bind<void (MinimalSubscriber::*(MinimalSubscriber*, std::_Placeholder<1>))(const std_msgs::msg::String_<std::allocator<void> >&) const>; AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: required from here
/usr/include/c++/9/bits/unique_ptr.h:71:9: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
71 | default_delete(const default_delete<_Up>&) noexcept
| ^~~~~~~~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:75:7: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
75 | operator()(_Tp* __ptr) const
| ^~~~~~~~
In file included from /opt/ros/foxy/include/rclcpp/subscription_base.hpp:29,
from /opt/ros/foxy/include/rclcpp/callback_group.hpp:26,
from /opt/ros/foxy/include/rclcpp/any_executable.hpp:20,
from /opt/ros/foxy/include/rclcpp/memory_strategy.hpp:24,
from /opt/ros/foxy/include/rclcpp/memory_strategies.hpp:18,
from /opt/ros/foxy/include/rclcpp/executor_options.hpp:20,
from /opt/ros/foxy/include/rclcpp/executor.hpp:33,
from /opt/ros/foxy/include/rclcpp/executors/multi_threaded_executor.hpp:26,
from /opt/ros/foxy/include/rclcpp/executors.hpp:21,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:18:
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp: In instantiation of ‘class rclcpp::AnySubscriptionCallback<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’:
/opt/ros/foxy/include/rclcpp/subscription.hpp:327:57: required from ‘class rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >’
/usr/include/c++/9/type_traits:1320:45: required by substitution of ‘template<class _From1, class _To1, class> static std::true_type std::__is_convertible_helper<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*, rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*, false>::__test<_From1, _To1, <template-parameter-1-3> >(int) [with _From1 = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*; _To1 = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*; <template-parameter-1-3> = <missing>]’
/usr/include/c++/9/type_traits:1329:42: required from ‘struct std::__is_convertible_helper<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*, rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*, false>’
/usr/include/c++/9/type_traits:1335:12: required from ‘struct std::is_convertible<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*, rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*>’
/usr/include/c++/9/bits/shared_ptr_base.h:927:12: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/9/bits/shared_ptr_base.h:1099:8: required by substitution of ‘template<class _Tp, __gnu_cxx::_Lock_policy _Lp> template<class _Yp> using _Assignable = std::__shared_ptr<_Tp, _Lp>::_Compatible<_Yp, std::__shared_ptr<_Tp, _Lp>&> [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:1271:2: required by substitution of ‘template<class _Yp> std::__shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >, __gnu_cxx::_S_atomic>::_Assignable<_Yp> std::__shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >, __gnu_cxx::_S_atomic>::operator=<_Yp>(std::__shared_ptr<_Tp>&&) [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/usr/include/c++/9/type_traits:1017:12: required from ‘struct std::is_assignable<std::__shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >, __gnu_cxx::_S_atomic>&, std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > > >’
/usr/include/c++/9/bits/shared_ptr.h:111:8: required by substitution of ‘template<class _Tp> template<class _Arg> using _Assignable = typename std::enable_if<std::is_assignable<std::__shared_ptr<_Tp>&, _Arg>::value, std::shared_ptr<_Tp>&>::type [with _Arg = std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
/usr/include/c++/9/bits/shared_ptr.h:341:2: required by substitution of ‘template<class _Yp> std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::_Assignable<std::shared_ptr<_Tp> > std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::operator=<_Yp>(std::shared_ptr<_Tp>&&) [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: required from here
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:111:8: error: ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const _Tp>)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’ cannot be overloaded with ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
111 | void set(CallbackT callback)
| ^~~
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:83:8: note: previous declaration ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
83 | void set(CallbackT callback)
| ^~~
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:125:8: error: ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>, const rclcpp::MessageInfo&)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const _Tp>, const rclcpp::MessageInfo&)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’ cannot be overloaded with ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>, const rclcpp::MessageInfo&)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>, const rclcpp::MessageInfo&)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
125 | void set(CallbackT callback)
| ^~~
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:97:8: note: previous declaration ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>, const rclcpp::MessageInfo&)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>, const rclcpp::MessageInfo&)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
97 | void set(CallbackT callback)
| ^~~
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp: In constructor ‘MinimalSubscriber::MinimalSubscriber()’:
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: error: no match for ‘operator=’ (operand types are ‘rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >::SharedPtr’ aka ‘std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >’ and ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’)
30 | "topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1));
| ^
In file included from /usr/include/c++/9/memory:81,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:16:
/usr/include/c++/9/bits/shared_ptr.h:309:19: note: candidate: ‘std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Tp>&) [with _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
309 | shared_ptr& operator=(const shared_ptr&) noexcept = default;
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:309:29: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ to ‘const std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >&’
309 | shared_ptr& operator=(const shared_ptr&) noexcept = default;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:313:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::_Assignable<const std::shared_ptr<_Yp>&> std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Yp>&) [with _Yp = _Yp; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
313 | operator=(const shared_ptr<_Yp>& __r) noexcept
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:313:2: note: template argument deduction/substitution failed:
/usr/include/c++/9/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class _Arg> using _Assignable = typename std::enable_if<std::is_assignable<std::__shared_ptr<_Tp>&, _Arg>::value, std::shared_ptr<_Tp>&>::type [with _Arg = const std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >&; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’:
/usr/include/c++/9/bits/shared_ptr.h:313:2: required by substitution of ‘template<class _Yp> std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::_Assignable<const std::shared_ptr<_Tp>&> std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::operator=<_Yp>(const std::shared_ptr<_Tp>&) [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: required from here
/usr/include/c++/9/bits/shared_ptr.h:111:8: error: no type named ‘type’ in ‘struct std::enable_if<false, std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >&>’
111 | using _Assignable = typename enable_if<
| ^~~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:324:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::_Assignable<std::auto_ptr<_Up> > std::shared_ptr<_Tp>::operator=(std::auto_ptr<_Up>&&) [with _Yp = _Yp; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
324 | operator=(auto_ptr<_Yp>&& __r)
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:324:2: note: template argument deduction/substitution failed:
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: note: ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ is not derived from ‘std::auto_ptr<_Up>’
30 | "topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1));
| ^
In file included from /usr/include/c++/9/memory:81,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:16:
/usr/include/c++/9/bits/shared_ptr.h:333:7: note: candidate: ‘std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Tp>&&) [with _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
333 | operator=(shared_ptr&& __r) noexcept
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:333:30: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ to ‘std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >&&’
333 | operator=(shared_ptr&& __r) noexcept
| ~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/shared_ptr.h:341:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::_Assignable<std::shared_ptr<_Yp> > std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Yp>&&) [with _Yp = _Yp; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
341 | operator=(shared_ptr<_Yp>&& __r) noexcept
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:341:2: note: substitution of deduced template arguments resulted in errors seen above
/usr/include/c++/9/bits/shared_ptr.h:349:2: note: candidate: ‘template<class _Yp, class _Del> std::shared_ptr<_Tp>::_Assignable<std::unique_ptr<_Up, _Ep> > std::shared_ptr<_Tp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Yp = _Yp; _Del = _Del; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
349 | operator=(unique_ptr<_Yp, _Del>&& __r)
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:349:2: note: template argument deduction/substitution failed:
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:30:75: note: ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ is not derived from ‘std::unique_ptr<_Tp, _Dp>’
30 | "topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1));
| ^
In file included from /usr/include/c++/9/ext/alloc_traits.h:36,
from /usr/include/c++/9/bits/stl_construct.h:61,
from /usr/include/c++/9/memory:64,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:144,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/not_composable.cpp:15:
/usr/include/c++/9/bits/alloc_traits.h: In instantiation of ‘struct std::allocator_traits<std::allocator<const std_msgs::msg::String_<std::allocator<void> >&> >’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:47:9: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = void (&)(const std_msgs::msg::String_<std::allocator<void> >&); AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/not_composable.cpp:35:83: required from here
/usr/include/c++/9/bits/alloc_traits.h:400:13: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
400 | using pointer = _Tp*;
| ^~~~~~~
/usr/include/c++/9/bits/alloc_traits.h:403:13: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
403 | using const_pointer = const _Tp*;
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/9/memory:80,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:144,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/not_composable.cpp:15:
/usr/include/c++/9/bits/unique_ptr.h: In instantiation of ‘struct std::default_delete<const std_msgs::msg::String_<std::allocator<void> >&>’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:119:18: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = void (&)(const std_msgs::msg::String_<std::allocator<void> >&); AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/not_composable.cpp:35:83: required from here
/usr/include/c++/9/bits/unique_ptr.h:71:9: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
71 | default_delete(const default_delete<_Up>&) noexcept
| ^~~~~~~~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:75:7: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
75 | operator()(_Tp* __ptr) const
| ^~~~~~~~
In file included from /usr/include/c++/9/ext/alloc_traits.h:36,
from /usr/include/c++/9/bits/stl_construct.h:61,
from /usr/include/c++/9/memory:64,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:16:
/usr/include/c++/9/bits/alloc_traits.h: In instantiation of ‘struct std::allocator_traits<std::allocator<const std_msgs::msg::String_<std::allocator<void> >&> >’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:47:9: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = MinimalSubscriberWithTopicStatistics::MinimalSubscriberWithTopicStatistics()::<lambda(const String&)>&; AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: required from here
/usr/include/c++/9/bits/alloc_traits.h:400:13: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
400 | using pointer = _Tp*;
| ^~~~~~~
/usr/include/c++/9/bits/alloc_traits.h:403:13: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
403 | using const_pointer = const _Tp*;
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/9/memory:80,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:16:
/usr/include/c++/9/bits/unique_ptr.h: In instantiation of ‘struct std::default_delete<const std_msgs::msg::String_<std::allocator<void> >&>’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:119:18: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = MinimalSubscriberWithTopicStatistics::MinimalSubscriberWithTopicStatistics()::<lambda(const String&)>&; AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: required from here
/usr/include/c++/9/bits/unique_ptr.h:71:9: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
71 | default_delete(const default_delete<_Up>&) noexcept
| ^~~~~~~~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:75:7: error: forming pointer to reference type ‘const std_msgs::msg::String_<std::allocator<void> >&’
75 | operator()(_Tp* __ptr) const
| ^~~~~~~~
In file included from /opt/ros/foxy/include/rclcpp/subscription_base.hpp:29,
from /opt/ros/foxy/include/rclcpp/callback_group.hpp:26,
from /opt/ros/foxy/include/rclcpp/any_executable.hpp:20,
from /opt/ros/foxy/include/rclcpp/memory_strategy.hpp:24,
from /opt/ros/foxy/include/rclcpp/memory_strategies.hpp:18,
from /opt/ros/foxy/include/rclcpp/executor_options.hpp:20,
from /opt/ros/foxy/include/rclcpp/executor.hpp:33,
from /opt/ros/foxy/include/rclcpp/executors/multi_threaded_executor.hpp:26,
from /opt/ros/foxy/include/rclcpp/executors.hpp:21,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:18:
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp: In instantiation of ‘class rclcpp::AnySubscriptionCallback<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >’:
/opt/ros/foxy/include/rclcpp/subscription.hpp:327:57: required from ‘class rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >’
/usr/include/c++/9/type_traits:1320:45: required by substitution of ‘template<class _From1, class _To1, class> static std::true_type std::__is_convertible_helper<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*, rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*, false>::__test<_From1, _To1, <template-parameter-1-3> >(int) [with _From1 = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*; _To1 = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*; <template-parameter-1-3> = <missing>]’
/usr/include/c++/9/type_traits:1329:42: required from ‘struct std::__is_convertible_helper<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*, rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*, false>’
/usr/include/c++/9/type_traits:1335:12: required from ‘struct std::is_convertible<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >*, rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >*>’
/usr/include/c++/9/bits/shared_ptr_base.h:927:12: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/9/bits/shared_ptr_base.h:1099:8: required by substitution of ‘template<class _Tp, __gnu_cxx::_Lock_policy _Lp> template<class _Yp> using _Assignable = std::__shared_ptr<_Tp, _Lp>::_Compatible<_Yp, std::__shared_ptr<_Tp, _Lp>&> [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’
/usr/include/c++/9/bits/shared_ptr_base.h:1271:2: required by substitution of ‘template<class _Yp> std::__shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >, __gnu_cxx::_S_atomic>::_Assignable<_Yp> std::__shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >, __gnu_cxx::_S_atomic>::operator=<_Yp>(std::__shared_ptr<_Tp>&&) [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/usr/include/c++/9/type_traits:1017:12: required from ‘struct std::is_assignable<std::__shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >, __gnu_cxx::_S_atomic>&, std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > > >’
/usr/include/c++/9/bits/shared_ptr.h:111:8: required by substitution of ‘template<class _Tp> template<class _Arg> using _Assignable = typename std::enable_if<std::is_assignable<std::__shared_ptr<_Tp>&, _Arg>::value, std::shared_ptr<_Tp>&>::type [with _Arg = std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
/usr/include/c++/9/bits/shared_ptr.h:341:2: required by substitution of ‘template<class _Yp> std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::_Assignable<std::shared_ptr<_Tp> > std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::operator=<_Yp>(std::shared_ptr<_Tp>&&) [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: required from here
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:111:8: error: ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const _Tp>)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’ cannot be overloaded with ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
111 | void set(CallbackT callback)
| ^~~
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:83:8: note: previous declaration ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
83 | void set(CallbackT callback)
| ^~~
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:125:8: error: ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>, const rclcpp::MessageInfo&)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const _Tp>, const rclcpp::MessageInfo&)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’ cannot be overloaded with ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>, const rclcpp::MessageInfo&)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>, const rclcpp::MessageInfo&)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
125 | void set(CallbackT callback)
| ^~~
/opt/ros/foxy/include/rclcpp/any_subscription_callback.hpp:97:8: note: previous declaration ‘template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<const std_msgs::msg::String_<std::allocator<void> >&>, const rclcpp::MessageInfo&)> >::value, void>::type* <anonymous> > void rclcpp::AnySubscriptionCallback<MessageT, Alloc>::set(CallbackT) [with CallbackT = CallbackT; typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<_Tp>, const rclcpp::MessageInfo&)> >::value>::type* <anonymous> = <enumerator>; MessageT = const std_msgs::msg::String_<std::allocator<void> >&; Alloc = std::allocator<void>]’
97 | void set(CallbackT callback)
| ^~~
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp: In constructor ‘MinimalSubscriberWithTopicStatistics::MinimalSubscriberWithTopicStatistics()’:
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: error: no match for ‘operator=’ (operand types are ‘rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >::SharedPtr’ aka ‘std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >’ and ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’)
44 | "topic", 10, callback, options);
| ^
In file included from /usr/include/c++/9/memory:81,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:16:
/usr/include/c++/9/bits/shared_ptr.h:309:19: note: candidate: ‘std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Tp>&) [with _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
309 | shared_ptr& operator=(const shared_ptr&) noexcept = default;
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:309:29: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ to ‘const std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >&’
309 | shared_ptr& operator=(const shared_ptr&) noexcept = default;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:313:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::_Assignable<const std::shared_ptr<_Yp>&> std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Yp>&) [with _Yp = _Yp; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
313 | operator=(const shared_ptr<_Yp>& __r) noexcept
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:313:2: note: template argument deduction/substitution failed:
/usr/include/c++/9/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class _Arg> using _Assignable = typename std::enable_if<std::is_assignable<std::__shared_ptr<_Tp>&, _Arg>::value, std::shared_ptr<_Tp>&>::type [with _Arg = const std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >&; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’:
/usr/include/c++/9/bits/shared_ptr.h:313:2: required by substitution of ‘template<class _Yp> std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::_Assignable<const std::shared_ptr<_Tp>&> std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >::operator=<_Yp>(const std::shared_ptr<_Tp>&) [with _Yp = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: required from here
/usr/include/c++/9/bits/shared_ptr.h:111:8: error: no type named ‘type’ in ‘struct std::enable_if<false, std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >&>’
111 | using _Assignable = typename enable_if<
| ^~~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:324:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::_Assignable<std::auto_ptr<_Up> > std::shared_ptr<_Tp>::operator=(std::auto_ptr<_Up>&&) [with _Yp = _Yp; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
324 | operator=(auto_ptr<_Yp>&& __r)
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:324:2: note: template argument deduction/substitution failed:
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: note: ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ is not derived from ‘std::auto_ptr<_Up>’
44 | "topic", 10, callback, options);
| ^
In file included from /usr/include/c++/9/memory:81,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:16:
/usr/include/c++/9/bits/shared_ptr.h:333:7: note: candidate: ‘std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Tp>&&) [with _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
333 | operator=(shared_ptr&& __r) noexcept
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:333:30: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ to ‘std::shared_ptr<rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > > >&&’
333 | operator=(shared_ptr&& __r) noexcept
| ~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/shared_ptr.h:341:2: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::_Assignable<std::shared_ptr<_Yp> > std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Yp>&&) [with _Yp = _Yp; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
341 | operator=(shared_ptr<_Yp>&& __r) noexcept
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:341:2: note: substitution of deduced template arguments resulted in errors seen above
/usr/include/c++/9/bits/shared_ptr.h:349:2: note: candidate: ‘template<class _Yp, class _Del> std::shared_ptr<_Tp>::_Assignable<std::unique_ptr<_Up, _Ep> > std::shared_ptr<_Tp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Yp = _Yp; _Del = _Del; _Tp = rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> > >]’
349 | operator=(unique_ptr<_Yp, _Del>&& __r)
| ^~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:349:2: note: template argument deduction/substitution failed:
/home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function_with_topic_statistics.cpp:44:37: note: ‘std::shared_ptr<rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > > >’ is not derived from ‘std::unique_ptr<_Tp, _Dp>’
44 | "topic", 10, callback, options);
| ^
In file included from /opt/ros/foxy/include/rclcpp/node_interfaces/node_topics_interface.hpp:32,
from /opt/ros/foxy/include/rclcpp/node.hpp:55,
from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
from /home/ros/RobCode/exam_ros2/src/examples-master/rclcpp/topics/minimal_subscriber/member_function.cpp:18:
/opt/ros/foxy/include/rclcpp/subscription_factory.hpp: In instantiation of ‘rclcpp::SubscriptionFactory rclcpp::create_subscription_factory(CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr, std::shared_ptr<rclcpp::topic_statistics::SubscriptionTopicStatistics<CallbackMessageT> >) [with MessageT = std_msgs::msg::String_<std::allocator<void> >; CallbackT = std::_Bind<void (MinimalSubscriber::*(MinimalSubscriber*, std::_Placeholder<1>))(const std_msgs::msg::String_<std::allocator<void> >&) const>; AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> >; typename MessageMemoryStrategyT::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’:
/opt/ros/foxy/include/rclcpp/create_subscription.hpp:144: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 = std_msgs::msg::String_<std::allocator<void> >; CallbackT = std::_Bind<void (MinimalSubscriber::*(MinimalSubscriber*, std::_Placeholder<1>))(const std_msgs::msg::String_<std::allocator<void> >&) const>; AllocatorT = std::allocator<void>; CallbackMessageT = const std_msgs::msg::String_<std::allocator<void> >&; SubscriptionT = rclcpp::Subscription<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void>, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std_msgs::msg::String_<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<const std_msgs::msg::String_<std::allocator<void> >&, std::allocator<void> > >]’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:98:47: required from ‘std::shared_ptr<SubscriptionT>以上是关于关于“ROS2 Topic-Statistics-Tutorial编译出错”的思考2的主要内容,如果未能解决你的问题,请参考以下文章