Skip to content

Concept: O(n log n) Swarm Collision Avoidance via Phase Topology (Python PoC) #603

Description

@Architect-Flow78

Hello Bitcraze team!

I know that running large swarms using crazyflie-lib-python can sometimes hit CPU bottlenecks when calculating collision avoidance, as standard Cartesian distance checks have an O(n^2) complexity.

I wrote a lightweight Proof of Concept in Python that reduces the complexity to O(n log n) by translating the swarm's spatial geometry into a 1D phase topology.

How it works:

It uses the Hurwitz constant (1/phi) for optimal initial phase distribution based on the Steinhaus Three-Distance Theorem.

Instead of checking every drone against every other drone, it sorts them by phase (O(n log n)) and only checks adjacent neighbors (O(n)).

For a 2000-drone swarm, this reduces mathematical operations per frame from ~4,000,000 down to ~22,000 (a 180x speedup).

While this specific PoC assumes a 2D circular orbital topology, the mathematical foundation could be adapted for 3D geofenced operations or multi-layered orbits in Crazyflie shows.

Here is the repository with the standalone script (runs in any standard Python environment):
https://github.com/Architect-Flow78/Swarm-Drones-Collision-Avoidance

I’d love to hear your thoughts on whether this phase-based mathematical approach could be useful for the community!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions