谷歌Cartographer学习(1)-快速安装测试

时间:2021-07-16 12:04:49

谷歌Cartographer学习(1)-快速安装测试

    谷歌自己提供了安装方法,但是安装比较繁琐,我做了一定的修改,代码放到个人github上,https://github.com/hitcm/

    ros下面的安装非常快捷,只需要catkin_make即可。

更多细节,可以看看知乎的问题https://www.zhihu.com/question/51348391/answer/125560951?from=profile_answer_card

    个人理解错误的地方还请不吝赐教,转载请标明出处,内容如有改动更新,请看原博:http://www.cnblogs.com/hitcm/,如有任何问题,feel free to contact me atrobotsming@gmail.com

     如有问题,请及时反馈给我,博客会持续更新

     如下,需要安装3个软件包,ceres solver、cartographer和cartographer_ros

0.安装所有依赖项

sudo apt-get install -y google-mock libboost-all-dev  libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.2-dev libprotobuf-dev  libsuitesparse-dev libwebp-dev ninja-build protobuf-compiler python-sphinx  ros-indigo-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev

1.首先安装ceres solver,选择的版本是1.11,路径随意

1.     git clone https://github.com/hitcm/ceres-solver-1.11.0.git

2.      cd ceres-solver-1.11.0/build

3.      cmake ..

4.      make –j

5.      sudo make install

 

2.然后安装 cartographer,路径随意

1.      git clone https://github.com/hitcm/cartographer.git

2 .     cd cartographer/build

3.       cmake .. -G Ninja

4.       ninja

5.       ninja test

6.       sudo ninja install

上述第3步执行错误的同学可以忽略3-6步,改用下面的方法。

7.      cmake  ..

8 .     make

9.      sudo make install

3.安装cartographer_ros。

谷歌官方提供的安装方法比较繁琐,我对原来的文件进行了少许的修改,核心代码不变,只是修改了编译文件

下载到catkin_ws下面的src文件夹下面

git clone https://github.com/hitcm/cartographer_ros.git

然后到catkin_ws下面运行catkin_make即可。

4.数据下载测试

2d数据,大概500M,用迅雷下载

https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag

3d数据,8G左右,同样用迅雷下载

https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/cartographer_3d_deutsches_museum.bag
 
然后运行launch文件即可。
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/cartographer_3d_deutsches_museum.bag
刚开始使用ROS的同学运行下面两句是无法工作的,可能出现的错误如下。

[demo_backpack_2d.launch] is neither a launch file in package [cartographer_ros] nor is [cartographer_ros] a launch file name
The traceback for the exception was written to the log file

这种错误的主要原因是ros的catkin_ws配置问题,可以运行rospack profile试试。

实在不行还有如下所示的两种解决方法。推荐第二种。

谷歌Cartographer学习(1)-快速安装测试

谷歌Cartographer学习(1)-快速安装测试

最终结果如下图,左侧为2d,右侧为3d。
Good luck!关于代码的原理解析,接下来的文章可能会详细探讨
谷歌Cartographer学习(1)-快速安装测试谷歌Cartographer学习(1)-快速安装测试
 


原文地址:http://www.cnblogs.com/hitcm/p/5939507.html


Cartographer简介

Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations. This project provides Cartographer's ROS integration.
Cartographer是google开源的通用2D和3D定位与地图同步构建的SLAM工具,并提供ROS接口。
官网地址:https://github.com/googlecartographer

安装说明

  1. 官网提供了基于Ubuntu14.04(Trusty)和ROS(indigo)的安装和测试说明,有博客写道在Ubuntu16.04(Xenial)和ROS(Kinetic)上安装和测试成功,该博客也有Cartographer的介绍和安装流程:
    http://blog.csdn.net/zhangrelay/article/details/52757573
  2. 以下安装流程主要参考hitcm(张明明)的博客及Cartographer的官方安装教程:

安装流程

    1. 安装Ubuntu14.04(Trusty),将安装镜像文件制作U盘镜像,进入BIOS或WIN10下进入设置->更新和安全->恢复->高级启动,使用U盘启动,完成Ubuntu14.04(Trusty)的安装。
    2. 安装ROS(indigo),参考文件http://wiki.ros.org/indigo/Installation/Ubuntu(英文原版)、http://wiki.ros.org/cn/indigo/Installation/Ubuntu(中文翻译);
      注意: 如果每次打开一个新的终端时ROS环境变量都能够自动配置好(即添加到bash会话中),那将会方便得多:
      echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
      source ~/.bashrc
      如果你安装有多个ROS版本, ~/.bashrc 必须只能 source你当前使用版本所对应的 setup.bash
      如果你只想改变当前终端下的环境变量,你可以执行命令:
      source /opt/ros/indigo/setup.bash
    3. 安装所有依赖项
      # Install the required libraries that are available as debs.
      sudo apt-get update
      sudo apt-get install -y \
      cmake \
      g++ \
      git \
      google-mock \
      libboost-all-dev \
      libeigen3-dev \
      libgflags-dev \
      libgoogle-glog-dev \
      liblua5.2-dev \
      libprotobuf-dev \
      libsuitesparse-dev \
      libwebp-dev \
      ninja-build \
      protobuf-compiler \
      python-sphinx \
      ros-indigo-tf2-eigen \
      libatlas-base-dev \
      libsuitesparse-dev \
      liblapack-dev
    4. 安装ceres solver,下载安装在主目录下,由于googlesource.com需要FQ,这里使用hitcm(张明明)的github地址
      # Build and install Ceres.
      # git clone https://ceres-solver.googlesource.com/ceres-solver
      # cd ceres-solver
      git clone https://github.com/hitcm/ceres-solver-1.11.0.git
      cd ceres-solver-1.11.0
      mkdir build
      cd build
      cmake .. -G Ninja
      ninja
      ninja test
      sudo ninja install
    5. 安装cartographer,下载安装在主目录下,这里同样使用的是hitcm(张明明)的github地址
      # Build and install Cartographer.
      git clone https://github.com/hitcm/cartographer.git
      cd cartographer
      mkdir build
      cd build
      cmake .. -G Ninja
      ninja
      ninja test
      sudo ninja install
    6. 安装cartographer_ros,这里使用的是hitcm(张明明)的github地址,由于google官方的教程需要FQ下载一些文件,因此容易失败,经验证hitcm(张明明)对原文件进行了少许修改后可以成功安装,在他的修改中核心代码不变,只修改了编译文件。
      We recommend using wstool and rosdep. For faster builds, we also recommend using Ninja.
      # Install wstool and rosdep.
      sudo apt-get update
      sudo apt-get install -y python-wstool python-rosdep ninja-build
      # Create a new workspace in 'catkin_ws'.
      mkdir catkin_ws
      cd catkin_ws
      wstool init src
      # 下载到catkin_ws下面的src文件夹下面
      cd src
      git clone https://github.com/hitcm/cartographer_ros.git
      # 然后到catkin_ws下面运行catkin_make安装
      cd
      cd catkin_ws
      catkin_make
      source ./devel/setup.bash
      注意: 如果每次打开一个新的终端时ROS环境变量都能够自动配置好(即添加到bash会话中),那将会方便得多:
      echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
      source ~/.bashrc
      如果你只想改变当前终端下的环境变量,你可以执行命令:
      source ~/catkin_ws/devel/setup.bash
    7. 运行DEMO
      Now that Cartographer and Cartographer’s ROS integration are installed, download the example bags (e.g. 2D and 3D backpack collections of the Deutsches Museum) to a known location, in this case ~/Downloads, and use roslaunch to bring up the demo:
      # Download the 2D backpack example bag.
      wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
      # Launch the 2D backpack demo.
      roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
      # Download the 3D backpack example bag.
      wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/cartographer_3d_deutsches_museum.bag
      # Launch the 3D backpack demo.
      roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/cartographer_3d_deutsches_museum.bag
      # Download the Revo LDS example bag.
      wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/revo_lds/cartographer_paper_revo_lds.bag
      # Launch the Revo LDS demo.
      roslaunch cartographer_ros demo_revo_lds.launch bag_filename:=${HOME}/Downloads/cartographer_paper_revo_lds.bag
      # Download the PR2 example bag.
      wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/pr2/2011-09-15-08-32-46.bag
      # Launch the PR2 demo.
      roslaunch cartographer_ros demo_pr2.launch bag_filename:=${HOME}/Downloads/2011-09-15-08-32-46.bag
      The launch files will bring up roscore and rviz automatically.


原文地址:http://www.cnblogs.com/wenhust/p/5961017.html