如何使用 Google Cartographer SLAM 演算法來建地圖

   2016-10-31 0
核心提示:Cartographer 是 Google 最近剛發表的 SLAM 演算法,效果看起來非常好,而且他們發表的論文裡主打這個演算法很 real-time,今天就來帶大家把這個演算法在自己的環境中跑起來,之後就可以自己玩了。建立模擬環境 我的測試環境是 Ubuntu 14.04 + ROS Indigo,不

Cartographer 是 Google 最近剛發表的 SLAM 演算法,效果看起來非常好,而且他們發表的論文裡主打這個演算法很 real-time,今天就來帶大家把這個演算法在自己的環境中跑起來,之後就可以自己玩了。

如何使用 Google Cartographer SLAM 演算法來建地圖

建立模擬環境

我的測試環境是 Ubuntu 14.04 + ROS Indigo,不過使用的指令都很 general,即便你使用其他版本,應該也不會有什麼問題。

首先我們確定已經安裝所需要的套件:

sudo apt-get install ros-indigo-gazebo-*

接下來在終端機輸入 gazebo 應該就可以成功啟動 Gazebo 模擬器。然後我們可以用現成的 package 啟動一個有 PR2 的複雜環境。

roslaunch pr2_gazebo pr2_wg_world.launch

理論上,你會碰到一個 error 說:

unused args [paused, gui] for include of [/opt/ros/jade/share/gazebo_ros/launch/willowgarage_world.launch] The traceback for the exception was written to the log file

這時候只要去編輯你的 pr2_wg_world.launch,把有 arg 的部分註解掉就好,註解完的檔案看起來會像下面這樣:

<launch>

<!-- start up empty world -->
<!-- <arg name="gui" default="true"/>
 <arg name="paused" default="true"/> -->
<!-- TODO:throttled not implemented in gazebo_ros/empty_world.launch
 <arg name="throttled" default="false"/>
 -->

<includefile="$(find gazebo_ros)/launch/willowgarage_world.launch">
<!-- <arg name="gui" value="$(arg gui)" />
 <arg name="paused" value="$(arg paused)" /> -->
<!-- TODO:throttled not implemented in gazebo_ros/empty_world.launch
 <arg name="throttled" value="$(arg throttled)" />
 -->
</include>

<!-- start pr2 robot -->
<includefile="$(find pr2_gazebo)/launch/pr2.launch"/>

</launch>

註解完畢就可以啟動啦。啟動之後的環境會長得像下面這樣:

如何使用 Google Cartographer SLAM 演算法來建地圖

如何使用 Google Cartographer SLAM 演算法來建地圖

安裝 & 啓動 Cartographer

安裝的方法滿簡單的,只要照著官方文件上的步驟做就可以了:

# 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

# Merge the cartographer_ros.rosinstall file and fetch code for dependencies.
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src

# Install deb dependencies.
rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash

重點是裝完之後,我們想要跑 cartographer_ros package 裡面的 demo_pr2.launch,但裡面原本預設是跑 bag file 的 demo 版本,所以我們要稍微修改一下 demo_pr2.launch :

rosed cartographer_ros demo_pr2.launch
<!--
 Copyright 2016 The Cartographer Authors

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<launch>
<paramname="/use_sim_time"value="true"/>

<nodename="cartographer_node"pkg="cartographer_ros"
type="cartographer_node"args="
 -configuration_directory
 $(find cartographer_ros)/configuration_files
 -configuration_basename pr2.lua"
output="screen">
<remapfrom="scan"to="/base_scan"/>
</node>

<nodename="tf_remove_frames"pkg="cartographer_ros"
type="tf_remove_frames.py">
<remapfrom="tf_out"to="/tf"/>
<rosparamparam="remove_frames">
 - map
 - odom_combined
</rosparam>
</node>

<nodename="rviz"pkg="rviz"type="rviz"required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz"/>
</launch>

修改完之後就可以執行了,這時應該可以看到 Rviz 的視窗跳出來,也可以看到目前的地圖。

roslaunch cartographer_ros demo_pr2.launch

Teleop PR2 來建地圖囉

只要啟動 teleop_keyborad 就可以用鍵盤控制機器人移動:

roslaunch pr2_teleop teleop_keyboard.launch

WASD 四個按鍵分別代表前左後右四個方向的平移、QE兩個按鍵是原地旋轉,這邊要注意必須選到啟動 teleop_keyboard的視窗,按按鍵才有用。使用 teleop 來控制 PR2 走一走之後,就可以看得出我們已經建立了一個有模有樣的地圖。不過因為這個地圖太大,我就不走完了。

如何使用 Google Cartographer SLAM 演算法來建地圖

總結

今天主要帶大家把 Cartographer 跑起來,把原本 demo 用的版本換成可以接上自己的機器人,有興趣深入研究的讀者可以搭配論文,有了可以玩的環境和程式碼可以參考,學習起來會比較有感。

 
标签: Linux命令
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • 每天一条linux命令——halt
    halt命令用来关闭正在运行的Linux操作系统。halt命令会先检测系统的runlevel,若runlevel为0或6,则关闭系统,否则即调用shutdown来关闭系统。 语法:halt(选项)选项:-d:不要在wtmp中记录;-f:不论目前的runlevel为何,不调用shutdown即强制关闭系统;-i:
    02-10
  • 几个linux命令查看堆栈内存问题 几个linux命令
      公司编写代码,发现整个在程序里面调用system时候总是失败,原因是can't allocate memory ,根本原因不是内存不足,而是堆栈内存不够。使用ulimit -s 2048后有所好转但是发现一旦系统进程开启多了后仍然会挂。后来使用objdump -x 后发现了原因有个动态库
    02-09
  • Linux命令总结--rm命令 linux的rmp命令
    (来源于http://www.cnblogs.com/xqzt/p/5398919.html)1、命令简介rm(Remove file 删除目录或文件)删除文件,对于链接文件,只是删除整个链接文件,而原有文件保持不变。新手在删除文件之前一定要知道这些:很重要1.可以用mv代替rm的绝对不要用rm,不要着急
    02-09
  • Linux命令行批量创建目录详解 linux创建目录
    以前一直用-p创建目录链,觉得很方便了。在空目录/opt/app/myapp里创建src,再创建main,再创建javamkdir -p /opt/app/myapp/src/main/java没想到还可以这样玩##¥%……*(root@vm1:~/tmp# mkdir -p src/{{main,test}/{java,resources},main/webapp}root@vm1:
    02-09
  • Linux命令之乐--script和scriptplay
    script和scriptplay可以把终端会话记录到一个文件中,可以用来制作命令行教学视屏。 开始录制会话[root@new test]# script -t 2timing.log -a output.sessionScript started, file is output.session[root@new test]# echo hellohello[root@new test]# echo
    02-09
  • java 开发常用的Linux命令
    1.查找文件 find / -name filename.txt 根据名称查找/目录下的filename.txt文件。find . -name "*.xml" 递归查找所有的xml文件find . -name "*.xml" |xargs grep "hello world" 递归查找所有文件内容中包含hello world的xml文件grep -H 'spring' *.xml 查找所
    02-09
  • 常用Linux命令整理 Linux常用命令总结
    常用Linux命令整理常见系统命令export 查看或修改环境变量# 例:临时修改命令提示符为字符串$export PS1=$# 例:临时修改命令提示符显示系统时间 时间使用\t 表示export PS1="[\u@\h \t \W]\$"man 查看linux系统的手册# 例:查看ls命令如何使用man ls # 回车
    02-09 Linux
  • linux命令行—《命令行快速入门》 linux常用命令csdn
    linux命令行—《命令行快速入门》 linux常用命
    pwd print working directory 打印工作目录hostname my computer's network name 电脑在网络中的名称mkdir make directory 创建路径cd change directory 改变路径ls list directory 列出路径下的内容rmdir remove directory 删除路径pushd push directory 推
    02-09
  • Linux命令(五) 五个常用的linux命令
    Linux命令(五) 五个常用的linux命令
    jenkins触发钉钉报警机制1、安装钉钉插件钉钉报警需要安装Ding Talk插件,支持钉钉报警2、打开钉钉创建钉钉机器人2.1选择机器人类型——自定义2.2添加机器人2.3填写机器人信息填写机器人姓名—设置安全设置为加密类型,并复制出来加密值2.4创建完成保持webhoo
    02-09
  • 03_Linux基础-文件类型-主辅提示符-第1提示符-Linux命令-内外部命令-快捷键-改为英文编码-3个时间-stat-其他基础命令
    03_Linux基础-文件类型-主辅提示符-第1提示符-L
    03_Linux基础-文件类型-主辅提示符-第1提示符-Linux命令-内外部命令-快捷键-改为英文编码-3个时间-stat-{1..100}-du-cd-cp-file-mv-echo-id-shell-ln-env-set-which-rpm-/usr-/与/root-hostname-vim-cat-pwd-alias-unalias-ls-ASCII-wc-chmod博客
    02-09
点击排行