Skip to content

Instantly share code, notes, and snippets.

@ptsurko
Created February 7, 2020 18:03
Show Gist options
  • Save ptsurko/a64f980fed8ad433f10eccf64f1cfad9 to your computer and use it in GitHub Desktop.
Save ptsurko/a64f980fed8ad433f10eccf64f1cfad9 to your computer and use it in GitHub Desktop.
Read rosbag from s3 bucket
import rosbag
import rospy
import s3fs
fs = s3fs.S3FileSystem(key="<access_key>", secret="<secret_key>")
with fs.open('<bag>/<key>', 'rb') as f:
print('opened file')
bag = rosbag.Bag(f, mode='r', allow_unindexed=True, skip_index=True)
print('opened bag')
print('version: ', bag.version)
print('_file_header_pos', bag._file_header_pos)
print('_index_data_pos', bag._index_data_pos)
for topic, message, _ in bag.read_messages(topics=['/points_raw']):
print('message')
# f.read()
print('a')
@Sowjanya06
Copy link

Sowjanya06 commented Jul 6, 2020

@ptsurko
TypeError: coercing to Unicode: need string or buffer, Key found. I get this error when I try to run the following line in python
bucket = conn.get_bucket("bucket_name")
for key in bucket.list("field_test_27_06_20/cameras/", "/"): # print "{name}\t{size}\t{modified}".format( # name = key.name, # size = key.size, # modified = key.last_modified, # ) if str(key.name).endswith(bag_to_be_searched): print(str(key)) bag = rosbag.Bag("bucket_name/key")
It would be grateful If you can help me in this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment