欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ros中message_filters编译问题

程序员文章站 2022-06-16 20:06:59
...

ros中message_filters编译问题

参考链接: link.
平台 ros melodic

问题描述

CMakeFiles/avoidance_sub.dir/src/avoidance_sub.cpp.o: In function message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime<geometry_msgs::Vector3Stamped_<std::allocator<void> >, geometry_msgs::Vector3Stamped_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType> >::disconnectAll()': avoidance_sub.cpp:(.text._ZN15message_filters12SynchronizerINS_13sync_policies15ApproximateTimeIN13geometry_msgs15Vector3Stamped_ISaIvEEES6_NS_8NullTypeES7_S7_S7_S7_S7_S7_EEE13disconnectAllEv[_ZN15message_filters12SynchronizerINS_13sync_policies15ApproximateTimeIN13geometry_msgs15Vector3Stamped_ISaIvEEES6_NS_8NullTypeES7_S7_S7_S7_S7_S7_EEE13disconnectAllEv]+0x43): undefined reference tomessage_filters::Connection::disconnect()’
CMakeFiles/avoidance_sub.dir/src/avoidance_sub.cpp.o: In function message_filters::Connection message_filters::Signal9<geometry_msgs::Vector3Stamped_<std::allocator<void> >, geometry_msgs::Vector3Stamped_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>::addCallback<boost::shared_ptr<geometry_msgs::Vector3Stamped_<std::allocator<void> > const> const&, boost::shared_ptr<geometry_msgs::Vector3Stamped_<std::allocator<void> > const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&>(boost::function<void (boost::shared_ptr<geometry_msgs::Vector3Stamped_<std::allocator<void> > const> const&, boost::shared_ptr<geometry_msgs::Vector3Stamped_<std::allocator<void> > const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&)> const&)': avoidance_sub.cpp:(.text._ZN15message_filters7Signal9IN13geometry_msgs15Vector3Stamped_ISaIvEEES4_NS_8NullTypeES5_S5_S5_S5_S5_S5_E11addCallbackIRKN5boost10shared_ptrIKS4_EESD_RKNS9_IKS5_EESH_SH_SH_SH_SH_SH_EENS_10ConnectionERKNS8_8functionIFvT_T0_T1_T2_T3_T4_T5_T6_T7_EEE[_ZN15message_filters7Signal9IN13geometry_msgs15Vector3Stamped_ISaIvEEES4_NS_8NullTypeES5_S5_S5_S5_S5_S5_E11addCallbackIRKN5boost10shared_ptrIKS4_EESD_RKNS9_IKS5_EESH_SH_SH_SH_SH_SH_EENS_10ConnectionERKNS8_8functionIFvT_T0_T1_T2_T3_T4_T5_T6_T7_EEE]+0x191): undefined reference tomessage_filters::Connection::Connection(boost::function<void ()> const&)’
CMakeFiles/avoidance_sub.dir/src/avoidance_sub.cpp.o: In function message_filters::Connection message_filters::SimpleFilter<geometry_msgs::Vector3Stamped_<std::allocator<void> > >::registerCallback<ros::MessageEvent<geometry_msgs::Vector3Stamped_<std::allocator<void> > const> const&>(boost::function<void (ros::MessageEvent<geometry_msgs::Vector3Stamped_<std::allocator<void> > const> const&)> const&)': avoidance_sub.cpp:(.text._ZN15message_filters12SimpleFilterIN13geometry_msgs15Vector3Stamped_ISaIvEEEE16registerCallbackIRKN3ros12MessageEventIKS4_EEEENS_10ConnectionERKN5boost8functionIFvT_EEE[_ZN15message_filters12SimpleFilterIN13geometry_msgs15Vector3Stamped_ISaIvEEEE16registerCallbackIRKN3ros12MessageEventIKS4_EEEENS_10ConnectionERKN5boost8functionIFvT_EEE]+0xba): undefined reference tomessage_filters::Connection::Connection(boost::function<void ()> const&)’
collect2: error: ld returned 1 exit status
avoidance/CMakeFiles/avoidance_sub.dir/build.make:113: recipe for target ‘/home/ljn/ROS/avoidance/catkin_ws/devel/lib/avoidance/avoidance_sub’ failed
make[2]: *** [/home/ljn/ROS/avoidance/catkin_ws/devel/lib/avoidance/avoidance_sub] Error 1
CMakeFiles/Makefile2:1592: recipe for target ‘avoidance/CMakeFiles/avoidance_sub.dir/all’ failed
make[1]: *** [avoidance/CMakeFiles/avoidance_sub.dir/all] Error 2
Makefile:140: recipe for target ‘all’ failed
make: *** [all] Error 2
Invoking “make -j4 -l4” failed

解决方法

在CMakeLists.txt中添加

find_package( catkin REQUIRED COMPONENTS
	 ...
	message_filters
)

在package.xml文件中添加相关依赖

find_package( catkin REQUIRED COMPONENTS
	<build_depend>message_filters</build_depend>
	<build_export_depend>message_filters</build_export_depend>
	<exec_depend>message_filters</exec_depend>
)