🚁 Autonomous UAV Coverage Path Planner → Autonomous UAV survey coverage system using A*, TSP & Boustrophedon decomposition
An autonomous survey coverage system for UAVs that computes optimal lawnmower flight paths over arbitrary polygon regions. Given a KML boundary file, the system decomposes the area into convex sub-regions, generates parallel sweep lines calibrated to camera FOV and overlap, and stitches them into a complete mission path using A* transitions and TSP ordering — minimizing total flight distance while guaranteeing area coverage.
Matplotlib visualization and KML output — importable directly into Google Earth / mission planners.
The system outputs two KML files:
optimized_convex_decomposition.kml— color-coded convex sub-regions overlaid on input boundarylawnmower_paths.kml— complete stitched mission path with inter-cell transitions
- Arbitrary polygon support — handles non-convex, irregular survey boundaries via KML input
- Hertel-Mehlhorn convex decomposition — decomposes non-convex polygons into minimal convex sub-cells ensuring complete, overlap-free coverage
- Camera-aware path spacing — automatically computes sweep line spacing from drone altitude, lens FOV (horizontal + vertical), camera pitch, and desired overlap percentage
- Boustrophedon (lawnmower) sweep — generates parallel sweep lines anchored to the longest edge of each convex cell for efficient coverage
- A* inter-cell transitions — computes obstacle-aware transition paths between cells constrained to stay within the polygon boundary
- TSP cell ordering — solves the Travelling Salesman Problem across cells to minimize total mission distance
- KML export — outputs mission paths directly importable into Google Earth Pro and ArduPilot/QGroundControl-compatible planners
Input KML (polygon boundary)
│
▼
┌─────────────────────────┐
│ Polygon Extraction │ minidom KML parser → Shapely Polygon
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Convex Decomposition │ Hertel-Mehlhorn → merge triangles → convex cells
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Path Spacing Calc │ Altitude × tan(FOV/2) × (1 - overlap)
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Lawnmower Path Gen │ Sweep lines anchored to longest edge, zigzag order
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ TSP + A* Stitching │ Optimal cell ordering + constrained transitions
└────────────┬────────────┘
│
▼
KML Output + Matplotlib Visualization
The path spacing is automatically computed from your drone's camera specs:
spacing = get_path_spacing(
altitude=12, # meters AGL
horizontal_fov=130, # degrees
vertical_fov=130, # degrees
overlap=0.3 # 30% overlap between passes
)Tested with Hawkeye Thumb 4K specs (168.5° H-FOV, 159.76° V-FOV). Adapt constants in
get_path_spacing()for your sensor.
pip install shapely simplekml matplotlib numpy-
Prepare your input KML — export a polygon boundary from Google Earth Pro as a
.kmlfile. -
Configure paths and camera in
Path_planning_code.py:
# In the __main__ block:
input_kml_path = "path/to/your/input_polygon.kml"
output_kml_path = "optimized_convex_decomposition.kml"
path_kml_output = "lawnmower_paths.kml"
start_pos = (longitude, latitude) # UAV home position
spacing = get_path_spacing(
altitude=12,
horizontal_fov=130,
vertical_fov=130,
overlap=0.3
)- Run:
python Path_planning_code.py- View outputs — open generated
.kmlfiles in Google Earth Pro or import into your mission planner.
├── Path_planning_code.py # Main pipeline (all modules)
├── input_polygon.kml # Sample input boundary (Bhopal test area)
├── lawnmower_paths.kml # Sample output: stitched mission path
├── optimized_convex_decomposition.kml # Sample output: decomposed cells
└── README.md
| Component | Algorithm | Why |
|---|---|---|
| Area decomposition | Hertel-Mehlhorn (triangle merging) | Minimal convex partition of arbitrary polygons |
| Sweep direction | Boustrophedon (longest-edge aligned) | Minimizes turn count and path length |
| Cell ordering | TSP via permutation (brute-force for small n) | Optimal inter-cell travel order |
| Transition paths | A* search constrained to polygon | Avoids leaving survey boundary |
| Coverage metric | Shapely area union ratio | Verifies ≥99% coverage before output |
On a sample test polygon (Bhopal region, ~0.001 sq degrees):
- Convex decomposition: typically 4–8 cells for irregular polygons
- Coverage ratio: ≥95% area coverage (verified via Shapely union)
- TSP ordering reduces inter-cell transit vs. naive sequential ordering
- Add no-fly zone obstacle support
- ROS integration for direct autopilot command
Pull requests are welcome. For major changes, please open an issue first to discuss the proposed change.
- Fork the repository
- Create a feature branch:
git checkout -b feat/your-feature - Commit with a descriptive message:
git commit -m "feat: add no-fly zone obstacle avoidance" - Open a PR against
main
MIT License — see LICENSE for details.
Built by Meghna Tiwari · Open to feedback and collaboration