cartographer 使用 定位_[基于ROS构建移动机器人]第五篇:使用cartographer建图和定位...

本文介绍了如何使用Cartographer在ROS环境下进行2D和3D环境的建图与定位,无需里程计信息。详细阐述了在树莓派上安装Cartographer的步骤,包括解决ceres-solver依赖问题、设置swap空间,以及数据集测试和激光雷达测试的过程。
摘要由CSDN通过智能技术生成

gmapping建图和amcl定位算法是在经典的建图和定位方法,缺点是需要里程计信息。google的cartographer不需要里程计信息,可以降低对电机和电机控制板的要求,车子成本能继续降一降。
考虑两个方案:(1)cartographer运行在pc机上,树莓派上只发布/scan雷达数据;(2)cartographer运行在树莓派上
安装方法:
[Cartographer](https://google-cartographer-ros.readthedocs.io/en/latest/)是谷歌提供的通用定位与地图同步构建的SLAM工具,并提供ROS接口。不需要里程计消息,用于2D和3D环境的建图定位。
## **1. 安装方法**
官方提供的安装方式如下:
#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
需要做如下一处改动。由于安装过程中无法顺利下载ceres-solver。 进入ROS工作空间的src目录,按下“ctrl和h”,编辑.rosinstall文件。 修改其中的ceres-solver下载地址:
- git: local-name: ceres-solver uri: https://github.com/ceres-solver/ceres-solver version:
而后运行:
wstool update -t src
# Install proto3.
src/cartographer/scripts/install_proto3.sh
# Install deb dependencies.
# The command 'sudo rosdep init' will print an error if you have already
# executed it since installing ROS. This error can be ignored.
sudo 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
在树莓派安装时(ubuntu mate 16.04),需要设置swap空间,低于4G编译会出错。
sudo swapoff /swapfile sudo rm /swapfile sudo vi /etc/dphys-swapfile
将 CONF_SWAPSIZE 的值修改成你想要的大小。
然后,重新启动 dphys-swapfile 文件服务:
sudo /etc/init.d/dphys-swapfile restart
最后查看大小:
$ free -h
树莓派安装实在是慢呀....
## **2. 数据集测试**
# Download the 2D backpack example bag.
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
我是用浏览器打开,下载的。保存在了/home目录下。
# Launch the 2D backpack demo.
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/cartographer_paper_deutsches_museum.bag
## **3. 用激光雷达进行测试**

  • 登录树莓派,将雷达节点运行起来;
  • 启动雷达节点的文件,使用demo_revo_lds.launch ,注意激光数据的名字一致;
  • 修改对应的revo_lds.lua配置文件,修改激光雷达的量程参数即可。
  • 编译而后运行

roslaunch cartographer_ros demo_revo_lds.launch

4ee4d996aa402b046ddb6bada2ac20db.png
PC机运行slam节点,得到的地图.手拿的雷达,不稳。

坐标系的解释,参考如下文章https://blog.csdn.net/mllearnertj/article/details/72871169
to do:
研究完怎么样解算出小车相对于地图的位姿后,再来写一篇。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值