当前位置:网站首页>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()
边栏推荐
- [2022强网杯] polydiv和gamemaster
- override学习(父类和子类)
- Unity2021发布WebGL雾效消失问题
- ML's yellowbrick: A case of interpretability (threshold map) for LoR logistic regression model using yellowbrick based on whether Titanic was rescued or not based on the two-class prediction dataset
- 工作小计 QT打包
- BMN: Boundary-Matching Network for Temporal Action Proposal Generation Reading Notes
- libnet
- V8中的快慢数组(附源码、图文更易理解)
- 【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
- 二叉搜索树解决落叶问题
猜你喜欢
End-to-End Lane Marker Detection via Row-wise Classification
直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践
First domestic open source framework 】 【 general cloud computing framework, any program can be made into cloud computing.
Creo 9.0在草图环境中创建坐标系
V8中的快慢数组(附源码、图文更易理解)
Pytest learn-setup/teardown
Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
用两个栈模拟队列
【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
二叉搜索树解决落叶问题
随机推荐
(PC+WAP)织梦模板不锈钢类网站
Click the icon in Canvas App to generate PDF and save it to Dataverse
ML之yellowbrick:基于titanic泰坦尼克是否获救二分类预测数据集利用yellowbrick对LoR逻辑回归模型实现可解释性(阈值图)案例
The salary of soft testers at each stage, come to Kangkang, how much can you get?
V8中的快慢数组(附源码、图文更易理解)
MiniAPI of .NET6 (14): Cross-domain CORS (Part 1)
Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation
最小化安装debian11
跨域的学习
静态文件快速建站
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
What is memoization and what is it good for?
2022/8/3 考试总结
图论-虚拟节点分层建图
Why Flutter Flutter of tutorials is the best choice for business?
【LeetCode】最长公共子序列(动态规划)
libnet
用两个栈模拟队列
Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
SRE运维解密-什么是SRE:DevOps模型的具体实践!