ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

message_filters example code error

asked 2020-02-02 06:25:54 -0500

Teslarekt gravatar image

updated 2020-02-02 10:48:37 -0500

gvdhoorn gravatar image

I get a huge error when just trying to compile this example code (http://wiki.ros.org/message_filters#E...) at 4.2 Example C++.

I am on Ubuntu 16.04 and I use ROS Kinetic

using namespace sensor_msgs; using namespace message_filters;

void callback(const ImageConstPtr& image, const CameraInfoConstPtr& cam_info) { // Solve all of perception here... }

int main(int argc, char** argv) {
ros::init(argc, argv, "vision_node");

ros::NodeHandle nh;

message_filters::Subscriber<image> image_sub(nh, "image", 1);
message_filters::Subscriber<camerainfo> info_sub(nh, "camera_info", 1);
TimeSynchronizer<image, camerainfo=""> sync(image_sub, info_sub, 10);
sync.registerCallback(boost::bind(&callback, _1, _2));

ros::spin();

return 0; }

The error message is huge:

CMakeFiles/listener.dir/listener.cpp.o: In function `callback(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)':
listener.cpp:(.text+0x52): undefined reference to `cv_bridge::toCvCopy(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
listener.cpp:(.text+0x114): undefined reference to `cv::noArray()'
listener.cpp:(.text+0x167): undefined reference to `cv::minMaxLoc(cv::_InputArray const&, double*, double*, cv::Point_<int>*, cv::Point_<int>*, cv::_InputArray const&)'
listener.cpp:(.text+0x232): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
listener.cpp:(.text+0x284): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
listener.cpp:(.text+0x2ac): undefined reference to `cv::waitKey(int)'
CMakeFiles/listener.dir/listener.cpp.o: In function `main':
listener.cpp:(.text+0x7dc): undefined reference to `cv::namedWindow(cv::String const&, int)'
listener.cpp:(.text+0x7f0): undefined reference to `cv::startWindowThread()'
listener.cpp:(.text+0x818): undefined reference to `cv::destroyWindow(cv::String const&)'
CMakeFiles/listener.dir/listener.cpp.o: In function `cv::String::String(char const*)':
listener.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x54): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/listener.dir/listener.cpp.o: In function `cv::String::~String()':
listener.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/listener.dir/listener.cpp.o: In function `cv::Mat::~Mat()':
listener.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
CMakeFiles/listener.dir/listener.cpp.o: In function `cv::Mat::release()':
listener.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
CMakeFiles/listener.dir/listener.cpp.o: In function `message_filters::Synchronizer<message_filters::sync_policies::ExactTime<sensor_msgs::Image_<std::allocator<void> >, sensor_msgs::Image_<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()':
listener.cpp:(.text._ZN15message_filters12SynchronizerINS_13sync_policies9ExactTimeIN11sensor_msgs6Image_ISaIvEEES6_NS_8NullTypeES7_S7_S7_S7_S7_S7_EEE13disconnectAllEv[_ZN15message_filters12SynchronizerINS_13sync_policies9ExactTimeIN11sensor_msgs6Image_ISaIvEEES6_NS_8NullTypeES7_S7_S7_S7_S7_S7_EEE13disconnectAllEv]+0x43): undefined reference to `message_filters::Connection::disconnect()'
CMakeFiles/listener.dir/listener.cpp.o: In function `message_filters::Connection message_filters::Signal9<sensor_msgs::Image_<std::allocator<void> >, sensor_msgs::Image_<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<sensor_msgs::Image_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::Image_<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<sensor_msgs::Image_<std::allocator<void> > const> const& ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-02 10:47:26 -0500

gvdhoorn gravatar image

updated 2020-02-02 10:49:49 -0500

Did you actually copy-paste the code you show here from the wiki?

Because capitalisation seems off.

Compare:

message_filters::Subscriber<image> image_sub(nh, "image", 1);

as you show it, with:

message_filters::Subscriber<Image> image_sub(nh, "image", 1);

as it is on the wiki.

Note the difference: image vs Image.

Same with camerainfo vs CameraInfo.

These are important details, and that is most likely why things aren't compiling for you.


Edit: however, the error message you link to is a linker error, not a compilation problem. With the code you show, I would've expected a compilation error.

The error you show would be most likely caused by missing parts in your CMakeLists.txt.

edit flag offensive delete link more

Comments

Thank you for your answer. I don't know why the code I posted had Image and CameraInfo lowercase, but its actually uppercase in my code.

What could I be missing in my CMakeLists? I still have the problem..

Teslarekt gravatar image Teslarekt  ( 2020-02-14 02:53:14 -0500 )edit

Oh my god.. I forgot to add the package in my CMakeLists.txt and package.xml Thx for giving me the clue @gvdhoorn

Teslarekt gravatar image Teslarekt  ( 2020-02-14 03:25:42 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-02-02 06:25:54 -0500

Seen: 776 times

Last updated: Feb 14 '20