Click to set a new leader waypoint. Thin lines = active comm links; dashed ghosts = target formation slots.

Drone Swarm Formation Control — Distributed Consensus (2D)

This 2D companion to the 3D drone swarm visualization implements a genuine formation-keeping mechanism instead of formation morphing: a distributed consensus control law drives every drone toward a fixed target offset from a moving virtual leader, using only local communication with neighbours inside a limited comm radius — one drone is pinned directly to the leader's goal, and the rest converge purely by averaging formation error with whoever they can currently reach on the communication graph. A separate repulsive potential field handles obstacle avoidance on top of the consensus law. Switch between wedge, circle, diamond and line formations, shrink the comm radius to watch the graph fragment and the shape degrade, or scatter the swarm to see the control law pull it back into formation from disorder.