Intelligent Replanning Drone Swarm

A simulated drone swarm mission in PyBullet where agents search a grid for a missing person, keep going even when drones fail, and dynamically re-plan tasks through a market-style allocation + fault retasking.

Overview

The swarm’s objective is to search a defined grid area (like a “lawnmower” sweep) to locate a randomly spawned subject. Agents continuously broadcast their state to a GUI, avoid collisions and borders, and can handle injected failures (battery, GPS, comms, motors) while the mission continues.

How It Works

  • Search area is divided into grid sections, initially allocated to agents.
  • Agents sweep their owned sections using waypoint paths (“lawnmower” pattern).
  • A market mechanism reallocates sections dynamically if drones fail or return home.
  • Fault injection triggers retasking (return home, hover as relay, emergency land, etc.).
  • When a subject is detected, three nearby agents verify and vote before ending the mission.

Code Overview (.py files)

High-level overview of the simulation codebase structure

Intelligent Replanning Drone Swarm simulation codebase structure

main.py

The simulation “orchestrator”: creates the environment, spawns drones + subject, runs the main control loop, handles searching, voting verification, market updates, avoidance, faults/retasking, and return-home logic.

controller.py

Shared control + state bridge between GUI and simulation thread: start/abort search, run simulation in a thread, inject faults, and track when drones are “home ready” and “charged”.

gui.py

PyQt control panel: choose grid size and number of agents, start/abort mission, inject health faults, show live pings/assignments/market/voting, and enable a “Charge Agent” button when a drone returns home.

drone.py

Drone agent wrapper: tracks per-agent state (health, commands, subject-found flag) and uses PID control to move toward target positions. Also formats broadcast messages used by the GUI.

env.py

Custom PyBullet “aviary” environment: draws the search area overlay (grid, labels, borders), colors searched cells, and creates the helipad visualization at home.

searchArea.py

Search-area data model: generates grid sections, assigns sections to drones, marks sections searched, and supports reassignment when a drone fails.

market.py

Market-based task allocation: drones “buy” sections with points, dynamic pricing can reassign ownership during the mission, and sections are released back to the market when a drone lands/crashes/returns late.

retasking.py

Fault-to-action mapping: converts health status codes (battery, GPS, comms, motor, etc.) into behaviors like RETURN_HOME, LAND_NOW, or REDUCED_ROLE/hover.

avoidance.py

Collision/boundary avoidance helpers: computes repulsion from nearby drones and pushes agents away from search-area borders, plus utility to fetch all drone positions.

subject.py

Subject spawning + persistence: randomly places a “missing person” URDF in a grid section, stores the location to JSON, and provides access to that saved position for display/logic.

tables.py

Shared constants/tables: health codes → names, command table, and a search-area table helper used for ownership/scoring-style bookkeeping and GUI-friendly display.

Video

What I Learned

This project helped me practice multi-agent coordination, failure handling, task allocation, simulation control loops, and building a live GUI to monitor and steer a running system.