当前位置:网站首页>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()
边栏推荐
- The salary of soft testers at each stage, come to Kangkang, how much can you get?
- Websocket multi-threaded sending message error TEXT_PARTIAL_WRITING--Use case of spin lock replacing synchronized exclusive lock
- Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素科研试剂
- 图论-虚拟节点分层建图
- Creo 9.0二维草图的诊断:加亮开放端点
- 用队列模拟实现栈
- 超级完美版布局有快捷键,有背景置换(解决opencv 中文路径问题)
- JS获得URL超链接的参数值
- V8中的快慢数组(附源码、图文更易理解)
- Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
猜你喜欢

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

FinClip,助长智能电视更多想象空间

用栈实现队列

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

Shell 用法梳理总结

逆波兰表达式求值

End-to-End Lane Marker Detection via Row-wise Classification

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

全球首款量产,获定点最多!这家AVP Tier1如何实现领跑?

The salary of soft testers at each stage, come to Kangkang, how much can you get?
随机推荐
用队列模拟实现栈
Flutter教程之为什么 Flutter 是创业的最佳选择?
SolidEdge ST8安装教程
utils timer
log4j-slf4j-impl cannot be present with log4j-to-slf4j
Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
Recognized by International Authorities | Yunzhuang Technology was selected in "RPA Global Market Pattern Report, Q3 2022"
【LeetCode】最长公共子序列(动态规划)
射频芯片ATE测试从入门到放弃之参数测试
OPC UA 与IEC61499 深度融合(1)
How many way of calling a function?
CAS: 178744-28-0, mPEG-DSPE, DSPE-mPEG, methoxy-polyethylene glycol-phosphatidylethanolamine supply
响应式织梦模板除尘器类网站
libnet
First domestic open source framework 】 【 general cloud computing framework, any program can be made into cloud computing.
2022/8/3 考试总结
jav一键生成数据库文档
Republish the lab report
leetcode/子串中不能有重复字符的最长子串
Minimized installation of debian11