当前位置:网站首页>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()
边栏推荐
- log4j-slf4j-impl cannot be present with log4j-to-slf4j
- The super perfect layout has shortcut keys and background replacement
- 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
- Pytest learn-setup/teardown
- utils timer
- 智能座舱的「交互设计」大战
- Super perfect version of the layout have shortcut, background replacement (solve the problem of opencv Chinese path)
- 直播预告 | 构建业务智联,快速拥抱财务数字化转型
- RPA power business automation super order!
- Unity2021 releases WebGL fog effect disappearing problem
猜你喜欢
Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素科研试剂
【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
- the skip/skipif Pytest learning
Scala基础【正则表达式、框架式开发原则】
智能座舱的「交互设计」大战
软件测试内卷严重,如何提升自己的竞争力呢?
响应式织梦模板塑身瑜伽类网站
学习笔记 | uiautomation(如何)实现自动化
Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
Analysys Analysis: The transaction scale of China's online retail B2C market in Q2 2022 will reach 2,344.47 billion yuan
随机推荐
websocket多线程发送消息报错TEXT_PARTIAL_WRITING--自旋锁替换synchronized独占锁的使用案例
Unity2021发布WebGL雾效消失问题
工作小计 QT打包
图论-虚拟节点分层建图
代码随想录笔记_动态规划_416分割等和子集
牛客2022 暑期多校3 H Hacker(SAM + 线段树查询区间内部最大子段和)
RSS订阅微信公众号初探-feed43
FinClip,助长智能电视更多想象空间
Redis persistence method
超级完美版布局有快捷键,有背景置换(解决opencv 中文路径问题)
Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
Creo 9.0创建几何点
utils 定时器
internship:编写excel表的上传方法(导入)
Scala basics [regular expressions, framework development principles]
七夕?new一个对象
AOSP CameraLatencyHistogram的原理与使用
MCS-51单片机,定时1分钟,汇编程序
Republish the lab report
最小化安装debian11