赞
踩
ORB-SLAM3 GitHub 链接: Link
如果要重新安装以下第三方库,可以在之前运行 sudo make install 的目录(一般是 build 文件夹)下运行 sudo make uninstall
对其进行卸载。
在 ORB-SLAM3 的 CMakeLists.txt 中会有检查,如果不满足会有报错。
参考文档: Link
这里我选择安装的是 Pangolin v0.6,下载链接: Link
git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
./scripts/install_prerequisites.sh recommended
如果有报错:E: Unable to locate package catch2
,则
参考 issue: Link
参考文档: Link
git clone https://github.com/catchorg/Catch2.git
cd Catch2
cmake -B build -S . -DBUILD_TESTING=OFF
sudo cmake --build build/ --target install
unzip Pangolin-0.6.zip -d ~/3rdparty
cd ~/3rdparty/Pangolin-0.6
cmake -B build
cmake --build build # instead of ”make“
sudo cmake --install build # instead of ”sudo make install“
参考文档: Link
这里我选择安装的是 OpenCV 4.4.0 + OpenCV_Contrib 4.4.0
sudo apt update && sudo apt install -y cmake g++ wget unzip
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.4.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.4.0.zip
unzip opencv.zip -d ~/3rdparty
unzip opencv_contrib.zip -d ~/3rdparty
cd ~/3rdparty/opencv-4.4.0
mkdir build && cd build
# Configure
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules ..
# Build
cmake --build .
# Install
sudo cmake --install .
要使用 Eigen,只需下载并提取 Eigen 的源代码,Eigen 子目录中的头文件是使用 Eigen 编译程序所需的唯一文件。
这里我选择安装的是 Eigen 3.3.0,下载链接: Link
unzip eigen-3.3.0.zip -d ~/3rdparty
cd ~/3rdparty/eigen-3.3.0
cmake -B build
sudo cmake --install build
参考文档: Link
如果不安装 librealsense2,运行 ./build.sh
后不会生成 stereo_inertial_realsense_D435i
等与 RealSense 有关的可执行文件。
使用 D435i 相机,设备信息如下:
下面有两种安装方式: 编译源码进行安装和利用预编译包进行安装,二选一即可,我这里用的是编译源码的方式。
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
sudo apt-get install libssl-dev libusb-1.0-0-dev libudev-dev pkg-config libgtk-3-dev
sudo apt-get install git wget cmake build-essential
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at
unzip librealsense-master.zip -d ~/3rdparty
cd ~/3rdparty/librealsense-master
./scripts/setup_udev_rules.sh
uname -r
如果是 Ubuntu 20/22 (focal/jammy) with LTS kernel 5.13, 5.15
,则
./scripts/patch-realsense-ubuntu-lts-hwe.sh
如果是 Ubuntu 18/20 with LTS kernel (< 5.13)
,则
./scripts/patch-realsense-ubuntu-lts.sh
cd ~/3rdparty/librealsense-master
mkdir build && cd build
cmake ../ -DBUILD_EXAMPLES=true
sudo make uninstall && make clean && make && sudo make install
realsense-viewer
参考文档: Link
# Register the server's public key sudo mkdir -p /etc/apt/keyrings curl -sSf https://librealsense.intel.com/Debian/librealsense.pgp | sudo tee /etc/apt/keyrings/librealsense.pgp > /dev/null # Make sure apt HTTPS support is installed sudo apt-get install apt-transport-https # Add the server to the list of repositories echo "deb [signed-by=/etc/apt/keyrings/librealsense.pgp] https://librealsense.intel.com/Debian/apt-repo `lsb_release -cs` main" | \ sudo tee /etc/apt/sources.list.d/librealsense.list sudo apt-get update # Deploy librealsense2 udev rules, build and activate kernel modules, runtime library and executable demos and tools sudo apt-get install librealsense2-dkms sudo apt-get install librealsense2-utils # Install the developer and debug packages sudo apt-get install librealsense2-dev sudo apt-get install librealsense2-dbg
realsense-viewer
修改 CMakeLists.txt 文件,将 realsense_INCLUDE_DIR
改为 realsense2_INCLUDE_DIR
,如下图:
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
cd ORB_SLAM3
chmod +x build.sh
./build.sh
完成后,将会在 lib 文件夹中创建 libORB_SLAM3.so,并在 Examples 和 Examples_old 文件夹中创建可执行文件。
先校准相机,并写入校准文件 your_camera.yaml
,但我这里直接用现成的。
./Examples/Stereo-Inertial/stereo_inertial_realsense_D435i Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/RealSense_D435i.yaml
报错如下:
terminate called after throwing an instance of 'rs2::invalid_value_error'
what(): object doesn't support option #85
Aborted (core dumped)
解决方法:
参考 issue: Link
将 D435i 相关的 .cc
文件中这一行内容注释掉: RS2_OPTION_AUTO_EXPOSURE_LIMIT
,然后重新编译 ./build.sh
。
报错如下:
解决方法:
参考 issue: Link
将 System.cc
文件中这一行内容注释掉: cout << (*settings_) << endl
,然后重新编译 ./build.sh
。
ROS_PACKAGE_PATH
环境变量中gedit ~/.bashrc
# Replace PATH by the folder where you cloned ORB_SLAM3
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples_old/ROS
source ~/.bashrc
echo "Building ROS nodes"
cd Examples_old/ROS/ORB_SLAM3
mkdir build
cd build
cmake .. -DROS_BUILD_TYPE=Release
make -j
chmod +x build_ros.sh
./build_ros.sh
下面提到的 CMakeLists.txt 文件是 ORB_SLAM3/Examples_old/ROS/ORB_SLAM3/CMakeLists.txt
。
报错如下:
解决方法:
删掉 CMakeLists.txt 文件中 find_package(OpenCV 3.0 QUIET)
的指定版本。
报错如下:
解决方法:
在 CMakeLists.txt 文件中的 include_directories()
加入 ${PROJECT_SOURCE_DIR}/../../../Thirdparty/Sophus
。
报错如下:
/home/polaris/workspace/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3/src/AR/ViewerAR.cc:405:53: error: no matching function for call to ‘std::vector<cv::Mat>::push_back(Eigen::Vector3f)’
405 | vPoints.push_back(pMP->GetWorldPos());
/home/polaris/workspace/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3/src/AR/ViewerAR.cc:530:42: error: conversion from ‘Eigen::Vector3f’ {aka ‘Eigen::Matrix<float, 3, 1>’} to non-scalar type ‘cv::Mat’ requested
530 | cv::Mat Xw = pMP->GetWorldPos();
/home/polaris/workspace/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3/src/AR/ros_mono_ar.cc:151:41: error: conversion from ‘Sophus::SE3f’ {aka ‘Sophus::SE3<float>’} to non-scalar type ‘cv::Mat’ requested
151 | cv::Mat Tcw = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
解决方法:
参考 issue: Link
我用不到 AR 的相关函数,所以选择将 CMakeLists.txt 文件中 AR 相关的编译部分注释掉。
euroc_examples.sh
和 tum_vi_examples.sh
在历史提交中可以找到: Link.cc
文件的这一行,其中最后一个参数如果为 false,改为 true 即可ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR, false);
Stereo
为例,运行测试roscore
每个 .cc
文件都会对其生成的可执行文件的所需命令行参数进行说明,以 ros_stereo.cc
为例:
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt Examples_old/Stereo/EuRoC.yaml true
播放 bag 时要对话题名进行映射,所需的话题名在对应的 .cc
文件中可以找到,以 ros_stereo.cc
为例:
rosbag play --clock V1_03_difficult.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw
stereo_inertial
为例,运行测试在 stereo_inertial_tum_vi.cc
文件中可以找到,其生成的可执行文件所需的命令行参数,如下图:
./Examples/Stereo-Inertial/stereo_inertial_tum_vi Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/TUM-VI.yaml ~/Datasets/TUM-VI/dataset-corridor1_512_16/mav0/cam0/data ~/Datasets/TUM-VI/dataset-corridor1_512_16/mav0/cam1/data Examples/Stereo-Inertial/TUM_TimeStamps/dataset-corridor1_512.txt Examples/Stereo-Inertial/TUM_IMU/dataset-corridor1_512.txt dataset-corridor1_512_stereoi
结束后,如下图:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。