Ubuntu20.04下跑通ORB-SLAM2
ORB-SLAM2官方代码源在Ubuntu12.04、14.04、16.04上实测成功,后续版本涉及到兼容性问题会有出入。本篇适用于Ubuntu20.04,18.04、22.04亦可参考。修改后的完整代码可后台私信。
1 软件包兼容说明
1.1 编译器版本
ORB-SLAM2官方源码使用C++11,因版本迭代影响博主使用C14。注意ORB-SLAM2相关软件包Pangolin、g2o、DBoW2编译器使用一致。
1.1.1 g++
博主使用9.4.0版,支持C14版,故CMakeLists.txt中需定义使用C14版编译。
g++版本查询命令:
g++ --version
1.1.2 clang++
博主使用10.0.0版,版本查询命令如下:
clang++ --version
1.2 OpenCV
至少需要2.4.3版,3.X兼容性最好,博主使用3.4.16版,因Ubuntu20.04版下默认安装4.X版本,需重装。
1.2.1 版本确认指令
pkg-config --modversion opencv4
//或
pkg-config --modversion opencv
1.2.2 安装3.4.16版
sudo apt-get install cmake g++ wget unzip
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.16.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.16.zipunzip opencv.zip
unzip opencv_contrib.zip
cd opencv-3.4.16
mkdir build && cd buildcmake -D CMAKE_BUILD_TYPE=Release \-D CMAKE_INSTALL_PREFIX=/usr/local \-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.16/modules \..
make -j$(nproc)
sudo make install
pkg-config --modversion opencv //检查安装后的版本
ORB-SLAM2源码下载后找到CMakeLists.txt,搜索找到find_package(OpennCV)改为3
1.3 Pangloin
必须是Pangolin-0.5版。
1.3.1 安装依赖
sudo apt-get install libglew-dev cmake libpython3-dev python3-dev
sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev
sudo apt-get install libdc1394-22-dev libraw1394-dev
1.3.2 安装libepoxy包
sudo apt-get install libepoxy-dev
否则报错:
ch@ch-TUF-Gaming-FX505GT-FX95GT:~/Pangolin/build$ cmake .. -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Setting build type to 'Release' as none was specified. -- libpng Found and Enabled -- libjpeg Found and Enabled -- libtiff Found and Enabled -- libopenexr Found and Enabled -- liblz4 Found and Enabled -- libzstd Found and Enabled -- Found Eigen: '/usr/include/eigen3' -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so found components: OpenGL EGL CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):Could NOT find epoxy (missing: epoxy_LIBRARIES epoxy_INCLUDE_DIRS) Call Stack (most recent call first):/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)cmake/Findepoxy.cmake:63 (find_package_handle_standard_args)components/pango_opengl/CMakeLists.txt:50 (find_package)CMakeLists.txt:125 (include)-- Configuring incomplete, errors occurred! See also "/home/ch/Pangolin/build/CMakeFiles/CMakeOutput.log". See also "/home/ch/Pangolin/build/CMakeFiles/CMakeError.log".
1.3.3 安装Pangolin
(1)预处理-删除“werror”、“wno”字样语句
因OpenEXR版本太新(Ubuntu20.04默认使用2.5+)及CMakeLists.txt里面写了有警告即报错语句,会导致整体编译报错(报错代码如下)。需找到Pangolin包对应的CMakeLists.txt,删除“werror”、“wno”字样语句。
ch@ch-TUF-Gaming-FX505GT-FX95GT:~/Pangolin/build$ make -j$(nproc) Scanning dependencies of target pango_python Scanning dependencies of target tinyobj Scanning dependencies of target pango_core [ 1%] Building CXX object CMakeFiles/pango_python.dir/components/pango_core/src/dummy.cpp.o [ 1%] Building CXX object CMakeFiles/tinyobj.dir/components/tinyobj/src/tinyobj.cpp.o [ 2%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/sigstate.cpp.o [ 3%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/file_utils.cpp.o [ 3%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/file_extension.cpp.o [ 4%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/threadedfilebuf.cpp.o [ 4%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/avx_math.cpp.o [ 4%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/factory/factory_registry.cpp.o [ 5%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/factory/factory_help.cpp.o [ 6%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/uri.cpp.o [ 7%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/param_set.cpp.o [ 7%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/posix/condition_variable.cpp.o [ 7%] Linking CXX shared library libpango_python.so [ 8%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/posix/semaphore.cpp.o [ 8%] Built target pango_python [ 9%] Building CXX object CMakeFiles/pango_core.dir/components/pango_core/src/posix/shared_memory_buffer.cpp.o [ 10%] Linking CXX shared library libtinyobj.so [ 10%] Built target tinyobj [ 10%] Linking CXX shared library libpango_core.so [ 10%] Built target pango_core Scanning dependencies of target pango_vars Scanning dependencies of target pango_image Scanning dependencies of target pango_packetstream [ 11%] Building CXX object CMakeFiles/pango_vars.dir/components/pango_vars/src/varstate.cpp.o [ 11%] Building CXX object CMakeFiles/pango_packetstream.dir/components/pango_packetstream/src/packetstream.cpp.o [ 12%] Building CXX object CMakeFiles/pango_packetstream.dir/components/pango_packetstream/src/packetstream_reader.cpp.o [ 12%] Building CXX object CMakeFiles/pango_vars.dir/components/pango_vars/src/vars.cpp.o [ 13%] Building CXX object CMakeFiles/pango_packetstream.dir/components/pango_packetstream/src/packet.cpp.o [ 14%] Building CXX object CMakeFiles/pango_packetstream.dir/components/pango_packetstream/src/packetstream_writer.cpp.o [ 14%] Building CXX object CMakeFiles/pango_packetstream.dir/components/pango_packetstream/src/playback_session.cpp.o [ 15%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/pixel_format.cpp.o [ 16%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_exr.cpp.o [ 16%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_jpg.cpp.o [ 16%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io.cpp.o [ 17%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_lz4.cpp.o [ 18%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_packed12bit.cpp.o [ 18%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_pango.cpp.o In file included from /usr/include/OpenEXR/ImfXdr.h:108,from /usr/include/OpenEXR/ImfGenericOutputFile.h:40,from /usr/include/OpenEXR/ImfTiledOutputFile.h:50,from /usr/include/OpenEXR/ImfInputFile.h:48,from /home/ch/Pangolin/components/pango_image/src/image_io_exr.cpp:10: /usr/include/OpenEXR/half.h: In member function ‘half half::round(unsigned int) const’: /usr/include/OpenEXR/half.h:515:10: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]515 | return *this;| ^~~~ /usr/include/OpenEXR/half.h:121:13: note: because ‘half’ has user-provided ‘half& half::operator=(half)’121 | half & operator = (half h);| ^~~~~~~~ /usr/include/OpenEXR/half.h:558:12: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]558 | return h;| ^ /usr/include/OpenEXR/half.h:121:13: note: because ‘half’ has user-provided ‘half& half::operator=(half)’121 | half & operator = (half h);| ^~~~~~~~ /usr/include/OpenEXR/half.h: In member function ‘half half::operator-() const’: /usr/include/OpenEXR/half.h:571:12: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]571 | return h;| ^ /usr/include/OpenEXR/half.h:121:13: note: because ‘half’ has user-provided ‘half& half::operator=(half)’121 | half & operator = (half h);| ^~~~~~~~ /usr/include/OpenEXR/half.h: In static member function ‘static half half::posInf()’: /usr/include/OpenEXR/half.h:717:12: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]717 | return h;| ^ /usr/include/OpenEXR/half.h:576:1: note: because ‘half’ has user-provided ‘half& half::operator=(half)’576 | half::operator = (half h)| ^~~~ /usr/include/OpenEXR/half.h: In static member function ‘static half half::negInf()’: /usr/include/OpenEXR/half.h:726:12: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]726 | return h;| ^ /usr/include/OpenEXR/half.h:576:1: note: because ‘half’ has user-provided ‘half& half::operator=(half)’576 | half::operator = (half h)| ^~~~ /usr/include/OpenEXR/half.h: In static member function ‘static half half::qNan()’: /usr/include/OpenEXR/half.h:735:12: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]735 | return h;| ^ /usr/include/OpenEXR/half.h:576:1: note: because ‘half’ has user-provided ‘half& half::operator=(half)’576 | half::operator = (half h)| ^~~~ /usr/include/OpenEXR/half.h: In static member function ‘static half half::sNan()’: /usr/include/OpenEXR/half.h:744:12: error: implicitly-declared ‘constexpr half::half(const half&)’ is deprecated [-Werror=deprecated-copy]744 | return h;| ^ /usr/include/OpenEXR/half.h:576:1: note: because ‘half’ has user-provided ‘half& half::operator=(half)’576 | half::operator = (half h)| ^~~~ [ 19%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_png.cpp.o [ 19%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_ppm.cpp.o [ 20%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_raw.cpp.o [ 21%] Building CXX object CMakeFiles/pango_image.dir/components/pango_image/src/image_io_tga.cpp.o At global scope: cc1plus: error: unrecognized command line option ‘-Wno-deprecated-register’ [-Werror] cc1plus: error: unrecognized command line option ‘-Wno-null-pointer-subtraction’ [-Werror] cc1plus: error: unrecognized command line option ‘-Wno-null-pointer-arithmetic’ [-Werror] cc1plus: all warnings being treated as errors make[2]: *** [CMakeFiles/pango_image.dir/build.make:89:CMakeFiles/pango_image.dir/components/pango_image/src/image_io_exr.cpp.o] 错误 1 make[2]: *** 正在等待未完成的任务.... make[1]: *** [CMakeFiles/Makefile2:779:CMakeFiles/pango_image.dir/all] 错误 2 make[1]: *** 正在等待未完成的任务.... [ 22%] Linking CXX shared library libpango_vars.so [ 23%] Linking CXX shared library libpango_packetstream.so [ 23%] Built target pango_vars [ 23%] Built target pango_packetstream make: *** [Makefile:130:all] 错误 2
(2)预处理-禁用FFmpeg视频模块及共享内存
Pangolin v0.5 和新版 FFmpeg 存在兼容性问题,需在src/CMakeLists.txt中禁用相关模块,否则会出现如下报错。
/home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_XVMC_MPEG2_MC’ was not declared in this scope41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_XVMC_MPEG2_IDCT’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VAAPI_IDCT’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_VDPAU_H264’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VDPAU’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_VDPAU_MPEG1’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VDPAU’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_VDPAU_MPEG2’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VDPAU’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_VDPAU_WMV3’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VDPAU’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_VDPAU_VC1’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VDPAU’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: error: ‘AV_PIX_FMT_VDPAU_MPEG4’ was not declared in this scope; did you mean ‘AV_PIX_FMT_VDPAU’?41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| ^~~~~~~~~~~ /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:41:41: note: in definition of macro ‘TEST_PIX_FMT_RETURN’41 | # define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;| /home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:501:33: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope; did you mean ‘AV_CODEC_FLAG_GLOBAL_HEADER’?501 | stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;| ^~~~~~~~~~~~~~~~~~~~~~~~| AV_CODEC_FLAG_GLOBAL_HEADER/home/ch/Pangolin/src/video/drivers/ffmpeg.cpp:564:39: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope564 | if (recorder.oc->oformat->flags & AVFMT_RAWPICTURE) {| ^~~~~~~~~~~~~~~~
在Pangloin中找到src/CMakeLists.txt,加入如下命令:
if(BUILD_PANGOLIN_VIDEO AND _LINUX_)list(APPEND LINK_LIBS rt pthread) endif()
(3)安装
make过程中会出现许多警告,这是版本兼容性问题,可以忽略。
git clone https://github.com/stevenlovegrove/Pangolin.git cd Pangolin git checkout v0.5 mkdir build && cd build cmake .. -DBUILD_PANGOLIN_VIDEO=OFF //禁用FFmpeg视频模块 make -j$(nproc) sudo make install
1.4 Eigen
官方代码源适配版本最低为3.1.0,与ORB-SLAM2兼任较好版本为3.3.7、3.3.9,博主使用3.3.7版。
版本查询指令:
pkg-config --modversion eigen3
1.5 g2o
博主使用ORB-SLAM2源码中自带的版本,为2017年10月commit版的快照。
2 安装ORB-SLAM2
编译安装过程会出现较多版本问题的报错,需要反复耐心修复,博主列出了几种典型报错问题。
不出现报错情况下编译指令:
cd ORB_SLAM2 mkdir build cd build cmake .. make -j$(nproc)
2.1 td::chrono::monotonic_clock
不存在
2.1.1 报错
/home/ch/ORB_SLAM2/Examples/Stereo/stereo_euroc.cc:147:22: error: ‘std::chrono::monotonic_clock’ has not been declared147 | std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();| ^~~~~~~~~~~~~~~
2.1.2 修复
将monotonic_clock改成:steady_clock
2.2 usleep
2.2.1 报错
/home/ch/ORB_SLAM2/Examples/RGB-D/rgbd_tum.cc:118:13: error: ‘usleep’ was not declared in this scope118 | usleep((T-ttrack)*1e6);| ^~~~~~
2.2.2 修复
在头文件中加入:#include <unistd.h>
2.3 KeyFrameAndPose
2.3.1 报错
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
2.3.2 修复
将上面语句换成下面标准形式。
typedef std::map<KeyFrame*, g2o::Sim3> KeyFrameAndPose;
2.4 编译成功
编译过错出现的警告是因为
Eigen::AlignedBit
被弃用(deprecated),忽略。
3 测试
博主使用TUM的rgbd_dataset_freiburg1_xyz数据集进行复现。
3.1 下载数据集
mkdir -p ~/Datasets/TUM cd ~/Datasets/TUM wget http://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_xyz.tgz tar -xvzf rgbd_dataset_freiburg1_xyz.tgz
3.2 关联文件
关联 TUM 的
rgb.txt
和depth.txt,生成
associate_tum.py,放在ORB_SLAM2 根目录下面。#!/usr/bin/env python3import sys import osdef read_file_list(filename):""" reads file with lines: timestamp path """lines = []with open(filename, 'r') as f:for line in f:line = line.strip()if not line or line.startswith('#'):continueparts = line.split()if len(parts) < 2:continuets = float(parts[0])path = parts[1]lines.append((ts, path))return linesdef associate(rgb_list, depth_list, max_difference=0.02):""" For each rgb, find closest depth within max_difference """output = []depth_idx = 0nd = len(depth_list)for ts_rgb, rgb_path in rgb_list:# advance depth_idx until depth timestamp >= rgb timestamp - max_differencewhile depth_idx < nd and depth_list[depth_idx][0] < ts_rgb - max_difference:depth_idx += 1if depth_idx == nd:break# candidate 1: depth_idxbest = Nonebest_diff = float('inf')# check depth_idxts_d, dp = depth_list[depth_idx]diff = abs(ts_rgb - ts_d)if diff < best_diff:best = (ts_d, dp)best_diff = diff# also check previous oneif depth_idx > 0:ts_d2, dp2 = depth_list[depth_idx - 1]diff2 = abs(ts_rgb - ts_d2)if diff2 < best_diff:best = (ts_d2, dp2)best_diff = diff2# if best match is good enough, record itif best_diff <= max_difference:output.append((ts_rgb, rgb_path, best[0], best[1]))return outputdef main():if len(sys.argv) != 4:print("Usage: associate_tum.py rgb.txt depth.txt associate.txt")returnrgb_fn = sys.argv[1]depth_fn = sys.argv[2]out_fn = sys.argv[3]if not os.path.exists(rgb_fn):print("RGB file not found:", rgb_fn)returnif not os.path.exists(depth_fn):print("Depth file not found:", depth_fn)returnrgb_list = read_file_list(rgb_fn)depth_list = read_file_list(depth_fn)associations = associate(rgb_list, depth_list)with open(out_fn, 'w') as f:for ts_rgb, rgb_path, ts_d, dp in associations:f.write("{:.6f} {} {:.6f} {}\n".format(ts_rgb, rgb_path, ts_d, dp))print("Done. Wrote {} associations".format(len(associations)))if __name__ == "__main__":main()
3.3 修改g2o中CMakeLists.txt
在Thirdparty/g2o/CMakeLists.txt中添加语句:
# 强制在 g2o 编译时带上此宏,避免 Eigen 静态对齐问题 add_definitions(-DEIGEN_DONT_ALIGN_STATICALLY)
重新编译g2o包
3.4 重新编译ORB-SLAM2
cd ~/ORB_SLAM2 rm -rf build mkdir build cd build cmake .. make -j$(nproc)
3.5 运行
cd ~/ORB_SLAM2 ./Examples/RGB-D/rgbd_tum \Vocabulary/ORBvoc.txt \Examples/RGB-D/TUM1.yaml \~/Datasets/TUM/rgbd_dataset_freiburg1_xyz \~/Datasets/TUM/rgbd_dataset_freiburg1_xyz/associate.txt