Cartographer ROS编译安装


安装gmapping比较简单,一条命令 (sudo apt install ros-noetic-gmapping)即可。

Cartographer并不在ROS packages列表中,安装起来比较麻烦,总体来说,按照官方的编译步骤即可编译成功,官方地址

Cartographer ROS编译安装

操作系统:ubuntu20.04,ros版本:noetic

  1. 安装相关工具

sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow

  1. 初始化工作空间

mkdir catkin_ws_carto
cd catkin_ws
wstool init src

  1. 安装cartographer、cartographer_ros
    下面是官方的安装步骤,如果无法连外网的话(替换为下面优化过的(1)(2)两步骤来安装),会报错,还是老问题,境外资源无法访问:

wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall

wstool update -t src

这里的意图是把cartographer_ros.rosinstall中的内容追加到src目录下的rosinstall文件中,我们来手动操作,解决上面的问题。

(1)首先,在github上找到cartographer_ros.rosinstall文件,打开后内容如下:

- git: {local-name: cartographer, uri: 'https://github.com/cartographer-project/cartographer.git', version: 'master'}
- git: {local-name: cartographer_ros, uri: 'https://github.com/cartographer-project/cartographer_ros.git', version: 'master'}

我们手动的将cartographer_ros.rosinstall中的内容复制到src目录下的.rosinstall文件中,默认此文件会被隐藏,可以勾选显示选项显示此文件:
在这里插入图片描述
在这里插入图片描述
如果github访问也有问题的话,也可以用其他资源,如下面的gitee资源也可以:

- git: {local-name: cartographer, uri: 'https://gitee.com/xfbug/cartographer.git', version: 'master'}
- git: {local-name: cartographer_ros, uri: 'https://gitee.com/xfbug/cartographer_ros.git', version: 'master'}

(2)修改完成.rosinstall完成后,无需再执行wstool merge命令,直接执行下面的update命令:

wstool update -t src

  1. 安装依赖
    注意:rosdep执行失败的话参考这里来解决,如果在搭建ros开发环境时已经成功执行过了rosdep初始化和update,这里也可以不再执行。

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${noetic} -y

  1. 安装abseil-cpp库
    执行下面的命令来运行install_abseil.sh脚本进行安装:

src/cartographer/scripts/install_abseil.sh

  1. 构建和安装

catkin_make_isolated --install --use-ninja

测试Cartographer环境

我们可以通过在演示包上运行Cartographer ROS来测试环境是否搭建成功。

下载、启动2D演示包:

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

启动前记得先source一下,source ~/catkin_ws_carto/devel_isolated/setup.bash,演示包展示的是一个2D环境建图的过程:
在这里插入图片描述

下载、启动3D演示包:

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可以在官方地址上下载体验。

☝ ★★★ — 返回 《ROS机器人开发笔记汇总》总目录 — ★★★ ☝

  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
### 回答1: 要在ROS 2中安装Cartographer,可以按照以下步骤进行操作: 1. 首先,确保已经安装ROS 2和Cartographer的依赖项。您可以通过运行以下命令安装ROS 2: ``` sudo apt update sudo apt install ros-<distro>-desktop ``` 注意在`<distro>`中替换为您要使用的ROS 2发行版(如`foxy`或`dashing`)。 2. 接下来,安装Cartographer的依赖项。您可以使用以下命令来安装它们: ``` sudo apt update sudo apt install git cmake protobuf-compiler libceres-dev libboost-all-dev liblua5.3-dev ``` 3. 接下来,创建一个工作空间并克隆Cartographer的源代码。使用以下命令: ``` mkdir -p cartographer_ws/src cd cartographer_ws/src git clone https://github.com/googlecartographer/cartographer.git git clone https://github.com/googlecartographer/cartographer_ros.git ``` 4. 然后,安装其他依赖项和构建Cartographer。使用以下命令: ``` sudo apt update sudo apt install python3-vcstool cd .. rosdep install --from-paths src --ignore-src --rosdistro <distro>-release -y colcon build --symlink-install ``` 请注意,将上述命令中的`<distro>`替换为您要使用的ROS 2发行版(如`foxy`或`dashing`)。 5. 最后,您需要设置与CartographerROS 2相关的环境变量。使用以下命令: ``` source install/setup.bash ``` 现在,您已经成功地在ROS 2上安装Cartographer。您可以通过使用Cartographer ROS软件包中提供的节点和服务来开始使用它进行建图和定位。 ### 回答2: 要在ROS2环境中安装Cartographer,需要执行以下步骤: 第一步,安装依赖项。在ROS2环境下,安装Cartographer之前,需要先安装一些依赖项。打开终端窗口,执行以下命令: ``` sudo apt-get update sudo apt-get install -y protobuf-compiler libprotobuf-dev libboost-all-dev python3-sphinx ros-<distribution>-gazebo-ros-pkgs ``` 在命令中将“<distribution>”替换为ROS2的发行版本,例如“foxy”或“rolling”。 第二步,克隆Cartographer源代码。继续在终端窗口执行以下命令: ``` mkdir -p ~/cartographer_ws/src cd ~/cartographer_ws/src git clone https://github.com/cartographer-project/cartographer.git ``` 第三步,构建Cartographer。在终端窗口执行以下命令: ``` cd ~/cartographer_ws source /opt/ros/<distribution>/setup.bash colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release ``` 同样,将命令中的“<distribution>”替换为ROS2的发行版本。 第四步,安装Cartographer ROS包。在终端窗口执行以下命令: ``` cd ~/cartographer_ws source ~/cartographer_ws/install/setup.bash sudo apt-get install -y ros-<distribution>-cartographer ros-<distribution>-cartographer-ros ``` 确保将命令中的“<distribution>”替换为ROS2的发行版本。 安装完成后,即可在ROS2中使用Cartographer进行建图和定位。根据需要,可以使用Cartographer提供的命令行工具或者编写自己的ROS节点来使用Cartographer的功能。 ### 回答3: 要安装ROS 2的Cartographer,你需要按照以下步骤进行操作: 1. 首先,确保你已经正确安装ROS 2。你可以从ROS官方网站上找到ROS 2的安装指南,并根据指南中的步骤进行安装。 2. 在安装ROS 2之后,你需要安装Cartographer的依赖项。打开一个终端窗口,执行以下命令来安装Cartographer的依赖项: ``` sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow python3-pep8 sudo pip3 install -U setuptools ``` 3. 接下来,你需要获取Cartographer源代码。在终端窗口中执行以下命令: ``` mkdir -p ~/cartographer_ws/src cd ~/cartographer_ws/src git clone https://github.com/cartographer-project/cartographer.git git clone https://github.com/cartographer-project/cartographer_ros.git cd ~/cartographer_ws rosdep update rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} ``` 在第三步中,我们将源代码克隆到了`~/cartographer_ws/src`目录下,并且使用`rosdep`来安装所需的ROS依赖项。 4. 现在,编译Cartographer。在终端窗口中执行以下命令: ``` cd ~/cartographer_ws src/cartographer/scripts/install_abseil.sh src/cartographer/scripts/install_proto3.sh ament build --symlink-install ``` 这一步骤可能需要一些时间来完成,确保网络连接良好,以便能够下载和编译所需的软件包。 5. 安装完成后,你可以尝试运行Cartographer的示例。在终端窗口中执行以下命令: ``` source install/local_setup.bash roslaunch cartographer_ros demo_revo_lds.launch ``` 这将运行Cartographer与一个示例激光雷达一起工作的启动文件。如果一切顺利,你应该能够在RViz中看到建图的结果。 以上就是使用300字中文回答ros2安装Cartographer的步骤。请注意,这只是简要的安装指南,更详细和特殊的需求请参考CartographerROS 2的官方文档。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

画茧自缚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值