In Ubuntu 20 04 installing ros and running vins fusion encountered many problems and stepped on many pits. A summary is sent here. The installation of ROS Noetic, Ceres solver, eigen and other libraries is omitted. In git vins-fusion After direct compilation, there will be various errors, which is caused by the difference between the opencv4 header file and parameter name of noetic and opencv3 used by vins fusion. Two methods are used to solve this problem.
1. Modify vins fusion project header file and some parameters
The first step is to change these places in the code, which is summarized as follows
because ubuntu20.04 Supported Ros Noetic Bring your own opencv4 And vins-fusion Dependent on opencv3 conflict Make changes 1.camera_model In header file Chessboard.h add to #include <opencv2/imgproc/types_c.h> #include <opencv2/calib3d/balib3d_c.h> 2.CameraCalibration.h add to #include <opencv2/imgproc/types_c.h> #include <opencv2/imgproc/imgproc_c.h> 3.loop_fusion/src/VRIEF.h add to #include <opencv2/imgproc/types_c.h> 4.loop_fusion/src/pose_graph.cpp * modify CV_FONT_HERSHEY_SIMPLEX -> cv::FONT_HERSHEY_SIMPLEX 5. vins_estimator/src/feature_tracker.h add to #include <opencv2/highgui.hpp> #include <opencv2/cvconfig.h> #include <opencv2/imgproc/types_c.h> 6. vins_estimator/src/KITTIOdomTest.cpp KITTIGPSTest.cpp * modify CV_LOAD_IMAGE_GRAYSCALE -> cv::IMREAD_GRAYSCALE
After completing the above steps, you can preliminarily compile the vins fusion project, and it is successful. I encountered the problem of core dumped in the step of reading the sensor configuration, that is
#On one terminal, it works normally cd catkin_ws source ./devel/setup.bash roslaunch vins vins_rviz.launch //This step is normal #On the second terminal, there is a problem of Segmentation Fault (core dump) in this step, resulting in no data reading for visualization cd catkin_ws source ./devel/setup.bash rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml #On the third terminal, it works normally cd catkin_ws source ./devel/setup.bash rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag #This step is the same as the second step. The problem of Segmentation Fault (core dump) occurs (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
The reason for this problem is that opencv4 and opencv3 versions are different, which requires opencv3 to compile the project
Compile the project using the OPENCV version of non ROS Noetic
thank Link 1 Link 2 Link 3 This problem is solved by modifying cv_ The configuration of the bridge links the vins fusion project to the opencv3 library
First find cv_ Location of bridge configuration file
cd /opt/ros/noetic/share/cv_bridge/cmake sudo gedit cv_bridgeConfig.cmake
In line 90 or so, amend the following
take
if(NOT "include;/usr/include/opencv4 " STREQUAL " ") set(cv_bridge_INCLUDE_DIRS "") set(_include_dirs "include;/usr/include/opencv4")
Change to
if(NOT "include;(/usr/local/include/opencv2) " STREQUAL " " ) set(cv_brideg_INCLUDE_DIRS "") set(_include_dirs "include;(/usr/local/include/opencv2)") #() the bracket part is the installation path of your OPENCV3
After that, modify the specified library file to the opencv library file installed by yourself. This step needs to be added manually.
take
set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_dnn.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_features2d.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_flann.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_ml.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_objdetect.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_photo.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_stitching.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_video.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_videoio.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_aruco.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_bgsegm.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_bioinspired.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_ccalib.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_datasets.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_dnn_objdetect.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_dnn_superres.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_dpm.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_face.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_freetype.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_fuzzy.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_hdf.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_hfs.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_img_hash.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_line_descriptor.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_optflow.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_phase_unwrapping.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_plot.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_quality.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_reg.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_rgbd.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_saliency.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_shape.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_stereo.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_structured_light.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_superres.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_surface_matching.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_text.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_tracking.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_videostab.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_viz.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_ximgproc.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_xobjdetect.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_xphoto.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_core.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.4.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.4.2.0")
Instead, it's actually all the files beginning with libopencv in your / usr/local/lib / path. This is mine. You can copy it, ha ha.
set(libraries "cv_bridge;/usr/local/lib/libopencv_calib3d.so;/usr/local/lib/libopencv_features2d.so.3.4.16;/usr/local/lib/libopencv_imgproc.so.3.4;/usr/local/lib/libopencv_shape.so;/usr/local/lib/libopencv_videoio.so.3.4.16;/usr/local/lib/libopencv_calib3d.so.3.4;/usr/local/lib/libopencv_flann.so;/usr/local/lib/libopencv_imgproc.so.3.4.16;/usr/local/lib/libopencv_shape.so.3.4;/usr/local/lib/libopencv_video.so;/usr/local/lib/libopencv_calib3d.so.3.4.16;/usr/local/lib/libopencv_flann.so.3.4;/usr/local/lib/libopencv_ml.so;/usr/local/lib/libopencv_shape.so.3.4.16;/usr/local/lib/libopencv_video.so.3.4;/usr/local/lib/libopencv_core.so;/usr/local/lib/libopencv_flann.so.3.4.16;/usr/local/lib/libopencv_ml.so.3.4;/usr/local/lib/libopencv_stitching.so;/usr/local/lib/libopencv_video.so.3.4.16;/usr/local/lib/libopencv_core.so.3.4;/usr/local/lib/libopencv_highgui.so;/usr/local/lib/libopencv_ml.so.3.4.16;/usr/local/lib/libopencv_stitching.so.3.4;/usr/local/lib/libopencv_videostab.so;/usr/local/lib/libopencv_core.so.3.4.16;/usr/local/lib/libopencv_highgui.so.3.4;/usr/local/lib/libopencv_objdetect.so;/usr/local/lib/libopencv_stitching.so.3.4.16;/usr/local/lib/libopencv_videostab.so.3.4;/usr/local/lib/libopencv_dnn.so;/usr/local/lib/libopencv_highgui.so.3.4.16;/usr/local/lib/libopencv_objdetect.so.3.4;/usr/local/lib/libopencv_superres.so;/usr/local/lib/libopencv_videostab.so.3.4.16;/usr/local/lib/libopencv_dnn.so.3.4;/usr/local/lib/libopencv_imgcodecs.so;/usr/local/lib/libopencv_objdetect.so.3.4.16;/usr/local/lib/libopencv_superres.so.3.4;/usr/local/lib/libopencv_viz.so;/usr/local/lib/libopencv_dnn.so;/usr/local/lib/libopencv_dnn.so.3.4.16;/usr/local/lib/libopencv_imgcodecs.so.3.4;/usr/local/lib/libopencv_photo.so;/usr/local/lib/libopencv_superres.so.3.4.16;/usr/local/lib/libopencv_viz.so.3.4;/usr/local/lib/libopencv_features2d.so;/usr/local/lib/libopencv_imgcodecs.so.3.4.16;/usr/local/lib/libopencv_photo.so.3.4;/usr/local/lib/libopencv_videoio.so;/usr/local/lib/libopencv_viz.so.3.4.16")
After modification, vins fusion can run normally
2. Use Docker
The second method is to use docker , 20.04 is a good way to install docker. It should be noted that if you are a non root user, you should first add the user to the docker group, that is, sudo usermod -aG docker, your user name, and then restart (I tried to log out and then log in, but restart is OK). I changed the git link of Ceres solver in Dokcerfile from google to github, and then go outside to have a look, After that, vins fusion can also run normally.