Skip to content

Instantly share code, notes, and snippets.

@ToniRV
Created January 6, 2021 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToniRV/d054fcc57b71a1691bfd9e8cfdb1bd2d to your computer and use it in GitHub Desktop.
Save ToniRV/d054fcc57b71a1691bfd9e8cfdb1bd2d to your computer and use it in GitHub Desktop.
Decompress uHumans2 dataset's rosbags
#!/usr/bin/env python3
import os
import errno
ids = {"apartment_scene":
["uHumans2_apartment_s1_00h.bag",
"uHumans2_apartment_s1_01h.bag",
"uHumans2_apartment_s1_02h.bag"
],
"office_scene":
["uHumans2_office_s1_00h.bag",
"uHumans2_office_s1_06h.bag",
"uHumans2_office_s1_12h.bag"
],
"subway_scene":
[
"uHumans2_subway_s1_00h.bag",
"uHumans2_subway_s1_24h.bag",
"uHumans2_subway_s1_36h.bag"
],
"neighborhood_scene":
[
"uHumans2_neighborhood_s1_00h.bag",
"uHumans2_neighborhood_s1_24h.bag",
"uHumans2_neighborhood_s1_36h.bag"
]
}
def run(args):
assert(os.path.exists(args.dataset_dir))
for dataset_name in ids.keys():
assert(os.path.exists(os.path.join(args.dataset_dir, dataset_name)))
print("Decompressing Rosbags for dataset: %s" % dataset_name)
for rosbag_name in ids[dataset_name].keys():
print("Decompressing rosbag: %s" % rosbag_name)
os.system("rosbag decompress %s" % os.path.join(args.dataset_dir, dataset_name, rosbag_name))
print("Done decompressing rosbag: %s" % rosbag_name)
print("Done decompressing rosbags.")
return True
def parser():
import argparse
basic_desc = "Decompress uHumans2 dataset."
shared_parser = argparse.ArgumentParser(add_help=True, description="{}".format(basic_desc))
output_opts = shared_parser.add_argument_group("output options")
output_opts.add_argument(
"--dataset_dir", type=str, help="Path to the directory where the datasets are.", required=True)
main_parser = argparse.ArgumentParser(description="{}".format(basic_desc))
sub_parsers = main_parser.add_subparsers(dest="subcommand")
sub_parsers.required = True
return shared_parser
import argcomplete
import sys
if __name__ == '__main__':
parser = parser()
argcomplete.autocomplete(parser)
args = parser.parse_args()
if run(args):
sys.exit(os.EX_OK)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment