Difference between revisions of "Swarm Robot Project Simulator"

From Mech
Jump to navigationJump to search
 
Line 10: Line 10:


==Control structure==
==Control structure==
[[Image:swarm_simlulator_control_structure.png|300px|right|thumb]]
The control structure is the logic portion of the code, representing code that might actually be run on the e-pucks. It is written modularly and without extraneous dependencies so it can be readily adapted to other algorithms.
The control structure is the logic portion of the code, representing code that might actually be run on the e-pucks. It is written modularly and without extraneous dependencies so it can be readily adapted to other algorithms.



Revision as of 10:26, 7 May 2009

The simulator is a part of the Swarm Robot Project that attempts to model the robots using MATLAB. It is built around a generic control structure so that it can be easily adapted to run other algorithms. Features include: asynchronous update cycles, a packet model, lossy communication, and flexible rendering options.

Getting started

The simulator is contained in a single executable M-file. This version implements the formation control algorithm. When it is run, the swarm will start centered around a random location and then move in on the goal moments (the stationary green ellipse). The user may click a location on the grid to restart the simulation with the robots centered around that point.

Constants

The constants at the top of the M-file (denoted by all-caps) give the user a great deal of control over the performance and rendering of the simulation without having to understand the code.

See the inline comments for more details.

Control structure

Swarm simlulator control structure.png

The control structure is the logic portion of the code, representing code that might actually be run on the e-pucks. It is written modularly and without extraneous dependencies so it can be readily adapted to other algorithms.

Time model

The simulation advances in timesteps; equally spaced spans of time. Timesteps are the unit used in specifying the distance between discrete events (ie. updating robot calculations or rendering).

The main loop runs once per timestep. It moves the robots along their chosen velocity vectors every timestep and makes calls to time-dependent update functions as needed.

Data model

Since all state data in the simulation can be associated with a robot, the only stored variable is a vector of N robots called bots. Each bot is individually represented as a structure, with the following fields (and initial value):

  • bots vector of N robots
    • state information the robot knows about itself
      • p ([rand; rand]) position (arranged randomly inside a square of side length SIDE, centered about a specified point)
      • angle (rand) direction facing
    • packets vector of N received packets (packet i of bot i is that robot's own estimate and does not age like the rest)
      • age (PACKET_AGE_LIMIT+1) timesteps since received
      • v ([0; 0; 0; 0; 0]) moments (packet i of bot i has v initialized to [p(1), p(2), 0, 0, 0])
      • w ([0; 0; 0; 0; 0]) I have no idea
    • u ([0; 0]) velocity
    • lastUpdate (0) timestep of last update
    • waitTime (rand) timesteps between previous update and next update