当前位置:网站首页>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()
边栏推荐
- [Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
- AOSP CameraLatencyHistogram的原理与使用
- How many way of calling a function?
- The sword refers to the offer question 22 - the Kth node from the bottom in the linked list
- Why do we need callbacks
- Unity2021发布WebGL雾效消失问题
- 跨域的学习
- 超级完美版布局有快捷键,有背景置换(解决opencv 中文路径问题)
- 举一个 web worker 的例子
- 学习笔记 | uiautomation(如何)实现自动化
猜你喜欢

Why Flutter Flutter of tutorials is the best choice for business?

Deep integration of OPC UA and IEC61499 (1)

Recognized by International Authorities | Yunzhuang Technology was selected in "RPA Global Market Pattern Report, Q3 2022"

Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!

Redis persistence method

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

Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation

代码随想录笔记_动态规划_416分割等和子集

数据分析知识点搜集(纯粹的搜集)

Republish the lab report
随机推荐
leetcode/子串中不能有重复字符的最长子串
Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素科研试剂
log4j-slf4j-impl cannot be present with log4j-to-slf4j
Shell 用法梳理总结
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
utlis 线程池
"Digital Economy Panorama White Paper" Financial Digital User Chapter released!
为什么我们需要回调
栈的压入、弹出序列
【LeetCode】最长回文子序列(动态规划)
电子邮件安全或面临新威胁!
【并发编程】ReentrantLock的lockInterruptibly()方法源码分析
【LeetCode】最长公共子序列(动态规划)
全球首款量产,获定点最多!这家AVP Tier1如何实现领跑?
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
[2022安恒夏令营] 5个小题
软件测试内卷严重,如何提升自己的竞争力呢?
BMN: Boundary-Matching Network for Temporal Action Proposal Generation Reading Notes
HCIP BGP lab report
七夕?new一个对象