Skip to content

Instantly share code, notes, and snippets.

@safijari
Created November 26, 2018 05:49
Show Gist options
  • Save safijari/bcc2b709efc6025c4ae1cb174089cf05 to your computer and use it in GitHub Desktop.
Save safijari/bcc2b709efc6025c4ae1cb174089cf05 to your computer and use it in GitHub Desktop.
from glob import glob
import rosbag
import yaml
import json
import os
fnames = glob('/folder/*.bag')
print fnames
bags = [rosbag.Bag(f) for f in fnames]
for fname, bag in zip(fnames, bags):
print "processing {}".format(fname)
for topic, msg, t in bag.read_messages("/scan"):
with open(os.path.splitext(fname)[0] + ".json", 'w') as ff:
ff.write(json.dumps(yaml.load(str(msg))))
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment