This project implements a multi-process Ground Station capable of autonomously monitoring and controlling a UAV using the MAVLink communication protocol. It is built to interface with PX4, ArduPilot, and other MAVLink-compatible flight stacks. It is designed to simulate real-world airside operations, where independent workers communicate via concurrent queues to handle telemetry aggregation, heartbeat monitoring, and command issuance in real-time with no data loss.
Python, MAVLink Protocol, Multithreading, CI/CD
The core system relies on Python's multiprocessing library to ensure non-blocking operations. The "Main" process acts as the orchestrator, managing the lifecycle of four distinct worker processes:
- Sender: Broadcasts
HEARTBEAT (0)messages at 1 Hz to maintain the link with the drone. - Receiver: Monitors incoming heartbeats. Implements a watchdog timer that flags the system as "Disconnected" if 5 consecutive heartbeats are missed.
- Input: Listens for
ATTITUDE (30)andLOCAL_POSITION_NED (32)MAVLink messages. - Logic: Synchronizes these asynchronous streams into a single, cohesive
TelemetryDataobject. - Output: Pushes the unified state packet to the Command Worker.
- Objective: Keeps the drone focused on a target in 3D space.
- Yaw Control: Issues
MAV_CMD_CONDITION_YAWif the heading deviates by more than 5°. - Altitude Control: Issues
MAV_CMD_CONDITION_CHANGE_ALTif the altitude deviates by more than 0.5m. - Performance: Calculates and logs the drone's average 3D velocity vector between updates.
The system includes a suite of integration tests that spawn "Mock Drones" to validate the logic and confirm consistency of each worker.
Running Integration Tests:
# Test Heartbeat Logic
python -m tests.integration.test_heartbeat_sender
python -m tests.integration.test_heartbeat_receiver
# Test Telemetry Aggregation
python -m tests.integration.test_telemetry
# Test Command Logic
python -m tests.integration.test_command
Each of these sections include a script for the logic behind the worker, a script to instantiate and create the worker, and a respective test for each worker. This is integrated into CI/CD testing.
The Waterloo Aerial Robotics Group (WARG) helped develop the initial framework for this project. However, all logic and integration was contributed by me.