forked from dmar-bonn/ipp-rl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid_maps.py
54 lines (41 loc) · 1.77 KB
/
grid_maps.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
48
49
50
51
52
53
54
import logging
from typing import Dict
logger = logging.getLogger(__name__)
class GridMap:
def __init__(self, params: Dict):
self.params = params
self.mean = None
self.cov_matrix = None
@property
def x_dim(self) -> int:
"""Returns map's x-dimension in number of cells"""
if "environment" not in self.params.keys():
logger.error(f"Cannot find environment specification in config file!")
raise ValueError
if "x_dim" not in self.params["environment"].keys():
logger.error(f"Cannot find environment's x_dim specification in config file!")
raise ValueError
return self.params["environment"]["x_dim"]
@property
def y_dim(self) -> int:
"""Returns map's y-dimension in number of cells"""
if "environment" not in self.params.keys():
logger.error(f"Cannot find environment specification in config file!")
raise ValueError
if "y_dim" not in self.params["environment"].keys():
logger.error(f"Cannot find environment's y_dim specification in config file!")
raise ValueError
return self.params["environment"]["y_dim"]
@property
def resolution(self) -> int:
"""Returns grid resolution in [m/cell]"""
if "environment" not in self.params.keys():
logger.error(f"Cannot find environment specification in config file!")
raise ValueError
if "resolution" not in self.params["environment"].keys():
logger.error(f"Cannot find environment's resolution specification in config file!")
raise ValueError
return self.params["environment"]["resolution"]
@property
def num_grid_cells(self):
return self.x_dim * self.y_dim