ubuntu16.04已经安装了ros_kinetic
安装准备
sudo apt-get install vim
sudo apt-get install git
sudo apt-get install gcc g++
安装Pangolin v0.5
1)安装依赖
sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install libpython2.7-dev
2)安装Pangolin v0.5
git clone https://github.com/zzx2GH/Pangolin.git
//解压
cd Pangolin-0.5
mkdir build
cd build
cmake ..
sudo make install
源码安装OpenCV-3.4.5
(1)安装依赖
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libswscale-dev
sudo apt-get install libtiff4.dev libjasper-dev
opencv提取链接:百度网盘 pan.baidu.com/s/1XFsJMEgD… 提取码slam
解压
cd opencv-3.4.5
mkdir build
cd build
cmake ..
make -j4
sudo make install
(3)配置环境变量
sudo gedit /etc/ld.so.conf.d/opencv.conf
在打开的空白文件中添加 /usr/local/lib (检查一下该路径下是否有OpenCV的各种依赖库)
执行 sudo ldconfig ,使配置的环境变量生效
(4) 配置 .bashrc ,末尾添加下面两行
//打开.bashrc
sudo gedit /etc/bash.bashrc
//添加以下两行内容到.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
(5)source 与 update
source /etc/bash.bashrc
sudo updatedb
(6)测试是否正常安装 (成功会出现带 “hello opcv” 字样的窗口)
cd opencv-3.4.5/samples/cpp/example_cmake
cmake .
make
// 如果成功或弹出窗口,显示Hello OpenCV
./opencv_example
注:这里opencv的cmakelists报错不影响他正常使用。
源码安装eigen-3.3.7
解压之后进入eigen文件夹并运行
mkdir build
cd build
cmake ..
sudo make install
#安装后 头文件安装在/usr/local/include/eigen3/
#移动头文件
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
备注:在很多程序中 include 时经常使用 #include <Eigen/Dense> 而不是使用 #include
<eigen3/Eigen/Dense> 所以要做下处理
安装运行ORB-SLAM2
下载代码:
git clone https://github.com/abhineet123/ORB_SLAM2
进入下载的工程主目录中为脚本文件添加可执行权限并执行,需要注意如果是虚拟机或者电脑性能不好需要打开build.sh文件修改make -j为make -j4或者make -j1,然后再执行。
先执行非ros环境的工程编译:
cd ORB_SLAM2
chmod +x build.sh
./build.sh
报错:error: ‘usleep’ was not declared in this scope
在提示的对应报错文件中添加:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
遇到Tracking.cc:39:33: fatal error: cv_bridge/cv_bridge.h: No such file or directory
在CMakeLists.txt文件中加上这一句话:
include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${EIGEN3_INCLUDE_DIR} ${Pangolin_INCLUDE_DIRS} /opt/ros/kinetic/include )
error while loading shared libraries: libboost_system.so.1.54.0不能找到boost链接库
error while loading shared libraries: libboost_system.so.1.54.0不能找到boost链接库_lykhahaha的博客-CSDN博客
ORB_SLAM2 libORB_SLAM2.so: cannot open shared object file: No such file or directory
考入文件
sudo cp /home/zyt/software/ORB_SLAM2/lib/libORB_SLAM2.so /usr/local/lib
赋予权限
sudo chmod 777 libORB_SLAM2.so
出现报错Pangolin X11: Unable to retrieve framebuffer options怎么办?
https://blog.csdn.net/abcwoabcwo/article/details/107959192
orbslam运行:
./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /home/zyt/software/ORB_SLAM2/sequences/01
地图栅格化运行:
./Examples/ROS/ORB_SLAM2/Monopub Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /home/zyt/software/ORB_SLAM2/sequences/01
ros编译
1. 添加环境变量
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/zyt/software/ORB_SLAM2/Examples/ROS
2. 配置运行环境
source ~/.bashrc
报错:
make[2]: *** [../Monopub] Error 1
CMakeFiles/Makefile2:402: recipe for target 'CMakeFiles/Monopub.dir/all' failed
make[1]: *** [CMakeFiles/Monopub.dir/all] Error 2
[ 92%] Linking CXX executable ../Stereo
/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/RGBD.dir/build.make:216: recipe for target '../RGBD' failed
make[2]: *** [../RGBD] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed
make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2
/usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/Stereo.dir/build.make:216: recipe for target '../Stereo' failed
make[2]: *** [../Stereo] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed
make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
确定是boost的问题,网上似乎找不到解决方案,后来自己瞎琢磨,竟然成功了
在ros的cmakelist里添加了boost的依赖库
添加了${Boost_LIBRARIES}依赖
3. 运行orbslam的发送节点
rosrun ORB_SLAM2 Monopub Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /home/zyt/software/ORB_SLAM2/sequences/01
4. 接受orbslam的接受节点
rosrun ORB_SLAM2 Monosub 30 2 6 -6 6 -6 0.55 0.50 1 5
或者:
rosrun ORB_SLAM2 Monosub 10 2 20 -20 20 -20 0.55 0.60 1 5
参数的含义:
scale_factor,提供比例信息。可以根据实际点的比例进行调整的变量!换句话说,它是从orbslam单位转换到米的实际比例。
调整系数只是调整最终二维网格地图图像的大小!(它不会影响2D地图的绘制过程。当地图大到屏幕无法显示时,可以使用它)
'visit_thresh'(访问阈值) 因为在orbslam中点是有噪声的,而且有些点在后几帧中被移除,使用这个阈值不考虑访问次数少的小区。为了确定一个单元是否被占用,无论比率是多少,都需要考虑'visit_thesh'的次数。
cloud_max, cloud_min是三维点云的最小和最大高度!这是为了找出网格地图的大小!
grid_size:网格大小是二维地图最后的网格大小
double grid_res_x = grid_max_x - grid_min_x, grid_res_z = grid_max_z - grid_min_z
h = grid_res_z;
w = grid_res_x
output_size:是应用'resize_factor'后的尺寸。
用kitti数据集进行测试:
用自己采集的数据集进行测试:(长廊环境)
参考:
ORBSLAM2创建栅格地图方法复现_orbslam2复现_哇塞少年的博客-CSDN博客ubuntu18.04 安装 ORB-SLAM2_Michael-Tian的博客-CSDN博客https://github.com/abhineet123/ORB_SLAM2