diff --git a/config.yaml b/config.yaml index af4d4dd8..afe5c1c9 100644 --- a/config.yaml +++ b/config.yaml @@ -56,6 +56,8 @@ flight_interface: timeout: 30.0 # seconds baud_rate: 57600 # symbol rate worker_period: 0.1 # seconds + enable_hitl: false # bool + images_path: "tests/brightspot_example" # file path data_merge: timeout: 60.0 # seconds diff --git a/main_2025.py b/main_2025.py index 1f43b8f3..45bc9ac1 100644 --- a/main_2025.py +++ b/main_2025.py @@ -50,6 +50,7 @@ def main() -> int: action="store_true", help="option to show annotated image", ) + parser.add_argument("--enable_hitl", action="store_true", help="enable the hitl workflow") args = parser.parse_args() # Configuration settings @@ -129,7 +130,8 @@ def main() -> int: ) case _: main.logger.error( - f"Inputted an invalid detect target option: {DETECT_TARGET_OPTION}", True + f"Inputted an invalid detect target option: {DETECT_TARGET_OPTION}", + True, ) return -1 @@ -137,6 +139,11 @@ def main() -> int: FLIGHT_INTERFACE_TIMEOUT = config["flight_interface"]["timeout"] FLIGHT_INTERFACE_BAUD_RATE = config["flight_interface"]["baud_rate"] FLIGHT_INTERFACE_WORKER_PERIOD = config["flight_interface"]["worker_period"] + if args.enable_hitl: + FLIGHT_INTERFACE_ENABLE_HITL = True + else: + FLIGHT_INTERFACE_ENABLE_HITL = config["flight_interface"]["enable_hitl"] + FLIGHT_INTERFACE_IMAGES_PATH = config["flight_interface"]["images_path"] DATA_MERGE_TIMEOUT = config["data_merge"]["timeout"] @@ -293,6 +300,8 @@ def main() -> int: FLIGHT_INTERFACE_TIMEOUT, FLIGHT_INTERFACE_BAUD_RATE, FLIGHT_INTERFACE_WORKER_PERIOD, + FLIGHT_INTERFACE_ENABLE_HITL, + FLIGHT_INTERFACE_IMAGES_PATH, LOG_TIMINGS, ), input_queues=[ @@ -378,7 +387,11 @@ def main() -> int: result, communications_worker_properties = worker_manager.WorkerProperties.create( count=1, target=communications_worker.communications_worker, - work_arguments=(COMMUNICATIONS_TIMEOUT, COMMUNICATIONS_WORKER_PERIOD, LOG_TIMINGS), + work_arguments=( + COMMUNICATIONS_TIMEOUT, + COMMUNICATIONS_WORKER_PERIOD, + LOG_TIMINGS, + ), input_queues=[ flight_interface_to_communications_queue, cluster_estimation_to_communications_queue, diff --git a/modules/auto_landing/auto_landing.py b/modules/auto_landing/auto_landing.py index be596d3c..14df6def 100644 --- a/modules/auto_landing/auto_landing.py +++ b/modules/auto_landing/auto_landing.py @@ -1,6 +1,6 @@ -""" -Auto-landing script that calculates the necessary parameters -for use with LANDING_TARGET MAVLink command. +""" +Auto-landing script that calculates the necessary parameters +for use with LANDING_TARGET MAVLink command. """ import math diff --git a/modules/common b/modules/common index a48579ef..14dae387 160000 --- a/modules/common +++ b/modules/common @@ -1 +1 @@ -Subproject commit a48579ef93b187e0a6b72ca941108866e270f089 +Subproject commit 14dae3875b4594178a2da6eeccb9354b7ba79ad3 diff --git a/modules/flight_interface/flight_interface.py b/modules/flight_interface/flight_interface.py index df857245..61c1a1c2 100644 --- a/modules/flight_interface/flight_interface.py +++ b/modules/flight_interface/flight_interface.py @@ -25,13 +25,23 @@ def create( timeout_home: float, baud_rate: int, local_logger: logger.Logger, + images_path: str | None, + enable_hitl: bool, ) -> "tuple[bool, FlightInterface | None]": """ address: TCP address or port. timeout_home: Timeout for home location in seconds. baud_rate: Baud rate for the connection. """ - result, controller = flight_controller.FlightController.create(address, baud_rate) + if enable_hitl: + if images_path is None: + return False, None + result, controller = flight_controller.FlightController.create( + address, baud_rate, enable_hitl, images_path=images_path + ) + else: + result, controller = flight_controller.FlightController.create(address, baud_rate) + if not result: local_logger.error("controller could not be created", True) return False, None diff --git a/modules/flight_interface/flight_interface_worker.py b/modules/flight_interface/flight_interface_worker.py index 1b420389..103d0536 100644 --- a/modules/flight_interface/flight_interface_worker.py +++ b/modules/flight_interface/flight_interface_worker.py @@ -18,6 +18,8 @@ def flight_interface_worker( timeout: float, baud_rate: int, period: float, + enable_hitl: bool, + images_path: str | None, log_timings: bool, input_queue: queue_proxy_wrapper.QueueProxyWrapper, coordinates_input_queue: queue_proxy_wrapper.QueueProxyWrapper, @@ -49,7 +51,7 @@ def flight_interface_worker( local_logger.info("Logger initialized", True) result, interface = flight_interface.FlightInterface.create( - address, timeout, baud_rate, local_logger + address, timeout, baud_rate, local_logger, images_path, enable_hitl ) if not result: local_logger.error("Worker failed to create class object", True) diff --git a/requirements-pytorch.txt b/requirements-pytorch.txt index f85de84d..080c64db 100644 --- a/requirements-pytorch.txt +++ b/requirements-pytorch.txt @@ -1,5 +1,5 @@ # For any non-Jetson computer (i.e. all developers) --extra-index-url https://download.pytorch.org/whl/cu124 -torch==2.4.1 -torchvision==0.19.1 +torch==2.7.0 +torchvision==0.22.0 ultralytics diff --git a/tests/integration/test_flight_interface_hardware.py b/tests/integration/test_flight_interface_hardware.py index 654d5134..a0f6ce72 100644 --- a/tests/integration/test_flight_interface_hardware.py +++ b/tests/integration/test_flight_interface_hardware.py @@ -11,6 +11,9 @@ MAVLINK_CONNECTION_ADDRESS = "tcp:localhost:14550" FLIGHT_INTERFACE_TIMEOUT = 10.0 # seconds FLIGHT_INTERFACE_BAUD_RATE = 57600 # symbol rate +FLIGHT_INTERFACE_WORKER_PERIOD = 0.1 # seconds +FLIGHT_ENABLE_HITL = False # bool +FLIGHT_IMAGE_PATH = "tests/brightspot_example" # file path def main() -> int: @@ -29,6 +32,8 @@ def main() -> int: FLIGHT_INTERFACE_TIMEOUT, FLIGHT_INTERFACE_BAUD_RATE, local_logger, + FLIGHT_IMAGE_PATH, + FLIGHT_ENABLE_HITL, ) assert result assert interface is not None diff --git a/tests/integration/test_flight_interface_worker.py b/tests/integration/test_flight_interface_worker.py index 97ea874a..472b3336 100644 --- a/tests/integration/test_flight_interface_worker.py +++ b/tests/integration/test_flight_interface_worker.py @@ -17,6 +17,8 @@ FLIGHT_INTERFACE_TIMEOUT = 10.0 # seconds FLIGHT_INTERFACE_BAUD_RATE = 57600 # symbol rate FLIGHT_INTERFACE_WORKER_PERIOD = 0.1 # seconds +FLIGHT_ENABLE_HITL = False # bool +FLIGHT_IMAGE_PATH = "tests/brightspot_example" # file path def apply_decision_test( @@ -115,6 +117,8 @@ def main() -> int: FLIGHT_INTERFACE_TIMEOUT, FLIGHT_INTERFACE_BAUD_RATE, FLIGHT_INTERFACE_WORKER_PERIOD, + FLIGHT_ENABLE_HITL, + FLIGHT_IMAGE_PATH, in_queue, # Added input_queue communications_in_queue, out_queue,