-
Notifications
You must be signed in to change notification settings - Fork 0
/
instruction_db.py
48 lines (40 loc) · 1.2 KB
/
instruction_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
""" utility functions for working with waypoints and maps """
### imports
from __future__ import with_statement
import json
class InstructionDB:
def __init__(self, instruction_db):
with open(instruction_db) as db:
data = json.load(db)
self.db = data
def __form_key(self, wp_src, wp_tgt):
key = "%s_to_%s" %(wp_src, wp_tgt)
return key
def get_path(self, wp_src, wp_tgt, config):
key = self.__form_key(wp_src, wp_tgt)
if key not in self.db:
return None
if config is None:
config='amcl-kinect'
return self.db[key][config]["path"]
def get_instructions(self, wp_src, wp_tgt, config):
key = self.__form_key(wp_src, wp_tgt)
if key not in self.db:
return None
if config is None:
config='amcl-kinect'
return self.db[key][config]["instructions"]
def get_predicted_duration(self, wp_src, wp_tgt, config):
key = self.__form_key(wp_src, wp_tgt)
if key not in self.db:
return -1
if config is None:
config='amcl-kinect'
return self.db[key][config]["time"]
def get_start_heading(self, wp_src, wp_tgt, config):
key = self.__form_key(wp_src, wp_tgt)
if key not in self.db:
return 0
if config is None:
config='amcl-kinect'
return self.db[key][config]["start-dir"]