在ROS noetic上安装cartographer

在ROS noetic上安装cartographer


记录一下在ROS noetic上安装cartographer的过程。

官方ros文档,官方文档很详细,建议看着官方文档配置。

安装

  1. 首先需要安装好ros noetic:ros-noetic-desktop-full
sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow
  1. 新建一个catkin_ws,catkin_google_ws可以改成别的你想要的名字。如果raw.githubusercontent.com上不去的话,懂得都懂,或者可以修改/etc/hosts中的主机IP映射。
mkdir catkin_google_ws
cd catkin_google_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
  1. 下面的rosdep init可能会报错,如果无法执行的话可以,这一步出错的话进行第4步,否则直接跳到第5步。
sudo rosdep init
rosdep update
  1. 使用国内的rosdepc工具
sudo pip install rosdepc
sudo rosdepc init
rosdepc update

致谢:https://mp.weixin.qq.com/s/VGs8oWdhHH6XsHcx21lN4Q

  1. 安装abseil-cpp依赖,如果和ros的abseil产生冲突的话,执行第6步,否则跳到7
src/cartographer/scripts/install_abseil.sh
  1. 卸载ros的abseil
sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp
  1. build and install
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash #如果用zsh的话,把.bash替换成.zsh

测试

文件很大,测一个看看效果得了。如果demo能够运行起来,那么恭喜你已经完成了cartographer的安装。

下载并测试2d 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

下载并测试3d 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

更多测试

在自己的环境中运行

cartographer的配置不像其他slam算法是通过launch文件来设置的,而是通过lua脚本来配置的。示例配置脚本的路径如下:

catkin_google_ws/src/cartographer_ros/cartographer_ros/configuration_files
backpack_2d.lua #如果想使用2d
backpack_3d.lua #如果想使用3d

把示例文件拷贝到你的工作区命名为my_robot.lua,之后编辑my_robot.lua文件来满足你自己的机器人的需要。

官方配置文档

参数的含义,机翻的:

  • map_frame

    • The ROS frame ID to use for publishing submaps, the parent frame of poses, usually “map”.
    • 用于发布子图的 ROS 框架 ID,姿势的父框架,通常是“地图”。
  • tracking_frame

    • The ROS frame ID of the frame that is tracked by the SLAM algorithm. If an IMU is used, it should be at its position, although it might be rotated. A common choice is “imu_link”.
    • SLAM算法跟踪的帧的ROS帧ID。如果使用 IMU,它应该在它的位置,尽管它可能会被旋转。一个常见的选择是“imu_link”。
  • published_frame

    • The ROS frame ID to use as the child frame for publishing poses. For example “odom” if an “odom” frame is supplied by a different part of the system. In this case the pose of “odom” in the map_frame will be published. Otherwise, setting it to “base_link” is likely appropriate.
    • 用作发布姿势的子框架的 ROS 框架 ID。例如,如果“odom”框架由系统的不同部分提供,则为“odom”。在这种情况下,将发布 map_frame 中“odom”的位姿。否则,将其设置为“base_link”可能是合适的。
  • odom_frameodom_frame

    • Only used if provide_odom_frame is true. The frame between published_frame and map_frame to be used for publishing the (non-loop-closed) local SLAM result. Usually “odom”.
    • 仅在 provide_odom_frame 为真时使用。 published_frame 和 map_frame 之间的帧,用于发布(非闭环)本地 SLAM 结果。通常是“odom”。
  • provide_odom_frame

    • If enabled, the local, non-loop-closed, continuous pose will be published as the odom_frame in the map_frame.
    • 如果启用,本地的、非闭环的、连续的姿势将作为 odom_frame 发布在 map_frame 中。
  • publish_frame_projected_to_2d

    • If enabled, the published pose will be restricted to a pure 2D pose (no roll, pitch, or z-offset). This prevents potentially unwanted out-of-plane poses in 2D mode that can occur due to the pose extrapolation step (e.g. if the pose shall be published as a ‘base-footprint’-like frame)
    • 如果启用,发布的姿势将被限制为纯 2D 姿势(无滚动、俯仰或 z 偏移)。这可以防止在 2D 模式下由于姿势外推步骤而可能发生的潜在不想要的平面外姿势(例如,如果姿势应发布为类似“base-footprint”的帧)
  • use_odometry

    • If enabled, subscribes to nav_msgs/Odometry on the topic “odom”. Odometry must be provided in this case, and the information will be included in SLAM.
    • 如果启用,则订阅主题“odom”的 nav_msgs/Odometry。在这种情况下必须提供里程计,并且该信息将包含在 SLAM 中。
  • use_nav_sat

    • If enabled, subscribes to sensor_msgs/NavSatFix on the topic “fix”. Navigation data must be provided in this case, and the information will be included in the global SLAM.
    • 如果启用,订阅 sensor_msgs/NavSatFix 主题“fix”。在这种情况下必须提供导航数据,并且该信息将包含在全局 SLAM 中。
  • use_landmarks

    • If enabled, subscribes to cartographer_ros_msgs/LandmarkList on the topic “landmarks”. Landmarks must be provided, as cartographer_ros_msgs/LandmarkEntry within cartographer_ros_msgs/LandmarkList. If cartographer_ros_msgs/LandmarkEntry data is provided the information will be included in the SLAM accoding to the ID of the cartographer_ros_msgs/LandmarkEntry. The cartographer_ros_msgs/LandmarkList should be provided at a sample rate comparable to the other sensors. The list can be empty but has to be provided because Cartographer strictly time orders sensor data in order to make the landmarks deterministic. However it is possible to set the trajectory builder option “collate_landmarks” to false and allow for a non-deterministic but also non-blocking approach.如果启用,订阅主题“landmarks”的cartographer_ros_msgs/LandmarkList。
    • 必须提供地标,作为 cartographer_ros_msgs/LandmarkList 中的 cartographer_ros_msgs/LandmarkEntry。如果提供了 cartographer_ros_msgs/LandmarkEntry 数据,则该信息将包含在 SLAM 中,对应于 cartographer_ros_msgs/LandmarkEntry 的 ID。 cartographer_ros_msgs/LandmarkList 应以与其他传感器相当的采样率提供。该列表可以为空,但必须提供,因为 Cartographer 严格按时间排序传感器数据,以使地标具有确定性。然而,可以将轨迹构建器选项“collate_landmarks”设置为 false,并允许使用非确定性但也非阻塞的方法。
  • num_laser_scans

    • Number of laser scan topics to subscribe to. Subscribes to sensor_msgs/LaserScan on the “scan” topic for one laser scanner, or topics “scan_1”, “scan_2”, etc. for multiple laser scanners.
    • 要订阅的激光扫描主题数。订阅 sensor_msgs/LaserScan 的“scan”主题以获取一台激光扫描仪,或订阅“scan_1”、“scan_2”等主题以获取多台激光扫描仪。
  • num_multi_echo_laser_scans

    • Number of multi-echo laser scan topics to subscribe to. Subscribes to sensor_msgs/MultiEchoLaserScan on the “echoes” topic for one laser scanner, or topics “echoes_1”, “echoes_2”, etc. for multiple laser scanners.
    • 要订阅的多回波激光扫描主题数。订阅 sensor_msgs/MultiEchoLaserScan 关于“echoes”主题的一个激光扫描仪,或主题“echoes_1”、“echoes_2”等,用于多个激光扫描仪。
  • num_subdivisions_per_laser_scan

    • Number of point clouds to split each received (multi-echo) laser scan into. Subdividing a scan makes it possible to unwarp scans acquired while the scanners are moving. There is a corresponding trajectory builder option to accumulate the subdivided scans into a point cloud that will be used for scan matching.
    • 将每个接收到的(多回波)激光扫描分割成的点云数量。细分扫描可以解开扫描仪移动时获取的扫描。有一个相应的轨迹构建器选项可将细分扫描累积到将用于扫描匹配的点云中。
  • num_point_clouds

    • Number of point cloud topics to subscribe to. Subscribes to sensor_msgs/PointCloud2 on the “points2” topic for one rangefinder, or topics “points2_1”, “points2_2”, etc. for multiple rangefinders.
    • 要订阅的点云主题数。订阅一个测距仪的“points2”主题的sensor_msgs/PointCloud2,或多个测距仪的“points2_1”、“points2_2”等主题。
  • lookup_transform_timeout_sec

    • Timeout in seconds to use for looking up transforms using tf2.
    • 用于使用 tf2 查找转换的超时(以秒为单位)。
  • submap_publish_period_sec

    • Interval in seconds at which to publish the submap poses, e.g. 0.3 seconds.
    • 发布子图姿势的时间间隔(以秒为单位),例如0.3 秒。
  • pose_publish_period_sec

    • Interval in seconds at which to publish poses, e.g. 5e-3 for a frequency of 200 Hz.
    • 发布姿势的时间间隔(以秒为单位),例如对于 200 Hz 的频率,请参见 5e-3。
  • publish_to_tf

    • Enable or disable providing of TF transforms.
    • 启用或禁用提供 TF 转换。
  • publish_tracked_pose

    • Enable publishing of tracked pose as a geometry_msgs/PoseStamped to topic “tracked_pose”.
    • 启用将跟踪姿势作为geometry_msgs/PoseStamped 发布到主题“tracked_pose”。
  • trajectory_publish_period_sec

    • Interval in seconds at which to publish the trajectory markers, e.g. 30e-3 for 30 milliseconds.
    • 发布轨迹标记的时间间隔(以秒为单位),例如30e-3 持续 30 毫秒。
  • rangefinder_sampling_ratio

    • Fixed ratio sampling for range finders messages.
    • 范围查找器消息的固定比率采样。
  • odometry_sampling_ratio

    • Fixed ratio sampling for odometry messages.
    • 里程计消息的固定比率采样。
  • fixed_frame_sampling_ratio

    • Fixed ratio sampling for fixed frame messages.
    • 固定帧消息的固定比率采样。
  • imu_sampling_ratio

    • Fixed ratio sampling for IMU messages.
    • IMU 消息的固定比率采样。
  • landmarks_sampling_ratio

    • Fixed ratio sampling for landmarks messages.
    • 地标消息的固定比率采样。
  • 3
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 要在ROS Noetic安装Cartographer,可以按照以下步骤进行操作: 1. 首先,确保已经安装ROS Noetic。如果没有安装,请先安装ROS Noetic。 2. 打开终端,输入以下命令来安装Cartographer: ``` sudo apt-get install -y python-wstool python-rosdep ninja-build ``` 3. 然后,创建一个工作空间并初始化wstool: ``` mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src git clone https://github.com/cartographer-project/cartographer.git git clone https://github.com/cartographer-project/cartographer_ros.git cd .. rosdep update rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y ``` 4. 编译Cartographer: ``` catkin_make_isolated --install --use-ninja ``` 5. 设置环境变量: ``` source ~/catkin_ws/install_isolated/setup.bash ``` 6. 测试Cartographer是否安装成功: ``` roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=`rospack find cartographer_ros`/test/backpack_2d/cartographer_paper_deutsches_museum.bag ``` 如果一切正常,Cartographer就已经成功安装了。 希望这些步骤能够帮助你安装Cartographer。 ### 回答2: 首先,安装ROS NoeticROS Noetic 是一个特定版本的ROS,我们需要先安装 ROS Noetic,才能安装 Cartographer安装ROS Noetic 后,接下来是安装 Cartographer。 1. 添加 Cartographer 的软件源: ```bash sudo apt-get install -y python-wstool python-rosdep ninja-build stow cd ~/ mkdir -p cartographer_ws/src cd cartographer_ws wstool init src wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall wstool update -t src ``` 2. 安装依赖: ```bash src/cartographer/scripts/install_proto3.sh sudo rosdep init rosdep update rosdep install --from-paths src --ignore-src --rosdistro=noetic -y ``` 3. 编译 Cartographer: ```bash catkin_make_isolated --install --use-ninja source install_isolated/setup.bash ``` 现在,Cartographer安装就完成了! 如果要验证是否安装成功, 转到某个已经运行的用于创建地图的ROS包目录中,并以仿真方式运行数据采集: ```bash source /opt/ros/noetic/setup.bash source /path/to/your/catkin_ws/devel/setup.bash roslaunch your_mapping_package your_cartographer_mapping.launch bag_filename:=/path/to/your/input.bag ``` 注意,这是一个示例,有关使用Cartographer的详细说明将涉及更多内容,例如如何运行机器人,生成bag文件和使用主题等等,还有一些常见的参数,用于地图构建,对于不同的应用程序可以配置各种也是不一样的。 ### 回答3: ROS NoeticROS的最新版本,其中包含了许多新的功能和统一的开发环境,使得ROS的开发和运行更加高效可靠。CartographerROS下用于2D或3D SLAM的工具,其功能强大,使用也相对简单,是目前ROS下最受欢迎的SLAM算法之一。 那么如何在ROS Noetic安装Cartographer呢?以下是一个简单的步骤: 1.首先,确保您已经安装ROS Noetic并且ROS环境已经正常配置了,这可以通过运行以下几个命令来查看: $ echo $ROS_DISTRO noetic $ env | grep ROS 2.安装Cartographer依赖的一些库: $ sudo apt-get update $ sudo apt-get install -y python-wstool python-rosdep ninja-build $ sudo rosdep init $ rosdep update 3.使用wstool来获取Cartographer代码并建立软连接: $ cd ~/ $ mkdir catkin_ws $ cd catkin_ws/ $ wstool init src $ wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall $ wstool update -t src $ rm -rfv src/cartographer_ros/cartographer_ros/reading/* src/cartographer_ros/cartographer_ros/urdf/* src/cartographer_ros/cartographer_ros/tf/* src/cartographer_ros/cartographer_ros/msg/* src/cartographer_ros/cartographer_ros/srv/* $ rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y 4.编译Cartographer: $ sudo apt-get install -y google-mock libboost-all-dev $ sudo apt-get remove -y ros-${ROS_DISTRO}-catkin $ sudo apt-get install -y python-catkin-tools $ catkin_make_isolated --install --use-ninja 5.运行Cartographer: $ source ~/catkin_ws/install_isolated/setup.bash $ roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag 以上就是在ROS Noetic安装Cartographer的简单步骤,当然,如果你是第一次安装ROSCartographer,在这个过程中可能会遇到一些错误,不过不要紧,通过搜索搜索引擎,或者参考Cartographer官方文档,你一定能够顺利完成安装
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值