当前位置:网站首页>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 "interaction design" battle of the smart cockpit
- curl使用指南
- libnet
- libnet
- End-to-End Lane Marker Detection via Row-wise Classification
- 直播预告 | 构建业务智联,快速拥抱财务数字化转型
- 【论文阅读】TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
- 响应式织梦模板除尘器类网站
- 简单了解下 TCP,学习握手和挥手以及各种状态到底是怎么样的
- 使用tf.image.resize() 和tf.image.resize_with_pad()调整图像大小
猜你喜欢
Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
BMN: Boundary-Matching Network for Temporal Action Proposal Generation Reading Notes
静态文件快速建站
End-to-End Lane Marker Detection via Row-wise Classification
Scala基础【正则表达式、框架式开发原则】
Unity 截取3D图像 与 画中画PIP的实现
rosbridge-WSL2 && carla-win11
Pytest learn-setup/teardown
CAS:178744-28-0,mPEG-DSPE,DSPE-mPEG,甲氧基-聚乙二醇-磷脂酰乙醇胺供应
3D 语义分割——2DPASS
随机推荐
[2022安恒夏令营] 5个小题
Storage engine written by golang, based on b+ tree, mmap
代码随想录笔记_动态规划_416分割等和子集
rosbridge-WSL2 && carla-win11
How many way of calling a function?
完全二叉树问题
JS获得URL超链接的参数值
MCS-51单片机,定时1分钟,汇编程序
The sword refers to the offer question 22 - the Kth node from the bottom in the linked list
【LeetCode】最长回文子序列(动态规划)
End-to-End Lane Marker Detection via Row-wise Classification
libnet
BMN: Boundary-Matching Network for Temporal Action Proposal Generation阅读笔记
1067 Sort with Swap(0, i)
Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
SRE运维解密-什么是SRE:DevOps模型的具体实践!
Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
What is memoization and what is it good for?
redis持久化方式
Why Flutter Flutter of tutorials is the best choice for business?