AbstractRobot Functions


Introduction:

Since every Controller File must have dual functionality, since it must run on both, the simulator and the Real Robot, therefore there must be a specific list of functions for the robot which are provide the same output but are implemented differently. The specific list of functions is denoted by the methods in the AbstractRobot class which is infact an interface. The process for using these methods in the Controller File is as follows:

1.) save the AbstractRobot parameter, which is passed through the: ' public abstract void initController(AbstractRobot r);' method in the Controller File as an instance variable in the Controller File.

NOTE: ' public abstract void initController(AbstractRobot r);' is required by the Controller Interface

2.) implement ALL of the functions in the by AbstractRobotVariable.FUNCTION (exactly like in the Sample Controller File)

The List of Constants:

 

CONSTANTS: DESCRIPTION:
 
1.) BACKWARD .../** constant for single motor to move backwards */
2.) FORWARD .../** constant for single motor to move forwards */
3.) MOTOR_A .../** constant for MOTOR A */
4.) MOTOR_C .../** constant for MOTOR C */
5.) S1 .../** constant for sensor 1 */
6.) S2 .../** constant for sensor 2 */
7.) S3 .../** constant for sensor 3*/

 

The List of Functions:

 

FUNCTION SIGNATURE: DESCRIPTION:
- - - - MOVING THE ROBOT - - - -
1.) public abstract void forward(); /**
* Sets the robot moving forwards, this will continue until some other
* method is called to stop it
*/
2.) public abstract void forward(int time); /**
* Makes the robot move forwards for the given amount of time
* @param time the time in milliseconds
*/
3.) public abstract void backward(); /**
* Sets the robot moving backwards, this will continue until some other
* method is called to stop it
*/
4.) public abstract void backward(int time); /**
* Makes the robot move backwards for the given amount of time
*
* @param time the time in milliseconds
*/
5.) public abstract void right(); /**
* Sets the robot spinning right on a dime, this will continue until some other
* method is called to stop it.
*/
6.) public abstract void right(int time); /**
* Spins the robot right on a dime for the given amount of time
*
* @param time the time in milliseconds
*/
7.) public abstract void left(); /**
* Sets the robot spinning left on a dime, this will continue until some other
* method is called to stop it.
*/
8.) public abstract void left(int time); /**
* Spins the robot left on a dime for the given amount of time
*
* @param time the time in milliseconds
*/
9.) public abstract void singleMotor(int motor, int direction);

/**
* Sets a single Motor moving, this will continue until some other
* method is called to stop it
* Created by: Simon Zienkiewicz
*
* @param motor the motor number (AbstractRobot.MOTOR_A or AbstractRobot.MOTOR_C);
* @param direction, the direction number (AbstractRobot.BACKWARD or AbstractRobot.FORWARD
*/

10.) public abstract void singleMotor(int motor, int direction, int time); / /**
* Sets a single Motor moving for the given amount of time
* Created by: Simon Zienkiewicz
*
* @param motor the motor number (AbstractRobot.MOTOR_A or AbstractRobot.MOTOR_C);
* @param direction, the direction number (AbstractRobot.BACKWARDS or AbstractRobot.FORWARDS
* @param time the time in milliseconds
*/
11.) public abstract void stopMoving(); /**
* Stops all motors immediately
*/
- - - - READING THE ROBOTS SENSORS - - - -
11.) public abstract int getSensor1(); /**
* Get the current reading of this sensor
*
* @return the current value
*/
12.) public abstract int getSensor2(); /**
* Get the current reading of this sensor
*
* @return the current value
*/
13.) public abstract int getSensor3(); /**
* Get the current reading of this sensor
*
* @return the current value
*/
14.) public abstract boolean[] getTouchSensorStatus(); /**
* Gets an array of boolean values for the touch sensors
* Created by: Simon Zienkiewicz
*
* @return boolean values of the status of the sensors
*/
- - - - HANDLING THE ROBOT'S LCD - - - -
15.) public abstract void displayNumberLCD(int num);

/**
* Display numbers on the LCD
* Created by: Simon Zienkiewicz

* @param num the number to display
*/

16.) public abstract void clearLCD(); /**
* Clears the display on the LCD
* Created by: Simon Zienkiewicz
*/
17.) public abstract void displayTextLCD(String word); /**
* Display text on the LCD
* Created by: Simon Zienkiewicz
*
* @param word, string to display
*/
- - - - HANDLING THE ROBOT'S PROPERTIES - - - -
18.) public abstract void setMotorPower(int power); /**
* Sets the power of the motors for the robot
* Created by: Simon Zienkiewicz
*
* @param power, the desired power
*/
19.) public abstract int getMotorPower(); /**
* Gets the power of the motors for the robot
* Created by: Simon Zienkiewicz
*
* @return the power of the motor 0-7
*/
20.) public abstract int getVoltage(); /**
* Gets the voltage of the RCX battery in MilliVolts
* Created by: Simon Zienkiewicz
*
* @return int voltage in the battery of the RCX
*/
21.) public abstract void activate(); /**
* Activates the light and touch sensors
* Created by: Simon Zienkiewicz
*
*/
22.) public abstract void playTune(int frequency, int duration); /**
* Plays a sound
* Created by: Simon Zienkiewicz
*
* @param frequency, the sound frequency
* @param duration, the duration of the sound in milliseconds
*/
23.) public abstract void beep(); /**
* Makes the robot beep
*/
- - - - HANDLING TIMER/TIMING EVENTS- - - -
24.) public abstract int createTimer(int time); /**
* Creates a timer
* Created by: Simon Zienkiewicz
*
* @param time, the delay for the timer
* @return int, the timer number
*/
25.) public abstract void startTimer(int num); /**
* Starts the requested timer
* Created by: Simon Zienkiewicz
*
* @param num, the timer number
*/
26.) public void stopTimer(int num); /**
* Stops the requested timer
* Created by: Simon Zienkiewicz
*
* @param num, the timer number
*/
27.) public void stopAllTimers(); /**
* Stops all timers
* Created by: Simon Zienkiewicz
*
*/
28.) public int getDelay(int num); /**
* Gets the delay from the requested timer
* Created by: Simon Zienkiewicz
*
* @param num, the timer number
* @return int, the timer delay
*/
29.) public void setDelay(int num, int time); /**
* Sets the delay for the requested timer
* Created by: Simon Zienkiewicz
*
* @param num, the timer number
* @param time, the new delay time
*/
30.) public abstract void pause(int num); /**
* Pauses the simulation
* Modified by: Simon Zienkiewicz
*
* @param num, the number of milliseconds
*/