This is a framework of lidar mapping and localization with strong extensibility. Mapping and matching are separate parts of the framework. Mapping contains
data pretreat
,front end
,back end
,loop closing
andviewer
.Matching
contains data pretreat and map matching. The characteristic of this framework is that most of it’s modules can be replaced very easily with the help of polymorphism in c++. For example, you can replace ndt with icp in the front end, or replace g2o with gtsam in the back end without change code in the flow. Therefor, it is a good framework for research.
1.软件环境总成
1.1 ubuntu 18.04
1.2 ros melodic
1.3 VTK 8.2.0
1.4 PCL 1.9.1
1.5 Protobuf 3.14.0
1.6 boost 1.77.0
1.7 Qt creator 5.12.11
1.8 g2o
1.9 glog
1.10 geographiclib
1.11 glew
1.12 cmake-3.10
so on…
这是我个人的调试环境,也没在别的环境上测试过,所以前期可能会暴露不少问题,如果遇到,各位可以在对应的博客下面的评论区留言。
2. 项目地址
https://github.com/Little-Potato-1990/localization_in_auto_driving/tree/master/lidar_localization
3.具体安装
3.1 VTK-8.2.0
VTK下载地址
下载后进入build文件夹下:
cd build
cmake-gui
选择文件路径,并勾选Grouped和Advanced, 如果看不到红色部分的内容,可以先点击底下的configure按钮,就可以出现红色部分的内容(我之前遇到过)
- 配置勾选:
Module_vtkGUISupportQt
、VTK_Group_Qt
[本人需要利用QVTKWidget控件,所以勾选QT]
注意:(1) 当点击
configure
的时候,如果一切正常,则可发现红色部分全都变为了白色,若发现有部分红色内容,则将文件夹build
中内容删除后,重新点击configure
就ok了。
(2)点击generate
时,可能出现报错:CMAKE
中找不到Qt5X11Extras
解决方案:
sudo apt install libqt5x11extras5-dev
- 编译安装
终端输入:
sudo make -j8
这个编译过程比较漫长
最后输入:
sudo make install
安装结束
3.2 PCL-1.9.1(编译安装)
reference by https://blog.csdn.net/weixin_41281151/article/details/108917446
- STEP 1 :从github 下载pcl-1.9.1
git clone -b v1.9.1 https://github.com/PointCloudLibrary/pcl.git #可在官网上下载source.zip离线安装
可能需要安装
git
,sudo apt-get install git
就好
- STEP 2:安装相关依赖
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common
sudo apt-get install libflann1.8 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
#sudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-dev #选择合适的版本
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre
大约半个小时,耐心等待
可能需要安装cmake
cmake安装:可参考博文
- STEP 3 :安装可视化库依赖
安装OpenNI
,OpenNI2
sudo apt-get install libopenni-dev
sudo apt-get install libopenni2-dev
安装ensensor
下载后直接安装就好…
sudo dpkg -i ensenso-sdk-2.2.147-x64.deb
sudo dpkg -i codemeter_6.80.3312.500_amd64.deb
如果遇到安装错误可fix install
sudo apt -f install
- STEP 4 :编译安装
cd pcl
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_GPU=ON-DBUILD_apps=ON -DBUILD_examples=ON \ -DCMAKE_INSTALL_PREFIX=/usr ..
make -j8
sudo make install
安装结束…
3.3 Protobuf 3.14.0(C++版本)
reference by https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
-
下载源码
github下载对应版本源码:https://codeload.github.com/google/protobuf/zip/v3.14.0 -
To build protobuf from source, the following tools are needed:
autoconf
automake
libtool
make
g++
unzip
On Ubuntu/Debian, you can install them with:
sudo apt-get install autoconf automake libtool curl make g++ unzip
On other platforms, please use the corresponding package managing tool to install them before proceeding.
and rhen…
git clone https://github.com/protocolbuffers/protobuf.git #默认下载最新版本
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make -j8
make check
sudo make install
sudo ldconfig # refresh shared library cache
3.4 boost 1.77.0
具体步骤:
1.官网下载(www.boost.org)
2.解压并进入文件夹
3.使用命令./bootstrap.sh,可以通过加上–prefix help
4.使用命令./b2 install
tar -xzvf boost_1_77_0.tar.gz
sudo ./bootstrap.sh
sudo ./b2 install
执行完语句,这样头文件就被默认安装在/usr/local/include
头文件下,库文件就被默认安装在/usr/local/lib
下
3.5 Qt creator 5.12.11
- 1.QtCreator 安装
(1)下载Qt
下载地址: https://download.qt.io/archive/qt/
(2) 下载后的文件加执行权限
chmod +x qt-opensource-linux-x64-5.12.10.run
(3)双击运行或者终端
./qt-opensource-linux-x64-5.12.10.run
- 2.环境配置 + 其余编译组件安装
(1) 添加环境配置到~/.bashrc
或者/etc/profile
export QT_DEBUG_PLUGINS=1
export PATH="/home/userName/Qt5.12.10/Tools/QtCreator/bin:$PATH"
export PATH="/home/userName/Qt5.12.10/5.12.10/gcc_64:$PATH"
立即生效 sudo source ~/.bashrc
或者 sudo source /etc/profile
或重启生效
(2) 安装QtCreator运行和编译所需要的组件
sudo apt-get install gcc g++
sudo apt-get install cmake
sudo apt-get install make
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
sudo apt-get install libxcb-xinerama0
- 搭建完成之后出现问题解决
qt.qpa.plugin:Could not load the Qt platform plugin “xcb“
cd /home/userName/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/
ldd libqxcb.so
3.6 G2o
- 环境依赖
1.cmake
2.eigen3
3.suitesparse-dev
4.qtdeclarative5-dev
5.qt5-qmake
6.qglviewer-dev
注:建议eigen3
进行源码编译自行安装
执行如下命令进行依赖安装:
sudo apt-get install cmake libeigen3-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev
其中如果libqglviewer-dev
安装不了,可以不安装,只是个可视化工具而已。也可以改为libqglviewer-dev-qt5
进行安装。
- 编译安装
git clone https://github.com/RainerKuemmerle/g2o.git
cd g2o
mkdir build
cd build
cmake ..
make -j8
sudo make install
sudo ldconfig
3.7 glog
apt安装与卸载
//安装
sudo apt-get install libgoogle-glog-dev
//卸载
sudo apt-get remove libgoogle-glog-dev
3.8 Geographiclib
cd GeographicLib-1.51
mkdir build
cd build
cmake ..
make
sudo make install
4.测试数据
开源程序最好使用开放数据集,所以我们选择了KITTI
,并且把RawData里的2011_10_03_drive_0027_sync
做成了bag文件,后面所有程序的测试都是在这个bag基础上做的。
数据文件我放在了百度网盘里
地址:https://pan.baidu.com/s/1TyXbifoTHubu3zt4jZ90Wg
提取码: n9ys
我下载的是2011_10_03_drive_0027_sync.zip' 和
2011_10_03_calib.zip`,下载解压后的文件夹结构如下:
然后转换为bag包
cd DATASET_PATH
kitti2bag -t 2011_10_03 -r 0027 raw_synced
转换完成之后会得到kitti_2011_10_03_drive_0027_synced.bag
,文件大小约为28.5G
5.功能实现
- 建图:
roslaunch lidar_localization mapping.launch
rosbag play kitti_2011_10_03_drive_0027_synced.bag
when the saw mapping is over in rviz, run
rosservice call /optimize_map
then the full cloud map will display in rviz.
to save map to pcd file, run
rosservice call /save_map
then “map.pcd” and “filtered_map.pcd” will be saved in the directory “lidar_localization/slam_data/map”
- 匹配:
roslaunch lidar_localization matching.launch
rosbag play kitti_2011_10_03_drive_0027_synced.bag
6.总结
…