Noetic-cartographer跑自己的数据包----记录(脑子不好容易忘记)

2024-01-30 20:50

本文主要是介绍Noetic-cartographer跑自己的数据包----记录(脑子不好容易忘记),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

根据官网的提示 和大佬:https://blog.csdn.net/qq_40216084/article/details/104599308?的文章
1.在/cartographer_ws/install_isolated/share/cartographer_ros/目录下
(1)在上面的目录下urdf中建立你自己的urdf文件my_robot_.urdf

<!--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.
-->
<!--加上上面这个之后 你必须用gedit 这个文件的名字 进行修改-->
<robot name="mini"><material name="orange"><color rgba="1.0 0.5 0.2 1" /></material><material name="gray"><color rgba="0.2 0.2 0.2 1" /></material><link name="imu"><visual><origin xyz="0 0 0" /><geometry><box size="0.06 0.04 0.02" /></geometry><material name="orange" /></visual></link><link name="lidar_mid"><visual><origin xyz="0 0 0" /><geometry><cylinder length="0.05" radius="0.03" /></geometry><material name="gray" /></visual></link><link name="base_link" /> <joint name="imu2lidar" type="fixed"><parent link="lidar_mid" /><child link="imu" /><origin xyz="0 0 0" /></joint><joint name="base_link2lidar" type="fixed"><parent link="base_link" /><child link="imu" /><origin xyz="0 0 0" /></joint></robot>

主要是声明坐标系以及自己的车的轮廓
(2)在configuration_files文件中建立mg_robot_config.lua

include "map_builder.lua"
include "trajectory_builder.lua"options = {map_builder = MAP_BUILDER,trajectory_builder = TRAJECTORY_BUILDER,map_frame = "map",tracking_frame = "imu",  #这里用到了imu,所以跟踪的是imu,如果只用雷达,把这个写lidar_midpublished_frame = "lidar_mid",odom_frame = "odom",provide_odom_frame = false,#我不用里程计publish_frame_projected_to_2d = false,use_pose_extrapolator = false,use_odometry = false,use_nav_sat = false,#不用GPSuse_landmarks = false,num_laser_scans = 1,#雷达个数num_multi_echo_laser_scans = 0,num_subdivisions_per_laser_scan = 1,#这个参数必须要填,>=1,博主目前也没搞明白.num_point_clouds = 0,#3d的话这里要改,2d填0lookup_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 = true
TRAJECTORY_BUILDER_2D.num_accumulated_range_data = 1return options

注意:上面盖的注释删了 .lua脚本中的注释我不知道怎么写
(3)在launch文件夹中建立两个launch文件1)my_robot01.launch

<launch><param name="robot_description"textfile="$(find cartographer_ros)/urdf/my_robot_.urdf" />#这里是你第一步定义的urdf文件<node name="robot_state_publisher" pkg="robot_state_publisher"type="robot_state_publisher" /><node name="cartographer_node" pkg="cartographer_ros"type="cartographer_node" args="-configuration_directory $(find cartographer_ros)/configuration_files-configuration_basename mg_robot_config.lua"#这里是你刚才新建的lua文件(运行时删除)output="screen"><remap from="scan" to="/scan" /><!--这里是我的2d包里雷达话题/Scan到carto框架Scan的映射--><remap from="imu" to="/imu" /></node><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
</launch>

2)my_robot02.launch

<launch><param name="/use_sim_time" value="true" /><include file="$(find cartographer_ros)/launch/my_robot01.launch" />#这里是你刚才建立的launch文件<node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" /><node name="playbag" pkg="rosbag" type="play"args="--clock $(arg bag_filename)" />
</launch>

运行时要把这两个文件中的#的注释删除
2.刷新环境变量

cd ~/cartographer_ws
source install_isolated/setup.bash

下载2d数据我的自己的 网址提取码:6375
在w10中下载
拖到Ubuntu中的一个文件夹中
3.运行

roslaunch cartographer_ros my_robot02.launch bag_filename:=拖进数据的文件夹路径/2d.bag

4.差不多跑完之后保存地图
首先要安装map——server

sudo apt install ros-<ROS版本>-map-server

我是用的launch文件来接受地图的
F:

<launch><arg name="filename" value="$(find demo01)/map/nav" /><node name="map_save" pkg="map_server" type="map_saver" args="-f $(arg filename)" />
</launch>

读取save的地图

<launch><!-- 设置地图的配置文件 --><arg name="map" default="nav.yaml" /><!-- 运行地图服务器,并且加载设置的地图--><node name="map_server" pkg="map_server" type="map_server" args="$(find demo01)/map/$(arg map)"/>
</launch>

读出来的地图是
在这里插入图片描述

这篇关于Noetic-cartographer跑自己的数据包----记录(脑子不好容易忘记)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/661511

相关文章

Windows 上如果忘记了 MySQL 密码 重置密码的两种方法

《Windows上如果忘记了MySQL密码重置密码的两种方法》:本文主要介绍Windows上如果忘记了MySQL密码重置密码的两种方法,本文通过两种方法结合实例代码给大家介绍的非常详细,感... 目录方法 1:以跳过权限验证模式启动 mysql 并重置密码方法 2:使用 my.ini 文件的临时配置在 Wi

Java使用SLF4J记录不同级别日志的示例详解

《Java使用SLF4J记录不同级别日志的示例详解》SLF4J是一个简单的日志门面,它允许在运行时选择不同的日志实现,这篇文章主要为大家详细介绍了如何使用SLF4J记录不同级别日志,感兴趣的可以了解下... 目录一、SLF4J简介二、添加依赖三、配置Logback四、记录不同级别的日志五、总结一、SLF4J

在Spring Boot中浅尝内存泄漏的实战记录

《在SpringBoot中浅尝内存泄漏的实战记录》本文给大家分享在SpringBoot中浅尝内存泄漏的实战记录,结合实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录使用静态集合持有对象引用,阻止GC回收关键点:可执行代码:验证:1,运行程序(启动时添加JVM参数限制堆大小):2,访问 htt

MySQL 中查询 VARCHAR 类型 JSON 数据的问题记录

《MySQL中查询VARCHAR类型JSON数据的问题记录》在数据库设计中,有时我们会将JSON数据存储在VARCHAR或TEXT类型字段中,本文将详细介绍如何在MySQL中有效查询存储为V... 目录一、问题背景二、mysql jsON 函数2.1 常用 JSON 函数三、查询示例3.1 基本查询3.2

Python获取中国节假日数据记录入JSON文件

《Python获取中国节假日数据记录入JSON文件》项目系统内置的日历应用为了提升用户体验,特别设置了在调休日期显示“休”的UI图标功能,那么问题是这些调休数据从哪里来呢?我尝试一种更为智能的方法:P... 目录节假日数据获取存入jsON文件节假日数据读取封装完整代码项目系统内置的日历应用为了提升用户体验,

Spring Boot 配置文件之类型、加载顺序与最佳实践记录

《SpringBoot配置文件之类型、加载顺序与最佳实践记录》SpringBoot的配置文件是灵活且强大的工具,通过合理的配置管理,可以让应用开发和部署更加高效,无论是简单的属性配置,还是复杂... 目录Spring Boot 配置文件详解一、Spring Boot 配置文件类型1.1 applicatio

MySQL INSERT语句实现当记录不存在时插入的几种方法

《MySQLINSERT语句实现当记录不存在时插入的几种方法》MySQL的INSERT语句是用于向数据库表中插入新记录的关键命令,下面:本文主要介绍MySQLINSERT语句实现当记录不存在时... 目录使用 INSERT IGNORE使用 ON DUPLICATE KEY UPDATE使用 REPLACE

Python 中的异步与同步深度解析(实践记录)

《Python中的异步与同步深度解析(实践记录)》在Python编程世界里,异步和同步的概念是理解程序执行流程和性能优化的关键,这篇文章将带你深入了解它们的差异,以及阻塞和非阻塞的特性,同时通过实际... 目录python中的异步与同步:深度解析与实践异步与同步的定义异步同步阻塞与非阻塞的概念阻塞非阻塞同步

Python Dash框架在数据可视化仪表板中的应用与实践记录

《PythonDash框架在数据可视化仪表板中的应用与实践记录》Python的PlotlyDash库提供了一种简便且强大的方式来构建和展示互动式数据仪表板,本篇文章将深入探讨如何使用Dash设计一... 目录python Dash框架在数据可视化仪表板中的应用与实践1. 什么是Plotly Dash?1.1

Spring Boot中定时任务Cron表达式的终极指南最佳实践记录

《SpringBoot中定时任务Cron表达式的终极指南最佳实践记录》本文详细介绍了SpringBoot中定时任务的实现方法,特别是Cron表达式的使用技巧和高级用法,从基础语法到复杂场景,从快速启... 目录一、Cron表达式基础1.1 Cron表达式结构1.2 核心语法规则二、Spring Boot中定