google cartographer参数配置和话题转发

2023-10-31

为了对google cartographer进行实验仿真:

安装完成后首先用官方rosbag进行实验没问题后再尝试用自己的rosbag文件!

重要的参考资料:

https://google-cartographer-ros.readthedocs.io/en/latest/ros_api.html

https://google-cartographer-ros.readthedocs.io/en/latest/configuration.html

https://www.guyuehome.com/19781

需要配置自己的.lua文件

include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "base_link",
  published_frame = "odom",
  odom_frame = "odom",
  provide_odom_frame = false,
  publish_frame_projected_to_2d = true,
  use_pose_extrapolator = true,
  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 = 50e-3,
  trajectory_publish_period_sec = 50e-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 = 1
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.min_range=0.1
TRAJECTORY_BUILDER_2D.max_range=16.0
TRAJECTORY_BUILDER_2D.voxel_filter_size = 0.05
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true

return options

重要参数解释:

map_frame 创建的地图参考系地址默认map

tracking_frame 根据自己情况选择,如果有imu最好选择imu_link,其他情况可以选择base_link

published_frame发布主题的参考系,因为我的bag文件里odom系零点与map不一样,我这里选择相对odom

odom_frame:这里设置为odom,如果provide_odom_frame设置成真就会出现警告,Ignoring transform from authority "unknown_publisher" with frame_id and child_frame_id  "odom" because they are the same  因此我这里设置成false

publish_frame_projected_to_2d = true意味着只发布二维pose,没有俯仰角度等

我这里使用laserscan和odom因此设置为真,use_nav_sat表示GPS定位,use_landmarks我这里没有

num_laserscans=1表示只有一个雷达,echoes回波雷达没有

samplling_ratio表示各个数据可信度的权重,可以根据自己的情况调整!

TRAJECTORY_BUILDER_2D中的一些参数根据自己的传感器和需求进行调整,use_online_correlative_scan_matching设置为真表示实时的闭环检测!

ROSLAUNCH文件

<launch>
    <arg name = "rosbag_file" value = "/home/x/xxx.bag"/>
	<!--machine name="local_alt" address="localhost" default="true" /-->
    <param name="/use_sim_time" value="true"/>	
	<!--node name="stage_ros" pkg="stage_ros" type="stageros" args="$(find stage_ros)/xxxx.world" /-->
    <node name="player" pkg="rosbag" type="play" args=" -r 1.0 $(arg rosbag_file)" cwd="node" required="true"/>	   
    <!--param name="robot_description"
    textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf" /-->
    <!--node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /-->
    <node name="rviz" pkg="rviz" type="rviz" required="true" args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
    <node name="cartographer_node" pkg="cartographer_ros" type="cartographer_node" args=" -configuration_directory $(find cartographer_ros)/configuration_files -configuration_basename cartographer.lua" output="screen">
        <!--remap from="scan" to="/stage/xx/ranger_0/laserscan" /-->
        <!--remap from="odom" to="/stage/xx/odometry"/-->
    </node>
    <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros" type="cartographer_occupancy_grid_node" args="-resolution 0.1" />
</launch>

如果用到urdf文件的话这需要启用robot state publisher

由于本人的bag文件中的坐标系名称不符合实际需要,需要进行修改,因为启用另一个python节点进行转发

#!/usr/bin/env python  
import rospy
from nav_msgs.msg import Odometry
from geometry_msgs.msg import TransformStamped, Twist
from sensor_msgs.msg import LaserScan
from tf2_msgs.msg import TFMessage
import tf2_ros
def tf_frame(x):
    return {
        '/stage/xx/odom': 'odom',
        '/stage/xx/base_footprint': 'base_footprint',
        '/stage/xx/base_link':'base_link',
        '/stage/xx/base_laser_link':'base_laser_link'
    }.get(x,x)
def tf_callback(msg):
    tfs = []
    for tf in msg.transforms:
        t = TransformStamped()
        t.header = tf.header
        #print 'tf',tf.header.frame_id
        #print 'tf2',tf.child_frame_id
        t.header.frame_id = tf_frame(tf.header.frame_id)
        t.child_frame_id = tf_frame(tf.child_frame_id)
        t.transform=tf.transform
        tfs.append(t)
    tfm = TFMessage(tfs)
    pub_tf.publish(tfm)
def odom_callback(msg):
    odo = Odometry()
    odo.header = msg.header
    #print 'odom', msg.header.frame_id
    odo.header.frame_id=tf_frame(msg.header.frame_id)
    odo.child_frame_id = 'base_link'
    odo.pose = msg.pose
    odo.twist = msg.twist
    pub_odom.publish(odo)
def ls_callback(msg):
    ls = LaserScan()
    ls.header = msg.header
    #print 'laserscan',msg.header.frame_id
    ls.header.frame_id = tf_frame(msg.header.frame_id)
    ls.angle_min = msg.angle_min
    ls.angle_max = msg.angle_max
    ls.angle_increment = msg.angle_increment
    ls.range_min = msg.range_min
    ls.range_max = msg.range_max
    ls.ranges = msg.ranges
    ls.intensities = msg.intensities
    pub_ls.publish(ls)
if __name__ == '__main__':
    rospy.init_node('broadcaster_for_cartographer')
    #br = tf2_ros.TransformBroadcaster()
    pub_tf = rospy.Publisher('/tf', TFMessage, queue_size=1)
    rospy.Subscriber('/tf', TFMessage, tf_callback,queue_size=1)
    pub_odom = rospy.Publisher('odom', Odometry, queue_size=1)
    rospy.Subscriber('/stage/xx/odometry', Odometry, odom_callback,queue_size=100)
    pub_ls = rospy.Publisher('scan', LaserScan, queue_size=1)
    rospy.Subscriber('/stage/xx/ranger_0/laserscan', LaserScan, ls_callback,queue_size=100)
    rospy.spin()

最终效果如下:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

google cartographer参数配置和话题转发 的相关文章

随机推荐

  • OpenVAS的安装、使用及实战(GVM,Metasploit使用)

    目录 简介 环境 openvas的组件构成 安装OpenVAS 失败 安装GVM 使用GVM 更新NVT特征库 WEB页面 登录 报告生成格式 内置扫描配置方案 实战 新建任务 漏洞报告 www dvssc com service com
  • 链表面试题-单链表带环和环的入口点问题

    带环问题 判断链表是否带环 如果带环则环长是多少 求环的入口点 1 判断单链表是否带环 思路 设置一个快指针 每次走两步 再设置一个慢指针每次走一步 然后判断是否有交点即可 就好比你在环形跑道和别人赛跑 不管你俩速度如何 只要他比你快 总会
  • cuda-cnn之mnist文件读取(1)

    https github com zhxfl CUDA CNN 第一步是通过readMnistData读取训练样本和测试样本 mnist train images idx3 ubyte 训练样本 mnist train labels idx
  • 回归分析

    线性回归分析的内容 能否找到一个线性组合来说明一组自变量和因变量的关系 如果能的话 这种关系的强度有多大 也就是利用自变量的线性组合来预测因变量的能力有多强 整体解释能力是否具有统计上的显著性意义 在整体解释能力显著的情况下 哪些自变量有显
  • 【Java】BufferedOutputStream与BufferedInputStream字节缓存输出流和字节缓存输入流的使用

    理解 BufferedInputStream 用于读取文本文件内容 它继承于FilterInputStream BufferedOutputStream 本身带有一个缓冲区 在写入数据时 先放到缓冲区中 实现缓冲的数据流 BufferedO
  • bash测试test详解

    bash测试test详解 概述 任何相对完整的计算机语言都能够测试某个条件 然后根据测试的结果采取不同的动作 对于测试条件 Bash使用test命令 各种方括号和圆括号 if then结构等来测试条件 7 1 Test Constructs
  • c++调用python,传递python的类

    引用yahstudio
  • 设计模式 - abstract class和interface区别

    本文摘自书籍 大话设计模式 此系列文章GitHub地址 abstract class和interface区别 abstract class和interface在Java语言中都是用来进行抽象类 本文中的抽象类并非从abstract clas
  • 斯坦福大学吴恩达教授machine learning(1): octave安装

    刚开始学习 写博客只为督促一下自己 记录一下学习的点滴 菜鸟开始了 一 octave的下载 octave官网 点击打开链接 如图所示 下载地址 点击打开链接 如下图 我选的octave 4 22 w64 installer exe 当前最新
  • ValueError:Shape of `pred` and `label should be equal, but there are [1, 288, 384] and [1, 292, 384]

    在用PaddleSeg训练时遇到问题 ValueError Shape of pred and label should be equal but there are 1 288 384 and 1 292 384 目录 问题分析 批量查询
  • 实现 后台需要显示订单信息,但是订单信息里面涉及到查询2张表 。本代码使用了MapListHandler

    Dao层的代码实现 Service层实现 Servlet层实现 Bean 实现效果 以上是图片展示 一下是部分代码展示 DAO部分 通过查出2个表的数据where u id o id的数据MapListHandler 然后再通过遍历MapL
  • CVE-2021-21287:MiniO未授权SSRF漏洞

    一 介绍 MinIO 是一个基于Apache License v2 0开源协议的对象存储服务 它兼容亚马逊S3云存储服务接口 非常适合于存储大容量非结构化的数据 例如图片 视频 日志文件 备份数据和容器 虚拟机镜像等 而一个对象文件可以是任
  • 尼科彻斯定理

    链接 尼科彻斯定理 牛客题霸 牛客网 nowcoder com 描述 验证尼科彻斯定理 即 任何一个整数m的立方都可以写成m个连续奇数之和 例如 1 3 1 2 3 3 5 3 3 7 9 11 4 3 13 15 17 19 输入一个正整
  • [Machine Learning & Algorithm] 随机森林(Random Forest)

    1 什么是随机森林 作为新兴起的 高度灵活的一种机器学习算法 随机森林 Random Forest 简称RF 拥有广泛的应用前景 从市场营销到医疗保健保险 既可以用来做市场营销模拟的建模 统计客户来源 保留和流失 也可用来预测疾病的风险和病
  • 使用MySQL8.0以上版本和MySQL驱动包8.0以上出现的问题

    目录 1 时区问题 2 驱动程序类问题 1 时区问题 问题代码
  • dll,lib,.a,.so的联系与区别。什么是共享库?与dll的区别是什么?

    dll lib a so的联系与区别 什么是共享库 与dll的区别是什么 区别与联系 静态库与动态库 问题 疑问 什么是共享存档 其他内容 map pdb 文件 区别与联系 本文结合所学和理解进行简单了描述dll与lib a so文件的关系
  • IBatis.net介绍

    从上而下的理解IBatis net这个简易的ORM框架 1 DAL层 public class AccountService public int TestInsertOne Accounts account Object obj Mapp
  • 基于QT开发的截图工具

    概述 这是一个使用QT设计的截图工具 目前效果图 历程 意动 现在网上免费的截图工具很多 最近用了一款很不错的 叫Snipaste 这个软件就是基于QT开发的 不过并没有开源 软件设计的很好用 界面也很清新 于是我也想自己尝试这设计一个这样
  • Oracle 性能最大化

    配置和优化有什么不同 获得最大的性能 配置操作系统 配置Oracle Oracle 性能 调整和配置数据库对象 优化Oracle 最大化 如果你问很多Oracle DBA 你工作中最大的一部分是什么 几乎所有的回答都是 数据库的配置和优化
  • google cartographer参数配置和话题转发

    为了对google cartographer进行实验仿真 安装完成后首先用官方rosbag进行实验没问题后再尝试用自己的rosbag文件 重要的参考资料 https google cartographer ros readthedocs i