讲真,建议用跟项目一样的环境去跑,不然真的很麻烦,各种问题.
相信大家看进来也不是看我瞎扯的,上点干货.
这里可以参考一下 https://blog.csdn.net/snnily/article/details/72991139
1 OpenCV ERROR
遇到这个问题其实就是OpenCV的版本问题. 如果你的本机是Ubuntu16.04, 那么很简单你只需要在本机安装OpenCV3, 然后找到各个包里面的CMakeLists.txt, 将find_package(OpenCV REQUIRED)修改为find_package(OpenCV XXX REQUIRED), XXX是你的OpenCV版本号,一定要是OpenCV3(ubuntu14也要改).下面说说我的情况:
我的系统是Ubuntu14的所以就很麻烦,因为对应的ros-indigo默认的是opencv2.4.8,而且系统里确实有自带的这个版本,但是VINS好像用的是OpenCV3, (幸好我平时用的是OpenCV3,要不然更麻烦).
重点来了,我们需要修改cv_bridge(如果没有,先安装)里默认配置的OpenCV版本为我们自己的OpenCV3.修改 /opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake
#set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_videostab.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_video.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_superres.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_stitching.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_photo.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_ocl.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_objdetect.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_ml.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_legacy.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_gpu.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_flann.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_features2d.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_contrib.so.2.4.8;/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.2.4.8")
set(libraries "cv_bridge;/usr/local/lib/libopencv_videostab.so.3.1.0;/usr/local/lib/libopencv_video.so.3.1.0;/usr/local/lib/libopencv_superres.so.3.1.0;/usr/local/lib/libopencv_stitching.so.3.1.0;/usr/local/lib/libopencv_photo.so.3.1.0;/usr/local/lib/libopencv_objdetect.so.3.1.0;/usr/local/lib/libopencv_ml.so.3.1.0;/usr/local/lib/libopencv_cudalegacy.so.3.1.0;/usr/local/lib/libopencv_imgproc.so.3.1.0;/usr/local/lib/libopencv_highgui.so.3.1.0;/usr/local/lib/libopencv_flann.so.3.1.0;/usr/local/lib/libopencv_features2d.so.3.1.0;/usr/local/lib/libopencv_core.so.3.1.0;/usr/local/lib/libopencv_calib3d.so.3.1.0")
上面注释掉的是原来的,下面的是我修改之后的.(有一些链接库是opencv3里面没有的所以直接去掉了)
还有一点就是我如果直接把原来的build文件夹和devel文件夹删掉重新catkin_make也是行不通. 保留原有的文件,在修改上面文件后,再执行一次catkin_make就可以运行了.(我这是莫名其妙的路数配置好的,希望路过的大神可以指导一下)