forked from ropod-project/task-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action_models.py
66 lines (53 loc) · 2.08 KB
/
action_models.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
55
56
57
58
59
60
61
62
63
64
65
66
import uuid
from ropod.structs.action import Action
from ropod.structs.area import Area
class ActionModelLibrary(object):
@staticmethod
def get_action_model(action_name: str, action_params: list) -> Action:
action = Action()
action.id = str(uuid.uuid4())
action.type = action_name
action = getattr(ActionModelLibrary, action_name)(action, action_params)
return action
@staticmethod
def GOTO(action: Action, params: list) -> Action:
destination_area = Area()
destination_area.name = ActionModelLibrary.__room_to_camel_case(params[2])
action.areas.append(destination_area)
return action
@staticmethod
def DOCK(action: Action, params: list) -> Action:
pickup_area = Area()
pickup_area.name = ActionModelLibrary.__room_to_camel_case(params[2])
action.areas.append(pickup_area)
return action
@staticmethod
def UNDOCK(action: Action, params: list) -> Action:
return action
@staticmethod
def REQUEST_ELEVATOR(action: Action, params: list) -> Action:
return action
@staticmethod
def WAIT_FOR_ELEVATOR(action: Action, params: list) -> Action:
return action
@staticmethod
def ENTER_ELEVATOR(action: Action, params: list) -> Action:
return action
@staticmethod
def RIDE_ELEVATOR(action: Action, params: list) -> Action:
return action
@staticmethod
def EXIT_ELEVATOR(action: Action, params: list) -> Action:
exit_area = Area()
exit_area.name = ActionModelLibrary.__room_to_camel_case(params[1])
action.areas.append(exit_area)
return action
@staticmethod
def __room_to_camel_case(area_name: str) -> str:
'''Based on the current naming convention of OSM, rooms are indicated
as [prefix]Room[suffix]; however, the task planner capitalises all
strings. This method simply replaces any instance of "ROOM" in the
area name with "Room".
@param area_name -- name of an OSM area
'''
return area_name.replace('ROOM', 'Room')