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

相关文章

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

统一返回JsonResult踩坑的记录

《统一返回JsonResult踩坑的记录》:本文主要介绍统一返回JsonResult踩坑的记录,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录统一返回jsonResult踩坑定义了一个统一返回类在使用时,JsonResult没有get/set方法时响应总结统一返回

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

java对接海康摄像头的完整步骤记录

《java对接海康摄像头的完整步骤记录》在Java中调用海康威视摄像头通常需要使用海康威视提供的SDK,下面这篇文章主要给大家介绍了关于java对接海康摄像头的完整步骤,文中通过代码介绍的非常详细,需... 目录一、开发环境准备二、实现Java调用设备接口(一)加载动态链接库(二)结构体、接口重定义1.类型

apache的commons-pool2原理与使用实践记录

《apache的commons-pool2原理与使用实践记录》ApacheCommonsPool2是一个高效的对象池化框架,通过复用昂贵资源(如数据库连接、线程、网络连接)优化系统性能,这篇文章主... 目录一、核心原理与组件二、使用步骤详解(以数据库连接池为例)三、高级配置与优化四、典型应用场景五、注意事

SpringBoot实现文件记录日志及日志文件自动归档和压缩

《SpringBoot实现文件记录日志及日志文件自动归档和压缩》Logback是Java日志框架,通过Logger收集日志并经Appender输出至控制台、文件等,SpringBoot配置logbac... 目录1、什么是Logback2、SpringBoot实现文件记录日志,日志文件自动归档和压缩2.1、

qtcreater配置opencv遇到的坑及实践记录

《qtcreater配置opencv遇到的坑及实践记录》我配置opencv不管是按照网上的教程还是deepseek发现都有些问题,下面是我的配置方法以及实践成功的心得,感兴趣的朋友跟随小编一起看看吧... 目录电脑环境下载环境变量配置qmake加入外部库测试配置我配置opencv不管是按照网上的教程还是de

使用nohup和--remove-source-files在后台运行rsync并记录日志方式

《使用nohup和--remove-source-files在后台运行rsync并记录日志方式》:本文主要介绍使用nohup和--remove-source-files在后台运行rsync并记录日... 目录一、什么是 --remove-source-files?二、示例命令三、命令详解1. nohup2.

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

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