PyBullet Swarm Sim

Fast, physics-accurate drone swarm simulation

Star
Swarm Algorithms in Action

10 Built-in Swarm Algorithms

PyBullet Swarm Sim includes a diverse library of foundational and advanced swarm intelligence algorithms. All algorithms implement the BaseAlgorithm interface and generate continuous velocity vectors based on the collective SwarmState.

Custom Algorithm Upload (.py)

The dashboard provides a powerful feature to test your own experimental algorithms instantly without touching the core codebase or restarting the server. You can upload a custom Python (.py) file directly through the UI.

How it works

  1. Create a Python file containing a class that inherits from BaseAlgorithm.
  2. Implement the compute(self, state) method.
  3. Upload the file in the "Upload Algorithm (.py)" section on the dashboard and click Run.

Your method will receive a SwarmState object every timestep containing the absolute positions and velocities of all drones, and it must return an (N, 3) NumPy array representing the target velocity vectors.

from swarm_sim.algorithms.base_algorithm import BaseAlgorithm
import numpy as np

class MyCustomSwarm(BaseAlgorithm):
    def __init__(self, num_drones, **kwargs):
        super().__init__(num_drones)
        self.speed = 1.0
        
    def compute(self, state):
        # state.positions: (N, 3) array of drone absolute (x,y,z) coordinates
        # state.velocities: (N, 3) array of drone velocities
        
        target_velocities = np.zeros((self.n, 3))
        # Example logic: Command all drones to move straight up
        target_velocities[:, 2] = self.speed 
        
        return target_velocities