-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_camera.py
executable file
·58 lines (43 loc) · 1.41 KB
/
test_camera.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
#!/usr/bin/env python3
"""Main runnable file for the codebase"""
import argparse
import logging
import time
from multiprocessing import Process, Queue
from multiprocessing.managers import BaseManager
from logger import init_logger, worker_configurer
from communication import Communication
from flight.flight import flight
from vision.camera.realsense import Realsense
from flight import config
def main() -> None:
parser: argparse.ArgumentParser = argparse.ArgumentParser()
parser.add_argument(
"-s", "--simulation", help="using the simulator", action="store_true"
)
args = parser.parse_args()
logging.debug("Simulation flag %s", "enabled" if args.simulation else "disabled")
run_threads(args.simulation)
def run_threads(sim: bool) -> None:
log_queue: Queue = Queue(-1)
logging_process = init_logger(log_queue)
logging_process.start()
worker_configurer(log_queue)
# Create new processes
logging.info("Spawning Processes")
camera: Realsense = Realsense(
config.REALSENSE_WIDTH, config.REALSENSE_HEIGHT, config.REALSENSE_FRAMERATE
)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
logging.info("All processes ended, Goodbye!")
logging_process.stop()
if __name__ == "__main__":
# Run multiprocessing function
try:
main()
except:
logging.exception("Unfixable error detected")