Geometry Lab [German] [Sitemap] [About geometrylab.de]

A Java applet for simulating swarms of robots

Please click on the button to start the applet.


Index

Applet

The Java applet RacingRobots simulates the way so-called randolph-robots move in grid environments. The robots are supposed to have minor sensor equipment, thus the translation in one direction is carried out, as long as the robot does not encounter an obstacle in his way, supposing that the robot can just evaluate his proper coordinates at contacts with solid walls - another roboter of the same type. Therefore all the contemporary randolph-robots in one grid environment are rather considered as a system of robots.

The two major tasks of this simulation applet are to solve navigation problems for systems of randolph robots in arbitrary grid environments and answer the question of reachability considering arbitrary target cells within these environments.

The start-up view of the applet shows an editor to design any two-dimensional grid envoronment as described below. After switching to the racer view, you can choose one of the following strategies

Menu

The Menu devides into three submenues

Using the mouse

The usage of the mouse differs considering the different applet views as described below.

Editor

Click left or right to mark a grid cell within the initial empty grid. The marked cells resemble the environment. Click again to unmark a cell.

Hold left or right mouse button and drag the mouse to mark a rectangular area of cells at once, whose coordinates depend on start and stop coordinates of the mouse drag. Before this works the editor mode has to be changed from 'pencil' to 'rectangle'.

Racer

Click left on a robot to select it. Afterwards a leftclick on any cell in the grid environment which is not inhabited by another robot will have the effect of placing the selected robot there, if this is possible by one translation or otherwise it has no effect.

Right click shows the following popup menue.

The popup menue contains four possibilities, which may be enabled or not, depending on the current position of the cursor.

Editor

The editor view consists of the following five panels

The lower right button changes the applet to racer view.

Racer

In the racer view - also containing five panels - ZoomPanel and ScrollPanel functions are mainly as mentioned above. Instead of edit support for the grid environment the ScrollPanel enables the popup menue also mentioned above. The remaining panels are

The lower right button chages the applet to racer view.

Implementing additional strategies

The abstract Class RRStrat [apps.RacingRobot], containing an instance of GridPoly [anja.grid] as environment as well as a SpreadGRS [apps.RacingRobot] (the robot system) and its start and target cell as instances of GridSquares [anja.grid], defines access methods for those member veriables for external use. Any derived class has protected access to the member variables mentioned above and furthermore there is an ActionListener (supposed to be an instance of RRStratEngines [apps.RacingRobot]) which can be used by these strategies.

All derived strategies are identified with a unique ID and a string constant as name, which can be retrieved from the ID by the method getNameByID(int id). Any new strategy has to be added in the list of IDs and names.

Similarly to the list of IDs, there is a list of event constants, which define various actions caused by the strategies and supposed to be handled by the ActionListener (an instance of RRStratEngines [apps.RacingRobot] or RRApp [apps.RacingRobot], etc.).

As RRStrat implements the interface Runnable, every derived strategy has to overwrite the run() method, considering the member variable '_stopped' as an invariant which allows a safe exit from the strategy thread by pressing the stop button. This run() method is started by pressing the start button.

The following abstract methods have to be implemented by any derived strategy.

The method 'createOptionPanel()' enables a strategy to insert optional user determined parameters into an RROptionPanel [apps.RacingRobot] which is initialized by RRStrat already. After checking 'hasOptionPanel()' RRStratEngine shows the option panel in a RROptionFrame [apps.RacingRobot] situated on the right of the applets main frame.

As mentioned above RRStratEngine connects strategies with the simulation environment. To insert a new strategy, the method 'initStrat()' of RRStratEngine has to be modified as follows

public void initStrat()
switch ( _stratID )
{
// Initializing already implemented strategies
.
.
.
// New Strategy
case RRStrat.NEWSTRATEGIE:
_strat = new NEWSTRATEGIE(_poly, _start);
_strat.setActionListener(this);
// Insert more initializing
// code here
break;
}
_createOptionDialog();
}// initStrat
}

Furthermore there are two simple message dialogues (derived from java.swing.Dialog) which can be used by sending the appropriate ActionEvent to an instance of RRStratEngine

author: Birgit Engels[engels@cs.uni-bonn.de]


© University of Bonn, Computer Science I - - Last modified 07-12-2005 10:15