mid360采集bag数据包以及bag包的基础操作

在上篇博客中,完成了mid360的接线、fast-lio配置,并可以用fast-lio时时跑出来点云地图。那么如何采集mid360数据呢?

一、其实还是比较简单,

(1)启动Mid360

启动sdk2的程序,注意不要用rviz_mid360.launch,因为这个所获得话题是通用话题,不是customMsg画话题,fast-lio是不能用的。如果启动的是roslaunch livox_ros_driver2 rviz_MID360.launch 则录制的是sensors_msg/pointcloud2类型的数据。

roslaunch livox_ros_driver2 msg_MID360.launch

(2)录制所有话题

rosbag record -a 

关于rosbag record的学习

rosbag record -a
	-a 表示把当前发布的所有 topic 数据都录制保存到一个 rosbag 文件中,录制的数据包名字为日期加时间,并保存到主目录中。
rosbag record /topic_name1 /topic_name2 /topic_name3
	录制/topic_name1 /topic_name2 /topic_name3话题
rosbag record -O filename.bag /topic_name1
	-O (大写)参数指定生成数据包的名字,保存在主目录下。
rosbag record -o partFileName /topic_name1
	-o (小写)参数指定生成数据包的前缀名,联合形式
<node pkg="rosbag" type="record" name="bag_record" args="/topic1 /topic2"/>
	在 launch 文件中使用 rosbag record 命令

二、在获得mid360数据之后,播放数据包,并使用fast-lio进行重建,得到重建的地图。通过如下两步就可以重建地图了。

(1)启动fast-lio

1.先cd到目录下,并source

2.roslaunch fast_lio mapping_mid360.launch

(2)播放bag包

rosbag play xx.bag

延伸知识:

rosbag play xx.bag 
	播放名称为xx.bag的bag包
rosbag play -r 2 filename.bag
	-r 后面的数字2对应播放速率
rosbag play -l filename.bag
	-l 表示循环播放
rosbag play filename.bag --topic /topic1
	只播放topic1
rosbag play --pause localization_test_scene_1.bag
	空格控制暂停与播放
rosbag play -s 10 filename.bag
	-s 表示从第几秒开始
rosbag play -u 100 filename.bag
	-u 表示仅use包的前几秒信息

三、bag包的基础操作

(1)查看bag包的信息,可以查看到消息的类型

rosbag info filename.bag
显示出来bag包的信息

(2)录制bag包出现异常情况的处理方法

假如在录制bag中出现了异常等情况,错误如下:
	运行.bag文件
		rosbag play xx_s.bag
	出现
		[ INFO] [1632745075.167633711]: Connected to master at [localhost:11311]
		[ INFO] [1632745075.169908499]: Opening rotate_platform_s.bag
		[FATAL] [1632745075.198540194]: Error reading from file: wanted 3173600016 bytes, read 597086 bytes
	修复
		rosbag reindex rotate_platform_s.bag
		
如果在录制bag中出现了异常等情况,生成的是.bag.active文件,则执行下面指令进行修复:
	rosbag reindex rotate_platform_s.bag.active
	rosbag fix rotate_platform_s.bag.active new.bag

(3)launch文件中playbag

launch文件中添加
<arg name="bag_name" value="/home/test01/mybag.bag"/> 
<node pkg="rosbag" type="play" name="rosbag" args="-r 1.0 -s 0.0 $(arg bag_name)"/>

(4)在播包的过程中,启动终端,输入rostopic list,可以查看消息

rostopic list

参考:

rosbag record 的用法(详细教程)-CSDN博客

相关推荐
破-风2 小时前
linux的用法
linux·运维·服务器
涛ing5 小时前
32. C 语言 安全函数( _s 尾缀)
linux·c语言·c++·vscode·算法·安全·vim
__雨夜星辰__5 小时前
Linux 学习笔记__Day2
linux·服务器·笔记·学习·centos 7
大耳朵土土垚5 小时前
【Linux】日志设计模式与实现
linux·运维·设计模式
深度Linux10 小时前
Linux网络编程中的零拷贝:提升性能的秘密武器
linux·linux内核·零拷贝技术
chian-ocean14 小时前
从理论到实践:Linux 进程替换与 exec 系列函数
linux·运维·服务器
拎得清n14 小时前
UDP编程
linux
敖行客 Allthinker14 小时前
从 UTC 日期时间字符串获取 Unix 时间戳:C 和 C++ 中的挑战与解决方案
linux·运维·服务器·c++
夏尔Gaesar16 小时前
Vim安装与配置教程(解决软件包Vim没有安装可候选)
linux·编辑器·vim
hunter20620616 小时前
如何监控ubuntu系统某个程序的运行状态,如果程序出现异常,对其自动重启。
linux·chrome·ubuntu