18.04 SLAM环境配置

目录

第1讲——配置Ubuntu、mentohust、同步时间、搜狗输入法

第2讲——CMake、g++、git

第3讲——Eigen

第4讲——Sophus

第5讲——OpenCV、PCL、Pangolin

第6讲——Ceres、g2o、DBoW3

第13讲——octomap


第1讲——配置Ubuntu、mentohust、同步时间、搜狗输入法

#在 home/package 下面放置所有需要安装的库文件。

安装mentuhust

sudo dpkg -i mentohust_0.3.4-1_amd64.deb

#启动
sudo mentohust

#后台运行
sudo gedit /etc/mentohust.conf
将DaemonMod改为1,或2即可 

#退出认证
sudo mentohust -k

#修改密码
sudo mentohust -u Username -p Password -w

#配置
sudo gedit /etc/mentohust.conf

#若是安装并认证完锐捷之后ubuntu右上角的网络图标会消失,要重新显示网络图标,只需要执行如下命令:
sudo service network-manager restart

同步时间

sudo apt-get install ntpdate

sudo ntpdate time.windows.com

sudo hwclock --localtime --systohc

搜狗输入法

sudo dpkg -i sogoupinyin_2.2.0.0108_amd64.deb

sudo apt-get install -f

sudo dpkg -i sogoupinyin_2.2.0.0108_amd64.deb

reboot

第2讲——CMake、g++、git

最基本的c++编译环境,需要安装g++,直接apt-get(有可能已经安装了)

sudo apt-get install cmake

sudo apt-get install g++

sudo apt-get install git

第3讲——Eigen

安装g2o的时候需要Eigen支持

安装
sudo apt-get install libeigen3-dev

检查安装
pkg-config --cflags eigen3

卸载
sudo apt-get remove libeigen3-dev

第4讲——Sophus

Sophus的安装存在两个问题,一个是Sophus模板类和非模板类的区别,为了新手方便使用高博在十四讲中推荐的是非模板类的Sophus,需要将git到的Sophus回滚到a621ff版本;另一个就是由于编译器版本的不同,出现非模板类Sophus编译不过。

在ubuntu18.04/18.10下会遇到如下问题:

“unit_complex_.real() = 1.;   unit_complex_.imag() = 0. ;"的错误

解决方法:在编译之前需要打开 sophus/so2.cpp 文件中,

将
unit_complex_.real() = 1. ;
unit_complex_.imag() = 0. ;

改为
unit_complex_.real(1.) ;
unit_complex_.imag(0.) ;

Sophus只需要编译不需要安装。

git clone https://github.com/strasdat/Sophus.git
cd Sophus
git checkout a621ff
mkdir build
cd build
cmake ..
make -j12

第5讲——OpenCV、PCL、Pangolin

下边是18.04下的3.3.1安装方法:2系OpenCV需要从官网下载自己 解压 编译 安装

sudo apt-get install build-essential libgtk2.0-dev libvtk6-dev libjpeg-dev libopenexr-dev libtbb-dev
sudo apt-get install libtiff4-dev

mkdir build
cd build 
cmake -D CMAKE_BUILD_TYPE=Release \ -D OPENCV_EXTRA_MODULES_PATH=/home/melodic/package/opencv-3.3.1/opencv_contrib-3.3.1/modules/ \ -D CMAKE_INSTALL_PREFIX=/usr/local ..

make -j12
sudo make install

查看版本
pkg-config --modversion opencv

笔者之前先源码安装的opencv3.4,在发现apt-get安装的版本为3.2后,选择一样源码安装2.4版本,同时通过源码安装两个版本需要将两个版本安装在不同位置,具体步骤在另一篇博客中https://blog.csdn.net/qq_41814939/article/details/81625666,官网下载源码可能会有一些慢,这篇文章也贴上了一种解决方法。

先写上ubuntu18.04的不同。之前版本的ubuntu终端apt-get安装到的opencv是二系的,而在ubuntu18.04安装到的是3.2版本的,这一区别之前直接下载源码安装的三系,用到二系安装时才发现的不对。

apt-get安装opencv最新版本

sudo apt-get install libopencv-dev

遇到错误

/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1484:21: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope
         c->flags |= CODEC_FLAG_GLOBAL_HEADER;
                     ^~~~~~~~~~~~~~~~~~~~~~~~
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1484:21: note: suggested alternative: ‘AV_CODEC_FLAG_GLOBAL_HEADER’
         c->flags |= CODEC_FLAG_GLOBAL_HEADER;
                     ^~~~~~~~~~~~~~~~~~~~~~~~
                     AV_CODEC_FLAG_GLOBAL_HEADER
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘int icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)’:
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1512:30: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
     if (oc->oformat->flags & AVFMT_RAWPICTURE) {
                              ^~~~~~~~~~~~~~~~
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1512:30: note: suggested alternative: ‘AVFMT_NOFILE’
     if (oc->oformat->flags & AVFMT_RAWPICTURE) {
                              ^~~~~~~~~~~~~~~~
                              AVFMT_NOFILE
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘void CvVideoWriter_FFMPEG::close()’:
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1686:35: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
         if( (oc->oformat->flags & AVFMT_RAWPICTURE) == 0 )
                                   ^~~~~~~~~~~~~~~~
/home/z2/pkg/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1686:35: note: suggested alternative: ‘AVFMT_NOFILE’
         if( (oc->oformat->flags & AVFMT_RAWPICTURE) == 0 )
                                   ^~~~~~~~~~~~~~~~
                                   AVFMT_NOFILE

解决办法https://www.jianshu.com/p/da49a712410f

#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020

卸载OpenCV

cd /home/opencv/build
make uninstall//卸载掉配置路径中的文件
sudo rm -r build//删除build文件
//删除掉环境中有关的其余包
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*

cd /home/hy chmod a+x opencv//给opencv权限
rm -r opencv//如果删除还是有文件权限不够,可以继续给相应文件权限,
chomd a+x 文件名

PCL

Ubuntu16.04之后安装pcl可以直接apt-get

sudo apt-get install libpcl-dev pcl-tools

Pangolin

就是git下源码,编译安装

安装依赖项
sudo apt-get install libglew-dev  libboost-dev libboost-thread-dev libboost-filesystem-dev

git clone https://github.com/stevenlovegrove/Pangolin.git

cd Pangolin
mkdir build
cd build
cmake -DCPP11_NO_BOOST= 1 ..
make -j12
sudo make install

第6讲——Ceres、g2o、DBoW3

Ceres依赖谷歌的日志和测试工具

#18.04对应的libcxsparse3.1.2软件包是libcxsparse3
sudo apt-get install liblapack-dev libsuitesparse-dev libgflags-dev libgoogle-glog-dev libgtest-dev libcxsparse3

git clone https://github.com/ceres-solver/ceres-solver.git

cd ceres-solver
mkdir build
cd build
cmake ..
make -j12
sudo make install

g2o

安装g2o的时候需要Eigen支持

在ubuntu18.04安装g2o与在14.04下安装的主要区别在于qt,18.04默认安装 qt5,libqglviewer-dev 要换成libqglviewer-headers

sudo apt-get install libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-headers

git clone https://github.com/RainerKuemmerle/g2o

cd g2o
mkdir build
cd build
cmake ..
make -j12
sudo make install

编译完成之后需要安装(否则会报错)

sudo apt-get install libsuitesparse-dev

DBoW3

安装DBoW2的时候需要OpenCV支持
git clone https://github.com/rmsalinas/DBow3.git

cd DBow3
mkdir build
cd build
cmake ..
make -j12
sudo make install

第13讲——octomap

sudo apt-get install doxygen-latex doxygen-doc doxygen-gui graphviz libclang1-6.0

cd octomap
mkdir build
cd build
cmake ..
make -j12
sudo make install

安装完成之后

sudo apt-get install libqglviewer-headers

 

你可能感兴趣的:(SLAM,ubuntu)