2018-12-29 18:14:44 -05:00
|
|
|
import rosbag
|
|
|
|
|
import tf
|
|
|
|
|
import sys
|
|
|
|
|
from tf.msg import tfMessage
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2025-09-18 04:43:24 +00:00
|
|
|
print('Usage: $ python extract_stereo.py "2012-01-25-12-14-25"')
|
2018-12-29 18:14:44 -05:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
bagName = sys.argv[1]
|
|
|
|
|
with rosbag.Bag(bagName + '_stereo.bag', 'w') as outbag:
|
2025-09-18 04:43:24 +00:00
|
|
|
print(f'Processing {bagName}.bag...')
|
2018-12-29 18:14:44 -05:00
|
|
|
for topic, msg, t in rosbag.Bag(bagName + '.bag').read_messages():
|
|
|
|
|
if topic == "/tf":
|
|
|
|
|
outbag.write(topic, msg, t)
|
|
|
|
|
elif topic == "/wide_stereo/left/camera_info":
|
2025-09-18 04:43:24 +00:00
|
|
|
outbag.write(topic, msg, t)
|
2018-12-29 18:14:44 -05:00
|
|
|
elif topic == "/wide_stereo/right/camera_info":
|
2025-09-18 04:43:24 +00:00
|
|
|
outbag.write(topic, msg, t)
|
2018-12-29 18:14:44 -05:00
|
|
|
elif topic == "/wide_stereo/left/image_raw":
|
2025-09-18 04:43:24 +00:00
|
|
|
outbag.write(topic, msg, t)
|
2018-12-29 18:14:44 -05:00
|
|
|
elif topic == "/wide_stereo/right/image_raw":
|
2025-09-18 04:43:24 +00:00
|
|
|
outbag.write(topic, msg, t)
|
2018-12-29 18:14:44 -05:00
|
|
|
|
2025-09-18 04:43:24 +00:00
|
|
|
print(f'Output: {bagName}_stereo.bag')
|