Simulator Overview

Introduction

This page provides an overview of the multi-robot simulator which is available to you as part of this class. The simulator allows you to simulate a large number of independent robots, easily modify the algorithms the robots use, and measure various aspects of their performance. The robots move in a simulated world, have simulated sensors, and simulated movement. The robots' algorithms only know what that robots sensors would show (with optional noise), and can only move in a physically sensible manner. There is basic collision detection to prevent robots from moving through obstacles or other robots. The simulator is designed such that you can easily add your own sensors to the robots, change any noise parameters, experiment with new algorithms, send simulated data transmissions between robots, measure many aspects of the performance of any individual or the entire swarm, run many simulations while changing one parameter, and visualize the execution of an algorithm with a simple GUI. The simulator is written in Java.

Simulator Architecture

sim_diagram.svg

The simulator is organized into three packages: swarmsim, sensors, and algorithms. Everything that's not a sensor or an algorithms is in swarmsim. The diagram above shows the important classes in swarmsim and examples of the classes in sensors (all of which implement the interface Sensor) and algorithms (all of which implement the interface Algorithm.

The basic control flow begins in the Controller where each Algorithm is called in turn. The Algorithms get information from the Sensors which calculate their reading using the WorldState. For example, if a robot had an IR proximity sensor, the sensor code would access the WorldState and knowing the position of the robot its attached to as well as the positions of all other objects, it would calculate whether or not the proximity sensor would sense something. It would then hand this information up to the Algorithm. The Algorithm implements some logic by which Actions are created. These could be move or turn actions, or pick-up-food actions, for example. Each robot's Algorithm creates zero, one, or more Actions and delivers them to Physics to be executed. Physics carries out the action to the extent it's possible, and may intentionally add noise. For example, if a robot has requested to move forward ten meters in a single time step, Physics would not allow this. There is also simple collision detection which, if enabled, will prevent a robot from taking an action which would cause it to occupy the same physical space as another object.

All aspects of the world state are contained in WorldState. This contains the positions and orientations of all robots, obstacles, food, the nest, any pheromones, as well as the amount of food in each pile and the nest. This information is stored as public static members of WorldState. This simplifies the architecture, but it also means that robots can 'cheat' - it is possible inside an Algorithm to access anything about the world state, and indeed to change it. Do not do this. If you want your robot to have some information about the world, you need to think carefully about what sensor would allow a real robot would have that information, and then write a Sensor which provides it. Similarly, the only way an Algorithm should modify the WorldState is by creating Actions. If you want your robot to do something which is not currently represented as an Action, think about whether a real robot would actually be able to do that, then make a new Action.

Examples

I have implemented several algorithms, including RandomWalk, AntForage, and Cardinality (which I discussed in class). You can use this code to get a feel for how to write algorithms in the simulator.

Source Code

Here is a tarball of the simulator source code: SwarmSim266.tar

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License