Cartographer ROS 整合(翻译) 2019.4.2更新

本文档详细介绍了如何整合Cartographer ROS,包括编译安装、运行示例bag、创建自定义配置文件及launch文件。此外,还探讨了算法调优,如输入配置、Local SLAM和Global SLAM的参数调整,帮助用户实现高效的SLAM解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Cartographer ROS 整合


        Cartographer 是一个提供2D和3D实时定位与建图(SLAM)功能的系统,支持跨越多个平台与多传感器配置融合。

编译 Cartographer ROS 包

系统要求

  • 64位现代的CPU(比如,i7 3代)
  • 16 GB RAM
  • Ubuntu 14.04 (Trusty) 或 16.04 (Xenial)
  • gcc 版本 4.8.4 或 5.4.0
支持的 ROS 版本
  • Indigo
  • Kinetic
  • Lunar
  • Melodic
已知问题

        32位系统编译eigen库会出现问题

编译安装

        为了编译 Cartographer ROS 包,我们推荐使用wstoolrosdep。从提高编译速度来讲,我们也推荐使用Ninja

sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build

        在’catkin_ws’中创建一个新的工作空间cartographer_ros

mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src

        安装cartographer_ros依赖(proto3 和 deb 包)。如果你之前已经执行过sudo rosdep init命令则这次执行会报错,因为你在安装 ROS 的时候已经执行过了,所以这个错误可以忽略。

src/cartographer/scripts/install_proto3.sh
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

        编译安装

catkin_make_isolated --install --use-ninja

通过 Demo bag 来运行 Cartographer ROS

        安装好了 Cartographer 和 Cartographer 的 ROS 整合包,可以下载样例bag(比如,德意志博物馆的 2D 和 3D系列)到指定位置,在此教程我们下载到~/Downloads,并使用roslaunch来启动样例。

        luanch文件会自动启动roscorerviz

注意:
当你运行cartographer_ros时,你可能需要先source一下你的 ROS 环境。运行如下命令
source install_isolated/setup.bash(如果你用的 zsh shell 就把 bash 后缀替换成 zsh)

德意志博物馆

        下载并运行 2D bag Demo:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag

        下载并运行 2D bag Demo:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/with_intensities/b3-2016-04-05-14-14-00.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag

定位

        定位功能需要使用两个不同的bag。第一个用来生成地图,第二个用来运行定位。

        下载 2D bag:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/b2-2016-04-05-14-44-52.bag
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/b2-2016-04-27-12-31-41.bag

        生成地图(等到cartographer_offline_node运行完毕)然后运行定位:

roslaunch cartographer_ros offline_backpack_2d.launch bag_filenames:=${HOME}/Downloads/b2-2016-04-05-14-44-52.bag
roslaunch cartographer_ros demo_backpack_2d_localization.launch \
   load_state_filename:=${HOME}/Downloads/b2-2016-04-05-14-44-52.bag.pbstream \
   bag_filename:=${HOME}/Downloads/b2-2016-04-27-12-31-41.bag

        下载 3D bag:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-13-54-42.bag
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-15-52-20.bag

        生成地图(等到cartographer_offline_node运行完毕)然后运行定位:

roslaunch cartographer_ros offline_backpack_3d.launch bag_filenames:=${HOME}<
<think>嗯,用户遇到了在克隆GitHub仓库时出现的GnuTLS recv错误(-54)。这个问题看起来和网络连接或Git配置有关。让我仔细分析一下。 用户应该是在执行git clone命令时遇到了问题,错误信息明确指向GnuTLS库的接收错误。从引用内容看,这可能与TLS连接中断有关,常见于网络不稳定或代理设置不当的情况。 参考几个解决方案:第一种是切换协议,把https换成git或ssh协议,这能绕过有问题的https连接。第二种是调整网络环境,比如更换网络或使用代理。第三种是修改Git配置,增加缓存大小或启用详细日志帮助诊断。用户可能需要根据实际网络环境选择最合适的方案。 考虑到用户克隆的是cartographer_ros这种大型仓库,特别要注意子模块的问题。引用[3]提到递归克隆时子模块失败的情况,建议添加--recursive参数时优先使用ssh协议。另外引用[4]提供的配置调整方案也很实用,特别是增大postBuffer值对大型仓库很有效。 用户可能不太熟悉Git的高级配置,所以需要给出清晰的操作步骤。比如修改协议的具体命令示例,调整配置时的完整参数设置,以及网络测试的方法。还要提醒用户注意权限问题,特别是修改.bashrc时需要sudo权限。 这个问题解决后,用户可能还会遇到相关网络问题,所以应该准备几个延伸问题。比如如何设置Git代理,如何排查TLS连接问题,或者处理大型仓库克隆时的超时问题。这些都能帮助用户更全面地掌握Git网络故障排除技巧。</think>好的,针对您在克隆 GitHub 仓库(如 `cartographer_ros`)时遇到的 `GnuTLS recv error (-54): Error in the pull function` 错误,以下是几种有效的解决方法,请根据您的网络环境尝试: **核心原因:** 此错误通常表示在通过 HTTPS 协议使用 Git 下载数据时,底层 TLS/SSL 连接(由 GnuTLS 库处理)被意外中断。这往往与**网络连接不稳定、代理设置问题、服务器限制或特定 Git 配置**有关。 **解决方案:** 1. **切换协议 (推荐尝试):** * **HTTPS -> SSH:** 如果您的 GitHub 账户设置了 SSH 密钥,这是最推荐的方法。将克隆命令中的 `https://` 替换为 `git@`: ```bash git clone git@github.com:cartographer-project/cartographer_ros.git # 如果包含子模块,递归克隆使用: git clone --recursive git@github.com:cartographer-project/cartographer_ros.git ``` * **HTTPS -> Git:** 有时使用原始的 `git://` 协议也能绕过问题(但注意此协议通常未加密且可能被防火墙阻止): ```bash git clone git://github.com/cartographer-project/cartographer_ros.git ``` 2. **调整 Git 配置 (针对 HTTPS):** * **增大 HTTP 缓存 (`postBuffer`):** Git 默认的 HTTP 缓存可能不足,特别是对于大型仓库或慢速网络。增大它: ```bash git config --global http.postBuffer 524288000 # 设置为 500MB ``` * **关闭 SSL 验证 (临时调试,不推荐长期使用):** 仅用于测试是否是 SSL 证书问题。**注意:这会降低安全性。** ```bash git config --global http.sslVerify false # 测试克隆... # 测试完成后,强烈建议恢复验证: git config --global http.sslVerify true ``` 3. **检查并配置网络/代理:** * **更换网络环境:** 尝试切换到更稳定、速度更快的网络(如从移动热点切换到宽带)。 * **检查代理设置:** 如果您在公司或使用了代理,确保 Git 正确配置了代理。查看当前代理设置: ```bash git config --global --get http.proxy git config --global --get https.proxy ``` * **设置代理:** 如果需要代理,请正确设置(替换 `proxy-server` 和 `port`): ```bash git config --global http.proxy http://proxy-server:port git config --global https.proxy https://proxy-server:port # 或 http:// 如果代理不支持 HTTPS ``` * **取消代理:** 如果不需要代理或代理配置错误,取消它: ```bash git config --global --unset http.proxy git config --global --unset https.proxy ``` 4. **尝试浅克隆 (仅获取最新提交):** 如果只需要最新代码,且仓库历史很长,浅克隆可以减少数据量: ```bash git clone --depth 1 https://github.com/cartographer-project/cartographer_ros.git # --depth 1 表示只克隆最近一次提交 ``` 5. **使用镜像或中间平台 (如 Gitee):** * 在 GitHub 仓库页面找到 “Fork” 按钮,将仓库 Fork 到您自己的 GitHub 账户。 * 登录 [Gitee](https://gitee.com/),使用 “从 GitHub/GitLab 导入仓库” 功能,将您 Fork 的 GitHub 仓库导入到 Gitee(国内访问通常更快更稳定)。 * 从 Gitee 克隆仓库: ```bash git clone https://gitee.com/your_gitee_username/cartographer_ros.git ``` * (可选)后续可以将 Gitee 仓库设置为上游 (upstream) 以同步 GitHub 的更新。 **建议尝试顺序:** 1. **最简单快速:** 尝试 **方法 1 (切换为 SSH 协议)**。这是解决此类问题最常见有效的方案。 2. 如果 SSH 不可用或不想设置:尝试 **方法 2 (增大 `postBuffer`)**。 3. 如果问题依旧:仔细检查 **方法 3 (网络/代理)**。更换网络或正确设置/取消代理。 4. 如果只需要最新代码:尝试 **方法 4 (浅克隆)**。 5. 如果网络条件确实很差且上述方法无效:考虑 **方法 5 (Gitee 镜像)**。 6. `http.sslVerify false
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值