target_type: 'aprilgrid' #gridtype
tagCols: 6 #number of apriltags
tagRows: 6 #number of apriltags
tagSize: 0.021 #size of apriltag, edge to edge [m]
tagSpacing: 0.285714285714 #ratio of space between tags to tagSize
codeOffset: 0 #code offset for the first tag in the aprilboard
target_type: 'aprilgrid' #gridtype
tagCols: 6 #number of apriltags
tagRows: 6 #number of apriltags
tagSize: 0.021 #size of apriltag, edge to edge [m]
tagSpacing: 0.285714285714 #ratio of space between tags to tagSize
codeOffset: 0 #code offset for the first tag in the aprilboard
%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
File.version: "1.0"
Camera.type: "PinHole"
# Camera calibration and distortion parameters (OpenCV)
Camera1.fx: 1685.16987763
Camera1.fy: 1656.93228364
Camera1.cx: 997.13041218
Camera1.cy: 474.31841484
Camera1.k1: -0.34038923175502456
Camera1.k2: 0.06977055299360228
Camera1.p1: 0.015293838790916657
Camera1.p2: -0.010372561499554008
# Camera resolution
Camera.width: 1920
Camera.height: 1080
Camera.newWidth: 600
Camera.newHeight: 350
# Camera frames per second
Camera.fps: 30
# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 1
# Transformation from camera to body-frame (imu)
IMU.T_b_c1: !!opencv-matrix
rows: 4
cols: 4
dt: f
data: [0.94880513, 0.12309341, 0.27236458, 0.00027046,
0.12309341, 0.98136615, 0.14754149, -0.00012572,
-0.29088973, -0.10646184, 0.95081494, 0.00034056,
0.0, 0.0, 0.0, 1.0]
# IMU noise
IMU.NoiseGyro: 1.2287169549703986e-05 #1.6968e-04
IMU.NoiseAcc: 1.7640241083260223e-03 #2.0e-3
IMU.GyroWalk: 8.1951127134973680e-07
IMU.AccWalk: 4.6133140085614272e-05 # 3e-03
IMU.Frequency: 30.0
#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------
# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000 # 1000
# ORB Extractor: Scale factor between levels in the scale pyramid
ORBextractor.scaleFactor: 1.2
# ORB Extractor: Number of levels in the scale pyramid
ORBextractor.nLevels: 8
# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7
#--------------------------------------------------------------------------------------------
# Viewer Parameters
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 1.0
Viewer.GraphLineWidth: 0.9
Viewer.PointSize: 2.0
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3.0
Viewer.ViewpointX: 0.0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -3.5 # -1.8
Viewer.ViewpointF: 500.0
5 Euroc单目+IMU数据集制作及跑通
用这个脚本进行拆包:
python复制代码
# -*- coding: utf-8 -*-
import rosbag
import csv
from sensor_msgs.msg import Imu
import os
import roslib
import rospy
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
from cv_bridge import CvBridgeError
import shutil
def CreateDIR():
folder_name = 'bag_tum'
subfolders = ['left', 'right' , 'rgb' , 'depth']
if not os.path.exists(folder_name):
os.makedirs(folder_name)
# 在主文件夹下创建子文件夹
for subfolder in subfolders:
subfolder_path = os.path.join(folder_name, subfolder)
if not os.path.exists(subfolder_path):
os.makedirs(subfolder_path)
def CreateIMUCSV(umpackbag):
csvfile = open('imudata.csv', 'w')
csvwriter = csv.writer(csvfile)
csvwriter.writerow(['timestamp [ns]', 'w_RS_S_x [rad s^-1]', 'w_RS_S_y [rad s^-1]', 'w_RS_S_z [rad s^-1]', 'a_RS_S_x [rad m s^-2]', 'a_RS_S_y [rad m s^-2]', 'a_RS_S_z [rad m s^-2]'])
for topic, msg, t in umpackbag.read_messages(topics=['/imu/data_raw']):
timestamp = msg.header.stamp.to_nsec()
ax = msg.linear_acceleration.x
ay = msg.linear_acceleration.y
az = msg.linear_acceleration.z
wx = msg.angular_velocity.x
wy = msg.angular_velocity.y
wz = msg.angular_velocity.z
csvwriter.writerow([timestamp, wx, wy, wz, ax, ay, az])
#umpackbag.close()
csvfile.close()
def TransIMUdatatotxt():
csv_file = './imudata.csv'
txt_file = './imudata.txt'
with open(csv_file, 'r') as file:
reader = csv.reader(file)
with open(txt_file, 'w') as output_file:
writer = csv.writer(output_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for i, row in enumerate(reader):
if i == 0:
writer.writerow(['#' + cell for cell in row]) # 添加#号
else:
writer.writerow(row)
# Save RGBD image and Save its timestamp
def Savergb(umpackbag):
path = './bag_tum/rgb/'
bridge = CvBridge()
image_names = []
txt_file = './rgbtimestamp.txt'
with rosbag.Bag(bagname, 'r') as bag:
for topic, msg, t in umpackbag.read_messages():
if topic == "/image/data_raw":
try:
cv_image = bridge.imgmsg_to_cv2(msg)
except CvBridgeError as e:
print(e)
continue
#timestr = "%.9f" % msg.header.stamp.to_sec()
timestr = "%.6f" % msg.header.stamp.to_sec()
#timestr = "%.1f" % msg.header.stamp.to_sec()
image_name = timestr
#image_name = timestr.replace('.', '') # Remove periods from the timestamp
cv2.imwrite(path + image_name + '.png', cv_image) # Save as PNG format
image_names.append(image_name) # Add image name to the list
with open(txt_file, 'w') as f:
#f.write('\n'.join(["{} rgb/{}.png".format(t, t) for t in image_names]))
f.write('\n'.join(image_names))
# Script Menu
# Make a folder name bag_tum include three sunfolder : left right rgb , in folder their image in it
# in python main.py folder , create imudata.scv and imudata.txt ,aim for KITTI or TUM dataset
# in python main.py folder , create timestamp.txt for image timestamp
# in python main.py folder , create timestamp.txt for image timestamp
if __name__ == '__main__':
bagname = 'imu_cam.bag'
umpackbag = rosbag.Bag(bagname)
CreateDIR()
CreateIMUCSV(umpackbag)
TransIMUdatatotxt()
Savergb(umpackbag)