 |
|
Robot.java Template |
/**
* Robot.java template
*
* The following class defintion represents the bare minimum
* fields and methods that are required by the simulator for
* this class. This code should be used as a starting point
* when writing your own controllers. The code here, as is,
* will compile, but will do nothing when run within the
* simulator. Thus, you need to add your own methods/fields
* to implement some control.
*
* NOTE: a text based copy of this file can be found in the
* controller sub-directory (Robot.java.template).
*/
public class Robot extends Thread {
/* Do NOT Modify these fields */
private CurrentRobotState currentData;
private MessagePasser messagePasser;
private Sensor[] sensors;
private Motor motorState;
private boolean active;
// Add your own fields here....
/* Creates new Robot
* you may append any other initialization code you
* want, but the 3 assignments MUST be present.
*/
public Robot(CurrentRobotState data, MessagePasser mp) {
currentData = data;
messagePasser = mp;
active = true;
}
private void getRobotObjects() {
sensors = currentData.getSensorValues();
motorState = currentData.getMotorState();
}
/* This method indirectly terminates the thread.*/
public void killControl() {
active = false;
}
/* Add your own private methods here.... */
/* Need to define run method inherited from Thread. */
public void run() {
getRobotObjects(); // always call this
while(active) {
/* Add your routines here.....
* This while loop will iterate until you press the
* halt button.
*/
}
}
}