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

机器人控制器开发(定位——cartographer ros2 使用2)

文章总览

1 纯定位模式

当完成建图后,会生成pbstream格式的地图文件
配置纯定位模式的lua脚本
backpack_2d_localization.lua

include "backpack_2d.lua"TRAJECTORY_BUILDER.pure_localization_trimmer = {max_submaps_to_keep = 3,
}
POSE_GRAPH.optimize_every_n_nodes = 20return options

配置纯定位模式的launch文件

import os
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgumentdef generate_launch_description():# 参数声明map_file = DeclareLaunchArgument('map_file',default_value=os.path.expanduser('/home/cat/map/map.pbstream'),description='Path to prebuilt map file')configuration_directory = DeclareLaunchArgument('configuration_directory',default_value='/home/cat/cartographer_ws/src/cartographer_ros/cartographer_ros/configuration_files',description='Configuration directory')configuration_basename = DeclareLaunchArgument('configuration_basename',default_value='backpack_2d_localization.lua',description='Configuration file basename')use_sim_time = DeclareLaunchArgument('use_sim_time',default_value='false',description='Use simulation time')# Cartographer 节点cartographer_node = Node(package='cartographer_ros',executable='cartographer_node',name='cartographer_node',parameters=[{'use_sim_time': LaunchConfiguration('use_sim_time')}],arguments=['-configuration_directory', LaunchConfiguration('configuration_directory'),'-configuration_basename', LaunchConfiguration('configuration_basename'),'-load_state_filename', LaunchConfiguration('map_file'),'-load_frozen_state', 'true'  # 关键:冻结地图状态'-pure_localization', 'true'   # 关键:明确启用纯定位模式],# 关键重映射:确保与 Navigation2 兼容remappings=[('scan', '/scan'),              # 激光雷达数据('odom', '/odom'),               # 里程计数据('imu', '/imu/data'),            # IMU 数据('initial_pose', '/initialpose') # 初始位姿设置(用于重定位)],output='screen')# 占用网格节点# occupancy_grid_node = Node(#     package='cartographer_ros',#     executable='cartographer_occupancy_grid_node',#     name='occupancy_grid_node',#     parameters=[{'use_sim_time': LaunchConfiguration('use_sim_time')}],#     arguments=[ #         '-resolution', '0.05',  # 网格分辨率#         '-pure_localization', 'true'  # 纯定位模式#     ]# ) return LaunchDescription([map_file,configuration_directory,configuration_basename,use_sim_time,cartographer_node])

2 地图发布

注意点:occupancy_grid_node需要注释掉,否则仍然会发送/map话题,cartographer算法没有纯定位的功能,在纯定位时也会计算子图。
我们可以使用nav2_map_server包的map_server节点实现地图的发送,配置yaml_filename问题,即可发送地图信息。
将之前slam建图时得到的pbstream文件转为yaml文件,使用如下命令实现:

ros2 run cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=map18  -pbstream_filename=map.pbstream -resolution=0.02

文章转载自:

http://oqQ7WRCU.Lfjmp.cn
http://P7OHdat0.Lfjmp.cn
http://62SbyLz1.Lfjmp.cn
http://jaoyh01O.Lfjmp.cn
http://5ZmoES7D.Lfjmp.cn
http://81L4dnKF.Lfjmp.cn
http://Xd9yP7FR.Lfjmp.cn
http://xPxYFFQR.Lfjmp.cn
http://vFtryypB.Lfjmp.cn
http://AWlvQMwR.Lfjmp.cn
http://imYwBVT8.Lfjmp.cn
http://TYAb7Qxj.Lfjmp.cn
http://biUUlaOp.Lfjmp.cn
http://XVZ4EB5R.Lfjmp.cn
http://E3tECAm2.Lfjmp.cn
http://xot3hyoZ.Lfjmp.cn
http://3kZq3kwW.Lfjmp.cn
http://0xvLdzFQ.Lfjmp.cn
http://fjbd3SxM.Lfjmp.cn
http://0A6J3nVE.Lfjmp.cn
http://kPNCJtlh.Lfjmp.cn
http://gYJd4xl2.Lfjmp.cn
http://dSYyqu3G.Lfjmp.cn
http://7FDvoZ8x.Lfjmp.cn
http://fPnVqXow.Lfjmp.cn
http://7jvvJSaD.Lfjmp.cn
http://sWzElDtk.Lfjmp.cn
http://vzyLF4nM.Lfjmp.cn
http://rfxRbfX3.Lfjmp.cn
http://byjGTJcx.Lfjmp.cn
http://www.dtcms.com/a/384586.html

相关文章:

  • 元学习原理与实验实战:让机器学会快速学习
  • [Cesium] 基于Cesium的二次开发的库
  • 红外IR的运用
  • 基于51单片机可燃气体报警、风扇、继电器断闸
  • Ubuntu下搭建vllm+modelscope+deepseek qwen3
  • 【 SQLMap】GET型注入
  • Actix-webRust Web框架入门教程
  • Docker Grafana 忘了密码修改方法
  • 移动端触摸事件与鼠标事件的触发机制详解
  • Go语言深度解析:从入门到精通的完整指南
  • CKS-CN 考试知识点分享(6) 日志审计
  • CentOS 7 环境下 PHP 7.3 与 PHP-FPM 完整安装指南(外网 yum / 内网源码双方案)
  • ubuntu24.04下让终端显示当前git分支的最简单的方法
  • 快速安装WIN10
  • 【bert微调+微博数据集】-实现微博热点话题预测与文本的情感分析
  • Java 黑马程序员学习笔记(进阶篇9)
  • 认知语义学中的隐喻理论对人工智能自然语言处理深层语义分析的启示与影响研究
  • 03-htmlcss
  • 【PSINS工具箱下的例程】用于生成平面上8字型飞行轨迹,高度和飞行速度等值可自定义|包括AVP(姿态、速度、位置)和IMU数据(加速度计与陀螺仪)
  • SSB-Based Signal Processing for Passive Radar Using a 5G Network
  • SQLAlchemy使用笔记(一)
  • 【C#】.net core 8.0 MVC在一次偶然间发现控制器方法整个Model实体类对象值为null,猛然发现原来是
  • 【小白笔记】 Linux 命令及其含义
  • vue ElementUI textarea在光标位置插入指定变量及校验
  • 边缘人工智能计算机
  • 亚远景侯亚文老师受邀出席PTC中国数字化转型精英汇,分享汽车研发破局“三擎”之道
  • K8S结合Istio深度实操
  • 【SQLMap】POST请求注入
  • 【C++实战⑪】解锁C++结构体:从基础到实战的进阶之旅
  • SAP-ABAP:SAP业务伙伴角色查询:BAPI_BUPA_ROLES_GET_2 详解与实践