Created
November 26, 2018 05:49
-
-
Save safijari/bcc2b709efc6025c4ae1cb174089cf05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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