Skip to content

Commit c1d2ada

Browse files
Tom AlmogTom Almog
authored andcommitted
fixed according to review
1 parent f9e64dd commit c1d2ada

27 files changed

+616
-248
lines changed

.DS_Store

6 KB
Binary file not shown.

bootcamp_main.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# Set queue max sizes (<= 0 for infinity)
3232
TELEM_TO_COMMAND_QUEUE_MAX = 32
3333
HEARTBEAT_RECV_TO_MAIN_QUEUE_MAX = 64
34+
COMMAND_TO_MAIN_QUEUE_MAX = 64
3435

3536
# Set worker counts
3637
HEARTBEAT_SENDER_COUNT = 1
@@ -98,6 +99,9 @@ def main() -> int:
9899
hb_recv_to_main_queue = queue_proxy_wrapper.QueueProxyWrapper(
99100
mp_manager, HEARTBEAT_RECV_TO_MAIN_QUEUE_MAX
100101
)
102+
command_to_main_queue = queue_proxy_wrapper.QueueProxyWrapper(
103+
mp_manager, COMMAND_TO_MAIN_QUEUE_MAX
104+
)
101105

102106
# Create worker properties for each worker type (what inputs it takes, how many workers)
103107
# Heartbeat sender
@@ -156,7 +160,7 @@ def main() -> int:
156160
HEIGHT_TOLERANCE_M,
157161
),
158162
input_queues=[telem_to_command_queue],
159-
output_queues=[], # In a real system, add a main queue if needed
163+
output_queues=[command_to_main_queue],
160164
controller=controller,
161165
local_logger=main_logger,
162166
)
@@ -171,8 +175,9 @@ def main() -> int:
171175
ok, mgr = worker_manager.WorkerManager.create(
172176
worker_properties=props, local_logger=main_logger
173177
)
174-
if not ok or mgr is None:
178+
if not ok:
175179
return -1
180+
assert mgr is not None
176181
worker_managers.append(mgr)
177182

178183
# Start worker processes
@@ -194,6 +199,13 @@ def main() -> int:
194199
break
195200
except: # pylint: disable=bare-except
196201
pass
202+
# Also read any command outputs
203+
try:
204+
cmd_out = command_to_main_queue.queue.get(timeout=0.1)
205+
if cmd_out is not None:
206+
main_logger.info(f"Command: {cmd_out}")
207+
except: # pylint: disable=bare-except
208+
pass
197209

198210
# Stop the processes
199211
controller.request_exit()
@@ -203,6 +215,7 @@ def main() -> int:
203215
# Fill and drain queues from END TO START
204216
telem_to_command_queue.fill_and_drain_queue()
205217
hb_recv_to_main_queue.fill_and_drain_queue()
218+
command_to_main_queue.fill_and_drain_queue()
206219

207220
main_logger.info("Queues cleared")
208221

Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
15:56:36: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 45] Logger initialized
2-
15:56:36: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
3-
15:56:36: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
4-
15:56:40: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
5-
15:56:40: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
6-
15:56:41: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
7-
15:56:41: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
8-
15:56:42: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
9-
15:56:42: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
10-
15:56:43: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
11-
15:56:43: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
12-
15:56:44: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
13-
15:56:44: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
14-
15:56:45: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
15-
15:56:45: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
16-
15:56:46: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
17-
15:56:46: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
18-
15:56:47: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
19-
15:56:47: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
20-
15:56:48: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
21-
15:56:48: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
22-
15:56:49: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
23-
15:56:49: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
24-
15:56:50: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
25-
15:56:50: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
26-
15:56:51: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
27-
15:56:51: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
28-
15:56:55: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 83] Passed!
1+
23:51:57: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 45] Logger initialized
2+
23:51:57: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
3+
23:51:58: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
4+
23:52:01: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
5+
23:52:01: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
6+
23:52:02: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
7+
23:52:02: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
8+
23:52:03: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
9+
23:52:03: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
10+
23:52:04: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
11+
23:52:04: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
12+
23:52:05: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
13+
23:52:05: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
14+
23:52:06: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
15+
23:52:06: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
16+
23:52:07: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
17+
23:52:07: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
18+
23:52:08: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
19+
23:52:08: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
20+
23:52:09: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
21+
23:52:09: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
22+
23:52:10: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
23+
23:52:10: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
24+
23:52:11: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
25+
23:52:11: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
26+
23:52:12: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
27+
23:52:12: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 76] Received a valid command
28+
23:52:16: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/mock_drones/command_drone.py | main | 83] Passed!
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
23:51:57: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command_worker.py | command_worker | 52] Logger initialized
2+
23:51:57: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 4.000)
3+
23:51:57: [INFO] CHANGE ALTITUDE: 1.0
4+
23:51:58: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 1.000)
5+
23:51:58: [INFO] CHANGE ALTITUDE: -1.0
6+
23:51:58: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.667)
7+
23:51:59: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.500)
8+
23:51:59: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.400)
9+
23:52:00: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.333)
10+
23:52:00: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.286)
11+
23:52:01: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 2.500, 0.250)
12+
23:52:01: [INFO] CHANGE YAW: 63.43494882292201
13+
23:52:01: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 4.444, 0.222)
14+
23:52:01: [INFO] CHANGE YAW: 90.0
15+
23:52:02: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 6.000, 0.200)
16+
23:52:02: [INFO] CHANGE YAW: 116.56505117707799
17+
23:52:02: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (1.818, 5.455, 0.182)
18+
23:52:02: [INFO] CHANGE YAW: 45.0
19+
23:52:03: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (3.333, 5.000, 0.167)
20+
23:52:03: [INFO] CHANGE YAW: 63.43494882292201
21+
23:52:03: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (4.615, 4.615, 0.154)
22+
23:52:03: [INFO] CHANGE YAW: 90.0
23+
23:52:04: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (4.286, 2.857, 0.143)
24+
23:52:04: [INFO] CHANGE YAW: 26.565051177077994
25+
23:52:04: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (4.000, 1.333, 0.133)
26+
23:52:04: [INFO] CHANGE YAW: 45.0
27+
23:52:05: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (3.750, 0.000, 0.125)
28+
23:52:05: [INFO] CHANGE YAW: 90.0
29+
23:52:05: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (2.353, 0.000, 0.118)
30+
23:52:05: [INFO] CHANGE YAW: 45.0
31+
23:52:06: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (1.111, 0.000, 0.111)
32+
23:52:06: [INFO] CHANGE YAW: 90.0
33+
23:52:06: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.105)
34+
23:52:06: [INFO] CHANGE YAW: 135.0
35+
23:52:07: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 1.000, 0.100)
36+
23:52:07: [INFO] CHANGE YAW: -26.565051177077994
37+
23:52:07: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 1.905, 0.095)
38+
23:52:07: [INFO] CHANGE YAW: -45.0
39+
23:52:08: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 2.727, 0.091)
40+
23:52:08: [INFO] CHANGE YAW: -90.0
41+
23:52:08: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.870, 2.609, 0.087)
42+
23:52:08: [INFO] CHANGE YAW: -45.0
43+
23:52:09: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (1.667, 2.500, 0.083)
44+
23:52:09: [INFO] CHANGE YAW: -90.0
45+
23:52:09: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (2.400, 2.400, 0.080)
46+
23:52:09: [INFO] CHANGE YAW: -135.0
47+
23:52:10: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (2.308, 1.538, 0.077)
48+
23:52:10: [INFO] CHANGE YAW: -63.43494882292201
49+
23:52:10: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (2.222, 0.741, 0.074)
50+
23:52:10: [INFO] CHANGE YAW: -90.0
51+
23:52:11: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (2.143, 0.000, 0.071)
52+
23:52:11: [INFO] CHANGE YAW: -116.56505117707799
53+
23:52:11: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (1.379, 0.000, 0.069)
54+
23:52:11: [INFO] CHANGE YAW: -45.0
55+
23:52:12: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.667, 0.000, 0.067)
56+
23:52:12: [INFO] CHANGE YAW: -63.43494882292201
57+
23:52:12: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/command/command.py | run | 100] Average velocity: (0.000, 0.000, 0.065)
58+
23:52:12: [INFO] CHANGE YAW: -90.0

logs/command/command_worker_90661.log

Lines changed: 0 additions & 32 deletions
This file was deleted.

logs/command/main.log

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
15:56:35: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/common/modules/logger/logger_main_setup.py | setup_main_logger | 62] main logger initialized
2-
15:56:36: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/test_command.py | main | 144] Connected!
3-
15:56:36: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/test_command.py | read_queue | 81] CHANGE ALTITUDE: 1.0
4-
15:56:36: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/test_command.py | read_queue | 81] CHANGE ALTITUDE: -1.0
1+
23:51:56: [INFO] [/Users/tomalmog/Clubs/WARG/p2/modules/common/modules/logger/logger_main_setup.py | setup_main_logger | 62] main logger initialized
2+
23:51:57: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/test_command.py | main | 144] Connected!
3+
23:51:57: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/test_command.py | read_queue | 81] CHANGE ALTITUDE: 1.0
4+
23:51:58: [INFO] [/Users/tomalmog/Clubs/WARG/p2/tests/integration/test_command.py | read_queue | 81] CHANGE ALTITUDE: -1.0

0 commit comments

Comments
 (0)