ROS中安装使用cartographer

来源:互联网 发布:剑三纯阳道长捏脸数据 编辑:程序博客网 时间:2024/04/29 13:08

一、在安装cartographer前,需要系统满足如下的要求:

·        64-bit, modern CPU (e.g. 3rd generation i7)

·        16 GB RAM

·        Ubuntu 14.04 (Trusty)

·        gcc version 4.8.4

·        ROS Indigo

本人是自己设计制作的机器人平台,只有一个激光雷达传感器URG-04LX-UG01。本人就是利用这个传感器实现的SLAM

二、安装过程及命令:

# Install wstool and rosdep.

sudo apt-getupdate

sudo apt-getinstall -y python-wstool python-rosdep ninja-build

 

# Create a new workspace in 'catkin_ws'.

mkdir catkin_ws

cd catkin_ws

wstool init src

 

# Merge the cartographer_ros.rosinstall file and fetchcode for dependencies.

wstool merge -tsrchttps://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall

wstool update -tsrc

 

# Install deb dependencies.

rosdep update

rosdep install--from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

 

# Build and install.

catkin_make_isolated --install --use-ninja

isolated --install --use-ninja

source install_isolated/setup.bash

备注:

问题:在catkin_make_isolated --install --use-ninja这一步,需要连接国外网下载ceres-solver,如果没有翻墙,会提示下载ceres-solver失败。

解决方法:

1.购买个VPN,连上国外网,翻墙后再运行该步骤的命令

2. 打开下面这个文件,修改git下载的地址

build_isolated/ceres_solver/install/ceres_src-prefix/tmp/ceres_src-gitclone.cmake

红色部分修改成如下这样

while(error_codeAND number_of_tries LESS 3)

  execute_process(

    COMMAND "/usr/bin/git" clone"https://github.com/ceres-solver/ceres-solver" "ceres_src"

    WORKING_DIRECTORY

修改好后从新运行该步骤命令

三、运行google提供的demo,显示google采集到的一个房间的地图。

# 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

备注,在运行测试这个demo的过程中,本人出现了两个错误:

1.rviz提示错误。原因是我是用teamviewer远程连到机器人上操作的,而rviz无法在远程运行显示。所以本人只好在机器人上接上了显示器,这样rviz就能正常运行了

2.playbag提示错误。原因是cartographer_paper_deutsches_museum.bag这个包没有完整下载。完整下载应该是500M左右。
四、利用cartographer,实现实时的构图定位
1.先将激光雷达节点的运行起来
rosrun hokuyo hokuyo
2.修改demo_revo_lds.launch
vim demo_revo_lds.launch
修改后的文件如下:
 
<launch>
  <param name="/use_sim_time" value="true" />
 
  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename revo_lds.lua"
      output="screen">
    <remap from="scan" to="scan" />
  </node>
 
  <node name="rviz" pkg="rviz" type="rviz" required="true"
      args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
</launch>
 
3.修改配置参数文件revo_lds.lua
vim ../configuration_files/revo_lds.lua
修改后的文件如下:
 
include "map_builder.lua"
 
options = {
  map_builder = MAP_BUILDER,
  sensor_bridge = {
    horizontal_laser_min_range = 0.3,
    horizontal_laser_max_range = 5.6,
    horizontal_laser_missing_echo_ray_length = 1.2,
    constant_odometry_translational_variance = 0.,
    constant_odometry_rotational_variance = 0.,
  },
  map_frame = "map",
  tracking_frame = "laser",
  published_frame = "laser",
  odom_frame = "odom",
  provide_odom_frame = true,
  use_odometry_data = false,
  use_horizontal_laser = true,
  use_horizontal_multi_echo_laser = false,
  num_lasers_3d = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
}
 
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
 
return options
4.重新编译
catkin_make_isolated --install --use-ninja
5.运行脚本进行实时构图定位
roslaunch cartographer_ros demo_revo_lds.launch
 
备注:
1.如果您使用的激光雷达不同,上面修改demo_revo_lds.launch和配置参数文件revo_lds.lua可能需要做相应的调整。
 
参考资料:
https://google-cartographer-ros.readthedocs.io/en/latest/index.html
http://wiki.ros.org/hokuyo_node/Tutorials/UsingTheHokuyoNode
2 0
原创粉丝点击