版本不对应后续可能会出现问题,本人就是在ceres版本较高的情况下运行vins-fusion时右边无轨迹显示,经过漫长的检查后才发现是版本不对应
链接: Ceres Solver
找到 cv_bridge 配置文件所在位置
cd /opt/ros/noetic/share/cv_bridge/cmake
sudo gedit cv_bridgeConfig.cmake
找到文件位置大概在94行左右,修改为以下代码:
if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
set(cv_bridge_INCLUDE_DIRS "")
set(_include_dirs "include;/usr/include;/usr/local/include/opencv")
找到文件大概在119行的位置
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")
修改代码为(注意:下面代码只针对opencv3.4.15,且没有修改安装位置):
set(libraries "cv_bridge;/usr/local/lib/libopencv_calib3d.so;/usr/local/lib/libopencv_calib3d.so.3.4;/usr/local/lib/libopencv_calib3d.so.3.4.15;/usr/local/lib/libopencv_ccalib.so;/usr/local/lib/libopencv_ccalib.so.3.4;/usr/local/lib/libopencv_ccalib.so.3.4.15;/usr/local/lib/libopencv_core.so;/usr/local/lib/libopencv_core.so.3.4;/usr/local/lib/libopencv_core.so.3.4.15;/usr/local/lib/libopencv_datasets.so;/usr/local/lib/libopencv_datasets.so.3.4;/usr/local/lib/libopencv_datasets.so.3.4.15;/usr/local/lib/libopencv_dnn.so;/usr/local/lib/libopencv_dnn.so.3.4;/usr/local/lib/libopencv_dnn.so.3.4.15;/usr/local/lib/libopencv_dnn_objdetect.so;/usr/local/lib/libopencv_dnn_objdetect.so.3.4;/usr/local/lib/libopencv_dnn_objdetect.so.3.4.15;/usr/local/lib/libopencv_dpm.so;/usr/local/lib/libopencv_dpm.so.3.4;/usr/local/lib/libopencv_dpm.so.3.4.15;/usr/local/lib/libopencv_face.so;/usr/local/lib/libopencv_face.so.3.4;/usr/local/lib/libopencv_face.so.3.4.15;/usr/local/lib/libopencv_features2d.so;/usr/local/lib/libopencv_features2d.so.3.4;/usr/local/lib/libopencv_features2d.so.3.4.15;/usr/local/lib/libopencv_flann.so;/usr/local/lib/libopencv_flann.so.3.4;/usr/local/lib/libopencv_flann.so.3.4.15;/usr/local/lib/libopencv_freetype.so;/usr/local/lib/libopencv_freetype.so.3.4;/usr/local/lib/libopencv_freetype.so.3.4.15;/usr/local/lib/libopencv_fuzzy.so;/usr/local/lib/libopencv_fuzzy.so.3.4;/usr/local/lib/libopencv_fuzzy.so.3.4.15;/usr/local/lib/libopencv_hfs.so;/usr/local/lib/libopencv_hfs.so.3.4;/usr/local/lib/libopencv_hfs.so.3.4.15;/usr/local/lib/libopencv_highgui.so;/usr/local/lib/libopencv_highgui.so.3.4;/usr/local/lib/libopencv_highgui.so.3.4.15;/usr/local/lib/libopencv_img_hash.so;/usr/local/lib/libopencv_img_hash.so.3.4;/usr/local/lib/libopencv_img_hash.so.3.4.15;/usr/local/lib/libopencv_imgcodecs.so;/usr/local/lib/libopencv_imgcodecs.so.3.4;/usr/local/lib/libopencv_imgcodecs.so.3.4.15;/usr/local/lib/libopencv_imgproc.so;/usr/local/lib/libopencv_imgproc.so.3.4;/usr/local/lib/libopencv_imgproc.so.3.4.15;/usr/local/lib/libopencv_line_descriptor.so;/usr/local/lib/libopencv_line_descriptor.so.3.4;/usr/local/lib/libopencv_line_descriptor.so.3.4.15;/usr/local/lib/libopencv_ml.so;/usr/local/lib/libopencv_ml.so.3.4;/usr/local/lib/libopencv_ml.so.3.4.15;/usr/local/lib/libopencv_objdetect.so;/usr/local/lib/libopencv_objdetect.so.3.4;/usr/local/lib/libopencv_objdetect.so.3.4.15;/usr/local/lib/libopencv_optflow.so;/usr/local/lib/libopencv_optflow.so.3.4;/usr/local/lib/libopencv_optflow.so.3.4.15;/usr/local/lib/libopencv_phase_unwrapping.so;/usr/local/lib/libopencv_phase_unwrapping.so.3.4;/usr/local/lib/libopencv_phase_unwrapping.so.3.4.15;/usr/local/lib/libopencv_photo.so;/usr/local/lib/libopencv_photo.so.3.4;/usr/local/lib/libopencv_photo.so.3.4.15;/usr/local/lib/libopencv_plot.so;/usr/local/lib/libopencv_plot.so.3.4;/usr/local/lib/libopencv_plot.so.3.4.15;/usr/local/lib/libopencv_reg.so;/usr/local/lib/libopencv_reg.so.3.4;/usr/local/lib/libopencv_reg.so.3.4.15;/usr/local/lib/libopencv_rgbd.so;/usr/local/lib/libopencv_rgbd.so.3.4;/usr/local/lib/libopencv_rgbd.so.3.4.15;/usr/local/lib/libopencv_saliency.so;/usr/local/lib/libopencv_saliency.so.3.4;/usr/local/lib/libopencv_saliency.so.3.4.15;/usr/local/lib/libopencv_shape.so;/usr/local/lib/libopencv_shape.so.3.4;/usr/local/lib/libopencv_shape.so.3.4.15;/usr/local/lib/libopencv_stereo.so;/usr/local/lib/libopencv_stereo.so.3.4;/usr/local/lib/libopencv_stereo.so.3.4.15;/usr/local/lib/libopencv_stitching.so;/usr/local/lib/libopencv_stitching.so.3.4;/usr/local/lib/libopencv_stitching.so.3.4.15;/usr/local/lib/libopencv_structured_light.so;/usr/local/lib/libopencv_structured_light.so.3.4;/usr/local/lib/libopencv_structured_light.so.3.4.15;/usr/local/lib/libopencv_superres.so;/usr/local/lib/libopencv_superres.so.3.4;/usr/local/lib/libopencv_superres.so.3.4.15;/usr/local/lib/libopencv_surface_matching.so;/usr/local/lib/libopencv_surface_matching.so.3.4;/usr/local/lib/libopencv_surface_matching.so.3.4.15;/usr/local/lib/libopencv_text.so;/usr/local/lib/libopencv_text.so.3.4;/usr/local/lib/libopencv_text.so.3.4.15;/usr/local/lib/libopencv_tracking.so;/usr/local/lib/libopencv_tracking.so.3.4;/usr/local/lib/libopencv_tracking.so.3.4.15;/usr/local/lib/libopencv_video.so;/usr/local/lib/libopencv_video.so.3.4;/usr/local/lib/libopencv_video.so.3.4.15;/usr/local/lib/libopencv_videoio.so;/usr/local/lib/libopencv_videoio.so.3.4;/usr/local/lib/libopencv_videoio.so.3.4.15;/usr/local/lib/libopencv_videostab.so;/usr/local/lib/libopencv_videostab.so.3.4;/usr/local/lib/libopencv_videostab.so.3.4.15;/usr/local/lib/libopencv_xfeatures2d.so;/usr/local/lib/libopencv_xfeatures2d.so.3.4;/usr/local/lib/libopencv_xfeatures2d.so.3.4.15;/usr/local/lib/libopencv_ximgproc.so;/usr/local/lib/libopencv_ximgproc.so.3.4;/usr/local/lib/libopencv_ximgproc.so.3.4.15;/usr/local/lib/libopencv_xobjdetect.so;/usr/local/lib/libopencv_xobjdetect.so.3.4;/usr/local/lib/libopencv_xobjdetect.so.3.4.15;/usr/local/lib/libopencv_xphoto.so;/usr/local/lib/libopencv_xphoto.so.3.4;/usr/local/lib/libopencv_xphoto.so.3.4.15")
完成后重新编译vins-fusion如果是其他版本,可以参考以下链接:
vins-fusion环境配置、安装与测试
利用上述版本安装vins-fusion后同样可以安装Vins-mono
首先,VIM-Fusion的Sophus库要求eigen库的最低版本为3.3.3,查看电脑的eigen库版本:
gedit /usr/include/eigen3/Eigen/src/Core/util/Macros.h
可以看到下图所示,表示该版本为3.7.7
而用其他命令则看到eigen版本为3.2.9
pkg-config --modversion eigen3
这是因为我自己编译的版本为eigen3.2.9,而ros自带的版本为3.7.7,在编译安装viw-fusion时需要3.3.0以上版本,因此可以手动改变高版本的eigen进行编译
新建文件夹编译Sophus
git clone https://github.com/strasdat/Sophus.git
cd Sophus && git checkout a0fe89a323e20c42d3cecb590937eb7a06b8343a
对cCmakelist.txt文件进行修改,使Sophus能够通过eigen3.3.7版本进行编译,根据自己eigen库的文件位置和版本进行修改,我修改的代码为:
find_package(Eigen3 3.3.7 REQUIRED PATHS /usr/include)
如果报错:fatal error: fmt/format.h: 没有那个文件或目录
sudo apt-get install -y libfmt-dev
mkdir build && cd ./build
cmake ..
make
sudo make install
新建CMakeLists.txt文件,添加链接库的代码
cmake_minimum_required(VERSION 2.8)
project(useSophus)
# 为使用 sophus,需要使用find_package命令找到它
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
# Eigen
include_directories("/usr/include/eigen3")
# //include_directories("/usr/local/include/eigen3")
add_executable(useSophus useSophus.cpp)
target_link_libraries(useSophus ${Sophus_LIBRARIES} fmt)
新建useSophus.cpp
#include <iostream>
#include <cmath>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "sophus/se3.hpp"
using namespace std;
using namespace Eigen;
/// 只是导入头文件看看能不能成
int main()
{
}
执行命令看看哪个eigen库和Sophus相对应的
错误则会报错:error: ‘ScalarBinaryOpTraits’ in namespace ‘Eigen’ does not name a template type
正确对应则编译成功:
首先,下载源码:
cd ~/catkin_ws/src
git clone https://github.com/TouchDeeper/VIW-Fusion.git
cd ../
catkin_make
如果报错error: ‘ScalarBinaryOpTraits’ in namespace ‘Eigen’ does not name a template type说明系统里的eigen依旧没有选择3.3.7版本,由于本人刚接触Linux系统和slam算法不久,在修改了很多次CmakeLists文件依旧报错后,选择了一个较为拙劣的方法,即将usr/include文件夹下的eigen3文件复制到usr/local/include文件夹下并将原来的eigen3重命名,以后在工程中如果遇到所需版本在将两个文件重新命名
可以用命令查看这两个eigen的版本
gedit eigen3/Eigen/src/Core/util/Macros.h
//gedit eigen33/Eigen/src/Core/util/Macros.h
编译VIW-Fusion编译成功后
source devel/setup.bash