This repository was archived by the owner on Nov 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Added new integration test for communication to ground #248
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c36cb9d
Added new integration test for communication to ground
janez45 7171b50
Changed to display actions required by the test operator
janez45 d2ab6ee
changed the queue
janez45 248f2ea
update with different queue
janez45 042e829
Added metadata to queue
janez45 1674784
Changed to use worker id
janez45 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
tests/integration/test_communications_to_ground_station.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| """ | ||
| Test MAVLink integration test | ||
| """ | ||
|
|
||
| import multiprocessing as mp | ||
| import time | ||
|
|
||
| from utilities.workers import queue_proxy_wrapper | ||
| from utilities.workers import worker_controller | ||
|
|
||
| from modules.common.modules import position_global | ||
| from modules.common.modules.data_encoding import message_encoding_decoding | ||
| from modules.flight_interface import flight_interface_worker | ||
|
|
||
|
|
||
| MAVLINK_CONNECTION_ADDRESS = "tcp:localhost:14550" | ||
| FLIGHT_INTERFACE_TIMEOUT = 30.0 # seconds | ||
| FLIGHT_INTERFACE_BAUD_RATE = 57600 # symbol rate | ||
| FLIGHT_INTERFACE_WORKER_PERIOD = 0.1 # seconds | ||
|
|
||
|
|
||
| def apply_communications_test( | ||
| communications_input_queue: queue_proxy_wrapper.QueueProxyWrapper, | ||
| ) -> bool: | ||
| """ | ||
| Method to send in hardcoded GPS coordinates to the flight interface worker | ||
| """ | ||
| gps_coordinates = [ | ||
| position_global.PositionGlobal.create(43.47321268948186, -80.53950244232878, 10), # E7 | ||
| position_global.PositionGlobal.create(37.7749, 122.4194, 30), # San Francisco | ||
| position_global.PositionGlobal.create(40.7128, 74.0060, -5.6), # New York | ||
| position_global.PositionGlobal.create(51.5072, 0.1276, 20.1), # London UK | ||
| ] | ||
|
|
||
| # Place the GPS coordinates | ||
| print(f"Inserting list of gps coordinates, length {len(gps_coordinates)}") | ||
|
|
||
| for success, gps_coordinate in gps_coordinates: | ||
| if not success: | ||
| print("ERROR: GPS Coordinate not successfully generated") | ||
| return False | ||
|
|
||
| success, message = message_encoding_decoding.encode_position_global( | ||
| "FLIGHT_INTERFACE_WORKER", gps_coordinate | ||
|
||
| ) | ||
|
|
||
| if not success: | ||
| print("ERROR: Conversion from PositionGlobal to bytes failed") | ||
| return False | ||
|
|
||
| communications_input_queue.queue.put(message) | ||
|
|
||
| # Wait for processing | ||
| time.sleep(10) | ||
|
|
||
| # Verify that stuff is sending | ||
| print( | ||
| "TEST OPERATOR ACTION REQUIRED: Open mission planner's MAVLink inspector or the groundside repo (https://github.com/UWARG/statustext-parser-2025) to check for MAVLink messages" | ||
| ) | ||
| return True | ||
|
|
||
|
|
||
| # pylint: disable=duplicate-code | ||
| def main() -> int: | ||
| """ | ||
| Main function | ||
| """ | ||
| # Setup | ||
| controller = worker_controller.WorkerController() | ||
|
|
||
| mp_manager = mp.Manager() | ||
|
|
||
| in_queue = queue_proxy_wrapper.QueueProxyWrapper(mp_manager) | ||
| communications_input_queue = queue_proxy_wrapper.QueueProxyWrapper(mp_manager) | ||
| out_queue = queue_proxy_wrapper.QueueProxyWrapper(mp_manager) | ||
| home_position_out_queue = queue_proxy_wrapper.QueueProxyWrapper(mp_manager) | ||
|
|
||
| worker = mp.Process( | ||
| target=flight_interface_worker.flight_interface_worker, | ||
| args=( | ||
| MAVLINK_CONNECTION_ADDRESS, | ||
| FLIGHT_INTERFACE_TIMEOUT, | ||
| FLIGHT_INTERFACE_BAUD_RATE, | ||
| FLIGHT_INTERFACE_WORKER_PERIOD, | ||
| in_queue, | ||
maxlou05 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| communications_input_queue, | ||
| out_queue, | ||
| home_position_out_queue, | ||
| controller, | ||
| ), | ||
| ) | ||
|
|
||
| worker.start() | ||
|
|
||
| time.sleep(3) | ||
|
|
||
| # Test | ||
| home_position = home_position_out_queue.queue.get() | ||
| assert home_position is not None | ||
|
|
||
| # Run the apply_communication tests | ||
| test_result = apply_communications_test(communications_input_queue) | ||
| if not test_result: | ||
| print("apply_communications test failed.") | ||
| worker.terminate() | ||
| return -1 | ||
|
|
||
| # Teardown | ||
| controller.request_exit() | ||
| worker.join() | ||
|
|
||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| result_main = main() | ||
| if result_main < 0: | ||
| print(f"ERROR: Status code: {result_main}") | ||
|
|
||
| print("Done!") | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.