dLife Home Page

dlife.robot
Class Controller

java.lang.Object
  extended by dlife.robot.Controller
Direct Known Subclasses:
FiniteStateController, SimpleWorldRobotController, SubsumptionController

public abstract class Controller
extends Object

Base class for controlling robots within the ControlCenter.

To control a robot (physical or simulated) you will create a sub-class of Controller. The Controller class is an abstract class that specifies three methods:

In addition, Controller sub-classes are required to have a no-arg (default) constructor in order to be used with the ControlCenter. Very typically this is accomplished by not defining any constructors in a Controller sub-class. Note: if you do not define any constructors in a class, Java automatically provides an empty default constructor. Controller sub-classes usually do not require the explicit definition of a constructor because all initialization can (and should) be done in the startUp(Robot) method.

Below is an example of a very simple Controller that moves a Hemisson robot forward until it detects an obstacle, at which point it simply stops.

Additional sample controllers can be found in the robot sub-packages of the examples package. Studying a few of these examples is a good way to get started. A few that make particularly good starting points are:

Version:
Apr 24, 2007
Author:
Grant Braught, Dickinson College

Constructor Summary
Controller()
           
 
Method Summary
 void shutDown()
          This method is invoked when the Shut Down button in the ControlCenter is clicked.
abstract  void startUp(Robot robot)
          This method is invoked automatically when the Start Up button in the ContolCenter is clicked.
abstract  void step()
          This method is invoked either once when the Step button is clicked or periodically when the Run button is clicked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller()
Method Detail

startUp

public abstract void startUp(Robot robot)
This method is invoked automatically when the Start Up button in the ContolCenter is clicked. This is typically where Sensors and Effectors are created and added to the Robot.

Parameters:
robot - the Robot that this Controller will be controlling.

step

public abstract void step()
This method is invoked either once when the Step button is clicked or periodically when the Run button is clicked. The rate at which step is invoked varies from Robot to Robot and is dependent on the computer being used as well as the amount of processing done in step, the number and type of sensors attached to the Robot and the robot's communication latency.


shutDown

public void shutDown()
This method is invoked when the Shut Down button in the ControlCenter is clicked. The default implementation of this method is empty.


dLife Home Page