< >
Home » ROS与VSLAM入门教程 » ROS与VSLAM入门教程-ubuntu16.04安装Rgbdslamv2

ROS与VSLAM入门教程-ubuntu16.04安装Rgbdslamv2

ROS与VSLAM入门教程-ubuntu16.04安装Rgbdslamv2

说明:

  • 介绍如何在虚拟机ubuntu16.04系统安装Rgbdslamv2
  • 环境:ubuntu 16.04 + kinetic

步骤:

  • 安装虚拟机
  • 安装ubuntu16.04 + kinetic
sudo su
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall
  • 创建工作空间
mkdir -p ~/rgbdslamv2/src
cd ~/rgbdslamv2
catkin_make
  • 下载rgbdslam_v2
cd ~/rgbdslamv2/src
git clone https://github.com/felixendres/rgbdslam_v2
  • 检测是否有老版本的g2o需要删除
dpkg -l | grep [Gg]2[Oo]    
ls /usr/local/lib
ls /usr/lib | grep [Gg]2[Oo]
ls /opt/ros/kinetic/lib | grep [Gg]2[Oo] 
  • 安装g2o依赖
sudo apt-get install libsuitesparse-dev
  • 下载eigen3,需要使用它的头文件
mkdir ~/rgbdslamv2/
cd ~/rgbdslamv2
wget http://bitbucket.org/eigen/eigen/get/3.2.10.tar.bz2
mkdir eigen
tar -xvjf 3.2.10.tar.bz2 -C eigen --strip-components 1
  • 下载编译g2o
cd ~/rgbdslamv2
git clone https://github.com/felixendres/g2o.git
cd ~/rgbdslamv2/g2o
mkdir ~/rgbdslamv2/g2o/build
cd ~/rgbdslamv2/g2o/build
  • 修改使用eigen3头文件
vi ~/rgbdslamv2/g2o/CMakeLists.txt

change line 251 from:

SET(G2O_EIGEN3_INCLUDE ${EIGEN3_INCLUDE_DIR} CACHE PATH "Directory of Eigen3")

to:

SET(G2O_EIGEN3_INCLUDE "/rgbdslamv2/eigen" CACHE PATH "Directory of Eigen3")

save the file and exit (:wq)

note: check to make sure the system eigen3 headers are in /usr/include/eigen3
  • /rgbdslamv2/eigen替换为你自己的绝对路径,一般/home/xxx/rgbdslamv2/eigen
  • 编译g2o
cd ~/rgbdslamv2/g2o/build
cmake ../
make
sudo make install
(installs to /usr/local/lib)
  • 安装pcl1.8 替代pcl1.7
cd ~/rgbdslamv2
wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.0.tar.gz
tar -xvzf pcl-1.8.0.tar.gz
  • 修改增加C++支持
cd ~/rgbdslamv2/pcl-pcl-1.8.0    
vi CMakeLists.txt
add the following to line #146 of CMakeLists.txt (right after endif()):
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
save the file and exit (:wq)
  • 编译pcl
mkdir build
cd build
cmake ../
make VERBOSE=1
sudo make install
  • 注意:编译需要很长时间,并需要空间大于7G
  • 更改rgbdslam_v2配置
cd ~/rgbdslamv2/src/rgbdslam_v2
vi CMakeLists.txt

change line 79 from:

find_package(PCL 1.7 REQUIRED COMPONENTS common io)

to:

find_package(PCL 1.8 REQUIRED COMPONENTS common io)
  • 把/usr/local/lib/目录下的libpcl相关文件都做软连接到/usr/lib/x86_64-linux。
  • 先移走/usr/lib/x86_64-linux下本身的libpcl文件,再做软连接。
ln -s /usr/local/lib/libpcl* /usr/lib/x86_64-linux/
  • 实际软连接的文件
lrwxrwxrwx 1 root root 16 Jul 12 21:51 libpcl_2d.so -> libpcl_2d.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 21:50 libpcl_common.so -> libpcl_common.so.1.8
lrwxrwxrwx 1 root root 22 Jul 12 21:52 libpcl_features.so -> libpcl_features.so.1.8
lrwxrwxrwx 1 root root 21 Jul 12 21:53 libpcl_filters.so -> libpcl_filters.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 21:53 libpcl_io_ply.so -> libpcl_io_ply.so.1.8
lrwxrwxrwx 1 root root 16 Jul 12 21:54 libpcl_io.so -> libpcl_io.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 21:54 libpcl_kdtree.so -> libpcl_kdtree.so.1.8
lrwxrwxrwx 1 root root 23 Jul 12 21:55 libpcl_keypoints.so -> libpcl_keypoints.so.1.8
lrwxrwxrwx 1 root root 16 Jul 12 21:55 libpcl_ml.so -> libpcl_ml.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 22:06 libpcl_octree.so -> libpcl_octree.so.1.8
lrwxrwxrwx 1 root root 23 Jul 12 21:56 libpcl_outofcore.so -> libpcl_outofcore.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 21:57 libpcl_people.so -> libpcl_people.so.1.8
lrwxrwxrwx 1 root root 25 Jul 12 21:57 libpcl_recognition.so -> libpcl_recognition.so.1.8
lrwxrwxrwx 1 root root 26 Jul 12 21:59 libpcl_registration.so -> libpcl_registration.so.1.8
lrwxrwxrwx 1 root root 30 Jul 12 21:58 libpcl_sample_consensus.so -> libpcl_sample_consensus.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 22:00 libpcl_search.so -> libpcl_search.so.1.8
lrwxrwxrwx 1 root root 26 Jul 12 22:00 libpcl_segmentation.so -> libpcl_segmentation.so.1.8
lrwxrwxrwx 1 root root 20 Jul 12 22:02 libpcl_stereo.so -> libpcl_stereo.so.1.8
lrwxrwxrwx 1 root root 21 Jul 12 22:03 libpcl_surface.so -> libpcl_surface.so.1.8
lrwxrwxrwx 1 root root 22 Jul 12 22:04 libpcl_tracking.so -> libpcl_tracking.so.1.8
lrwxrwxrwx 1 root root 27 Jul 12 22:04 libpcl_visualization.so -> libpcl_visualization.so.1.8
  • 编译siftgpu
cd ~/rgbdslamv2/src/rgbdslam_v2/external/SiftGPU

sudo apt-get install libglew-dev

sudo apt-get install libdevil1c2 libdevil-dev

make
  • 编译rgbdslam_v2
cd ~/rgbdslamv2

vi src/rgbdslam_v2/CMakeLists.txt

Add the following line to the bottom of the file:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

catkin_make

测试

  • 新终端,执行roscore
roscore  
  • 新终端,执行
~/rgbdslamv2/devel/lib/rgbdslam/rgbdslam
  • 运行如果出现
segmentation fault (core dumped)
  • 查看问题部分。

运行rosbag

  • 下载rosbag
cd ~/rgbdslamv2/src/rgbdslam_v2/test
wget http://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_xyz.bag
  • 新终端, 启动roscore
roscore 
  • 新终端,启动rgbdslam_v2
roslaunch rgbdslam test_settings.launch bagfile_name:="/home/ubuntu/rgbdslamv2/src/rgbdslam_v2/test/rgbd_dataset_freiburg1_xyz.bag"

问题:

  • 错误:g++: error: unrecognized command line option ‘-mfpmath=sse’
  • 原因:因为在TX2下编译的话,去掉sse
  • 解决:https://answers.ros.org/question/230794/install-rgbdslam-on-arm/
  • 错误:
-- The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.
  • 原因:Ubuntu 16.04采用vtk6,需要做软连接。
  • 解决:
https://wenda.ncnynl.com/question/186
https://wenda.ncnynl.com/question/185
  • 错误:
/usr/local/bin/g2o: error while loading shared libraries: libg2o_cli.so: cannot open shared object file: No such file or directory
  • 原因:重新编译g2o之后导致库文件找不到
  • 解决:库路径加到 ~/.bashrc 中,在该文件的未尾,可采用如下语句来使设置生效:
  • https://wenda.ncnynl.com/question/187
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

参考:

  • https://github.com/felixendres/rgbdslam_v2
  • https://github.com/felixendres/rgbdslam_v2/wiki/Instructions-for-Compiling-Rgbdslam-(V2)-on-a-Fresh-Ubuntu-16.04-Install-(Ros-Kinetic)-in-Virtualbox

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros与vslam入门教程, rgbdslam_v2