Decide action parameters based on high-level action and current observation.
This function implements heuristic decision-making for low-level action parameters. It analyzes the current state observation to determine appropriate parameters for the given high-level action.
3def decide_parameters(obs, high_level_action):
4 """!
5 @brief Decide action parameters based on high-level action and current observation
6
7 This function implements heuristic decision-making for low-level action parameters.
8 It analyzes the current state observation to determine appropriate parameters
9 for the given high-level action.
10
11 @param obs Current state observation array
12 @param high_level_action High-level action string to execute
13 @return Tuple of (action_name, parameters) or ("None", []) if no action possible
14 """
15 n_racks = 10
16
17
18 match high_level_action:
19
20 case "unload_beluga":
21 return "unload_beluga", []
22
23
24 case "load_beluga":
25 for i in range(3):
26 if obs[1 + i] == 0:
27 return "load_beluga", {"trailer_beluga": i, "none": None}
28
29
30 case "right_unstack_rack":
31 for rack_idx in range(n_racks):
32 slot = 10 + rack_idx * 3
33 if obs[slot + 1] == 1:
34 for trailer_idx in range(3):
35 if obs[4 + trailer_idx] == 0.5:
36 return "right_unstack_rack", {"rack": rack_idx, "trailer_id": trailer_idx}
37
38
39 case "left_unstack_rack":
40 for rack_idx in range(n_racks):
41 slot = 10 + rack_idx * 3
42 if obs[slot] == 1:
43 for trailer_idx in range(3):
44 if obs[1 + trailer_idx] == 0.5:
45 return "left_unstack_rack", {"rack": rack_idx, "trailer_id": trailer_idx}
46
47
48 case "get_from_hangar":
49 for hangar_idx in range(3):
50 if obs[7 + hangar_idx] == 1:
51 for trailer_idx in range(3):
52 if obs[4 + trailer_idx] == 0.5:
53 return "get_from_hangar", {"hangar": hangar_idx, "trailer_factory": trailer_idx}
54
55
56 case "deliver_to_hangar":
57 for trailer_idx in range(3):
58 if obs[4 + trailer_idx] == 1:
59 for hangar_idx in range(3):
60 if obs[7 + hangar_idx] == 0:
61 return "deliver_to_hangar", {"hangar": hangar_idx, "trailer_factory": trailer_idx}
62
63
64
65 case _:
66 return "None", []
67
68 return "None", []