This project focuses on developing and optimizing formation control algorithms for multi-UAV systems. Using distance-based formation and gradient descent optimization, our approach enables drones to maintain safe distances, avoid collisions, and achieve precise formations.
Note
This is an optimization of the original gym-pybullet-drones/examples/pid.py repository , designed for compatibility with PyBullet
|
Classical Formation Control with Collision
|
Implemented Optimization with No Collision
|
This project tests its simulations on: PyBullet and uses Python 3.10+
For more information, please visit PyBullet's repository.
-
Install necessary packages:
pip install pybullet pip intall numpy pip install matplotlib
-
Important Notice
If using Windows 11, you may need to install Microsoft's Visual Studio and disable Windows 11 SDK from the
Installation Detailssection to get the PyBullet simulator to work.
-
Using a python terminal
python pid_square_form.py
Simulation Variables:
H_STEP (the step-size for gradient descent): 0.15DEFAULT_DURATION_SEC: 10DEFAULT_NUM_DRONES: 4
-
Output
- Initializes the PyBullet simulation environment and sets up drones at random starting positions.
- Can use
np.random.seed(0)to get both in the same initial positions
- Can use
- Calculates desired inter-drone distances based on a target square formation.
- Runs the formation control algorithm using gradient descent to minimize formation error.
- Applies a repulsive force for collision avoidance when drones are closer than the safe distance for the first
runfunction. - Updates drone positions in real time using PID controllers to track gradient-based target points.
- Displays a live 3D simulation in the PyBullet viewer showing drones moving into formation.
- Initializes the PyBullet simulation environment and sets up drones at random starting positions.
- Gradient magnitude over time for each drone
- Objective function error over time comparison



