ubuntu18.04配置ros与ORB-SLAM2

1.配置ROS(melodic)

1.1 安装源

注意:尽量使用官方源,其他源有可能出问题

1 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

1.2 设置key

1 sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

1.3 安装ROS

1 sudo apt update
2 sudo apt install ros-melodic-desktop-full

1.4 环境设置

  • 配置环境变量,方便在任意 终端中使用 ROS
1 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
2 source ~/.bashrc

1.5 安装依赖

1 sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

1.6 初始化rosdep

1 sudo rosdep init
2 rosdep update

注意:1.6步应该会出现如下异常

1 ERROR: cannot download default sources list from:
2 https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
3 Website may be down.

解决办法

1 sudo pip install rosdepc
2 sudo rosdepc init
3 rosdepc update

2.Pangolin安装

2.1 从Pangolin0.6下载pangolin稳定版

2.2 配置

 1 # 安装依赖项
 2 sudo apt-get install libglew-dev
 3 sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
 4 sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev
 5 sudo apt-get install libpng-dev
 6 
 7 # 配置并编译
 8 cd Pangolin 
 9 mkdir build && cd build
10 cmake -DCPP11_NO_BOOST=1 ..
11 make -j
12 sudo make install
13 # 验证
14 cd examples/HelloPangolin
15 mkdir build && cd build
16 cmake ..
17 make
18 ./HelloPangolin

3.Opencv3.4.5安装

3.1源码下载地址:Opencv

3.2配置

 1 # 安装依赖项
 2 sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
 3 sudo apt update
 4 sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff5.dev libswscale-dev libjasper-dev 
 5 sudo apt install libcanberra-gtk-module libcanberra-gtk3-module 
 6 # 配置并编译
 7 mkdir build && cd build 
 8 cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
 9 make -j
10 sudo make install

4.Sophus库安装

4.1 安装fmt库

注意:不要使用git直接下载,必须下载8.1.1版本才可正常使用。下载地址:fmt

1 cd fmt
2 mkdir build
3 cd build
4 cmake ..
5 make
6 sudo make install

4.2 安装Sophus库

1 git clone https://github.com/strasdat/Sophus.git
2 cd Sophus/
3 mkdir build
4 cd build
5 cmake ..
6 make
7 sudo make install

5.ORB-SLAM2

注意:直接下载的源码肯定会遇到两个bug,先修改再编译

bug1

1

  • 解决办法
1 将 ORB_SLAM2/include/LoopClosing.h::47 处的
2 typedef map<KeyFrame *, g2o::Sim3, std::less<KeyFrame *>, Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3>>> KeyFrameAndPose;
3 改为
4 typedef map<KeyFrame *, g2o::Sim3, std::less<KeyFrame *>, Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3>>> KeyFrameAndPose;

bug2: ‘usleep’ was not declared in this scope

  • 解决办法
 1 在下面这些文件中添加头文件:#include<unistd.h>
 2 
 3 Examples/Monocular/mono_euroc.cc
 4 Examples/Monocular/mono_kitti.cc
 5 Examples/Monocular/mono_tum.cc
 6 Examples/RGB-D/rgbd_tum.cc
 7 Examples/Stereo/stereo_euroc.cc
 8 Examples/Stereo/stereo_kitti.cc
 9 src/LocalMapping.cc
10 src/LoopClosing.cc
11 src/System.cc
12 src/Tracking.cc
13 src/Viewer.cc

编译ORB-SLAM2

1 cd ORB_SLAM2
2 chmod +x build.sh
3 ./build.sh

6.pcl库安装

6.1 安装依赖项

 1 sudo apt-get update  
 2 sudo apt-get install git build-essential linux-libc-dev  
 3 sudo apt-get install cmake cmake-gui   
 4 sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev  
 5 sudo apt-get install mpi-default-dev openmpi-bin openmpi-common    
 6 sudo apt-get install libflann1.8 libflann-dev  
 7 sudo apt-get install libeigen3-dev  
 8 sudo apt-get install libboost-all-dev  
 9 sudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-dev  
10 sudo apt-get install libqhull* libgtest-dev  
11 sudo apt-get install freeglut3-dev pkg-config  
12 sudo apt-get install libxmu-dev libxi-dev   
13 sudo apt-get install mono-complete  
14 sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre 

6.2 下载pcl源码并编译

 1 git clone https://github.com/PointCloudLibrary/pcl.git  
 2 
 3 cd pcl
 4 mkdir release
 5 cd release
 6 cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \
 7       -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON \
 8       -DCMAKE_INSTALL_PREFIX=/usr ..
 9 make
10 sudo make install
posted @ 2022-07-13 09:41  Z-LIANG  阅读(544)  评论(0编辑  收藏  举报