gazebo仿真环境下cartographer应用建图(融合odom和scan) 一、环境说明ros1 noetic版本仿真环境为turtlebot3_house.world下图为笔者自己搭建的丑陋小车二、配置2.1、文章参考可以参考笔者上篇文章快速配置。链接:Turtlebot3gazebo仿真cartographer建图踩坑经验分享2.2、.lua 代码my_car/config/turtlebot3_lds_2d_gazebo.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.includemap_builder.luaincludetrajectory_builder.luaoptions{map_builderMAP_BUILDER,trajectory_builderTRAJECTORY_BUILDER,map_framemap,tracking_framebase_footprint,-- imu_link, If you are using gazebo, use base_footprint (libgazebo_ros_imus bug)published_frameodom,odom_frameodom,provide_odom_framefalse,publish_frame_projected_to_2dfalse,use_odometrytrue,use_nav_satfalse,use_landmarksfalse,num_laser_scans1,num_multi_echo_laser_scans0,num_subdivisions_per_laser_scan1,num_point_clouds0,lookup_transform_timeout_sec0.2,submap_publish_period_sec0.3,pose_publish_period_sec5e-3,trajectory_publish_period_sec30e-3,rangefinder_sampling_ratio1.,odometry_sampling_ratio1.,fixed_frame_pose_sampling_ratio1.,imu_sampling_ratio1.,landmarks_sampling_ratio1.,}MAP_BUILDER.use_trajectory_builder_2dtrueTRAJECTORY_BUILDER_2D.min_range0.1TRAJECTORY_BUILDER_2D.max_range3.5TRAJECTORY_BUILDER_2D.missing_data_ray_length3.TRAJECTORY_BUILDER_2D.use_imu_datafalse#笔者只改了这里把imu关掉 TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matchingtrueTRAJECTORY_BUILDER_2D.motion_filter.max_angle_radiansmath.rad(0.1)POSE_GRAPH.constraint_builder.min_score0.65POSE_GRAPH.constraint_builder.global_localization_min_score0.7returnoptions注意笔者这部分的代码是直接复制的turtlebot3/turtlebot3_slam/config/turtlebot3_lds_2d_gazebo.lua只把imu关掉了如上代码的中文注释部分为什么要把imu关掉呢turtlebot3官方建图融合的是odom、scan、imu但是turtlebot3的launch文件里多启动了一个turtlebot3/turtlebot3_slam/src/flat_world_imu_node.cpp节点这个节点大家可以自行研究不启动这个节点建图就会报错笔者目前能力有限暂时调过这个节点把imu关掉只融合odom和scan2.3、launch代码启动次文件前需要启动你的gazebo环境并检查tf链是否正确文件my_car/launch/new_cartographer.launch代码如下launchargnameconfiguration_basenamedefaultturtlebot3_lds_2d_gazebo.lua/!-- cartographer_node --nodepkgcartographer_rostypecartographer_nodenamecartographer_nodeargs-configuration_directory $(find my_car)/config -configuration_basename $(arg configuration_basename)outputscreen/node!-- cartographer_occupancy_grid_node --nodepkgcartographer_rostypecartographer_occupancy_grid_nodenamecartographer_occupancy_grid_nodeargs-resolution 0.05//launchrviz需在单独在一终端另行启动2.4、启动通用键盘控制节点rosrun teleop_twist_keyboard teleop_twist_keyboard.py当然如果你对move_base足够熟练可以用move_base需自行添加这样建图只需要简单鼠标点几下就可以了三、建图结果如下

相关新闻

最新新闻

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现 【免费下载链接】serenity The Serenity Operating System 🐞 项目地址: https://gitcode.com/GitHub_Trending/se/serenity 导读 本文以 getopt(3) 手册 为核心&a…

2026/10/3 16:42:15
轻量服务器还是ECS?大促云服务器选购与避坑实战指南

轻量服务器还是ECS?大促云服务器选购与避坑实战指南

每年大促节点,群里永远有人在问同一个问题:“38元的轻量服务器到底怎么抢?为什么我每次点进去都是已售罄?68元直购和99元的ECS我到底选哪个?”作为一个常年帮团队和自己采购云服务器的老用户,我太清楚这种纠…

2026/10/3 16:42:30
为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南 【免费下载链接】agents Multi-harness agentic plugin marketplace for Claude Code, Codex, Cursor, OpenCode, GitHub Copilot, and Google Antigravity 项目地址:…

2026/10/3 16:42:22
PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署 【免费下载链接】PaddleOCR Turn any PDF or image document into structured data for your AI. A powerful, lightweight OCR toolkit that bridges the gap between i…

2026/10/3 7:41:27
Spring源码解析:构造器注入的类型转换与候选匹配机制

Spring源码解析:构造器注入的类型转换与候选匹配机制

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/3 16:42:24
openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由 【免费下载链接】openai-agents-python A lightweight, powerful framework for multi-agent workflows 项目地址: https://gitcode.com/GitHub_Trending/op/openai-agents-pyth…

2026/10/3 16:42:28

日新闻

周新闻

月新闻