-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* send_statustext_message * updated function name * Added test script and restriction for after encoding * changed file name so pytest can't detect it * Added testing * Fixed formatting * Refactored and made error messages print * Unchanged connection address * Main guarded test_send_messages * Minor refactoring * Minor fixes --------- Co-authored-by: lilyjge <[email protected]>
- Loading branch information
1 parent
ce40732
commit c7ab98a
Showing
3 changed files
with
86 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,51 @@ | ||
""" | ||
Test script to send messages to the drone using the FlightController class. | ||
""" | ||
|
||
import time | ||
|
||
from pymavlink import mavutil | ||
|
||
from modules.mavlink.flight_controller import FlightController | ||
|
||
|
||
DELAY_TIME = 0.5 # seconds | ||
MISSION_PLANNER_ADDRESS = "tcp:localhost:5672" | ||
|
||
|
||
def main() -> int: | ||
""" | ||
Main function. | ||
""" | ||
# Connect to the vehicle | ||
success, controller = FlightController.create(MISSION_PLANNER_ADDRESS) | ||
if not success: | ||
print("Failed to connect") | ||
return -1 | ||
|
||
messages = [ # 10 random messages | ||
"System startup", | ||
"Initializing sensors", | ||
"GPS lock acquired", | ||
"Motors armed", | ||
"Taking off", | ||
"Reaching altitude", | ||
"Mission started", | ||
"Waypoint reached", | ||
"Returning home", | ||
"Landing sequence initiated", | ||
] | ||
|
||
for msg in messages: | ||
controller.send_statustext_msg(msg, mavutil.mavlink.MAV_SEVERITY_INFO) | ||
time.sleep(DELAY_TIME) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
result_main = main() | ||
if result_main != 0: | ||
print(f"ERROR: Status code: {result_main}") | ||
|
||
print("Done!") |