当前位置: 首页 > news >正文

cartographer建图与定位应用

文章目录

  • 前言
  • 一、安装cartographer
    • 1.安装环境
    • 2.源码编译
      • 2.1 下载
      • 2.2 编译
  • 二、gazebo仿真2d建图
    • 0.准备仿真环境
    • 1.编写lua文件
    • 2.编写启动文件
    • 3.建图保存
  • 三、cartographer定位 + move_base导航
    • 3.1 编写启动文件
    • 3.2 启动launch
  • 总结


前言

本文介绍cartographer在ubuntu18.04下的使用过程,作为笔记仅供参考。


一、安装cartographer

使用李想大佬的脚本进行安装,同时参考下面的文章
Cartographer 环境极速配置 + 2D 3D建图测试
在此感谢两位大佬的教程。

1.安装环境

文件下载参考上文链接。
下载完成后,将cartographer_install_2021-04-20压缩文件解压,执行安装脚本即可。

./auto-carto-build.sh

2.源码编译

2.1 下载

mkdir ~/carto_ws
cd carto_ws/
git clone https://github.com/xiangli0608/cartographer_detailed_comments_ws.git
cd cartographer_detailed_comments_ws/
git pull origin master

2.2 编译

cd cartographer_detailed_comments_ws/
./catkin_make.sh

至此,cartographer源码编译完成。

二、gazebo仿真2d建图

0.准备仿真环境

以mbot仿真机器人为例,不发布odom->dummy的TF变换,注意底盘的坐标系dummy和imu的坐标系imu_link,激光话题: /scan,里程计话题: /odom ,imu话题: /imu
在这里插入图片描述

1.编写lua文件

以2d_online.lua为例,在~/carto_ws/cartographer_detailed_comments_ws/src/cartographer_ros/cartographer_ros/configuration_files/目录下创建2d_online.lua文件,内容如下:

-- 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.include "map_builder.lua"
include "trajectory_builder.lua"options = {map_builder = MAP_BUILDER,trajectory_builder = TRAJECTORY_BUILDER,map_frame = "map",tracking_frame = "imu_link",published_frame = "dummy",odom_frame = "odom",provide_odom_frame = true,publish_frame_projected_to_2d = false,use_odometry = true,use_nav_sat = false,use_landmarks = false,num_laser_scans = 1,num_multi_echo_laser_scans = 0,num_subdivisions_per_laser_scan = 1,num_point_clouds = 0,lookup_transform_timeout_sec = 0.2,submap_publish_period_sec = 0.3,pose_publish_period_sec = 5e-3,trajectory_publish_period_sec = 30e-3,rangefinder_sampling_ratio = 1.,odometry_sampling_ratio = 1.,fixed_frame_pose_sampling_ratio = 1.,imu_sampling_ratio = 1.,landmarks_sampling_ratio = 1.,
}MAP_BUILDER.use_trajectory_builder_2d = trueTRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.2
TRAJECTORY_BUILDER_2D.max_range = 20.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = true
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 35
POSE_GRAPH.constraint_builder.min_score = 0.65return options--报错:map_by_time.h:43]Check failed: data.time > std::prev(trajectory.end())->first
--修改map_by_time.h:43行 :CHECK_GT(data.time, std::prev(trajectory.end())->first)中的CHECK_GT改为CHECK_GE--使用gazebo发布的odom数据,并发布TF变换,此时map->odom->dummy
--对使用imu数据 use_imu_data=true,要将tracking_frame设置为imu的坐标系;

2.编写启动文件

仿照lx_rs16_2d_outdoor.launch文件编写test_2d_laser.launch文件

<launch><param name="/use_sim_time" value="true" /><!-- 启动cartographer --><node name="cartographer_node" pkg="cartographer_ros"type="cartographer_node" args="-configuration_directory $(find cartographer_ros)/configuration_files-configuration_basename 2d_online.lua"output="screen"><!-- <remap from="points2" to="rslidar_points" /> --><remap from="scan" to="/scan" /><remap from="odom" to="/odom" /><remap from="imu" to="/imu" /></node><!-- 生成ros格式的地图 --><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05" /><!-- 启动rviz --><node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/lx_2d.rviz" />
</launch>

3.建图保存

roslaunch mbot_gazebo mbot_laser_nav_gazebo_t.launch
roslaunch cartographer_ros test_2d_laser.launch

开始建图
 开始建图 键盘控制机器人进行建图,效果如下
结束建图
保存地图(脚本中地图名字记得修改)

./finish_slam_2d.sh 

三、cartographer定位 + move_base导航

使用cartographer定位代替amcl定位。

3.1 编写启动文件

编写lua文件

include "2d_online.lua"TRAJECTORY_BUILDER.pure_localization_trimmer = {max_submaps_to_keep = 3,
}
MAP_BUILDER.num_background_threads = 8
POSE_GRAPH.optimize_every_n_nodes = 80return options

编写launch文件

<!--Copyright 2016 The Cartographer AuthorsLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
--><launch><!-- pbstream的地址与名称 --><arg name="load_state_filename" default="$(env HOME)/carto_ws/map/test-1.pbstream"/><param name="/use_sim_time" value="true" /><!-- 重定位用,接收/initialpose话题--><param name="/localization" type="bool" value = "1"/><param name="/set_inital_pose_x" type="double" value = "0"/><param name="/set_inital_pose_y" type="double" value = "0"/><param name="/set_inital_pose_z" type="double" value = "0.0"/><param name="/set_inital_pose_ox" type="double" value = "0.0"/><param name="/set_inital_pose_oy" type="double" value = "0.0"/><param name="/set_inital_pose_oz" type="double" value = "0"/><param name="/set_inital_pose_ow" type="double" value = "1"/><!-- 启动cartographer --><node name="cartographer_node" pkg="cartographer_ros"type="cartographer_node" args="-configuration_directory $(find cartographer_ros)/configuration_files-configuration_basename 2d_localization.lua-load_state_filename $(arg load_state_filename)"output="screen"><!-- <remap from="points2" to="rslidar_points" /> --><remap from="scan" to="scan" /><remap from="odom" to="odom" /><remap from="imu" to="imu" /></node><!-- 启动map_server --><node name="map_server" pkg="map_server" type="map_server"args="$(env HOME)/carto_ws/map/test-1.yaml" /> <!-- LX大佬修改过的--><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05-pure_localization 1" />  <!-- 启动rviz --><node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" /></launch>

3.2 启动launch

#仿真环境
roslaunch mbot_gazebo mbot_laser_nav_gazebo_t.launch
#定位及加载地图
roslaunch cartographer_ros test_2d_laser_localization.launch
#导航
roslaunch mbot_navigation nav_cloister_demo_teb.launch

从TF可看到,cartographer定位已代替amcl定位。
在这里插入图片描述导航效果图
在这里插入图片描述


总结

本文简单介绍了cartographer的使用包括建图和定位,没有进行具体的理论介绍与推导,也没有针对具体参数进行介绍,仅仅记录使用过程。

相关文章:

cartographer建图与定位应用

文章目录 前言一、安装cartographer1.安装环境2.源码编译2.1 下载2.2 编译 二、gazebo仿真2d建图0.准备仿真环境1.编写lua文件2.编写启动文件3.建图保存 三、cartographer定位 move_base导航3.1 编写启动文件3.2 启动launch 总结 前言 本文介绍cartographer在ubuntu18.04下的…...

专业解析 .bashrc 中 ROS 工作空间的加载顺序及其影响 ubuntu 机器人

专业解析 .bashrc 中 ROS 工作空间的加载顺序及其影响 在使用 ROS&#xff08;Robot Operating System&#xff09;进行开发时&#xff0c;通常会涉及多个 Catkin 工作空间&#xff08;Catkin Workspace&#xff09;。这些工作空间包含不同的 ROS 包和节点&#xff0c;可能相互…...

Apache Doris 现行版本 Docker-Compose 运行教程

特别注意&#xff01;Doris On Docker 部署方式仅限于开发环境或者功能测试环境&#xff0c;不建议生产环境部署&#xff01; 如有生产环境或性能测试集群部署诉求&#xff0c;请使用裸机/虚机部署或K8S Operator部署方案&#xff01; 原文阅读&#xff1a;Apache Doris 现行版…...

Flink四大基石之窗口(Window)使用详解

目录 一、引言 二、为什么需要 Window 三、Window 的控制属性 窗口的长度&#xff08;大小&#xff09; 窗口的间隔 四、Flink 窗口应用代码结构 是否分组 Keyed Window --键控窗 Non-Keyed Window 核心操作流程 五、Window 的生命周期 分配阶段 触发计算 六、Wi…...

NGINX配置https双向认证(自签一级证书)

一 生成自签证书 以下是生成自签证书(包括服务端和客户端的证书)的步骤&#xff0c;以下命令执行两次&#xff0c;分别生成客户端和服务端证书和私钥。具体执行可以先建两个目录client和server&#xff0c;分别进入到这两个目录下执行下面的命令。 生成私钥&#xff1a; 首先&…...

Flink双流Join

在离线 Hive 中&#xff0c;我们经常会使用 Join 进行多表关联。那么在实时中我们应该如何实现两条流的 Join 呢&#xff1f;Flink DataStream API 为我们提供了3个算子来实现双流 join&#xff0c;分别是&#xff1a; join coGroup intervalJoin 下面我们分别详细看一下这…...

【数据结构实战篇】用C语言实现你的私有队列

&#x1f3dd;️专栏&#xff1a;【数据结构实战篇】 &#x1f305;主页&#xff1a;f狐o狸x 在前面的文章中我们用C语言实现了栈的数据结构&#xff0c;本期内容我们将实现队列的数据结构 一、队列的概念 队列&#xff1a;只允许在一端进行插入数据操作&#xff0c;在另一端…...

基于web的海贼王动漫介绍 html+css静态网页设计6页+设计文档

&#x1f4c2;文章目录 一、&#x1f4d4;网站题目 二、✍️网站描述 三、&#x1f4da;网站介绍 四、&#x1f310;网站演示 五、⚙️网站代码 &#x1f9f1;HTML结构代码 &#x1f492;CSS样式代码 六、&#x1f527;完整源码下载 七、&#x1f4e3;更多 一、&#…...

2022 年 9 月青少年软编等考 C 语言三级真题解析

目录 T1. 课程冲突T2. 42 点思路分析T3. 最长下坡思路分析T4. 吃糖果思路分析T5. 放苹果思路分析T1. 课程冲突 此题为 2021 年 9 月三级第一题原题,见 2021 年 9 月青少年软编等考 C 语言三级真题解析中的 T1。 T2. 42 点 42 42 42 是: 组合数学上的第 5 5 5 个卡特兰数字…...

机器学习算法(六)---逻辑回归

常见的十大机器学习算法&#xff1a; 机器学习算法&#xff08;一&#xff09;—决策树 机器学习算法&#xff08;二&#xff09;—支持向量机SVM 机器学习算法&#xff08;三&#xff09;—K近邻 机器学习算法&#xff08;四&#xff09;—集成算法 机器学习算法&#xff08;五…...

计算机科学中的主要协议

1、主要应用层协议&#xff1a; HTTP、FTP、SMTP、POP、IMAP、DNS、TELNET和SSH等 应用层协议的主要功能是支持网络应用&#xff0c;定义了不同应用程序之间的通信规则。它们负责将用户操作转换为网络可以理解的数据格式&#xff0c;并通过传输层进行传输。应用层协议直接与用…...

下载maven 3.6.3并校验文件做md5或SHA512校验

一、下载Apache Maven 3.6.3 Apache Maven 3.6.3 官方下载链接&#xff1a; 二进制压缩包&#xff08;推荐&#xff09;: ZIP格式: https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zipTAR.GZ格式: https://archive.apache.org/dist/…...

【Android】View工作原理

View 是Android在视觉上的呈现在界面上Android提供了一套GUI库&#xff0c;里面有很多控件&#xff0c;但是很多时候我们并不满足于系统提供的控件&#xff0c;因为这样就意味这应用界面的同类化比较严重。那么怎么才能做出与众不同的效果呢&#xff1f;答案是自定义View&#…...

TIE算法具体求解-为什么是泊松方程和傅里叶变换

二维泊松方程的通俗理解 二维泊松方程 是偏微分方程的一种形式&#xff0c;通常用于描述空间中某个标量场&#xff08;如位相场、电势场&#xff09;的分布规律。其一般形式为&#xff1a; ∇ 2 ϕ ( x , y ) f ( x , y ) \nabla^2 \phi(x, y) f(x, y) ∇2ϕ(x,y)f(x,y) 其…...

postman中获取随机数、唯一ID、时间日期(包括当前日期增减)截取指定位数的字符等

在Postman中&#xff0c;您可以使用内置的动态变量和编写脚本的方式来获取随机数、唯一ID、时间日期以及截取指定位数的字符。以下是具体的操作方法&#xff1a; 一、postman中获取随机数、唯一ID、时间日期&#xff08;包括当前日期增减&#xff09;截取指定位数的字符等 获取…...

【计算机网络】实验3:集线器和交换器的区别及交换器的自学习算法

实验 3&#xff1a;集线器和交换器的区别及交换器的自学习算法 一、 实验目的 加深对集线器和交换器的区别的理解。 了解交换器的自学习算法。 二、 实验环境 • Cisco Packet Tracer 模拟器 三、 实验内容 1、熟悉集线器和交换器的区别 (1) 第一步&#xff1a;构建网络…...

flink学习(14)—— 双流join

概述 Join:内连接 CoGroup&#xff1a;内连接&#xff0c;左连接&#xff0c;右连接 Interval Join&#xff1a;点对面 Join 1、Join 将有相同 Key 并且位于同一窗口中的两条流的元素进行关联。 2、Join 可以支持处理时间&#xff08;processing time&#xff09;和事件时…...

HTTP协议详解:从HTTP/1.0到HTTP/3的演变与优化

深入浅出&#xff1a;从头到尾全面解析HTTP协议 一、HTTP协议概述 1.1 HTTP协议简介 HTTP&#xff08;HyperText Transfer Protocol&#xff0c;超文本传输协议&#xff09;是互联网上应用最广泛的通信协议之一。它用于客户端与服务器之间的数据传输&#xff0c;尤其是在Web…...

张量并行和流水线并行在Transformer中的具体部位

目录 张量并行和流水线并行在Transformer中的具体部位 一、张量并行 二、流水线并行 张量并行和流水线并行在Transformer中的具体部位 张量并行和流水线并行是Transformer模型中用于提高训练效率的两种并行策略。它们分别作用于模型的不同部位,以下是对这两种并行的具体说…...

WEB开发: 丢掉包袱,拥抱ASP.NET CORE!

今天的 Web 开发可以说进入了一个全新的时代&#xff0c;前后端分离、云原生、微服务等等一系列现代技术架构应运而生。在这个背景下&#xff0c;作为开发者&#xff0c;你一定希望找到一个高效、灵活、易于扩展且具有良好性能的框架。那么&#xff0c;ASP.NET Core 显然是一个…...

后进先出(LIFO)详解

LIFO 是 Last In, First Out 的缩写&#xff0c;中文译为后进先出。这是一种数据结构的工作原则&#xff0c;类似于一摞盘子或一叠书本&#xff1a; 最后放进去的元素最先出来 -想象往筒状容器里放盘子&#xff1a; &#xff08;1&#xff09;你放进的最后一个盘子&#xff08…...

uniapp 对接腾讯云IM群组成员管理(增删改查)

UniApp 实战&#xff1a;腾讯云IM群组成员管理&#xff08;增删改查&#xff09; 一、前言 在社交类App开发中&#xff0c;群组成员管理是核心功能之一。本文将基于UniApp框架&#xff0c;结合腾讯云IM SDK&#xff0c;详细讲解如何实现群组成员的增删改查全流程。 权限校验…...

华为云AI开发平台ModelArts

华为云ModelArts&#xff1a;重塑AI开发流程的“智能引擎”与“创新加速器”&#xff01; 在人工智能浪潮席卷全球的2025年&#xff0c;企业拥抱AI的意愿空前高涨&#xff0c;但技术门槛高、流程复杂、资源投入巨大的现实&#xff0c;却让许多创新构想止步于实验室。数据科学家…...

python打卡day49

知识点回顾&#xff1a; 通道注意力模块复习空间注意力模块CBAM的定义 作业&#xff1a;尝试对今天的模型检查参数数目&#xff0c;并用tensorboard查看训练过程 import torch import torch.nn as nn# 定义通道注意力 class ChannelAttention(nn.Module):def __init__(self,…...

Mac软件卸载指南,简单易懂!

刚和Adobe分手&#xff0c;它却总在Library里给你写"回忆录"&#xff1f;卸载的Final Cut Pro像电子幽灵般阴魂不散&#xff1f;总是会有残留文件&#xff0c;别慌&#xff01;这份Mac软件卸载指南&#xff0c;将用最硬核的方式教你"数字分手术"&#xff0…...

安卓基础(aar)

重新设置java21的环境&#xff0c;临时设置 $env:JAVA_HOME "D:\Android Studio\jbr" 查看当前环境变量 JAVA_HOME 的值 echo $env:JAVA_HOME 构建ARR文件 ./gradlew :private-lib:assembleRelease 目录是这样的&#xff1a; MyApp/ ├── app/ …...

Python+ZeroMQ实战:智能车辆状态监控与模拟模式自动切换

目录 关键点 技术实现1 技术实现2 摘要&#xff1a; 本文将介绍如何利用Python和ZeroMQ消息队列构建一个智能车辆状态监控系统。系统能够根据时间策略自动切换驾驶模式&#xff08;自动驾驶、人工驾驶、远程驾驶、主动安全&#xff09;&#xff0c;并通过实时消息推送更新车…...

【p2p、分布式,区块链笔记 MESH】Bluetooth蓝牙通信 BLE Mesh协议的拓扑结构 定向转发机制

目录 节点的功能承载层&#xff08;GATT/Adv&#xff09;局限性&#xff1a; 拓扑关系定向转发机制定向转发意义 CG 节点的功能 节点的功能由节点支持的特性和功能决定。所有节点都能够发送和接收网格消息。节点还可以选择支持一个或多个附加功能&#xff0c;如 Configuration …...

tauri项目,如何在rust端读取电脑环境变量

如果想在前端通过调用来获取环境变量的值&#xff0c;可以通过标准的依赖&#xff1a; std::env::var(name).ok() 想在前端通过调用来获取&#xff0c;可以写一个command函数&#xff1a; #[tauri::command] pub fn get_env_var(name: String) -> Result<String, Stri…...

Python 训练营打卡 Day 47

注意力热力图可视化 在day 46代码的基础上&#xff0c;对比不同卷积层热力图可视化的结果 import torch import torch.nn as nn import torch.optim as optim from torchvision import datasets, transforms from torch.utils.data import DataLoader import matplotlib.pypl…...