一键安装ROS,需要在属性里面给fishros.sh文件设置运行权限
wget http://fishros.com/install -O fishros sudo ./fishros
sudo apt install libgl1-mesa-dev sudo apt install libglew-dev sudo apt install libpython2.7-dev sudo apt install pkg-config sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols
下载地址:https://github.com/stevenlovegrove/Pangolin.git
最好安装0.5版本的:Release v0.5 · stevenlovegrove/Pangolin (github.com)
cd Pangolin mkdir build cd build cmake .. cmake --build . sudo make install
下载地址:Releases · libeigen / eigen · GitLab
mkdir build cd build cmake .. sudo make install sudo ln -s /usr/local/include/eigen3 /usr/include/eigen3
下载地址:https://github.com/opencv/opencv/releases/tag/3.2.0
mkdir build cd build cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. -DENABLE_PRECOMPILED_HEADERS=OFF //编译中遇到问题,把ippicv_linux_20151201.tgz替换到opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e文件下 之后再cmake一下 sudo make sudo make install //配置环境 sudo gedit /etc/ld.so.conf.d/opencv.conf 文末添加 /usr/local/lib sudo ldconfig sudo gedit /etc/bash.bashrc 文末添加 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH 配置生效 source /etc/bash.bashrc sudo updatedb
下载地址:https://www.boost.org/users/download/
tar -xvf boost_1_77_0.tar.gz cd ./boost_1_77_0 ./bootstrap.sh sudo ./b2 install
下载地址:UZ-SLAMLab/ORB_SLAM3: ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM (github.com)
确保这些都安装上
sudo apt install libboost-filesystem-dev sudo apt-get install libssl-dev sudo apt install libboost-all-dev
把ORB_SLAM3/Examples/Monocular中的mono_euroc.cc中第83行的函数第四个参数中的false改为true
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR, true);
把ORB_SLAM3文件夹下的CMakeLists.txt中opencv和eigen的版本换一下,Thirdparty/g2o中也有一个CMakeLists一同修改
把CMakeLists.txt中-Wall后面加一个-w,添加c++14的编译选择
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -w -O3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -w -O3") add_compile_options(-std=c++14) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=native") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
报错:c++: internal compiler ereor: killed(program cciplus)
添加一个交换空间,我之前加的4G的好像还是运行错误,直接加了8G
sudo swapoff -a sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 sudo mkswap /swapfile sudo swapon /swapfile 最后启动的时候可能会遇到错误:swapon: /swapfile: insecure permissions 0644, 0600 suggested. sudo chmod -R 600 swapfile //关闭删除交换空间 sudo swapoff /swapfile sudo rm /swapfile
在编译ROS——ORB_SLAM3时,需要改一些代码
找到ORB_SLAM3/Examples_old/ROS/ORB_SLAM3/src/AR下的ros_mono_ar.cc文件:
把
cv::Mat Tcw = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
改为
cv::Mat Tcw; Sophus::SE3f Tcw_SE3f = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec()); Eigen::Matrix4f Tcw_Matrix = Tcw_SE3f.matrix(); cv::eigen2cv(Tcw_Matrix, Tcw);
找到ORB_SLAM3/Examples_old/ROS/ORB_SLAM3/src/AR下的ViewerAR.cc文件
把
vPoints.push_back(pMP->GetWorldPos());
改为
cv::Mat WorldPos; cv::eigen2cv(pMP->GetWorldPos(), WorldPos); vPoints.push_back(WorldPos);
把
cv::Mat Xw = pMP->GetWorldPos();
改为
cv::Mat Xw; cv::eigen2cv(pMP->GetWorldPos(), Xw);
cd Thirdparty/DBoW2 mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j cd ../../g2o mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j cd ../../Sophus mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j cd ../../../ cd Vocabulary tar -xf ORBvoc.txt.tar.gz cd .. mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j4
下载:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets
下载Machine Hall 01数据
下载完解压到MH01文件夹,注意MH01文件夹下面是mav0
下载euroc_examples.sh脚本,放到Example文件夹下面
下载地址:ORB_SLAM3/euroc_examples.sh at master · yuantao15/ORB_SLAM3 (github.com)
将pathDatasetEuroc=后面放上MH01的上级文件夹,注意是相对路径
我的MH01的绝对路径是/home/orbslam3/workspace/ORB_SLAM3/Examples/Datasets/EuRoC/MH01
所以应该加上./Datasets/EuRoC
之后就可以运行了。
./euroc_examples.sh 或者 ./Monocular/mono_euroc ../Vocabulary/ORBvoc.txt ./Monocular/EuRoC.yaml ./Datasets/EuRoC/MH01 ./Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
把
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples_old/ROS
//path需要补全为绝对路径
加到~/.bashrc最后一行
sudo gedit ~/.bashrc
source ~/.bashrc
到ORB_SLAM3/Examples_old/ROS/ORB_SLAM3下的CMakeLists.txt,找到include_directories并添加 ${PROJECT_SOURCE_DIR}/…/…/…/Thirdparty/Sophus
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${PROJECT_SOURCE_DIR}/../../../include/CameraModels
${PROJECT_SOURCE_DIR}/../../../Thirdparty/Sophus
${Pangolin_INCLUDE_DIRS}
)
同时修改eigen和opencv的版本号
cd Examples/ROS/ORB_SLAM3
mkdir build
cd build
cmake .. -DROS_BUILD_TYPE=Release
make -j
下载:http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets
下载ROS bag数据集
roscore
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt Examples_old/Stereo/EuRoC.yaml true
rosbag play --pause MH_01_easy.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu
运行效果和上面的是一样的。
如果运行相机节点的话,需要修改asus.yaml中的相机内参配置,并且修改对应.cc文件中的订阅节点。还没实现,后面再来更新。
基于ubuntu18.04的ORB_SLAM3安装 (qq.com)
(22条消息) Ubuntu18.04安装Ros(最新最详细亲测)_向日葵骑士Faraday的博客-CSDN博客_ubuntu18.04安装ros
(22条消息) ubuntu18.04配置ORB-SLAM3(包含ROS)完整版教程_黄宏智的博客-CSDN博客_orbslam3 ros