ros2节点编译失败

刚开始使用ros2,编译一个节点,怎么改都不能通过。报错如下
ATMK-176 12:25:47
/usr/include/c++/9/bits/stl_algo.h:120:14: required from ‘_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::GuardCondition, std::vector<std::weak_ptrrclcpp::GuardCondition > >; _Predicate = __gnu_cxx::__ops::_Iter_pred<rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)> >]’
/usr/include/c++/9/bits/stl_algo.h:161:23: required from ‘_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::GuardCondition
, std::vector<std::weak_ptrrclcpp::GuardCondition > >; _Predicate = __gnu_cxx::__ops::_Iter_pred<rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)> >]’
/usr/include/c++/9/bits/stl_algo.h:3969:28: required from ‘_IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::GuardCondition, std::vector<std::weak_ptrrclcpp::GuardCondition > >; _Predicate = rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)>]’
/usr/include/c++/9/bits/stl_algo.h:526:47: required from ‘bool std::none_of(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::GuardCondition
, std::vector<std::weak_ptrrclcpp::GuardCondition > >; _Predicate = rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)>]’
/usr/include/c++/9/bits/stl_algo.h:544:27: required from ‘bool std::any_of(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::GuardCondition, std::vector<std::weak_ptrrclcpp::GuardCondition > >; _Predicate = rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)>]’
/opt/ros/foxy/include/rclcpp/wait_set_policies/dynamic_storage.hpp:223:23: required from ‘static bool rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]’
/opt/ros/foxy/include/rclcpp/wait_set_policies/dynamic_storage.hpp:265:69: required from here
/usr/include/c++/9/bits/predefined_ops.h:283:11: error: no match for call to ‘(rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)>) (const std::weak_ptrrclcpp::GuardCondition&)’
283 | { return bool(_M_pred(
__it)); }
| ^~~~~~~~~~~~~~~~~~~~
In file included from /opt/ros/foxy/include/rclcpp/wait_set.hpp:25,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:157,
from /home/xysk/ros2_ws/src/face_recognition/src/feature_match.cpp:1:
/opt/ros/foxy/include/rclcpp/wait_set_policies/dynamic_storage.hpp:226:7: note: candidate: ‘rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::GuardCondition; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::GuardCondition >]::<lambda(const int&)>’
226 | [&entity](const auto & inner) {return &entity == inner.lock().get();});
| ^
/opt/ros/foxy/include/rclcpp/wait_set_policies/dynamic_storage.hpp:226:7: note: no known conversion for argument 1 from ‘const std::weak_ptrrclcpp::GuardCondition’ to ‘const int&’
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
from /usr/include/c++/9/memory:62,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:144,
from /home/xysk/ros2_ws/src/face_recognition/src/feature_match.cpp:1:
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of ‘bool __gnu_cxx::__ops::_Iter_pred<_Predicate>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::TimerBase, std::vector<std::weak_ptrrclcpp::TimerBase > >; _Predicate = rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::TimerBase; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::TimerBase >]::<lambda(const int&)>]’:
/usr/include/c++/9/bits/stl_algo.h:120:14: required from ‘_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::TimerBase
, std::vector<std::weak_ptrrclcpp::TimerBase > >; _Predicate = __gnu_cxx::__ops::_Iter_pred<rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::TimerBase; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::TimerBase >]::<lambda(const int&)> >]’
/usr/include/c++/9/bits/stl_algo.h:161:23: required from ‘_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::TimerBase, std::vector<std::weak_ptrrclcpp::TimerBase > >; _Predicate = __gnu_cxx::__ops::_Iter_pred<rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::TimerBase; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::TimerBase >]::<lambda(const int&)> >]’
/usr/include/c++/9/bits/stl_algo.h:3969:28: required from ‘_IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const std::weak_ptrrclcpp::TimerBase
, std::vector<std::weak_ptrrclcpp::TimerBase > >; _Predicate = rclcpp::wait_set_policies::DynamicStorage::storage_has_entity(const EntityT&, const SequenceOfEntitiesT&) [with EntityT = rclcpp::TimerBase; SequenceOfEntitiesT = std::vector<std::weak_ptrrclcpp::TimerBase >]::<lambda(const int&)>]’
/usr/include/c++/9/bits/stl_algo.h:526:47: required from ‘bool std::none_of(_IIter, _IIter, _Predicate) [with _IIter = __gn

后来发现,把CMAKE_CXX_STANDARD从11改为14就可以了。
在ROS 2中,cmake_cxx_standard 通常设置为 C++14 或 C++17,具体取决于ROS 2的版本和你的项目需求。
ROS 2 Foxy Fitzroy 及之后的版本默认使用 C++17。
ROS 2 Eloquent Elusor 及之前的版本默认使用 C++14。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值