MCPcopy Index your code
hub / github.com/emmanuel-battesti/swarm-rescue

github.com/emmanuel-battesti/swarm-rescue @v5.1.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.1.3 ↗ · + Follow
1,002 symbols 3,917 edges 138 files 793 documented · 79% updated 5mo ago★ 621 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Table of Content

Welcome to Swarm-Rescue

With this project, you will try to save human lives, in simulation... Teach a swarm of drones how to behave to save a maximum of injured people in a minimum of time!

Your job will be to develop your own drone controller. In the competition, each participating team will be evaluated on new, unknown maps. The winner will be determined by a scoring system based on multiple criteria: rescue speed, exploration efficiency, number of injured people saved, remaining health of the drones, and more.

Swarm-Rescue is the environment that simulates the drones and that describes the maps used, the drones and the different elements of the map.

Access to the GitHub repository Swarm-RescueWebsiteChangelog

The Challenge requires only basic knowledge of Python and emphasizes creativity, problem-solving, and algorithmic thinking. Success depends more on innovative approaches to swarm coordination than on advanced programming skills.

The Competition

Mission

The objective is simple: explore an unknown area (like the basement of a collapsed building), detect injured people, and guide them to the rescue center.

Each team has a fleet of 10 drones, equipped with sensors and communication devices. Your role is to program the intelligence of these drones to make them 100% autonomous by programming them in Python.

They will need to collaborate, manage failures, communication losses, and unforeseen events to successfully complete their mission. All development is done exclusively within this simulation environment, with maps of increasing complexity.

The final evaluation will be done on several unknown maps designed by the organizers and not available to the contestants. Every proposition will be tested on a same computer and a score related to the performance will be computed.

Scoring

Depending on the scenario evolution before the final evaluation, the score calculation may be slightly modified.

A mission ends when: - The maximum simulation timestep is reached (max timestep limit). - The maximum real-world execution time is exceeded (max walltime limit, typically 2 to 5 minutes). When one of the two limits is reached, the game is over. If your algorithm is fast, you will reach the "max timestep limit" first. If your algorithm is too slow, you will reach the "max walltime limit" before the "max timestep limit".

Your score will be calculated based on: - ✅ Rescued People: The percentage of injured people brought back to the rescue center. - 🗺️ Exploration: The percentage of the map explored. - ❤️ Drone Health: The percentage of health points remaining for your drones at the end of the mission. - ⏱️ Efficiency: The time remaining if all people are rescued and all the map is explored.

Simulation Environment

Swarm-Rescue is built on a modified code of the 2D simulation library Simple-Playgrounds (SPG), which uses the Pymunk physics engine and the Arcade game engine.

In practical terms, this means: - Drones and objects have mass and inertia (they don't stop instantly). - Collisions are handled by the physics engine. - The simulator manages a perception-action-communication loop at each time step.

Installation

For installation instructions, please refer to the INSTALL.md file.

Elements of the environment

Drones

Drones are a type of agent in Simple-Playgrounds. Drones are composed of different body parts attached to a Base.

Drones perceive their surroundings through two first-person view sensors: - Lidar sensor - Semantic sensor

Drones also have a communication system.

Drones are equipped with sensors that allow them to estimate their position and orientation. We have two kinds: - with absolute measurements: the GPS for positions and the magnetic compass for orientation. - with relative measurements: the odometer which provides positions and orientation relative to the previous position of the drone.

They are also equipped with life points (or health) that decrease with each collision with the environment or other drones, leading to destruction when reaching zero. When a drone is destroyed, it disappears from the map. The drone has access to this value with its data attribute drone_health.

Lidar sensor

In the file src/swarm_rescue/simulation/ray_sensors/drone_lidar.py, class DroneLidar.

It emulates a lidar sensor with the following specifications:

  • fov (field of view): 360 degrees
  • resolution (number of rays): 181
  • max range (maximum range of the sensor): 300 pixels

Gaussian noise has been added to the distance measurements to simulate real-world conditions. As the field of view (fov) is 360°, the first value (at -Pi rad) and the last value (at Pi) should be the same.

You can find an example of lidar use in the src/swarm_rescue/solutions/my_drone_lidar_communication.py file.

To visualize lidar sensor data, you need to set the parameter draw_lidar_rays of the GuiSR class to True.

Semantic sensor

In the file src/swarm_rescue/simulation/ray_sensors/drone_semantic_sensor.py, it is described in the class DroneSemanticSensor.

The semantic sensor allows to determine the nature of an object, without data processing, around the drone.

  • fov (field of view): 360 degrees
  • max range (maximum range of the sensor): 200 pixels
  • resolution, number of rays evenly spaced across the field of view: 35

As the fov is 360°, the first (at -Pi rad) and the last value (at Pi) should be the same.

You can find an example of semantic sensor use in the examples/example_semantic_sensor.py file.

For this competition, the semantic sensor can only detect WoundedPerson, RescueCenter and other Drones, but NOT Walls (use Lidar for wall detection and avoidance).

Each sensor ray provides a data object with these properties: - data.distance: Distance to the nearest object detected - data.angle: Angle of the ray in radians - data.entity_type: Type of the detected object (WoundedPerson, RescueCenter, Drone) - data.grasped: Boolean indicating if the object is already being grasped

Note: If a wall is detected, both distance and angle will be 0 to prevent usage of wall data through this sensor.

Gaussian noise is applied to the distance measurements to simulate real-world sensor limitations.

To visualize semantic data, you need to set the draw_semantic_rays parameter of the GuiSR class constructor to True.

GPS sensor

In the file src/swarm_rescue/simulation/drone/drone_sensors.py, it is described in the class DroneGPS.

This sensor gives the position vector along the horizontal axis and vertical axis. The position (0, 0) is at the center of the map. Noise has been added to the data to make it look like GPS noise. This is not just gaussian noise but noise that follows an autoregressive model of order 1.

If you want to enable the visualization of the noises, you need to set the enable_visu_noises parameter of the GuiSR class constructor to True.

Compass sensor

In the file src/swarm_rescue/simulation/drone/drone_sensors.py, it is described in the class DroneCompass.

This sensor gives the orientation of the drone. The orientation increases with a counter-clockwise rotation of the drone. The value is between -Pi and Pi. Noise has been added to the data to make it look like Compass noise. This is not just gaussian noise but noise that follows an autoregressive model of order 1.

If you want to enable the visualization of the noises, you need to set the enable_visu_noises parameter of the GuiSR class constructor to True.

Odometer sensor

In the file src/swarm_rescue/simulation/drone/drone_sensors.py, it is described in the class DroneOdometer.

This sensor provides relative positioning data through an array with three key measurements: - dist_travel: Distance traveled during the last timestep (in pixels) - alpha: Relative angle of the current position with respect to the previous frame (in radians) - theta: Orientation variation (rotation) during the last timestep (in radians)

These measurements are all relative to the drone's previous position. By integrating these odometry readings over time, you can estimate the drone's current position when absolute positioning (GPS) is unavailable.

This capability is essential when navigating through GPS-denied areas on the map, such as No-GPS zones.

Angles, alpha and theta, increase with a counter-clockwise rotation of the drone. Their value is between -Pi and Pi. Gaussian noise was added separately to the three parts of the data to make them look like real noise.

odometer values

If you want to enable the visualization of the noises, you need to set the parameter enable_visu_noises parameter of the GuiSR class constructor to True. It will show also a demonstration of the integration of odometer values, by drawing the estimated path.

Communication

Drones can exchange information with nearby teammates through the communication system: * Each drone can communicate with all other drones within 250 pixels. * Messages are sent and received at each simulation timestep. * You can define custom message content through the define_message_for_all() method * Received messages are available through the received_messages attribute

You can find a practical example of drone communication in src/swarm_rescue/solutions/my_drone_lidar_communication.py.

Actuators

At each time step, you must provide values for your actuators.

You have 3 values to control your drone's movement: - forward: A float value between -1 and 1. This applies force in the longitudinal direction. - lateral: A float value between -1 and 1. This applies force in the lateral direction. - rotation: A float value between -1 and 1. This controls the rotation speed.

To interact with the world, you can grasp certain graspable objects. To rescue a wounded person, you must: 1. Approach them 2. Grasp them by setting the grasper value to 1 3. Transport them to the rescue center 4. Release them by setting the grasper value to 0

The grasper actuator is binary: - 0: Released (not carrying anything) - 1: Grasped (carrying an object)

When a wounded person is grasped by a drone, they become "transparent" to the drone's sensors. This design allows the drone to navigate more easily without having its sensors obstructed by the carried person.

You can find examples of actuator use in almost all files in examples/ and src/swarm_rescue/solutions/.

Playground

Drones act and perceive in a Playground.

A playground is composed of scene elements, which can be fixed or movable. A drone can grasp certain scene elements. The playground with all its elements, except for the drones, is called a "Map" within this Swarm-Rescue repository.

Coordinate System

The playground uses a standard Cartesian coordinate system:

  • The position (x, y) :
  • Origin (0,0) is at the center of the map.
  • x: Horizontal position (positive values to the right)
  • y: Vertical position (positive values upward)

  • The orientation theta:

  • Measured in radians between -π and π
  • Increases with counter-clockwise rotation
  • At theta = 0, the drone faces right (positive x-axis)

  • Map Dimensions:

  • Maps have a size [width, height], with width along x-axis and height along y-axis
  • All measurements are in pixels

Wounded Person

A Wounded Person appears as a yellow character on the map and represents an injured individual requiring rescue.

Rescue Process: 1. Detect the wounded person (using the semantic sensor) 2. Approach them 3. Grasp them (set grasper = 1) 4. Transport them to the rescue center 5. Release them at the rescue center (set grasper = 0)

Types of Wounded Persons: - Static (majority): Remain in fixed positions - Dynamic: Move along predetermined paths, following these behaviors: - Move back and forth along their defined route - If dropped by a drone somewhere off their path, they will move in a straight line attempting to rejoin their original route - May be more challenging to rescue due to their movement

A practical example of grasping a wounded person can be found in examples/example_semantic_sensor.py.

You can find an example of some dynamic wounded persons in the examples/example_moving_wounded.py file.

The Rescue Center

The Rescue Center is a red element on the map where the drones have to bring the Wounded Person.

A reward is given to a drone each time it gives a Wounded Person to the Rescue Center.

You can find an example of rescue center used in the examples/example_semantic_sensor.py file.

The Return Area

The Return Area is a blue area on the map where the drones should stay at the end of the mission. Part of the final score is calculated with this zone: the percentage of health points of the drones that return to this return area at the end of the mission compared to the health points of the drones at the beginning of the mission. If there is no Return Area in the map, then the score is calculated with the percentage of health points of all drones in the map.

This return area is not visible to any sensor, but the boolean data attribute is_inside_return_area gives information about whether the drone is inside the return a

Core symbols most depended-on inside this repo

Shape

Method 728
Class 145
Function 129

Languages

Python100%

Modules by API surface

src/swarm_rescue/simulation/drone/drone_abstract.py49 symbols
src/swarm_rescue/simulation/gui_map/playground.py41 symbols
src/swarm_rescue/simulation/elements/embodied.py31 symbols
src/swarm_rescue/simulation/drone/drone_sensors.py31 symbols
src/swarm_rescue/simulation/reporting/evaluation_pdf_report.py25 symbols
src/swarm_rescue/simulation/gui_map/gui_sr.py25 symbols
src/swarm_rescue/simulation/drone/agent.py25 symbols
src/swarm_rescue/simulation/drone/controller.py24 symbols
src/swarm_rescue/simulation/utils/timer_spg.py16 symbols
src/swarm_rescue/simulation/ray_sensors/ray_compute.py16 symbols
src/swarm_rescue/simulation/gui_map/top_down_view.py16 symbols
tests/test_remove_comprehensive.py15 symbols

For agents

$ claude mcp add swarm-rescue \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page