当前位置:网站首页>ros mavros stereo读取rosbag并记录IMU和图片到文件夹
ros mavros stereo读取rosbag并记录IMU和图片到文件夹
2022-08-03 23:27:00 【qq_40247880】
长安对马
# coding:utf-8
import os
import sys
import rosbag
import roslib; # roslib.load_manifest(PKG)
import rospy
import cv2
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
def CreateFolder(FolderPath):
folder = os.path.exists(FolderPath)
if not folder: # 判断是否存在文件夹如果不存在则创建为文件夹
os.makedirs(FolderPath) # makedirs 创建文件时如果路径不存在会创建这个路径
print("--- new folder... ---")
else:
print("--- There is this folder! ---")
BagPath = sys.argv[1]
bag = rosbag.Bag(BagPath, "r")
# SavePath = "./ImgRight"
# CreateFolder(SavePath)
# bridge = CvBridge()
# TopicData = bag.read_messages('/camera/right/image_raw')
# for topic, msg, t in TopicData:
# cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
# sImgName = "/" + str(t) + ".jpg" # 图像命名:时间戳.jpg
# print(sImgName)
# # image_name = SavePath+" "+ str(Idx) + ".jpg" # 图像命名:时间戳.jpg
# image_name = SavePath + sImgName # 图像命名:时间戳.jpg
# cv2.imwrite(image_name, cv_image) # 保存;
# cv2.waitKey(1)
ImuFile = open("./Imu.txt", 'w')
TopicData = bag.read_messages('/mavros/imu/data_raw')
for topic, msg, t in TopicData:
AccX = "%.6f" % msg.linear_acceleration.x
AccY = "%.6f" % msg.linear_acceleration.y
AccZ = "%.6f" % msg.linear_acceleration.z
AngX = "%.6f" % msg.angular_velocity.x
AngY = "%.6f" % msg.angular_velocity.y
AngZ = "%.6f" % msg.angular_velocity.z
Time = "%19.9f" % msg.header.stamp.to_sec()
ImuEpoc = Time + " " + AccX + " " + AccY + " " + AccZ + " " + AngX + " " + AngY + " " + AngZ + "\n"
ImuFile.write(ImuEpoc)
ImuFile.close()
边栏推荐
- Super perfect version of the layout have shortcut, background replacement (solve the problem of opencv Chinese path)
- 使用tf.image.resize() 和tf.image.resize_with_pad()调整图像大小
- Flutter教程之为什么 Flutter 是创业的最佳选择?
- Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素科研试剂
- Scala基础【正则表达式、框架式开发原则】
- 射频芯片(RFIC)的协议之5G及其调制
- 获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
- jav一键生成数据库文档
- The "interaction design" battle of the smart cockpit
- 【并发编程】ReentrantLock的lockInterruptibly()方法源码分析
猜你喜欢

Interpretation of ML: A case of global interpretation/local interpretation of EBC model interpretability based on titanic titanic rescued binary prediction data set using interpret

The principle and use of AOSP CameraLatencyHistogram

V8中的快慢数组(附源码、图文更易理解)

MiniAPI of .NET6 (14): Cross-domain CORS (Part 1)

Creo 9.0二维草图的诊断:着色封闭环

redis持久化方式
![[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve](/img/17/342676e20fc04ce9083c5ed443bc1d.png)
[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve

- the skip/skipif Pytest learning

【深度学习】基于tensorflow的服装图像分类训练(数据集:Fashion-MNIST)

栈的压入、弹出序列
随机推荐
Click the icon in Canvas App to generate PDF and save it to Dataverse
Creo 9.0在草图环境中创建坐标系
学习笔记 | uiautomation(如何)实现自动化
redis持久化方式
Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
七夕?new一个对象
获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
二叉搜索树解决落叶问题
Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素科研试剂
(PC+WAP)织梦模板不锈钢类网站
[2022安恒夏令营] 5个小题
单例模式使用饿汉式和懒汉式创建一定安全?很多人不知
ML之yellowbrick:基于titanic泰坦尼克是否获救二分类预测数据集利用yellowbrick对LoR逻辑回归模型实现可解释性(阈值图)案例
Analysys Analysis: The transaction scale of China's online retail B2C market in Q2 2022 will reach 2,344.47 billion yuan
Create function report error, prompting DECLARE definition syntax problem
完全二叉树问题
禾匠编译错误记录
用两个栈模拟队列
Pytest学习-skip/skipif
What is the difference between the generator version and the viewer version?