This project of M-Planner API for QGroundControl combines an interactive web interface with a backend powered by a custom coverage path planning algorithm. Missions are sent directly to QGroundControl(QGC) using MAVLink over UDP, allowing real-time waypoint updates without manual reloading.
This project is organized into different folder as follows :
├── audios
....
├── index.html --> Used to see interface
├── js
--> JavaScript for UI logic
| ├── scripts.js --> Sends map points from UI to backend via http requests
└──...
├── python
│ ├── coverage_path_planning
│ │ ├── coverage_planner.py
│ │ ├── coverage_test.py
│ │ ├── json --> Used to save json files
│ │ │ ├── json_to_numpy.py
│ │ │ ├── missionPoints.json
│ │ │ ├── pycache
│ │ │ ├── updated_missionPoints.json
| | | └── mission_29-04-2025_125308.json
--> Saves the json points individually
│ ├── flask_server.py --> Used to run planner backend
| ├── qgc_sender.py --> Handles MAVLink UDP communication to QGC
│ ├── install.txt
│ ├── planner_venv
│ └── requirements.txt
├── ...
└──
Our approach is compared with a state of art solution that could be found here :
https://github.com/rodriguesrenato/coverage-path-planning
This solution try to identify the "best" heuristic to plan the coverage path. These heuristics difference mainly in
the manner of neighborhood definition. It takes also into account the movement to operate by the robot. Based on these parameters, the approach defines a policy matrix, which in turn defines the sequence of movements given a position.
Building on these ideas, this project evolves into a complete mission planning framework by integrating:
-
Matrix-based heuristic logic for path optimization.
-
A web-based user interface for mission zone selection.
-
A backend planning pipeline with intelligent waypoint sequencing.
-
Real-time transmission of missions to QGroundControl using MAVLink over UDP.
This system is designed to support automated and visual mission creation, reducing operator burden and improving drone path efficiency during aquatic monitoring missions.
-
Interactive Web-Based Mission Planning: Users can select mission points from a browser-based map interface to define coverage or exploration zones for the aquatic drone.
-
Custom Point Sequencing with PT_planner: The PT_planner module intelligently determines the optimal sequence of mission waypoints based on simple heuristics. This improves the logical flow of missions and is easily extendable for advanced path optimization.
In our approach we define 3 Main matrix, V, A and R each is of the size of the map conatainig :
V: Visted : Binary matrix defining selecting the visited regions during sweep
A: Attractivty : Depending on a "goal point", more the point is far from the goal the more is attractive.
R: Reachability : Depending on obstacles and visited neighbors the region is more or less reachable.
By using these three matrix, we can define a logic that optimizes the path by going to the more attractive point while prioritizing the mess reachable ones.
The visited matrix can help if we want a strategy to visit each point once. or reduce the number of pass-through of each region
-
Real-Time MAVLink Communication: Seamless transmission of waypoints to QGroundControl (QGC) via UDP using the pymavlink library, supporting full automation.
-
Live Mission Updates in QGC: Uploaded missions are visible in QGC’s Plan view without needing to restart the application, using MAVLink refresh commands.
-
Modular Architecture: Clean separation between the frontend (JS),backend server (Flask_server), mission planning logic (PT_planner) and communication logic (qgc_sender.py) makes the system extensible and easy to maintain.
To be able to compare different solutions and the "best" optimized path we define three metrics :
Coverage Distance : the total distance of coverage path.
Turn / Rotation number : the number of left / right turns.
Pass-through distance : the total distance of passing over already visited region.
To run this project you need to open index.html in a browser :
To run the backend flask server, move inside python folder cd python and do :
-
Move to python directory : cd pythonication with QGroundCication with QGroundControl using the pymavlink library. It creates the MAVLink mission items and sends them via UDP.
ontrol using the pymavlink library. It creates the MAVLink mission items and sends them via UDP. -
Create Python Virtual Environment by running:
run : python3 -m venv <env_name>
replace <env_name> by the name of your environment
source <env_name>/bin/activate
You should see the environment activated -
Install requirements by running :
pip install requirements.txt
Or run each of needed packages installation inside folder file python/install.txt, it will automatically install dependencies -
Run :
Go to root directory of this project then run :
bash python3 -m http.server 8000
Open your browser and go to:
http://localhost:8000/index.html
Navigate to the python folder:
cd python
(Optional / if not done yet) Activate your virtual environment if needed:
source <env_name>/bin/activate
Start the Flask server:
python3 flask_server.py
Use web interface to plan a mision and generate a path.
- Launch QGroundControl :
In a separate terminal, start the ArduPilot SITL simulation:
cd suv_ws/src/suv_simulation/scripts/ <br>
Then:
Open QGroundControl using ./launch simulation.sh
QGC will automatically connect to the simulator (default UDP port 14550) and display the mission once it receives waypoints.
- Output
All generated mission plans (waypoints) are saved to:
python/coverage_path_planning/json/ <br>
Each file is timestamped for easy reference and recovery.
This is the main Flask-based backend server that receives mission data from the frontend and initiates all logic to compute and send waypoints to QGroundControl (QGC).
Main Responsibilities:
-
Receives mission points (landmarks) from frontend
- Accepts a POST request rom the frontend UI at the endpoint /landmarks.
- Accepts a POST request rom the frontend UI at the endpoint /landmarks.
-
Performs path planning
- Calls your custom coverage path planner (PT_planner.main()) to determine the optimal sequence of waypoints.
- This planner uses matrices V, A, and R to calculate efficient traversal paths while avoiding redundancy and obstacles.
- Calls your custom coverage path planner (PT_planner.main()) to determine the optimal sequence of waypoints.
-
Prepares ordered waypoints
- Converts the ordered points into a list of dictionaries with latitude, longitude, and altitude (typically a default of 0m).
- Ensures the sequence follows the path planner logic.
- Converts the ordered points into a list of dictionaries with latitude, longitude, and altitude (typically a default of 0m).
-
Establishes a MAVLink connection
- Calls qgc_sender.connect_to_qgc() to open a UDP connection to QGC on port 14551.
- Calls qgc_sender.connect_to_qgc() to open a UDP connection to QGC on port 14551.
-
Uploads the mission to QGC
- Calls:
send_mission_to_qgc(connection, waypoints) - Sends a complete MAVLink mission that includes all waypoints with lat/lon/alt.
- Calls:
-
Handles cleanup and logging
- Prints connection success, mission upload confirmation, and gracefully closes the connection.
This module handles low-level communication with QGroundControl using the pymavlink library. It creates the MAVLink mission items and sends them via UDP.
Main Responsibilities:
-
Connects to QGC via UDP
- Opens a UDP connection to QGC’s listening port (default is 127.0.0.1:14551) using:
mavutil.mavlink_connection('udpout:127.0.0.1:14551')
- Waits for a heartbeat to confirm communication is live.
- Opens a UDP connection to QGC’s listening port (default is 127.0.0.1:14551) using:
-
Creates and sends waypoints
- Converts each waypoint (lat, lon, alt) into a MAVLink MISSION_ITEM_INT message:
connection.mav.mission_item_int_send(...)
- Converts each waypoint (lat, lon, alt) into a MAVLink MISSION_ITEM_INT message:
-
Sends mission count and index
- Initiates the mission upload by sending:
connection.mav.mission_count_send(...)
followed by each waypoint message.
- Initiates the mission upload by sending:
-
Logs progress
- Prints helpful debug information (mission accepted, failed, invalid, etc.).
- Can be run in debug mode to print every MAVLink message exchanged (useful for diagnostics).
- Prints helpful debug information (mission accepted, failed, invalid, etc.).