-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_manager.py
More file actions
105 lines (82 loc) · 2.87 KB
/
Copy pathmap_manager.py
File metadata and controls
105 lines (82 loc) · 2.87 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""Map configuration and management module."""
from typing import Any
from maps.map_a_afm import AFMOpenTrackEnv
from maps.map_b_apt import APTAlignmentEnv
from maps.map_c_azr import AZRReorientationEnv
from maps.tri_mode_composite_map import TriModeCompositeEnv
class MapManager:
"""
Map manager - used for selecting maps and configuring parameters
"""
_MAP_ALIASES = {}
def __init__(self):
"""
Initialize map manager
"""
pass
def create_map(self, map_type: str, **kwargs) -> Any:
"""
Create map environment
Args:
map_type: Map type ('map_a', 'map_b', 'map_c', 'tri_mode_composite')
**kwargs: Other parameters
- start_point: Start point coordinates (x, y)
- start_heading: Start heading (rad)
- end_point: End point coordinates (x, y)
- end_heading: End heading (rad)
Returns:
Map environment object
"""
map_type = self._normalize_map_type(map_type)
if map_type == 'map_a':
env = AFMOpenTrackEnv(**kwargs)
elif map_type == 'map_b':
env = APTAlignmentEnv(**kwargs)
elif map_type == 'map_c':
env = AZRReorientationEnv(**kwargs)
elif map_type == 'tri_mode_composite':
env = TriModeCompositeEnv(**kwargs)
else:
raise ValueError(f"Unknown map type: {map_type}")
# Configure start point
if 'start_point' in kwargs:
env.set_start_point(kwargs['start_point'])
# Configure start heading
if 'start_heading' in kwargs:
env.set_start_heading(kwargs['start_heading'])
# Configure end point
if 'end_point' in kwargs:
env.set_end_point(kwargs['end_point'])
# Configure end heading
if 'end_heading' in kwargs:
env.set_end_heading(kwargs['end_heading'])
return env
@classmethod
def _normalize_map_type(cls, map_type: str) -> str:
"""Map user-facing aliases to the internal canonical map name."""
return cls._MAP_ALIASES.get(map_type, map_type)
@staticmethod
def get_available_maps() -> list:
"""
Get available map types
Returns:
list: Map type list
"""
return [
'map_a',
'map_b',
'map_c',
'tri_mode_composite',
]
@staticmethod
def validate_map_type(map_type: str) -> bool:
"""
Validate if map type is valid
Args:
map_type: Map type
Returns:
bool: Whether valid
"""
return MapManager._normalize_map_type(map_type) in {
'map_a', 'map_b', 'map_c', 'tri_mode_composite'
}