Python project for multi-UAV trajectory optimization in cluttered 3D environments. The repository combines map generation, waypoint sampling, Voronoi-based area partitioning, and Model Predictive Control (MPC) to coordinate a fleet of drones for coverage and obstacle avoidance tasks.
The current pipeline implemented in the repository is:
- Random 3D environment generation with cylindrical obstacles
- Multi-UAV initial placement
- Waypoint generation over the free space
- Waypoint sanitization with obstacle safety margins
- Voronoi partition of the workspace
- Waypoint assignment to each drone
- Waypoint ordering
- Distributed MPC-based trajectory optimization
- Visualization of trajectories, costs, and simulation playback
- Procedural 3D map generation with configurable bounds and obstacle sets
- Free-space waypoint generation through clustering
- Voronoi partitioning for decentralized workspace assignment
- Per-drone waypoint ordering before optimization
- MPC formulation for trajectory tracking, collision avoidance, and motion regularization
- Plotting utilities for environment setup, partitioning, kinematics, and simulation animation
multi-UAVs-trajectory-optimization/
|-- main.py
|-- requirements.txt
|-- configs/
| |-- demo_parameters.json
| `-- optimization_params.json
`-- src/
|-- config.py
|-- environment/
| |-- map_generation.py
| `-- map_generation_v2.py
|-- optimization/
| |-- mpc.py
| |-- optimization_plots.py
| `-- waypoints_sorter.py
|-- partition/
| `-- voronoi.py
`-- utils/
|-- drones.py
|-- geometry.py
|-- kmeans.py
|-- plot_initial_envronment.py
`-- plot_voronoi.py
- Python 3.10+
numpyscipyshapelymatplotlibcasadi
Clone the repository:
git clone https://github.com/veneziaandrea/multi-UAVs-trajectory-optimization.git
cd multi-UAVs-trajectory-optimizationCreate and activate a virtual environment if you want an isolated setup:
python -m venv .venvOn Windows:
.venv\Scripts\activateOn macOS/Linux:
source .venv/bin/activateInstall the core dependencies:
pip install numpy scipy shapely matplotlib casadiThe simulation is driven by two JSON files in configs/:
demo_parameters.json: workspace size, obstacle generation, number of UAVs, altitude, and initial separationoptimization_params.json: MPC horizon, timestep, iteration budget, safety distance, and cost weights
Default execution uses:
configs/demo_parameters.jsonfor environment generationconfigs/optimization_params.jsonfor MPC settings
Run the main simulation with:
python main.pyThe script will:
- generate a random 3D map
- compute candidate waypoints in the free space
- build a Voronoi partition for the fleet
- assign and sort waypoints for each drone
- run the MPC loop
- open plots for partitioning, cost evolution, trajectories, kinematics, and animation
- The project is currently research-oriented and still evolving.
- Some legacy files from earlier experiments are still present in the repository.
- The simulation is visualization-heavy, so running it in an environment with GUI support is recommended.
Issues and pull requests are welcome.
This project is released under the MIT License. See LICENSE for details.