ungovernable.tech

Field guide[ GUIDE ][ OFF-GRID AND MESH NETWORKS ]

Getting Started with Swarm Robotics

Also Learn swarm robotics, Multi-drone simulation tutorial, Swarm robotics roadmap.

Start in simulation, learn five classic coordination methods, design for bad radio links, then scale to cheap hardware. Civilian, research and learning use.

Experimental updated 2026-11-29 5 min read [ INTERMEDIATE ] [ A WEEKEND FOR THE SIMULATION STEPS ]
Contents

Summary

This is a learning path, not a recipe for any particular vehicle. You will get a multi-robot simulation running, implement the classic coordination algorithms, add realistic communication limits, and only then consider hardware. It assumes you can use Linux and a terminal and have seen ROS 2 before. For background read Swarm Robotics: Coordination Without a Controller; for project details and maintenance status see Open-Source Swarm Projects Compared.

1. Stay in simulation first

Simulation is where nearly all the learning happens, and a crash costs nothing.

  • Install ROS 2 (Humble or Jazzy, the releases most current projects target) and Gazebo.
  • Pick one starting point:
    • Aerostack2: a maintained multi-drone framework whose missions run in simulation and on aircraft. The best default.
    • PX4 multi-vehicle simulation: if you want the real flight-controller software in the loop.
    • ARGoS: if you care about hundreds of simple robots rather than a few realistic drones.
    • Project Flockwork: a small, readable, from-scratch ROS 2 and Gazebo example to learn from. It is experimental and simulation-only.
  • Goal for this step: four to six simulated drones that take off, hold position and land from one script.

2. Implement the classic algorithms

Write each one yourself on top of a simulator before reaching for a library. Each has a standard reference.

  1. Leader-follower. One agent follows a path; others hold an offset to it. Easiest to build and the weakest on resilience, since losing the leader ends the formation. ArduPilot's Follow mode is a real-world version of this.
  2. Virtual structure. The formation is a rigid shape that moves as one body, and each agent tracks its slot in that shape. See the formation-control survey by Oh, Park and Ahn.
  3. Potential fields. Goals attract and neighbors or obstacles repel. Simple and local, but agents can get stuck in local minima.
  4. Consensus. Each agent repeatedly averages with its neighbors until the group agrees, for example on a heading or rendezvous point. Start with Olfati-Saber and Murray (2004).
  5. Flocking. Separation, alignment and cohesion, from Reynolds (1987) and formalized by Olfati-Saber (2006).

For mission logic above these, behavior trees are a common choice, and Aerostack2 missions can be written in Python or as behavior trees. A sensible use is fail-safe logic, for example "if no neighbor is heard for several seconds, hold position".

For dividing an area among agents, see Cortés et al. on coverage control.

3. Add the communication limits

Real swarms rarely have a clean network. Make the simulator model that before you trust any result.

  • Limit what you share. Send small, periodic state messages (position, velocity, a status flag), not maps or video. ESP-NOW, a connectionless Wi-Fi protocol for ESP32 boards, carries up to 250 bytes per packet in v1.0 (v2.0 raises this to 1470 bytes), per Espressif's documentation; LoRa is slower still (see the LoRa Mesh Field Guide).
  • Inject faults. Drop packets, add delay and cut random links in your simulation. Check that the formation degrades gracefully instead of oscillating or colliding.
  • Try sensing instead of messaging. The vswarm paper shows flocking from onboard cameras with no inter-agent communication (arXiv:2012.01245).
  • Start with Wi-Fi for demos. A plain Wi-Fi network is the easiest way to move from simulation to a bench test; then move to ESP-NOW or a mesh link once the algorithms work.
  • Think about the mesh itself. If relays or long links matter, read Off-Grid and Mesh Networks, Building a Mesh and Meshtastic.

4. Scale up to hardware

Go in small steps, and keep every step indoors or inside a safety net until you trust the software.

Step Platform Notes
Wheeled robots HeRoSwarm v2 (open hardware, MIT) or a TurtleBot-class robot Safest way to test real radios and sensing; ROS2swarm's patterns were built for ground robots
Micro-drones Bitcraze Crazyflie with Crazyswarm2 A common lab fleet. Control is centralized through Crazyradio dongles, which is fine for learning but not decentralized
Do-it-yourself micro-drones ESP-Drone on ESP32 Cheap; Wi-Fi-based; lower performance
Larger drones Pixhawk-class autopilot running PX4 or ArduPilot, plus a companion computer running ROS 2 Where Aerostack2 and similar frameworks run. Needs proper range, safety procedures and legal clearance

Power and radio hardware are a project of their own: see Off-Grid Power and Antennas.

5. Read the research

Safety, law and dual use

Multi-vehicle flight is regulated in most countries, often with limits on how many aircraft one operator may control and where. Check your national aviation authority and local rules before any outdoor flight. Keep early tests in simulation or inside a netted room, use hardware kill switches and geofences, and never fly near people or crowds. This guide is for civilian, research and education use. Coordination algorithms are dual-use in general, and this library does not provide guidance on weaponizing them or defeating safety measures.

Going further

Primary sources

Page history

Updated
2026-11-29
Origin
Written for ungovernable.tech.
Improve this page
Suggest an edit — issues and pull requests are welcome.