Datasets:
Download code/robohome/src/tools/rplan/sample_with_topology.py from RoboParty/RoboHome: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/tools/rplan/sample_with_topology.py
- Command line
-
hf download hf://datasets/RoboParty/RoboHome/code/robohome/src/tools/rplan/sample_with_topology.py
-
curl -L -o sample_with_topology.py https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/tools/rplan/sample_with_topology.py
1.37 kB
| #!/usr/bin/env python3 | |
| """Draw a random sample of a screened library with the doors and windows the chain's topology step gives it, for draw_plans.py. | |
| sample_with_topology.py --src <repo root> --library screened.json --out sample.json [--count 12] [--seed 1] [--ids a,b,c]""" | |
| import argparse | |
| import copy | |
| import json | |
| import random | |
| import screen_library as sl | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument('--src', required=True) | |
| ap.add_argument('--library', required=True) | |
| ap.add_argument('--out', required=True) | |
| ap.add_argument('--count', type=int, default=12) | |
| ap.add_argument('--seed', type=int, default=1) | |
| ap.add_argument('--ids') | |
| args = ap.parse_args() | |
| plans = json.load(open(args.library))['plans'] | |
| if args.ids: | |
| wanted = args.ids.split(',') | |
| chosen = [p for p in plans if p['plan_id'] in wanted] | |
| else: | |
| chosen = random.Random(args.seed).sample(plans, min(args.count, len(plans))) | |
| sl.init_worker(args.src) | |
| out = [] | |
| for plan in chosen: | |
| topo = sl.NATIVE.add_plan_topology(copy.deepcopy(plan), include_windows=True) | |
| plan = copy.deepcopy(plan) | |
| plan['doors'], plan['windows'] = topo.get('doors', []), topo.get('windows', []) | |
| plan['connection_kinds'] = [(a['room_ids'], a.get('connection_kind')) for a in topo.get('topology_adjacencies', [])] | |
| out.append(plan) | |
| json.dump({'plans': out}, open(args.out, 'w')) | |
| print('wrote %d plans' % len(out)) | |