extract_stereo.py
Go to the documentation of this file.
1 import rosbag
2 import tf
3 import sys
4 from tf.msg import tfMessage
5 
6 if len(sys.argv) < 2:
7  print 'Usage: $ python extract_stereo.py "2012-01-25-12-14-25"'
8  sys.exit(0)
9 
10 bagName = sys.argv[1]
11 with rosbag.Bag(bagName + '_stereo.bag', 'w') as outbag:
12  print 'Processing ' + bagName + '.bag...'
13  leftCamInfoStatus = True
14  leftImageStatus = True
15  rightCamInfoStatus = True
16  rightImageStatus = True
17  for topic, msg, t in rosbag.Bag(bagName + '.bag').read_messages():
18  if topic == "/tf":
19  outbag.write(topic, msg, t)
20  elif topic == "/wide_stereo/left/camera_info":
21  if leftCamInfoStatus:
22  outbag.write(topic, msg, t)
23  leftCamInfoStatus = not leftCamInfoStatus
24  elif topic == "/wide_stereo/right/camera_info":
25  if rightCamInfoStatus:
26  outbag.write(topic, msg, t)
27  rightCamInfoStatus = not rightCamInfoStatus
28  elif topic == "/wide_stereo/left/image_raw":
29  if leftImageStatus:
30  outbag.write(topic, msg, t)
31  leftImageStatus = not leftImageStatus
32  elif topic == "/wide_stereo/right/image_raw":
33  if rightImageStatus:
34  outbag.write(topic, msg, t)
35  rightImageStatus = not rightImageStatus
36 
37 print 'Output: ' + bagName + '_out.bag'


rtabmap_ros
Author(s): Mathieu Labbe
autogenerated on Tue Jan 24 2023 04:04:40