PyBullet Swarm Sim

Fast, physics-accurate drone swarm simulation

Star

Multi-Agent Reinforcement Learning (MARL)

PyBullet Swarm Sim provides first-class support for Reinforcement Learning (RL). By deeply integrating with Gymnasium and Stable-Baselines3, the platform bridges the gap between rigid-body physics simulation and state-of-the-art policy optimization.

MARL Training Dashboard

Use Cases & Requirements

While classical algorithms (like Flocking or PSO) rely on explicit mathematical rules, MARL allows drones to learn optimal behaviors through trial and error. This is critical for discovering complex strategies such as cooperative collision avoidance, adversarial evasion (for Battle Mode), and decentralized target tracking in cluttered environments.

Requirements: To enable RL features, install the optional dependencies:

pip install -e ".[rl]"

Technical Implementation

The core of our RL integration is the custom Gymnasium environment: MARLSwarm-v0. Instead of training $N$ distinct neural networks, we utilize parameter sharing. A single Proximal Policy Optimization (PPO) policy is trained, but each drone queries it using decentralized, ego-centric observations.

Command-Line Training

You can train policies headlessly using the built-in training runner. This script orchestrates the PPO algorithm, sets up the vectorized environments, and logs progress.

python -m swarm_sim.training.marl_train --timesteps 100000 --drones 5 --run-name initial-marl

Once training completes, the policy is serialized and saved as a .zip checkpoint inside the models/ directory.

Dashboard Integration

As shown in the image above, the Web Dashboard features a dedicated RL Training Panel. This provides a user-friendly way to democratize AI research:

  1. Specify the number of training timesteps.
  2. Launch the training asynchronously directly from the UI.
  3. Monitor the PPO learning metrics via live Server-Sent Events (SSE) streaming logs.
  4. Once finished, the new model instantly appears in the algorithm dropdown, ready to be deployed as a standard algorithm against classical baselines in Battle Mode.