simworldobjects
Class SimRCX

java.lang.Object
  extended bysimworldobjects.BasicSimObject
      extended bysimworldobjects.SimRCX
All Implemented Interfaces:
AbstractRobot, SimObject

public class SimRCX
extends BasicSimObject
implements AbstractRobot

Simulates an RCX for use in SimWorld

Author:
Graham Ritchie

Field Summary
static int STATE_BACKWARD
           
static int STATE_FORWARD
           
static int STATE_LEFT
           
static int STATE_RIGHT
           
static int STATE_STOPPED
           
 
Fields inherited from interface interfaces.AbstractRobot
BACKWARD, FORWARD, MOTOR_A, MOTOR_C
 
Constructor Summary
SimRCX(SimWorld w, Controller c)
          Constructor: sets up the robot with some predefined parameters
SimRCX(SimWorld w, Controller c, double height, double width, double length, java.lang.String type, double x, double y, double z, double bearingXY, double bearingXZ, int battery)
          Constructor: sets up the robot according to the parameters
 
Method Summary
 void activate()
          Activates the light and touch sensors Created by: Simon Zienkiewicz
 void backward()
          Sets the robot moving backwards, this will continue until some other method is called to stop it.
 void backward(int time)
          Makes the robot move backwards for the given amount of time
 void beep()
          Makes the robot beep
 void clearLCD()
          Clears the display on the LCD Modified by: Simon Zienkiewicz
 int createTimer(int time)
          Creates a timer Created by: Simon Zienkiewicz
 void displayNumberLCD(int num)
          Display numbers on the LCD Modified by: Simon Zienkiewicz
 void displayTextLCD(java.lang.String word)
          Display text on the LCD Modified by: Simon Zienkiewicz
 void forward()
          Sets the robot moving forwards, this will continue until some other method is called to stop it.
 void forward(int time)
          Makes the robot move forwards for the given amount of time
 int getDelay(int num)
          Gets the delay from the requested timer Created by: Simon Zienkiewicz
 java.lang.String getLCDOutput()
           
 int getMotorPower()
          Gets the power of the motors for the robot Modified by: Simon Zienkiewicz
 boolean getSelected()
           
 int getSensor1()
          Get the current reading of this sensor
 int getSensor2()
          Get the current reading of this sensor
 int getSensor3()
          Get the current reading of this sensor
 boolean[] getTouchSensorStatus()
          Gets an array of boolean values for the touch sensors Modified by: Simon Zienkiewicz
 int getVoltage()
          Gets the voltage of the RCX battery in MilliVolts Modified by: Simon Zienkiewicz
 SimWorld getWorld()
           
 void left()
          Sets the robot spinning left, this will continue until some other method is called to stop it.
 void left(int time)
          Spins the robot left for the given amount of time
 void lightEvent(int index)
           
 void pause(int num)
          Pauses the simulation Created by: Simon Zienkiewicz
 void pivotRotation()
           
 void playTune(int frequency, int duration)
          Plays a sound Created by: Simon Zienkiewicz
 void right()
          Sets the robot spinning right, this will continue until some other method is called to stop it.
 void right(int time)
          Spins the robot right for the given amount of time
 void setDelay(int num, int time)
          Sets the delay for the requested timer Created by: Simon Zienkiewicz
 void setMotorPower(int power)
          Sets the power of the motors for the robot Modified by: Simon Zienkiewicz
 void setSelected(boolean selected)
           
 void singleMotor(int motor, int direction)
          Sets a single Motor moving, this will continue until some other method is called to stop it
 void singleMotor(int motor, int direction, int time)
          Sets a single Motor moving for the given amount of time
 void startTimer(int num)
          Starts the requested timer Created by: Simon Zienkiewicz
 void stopAllTimers()
          Stops all timers Created by: Simon Zienkiewicz
 void stopMoving()
          Stops all motors immediately
 void stopTimer(int num)
          Stops the requested timer Created by: Simon Zienkiewicz
 void touchEvent(int index)
           
 
Methods inherited from class simworldobjects.BasicSimObject
getActualBearingVelocityXY, getActualBearingVelocityXZ, getActualBearingXY, getActualBearingXZ, getActualVelocity, getDesiredBearingVelocityXY, getDesiredBearingVelocityXZ, getDesiredVelocity, getHeight, getLength, getType, getWidth, getXCoord, getYCoord, getZCoord, setActualBearingVelocityXY, setActualBearingVelocityXZ, setActualBearingXY, setActualBearingXZ, setActualVelocity, setDesiredBearingVelocityXY, setDesiredBearingVelocityXZ, setDesiredVelocity, setXCoord, setYCoord, setZCoord, updateLength, updateWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_STOPPED

public static final int STATE_STOPPED
See Also:
Constant Field Values

STATE_FORWARD

public static final int STATE_FORWARD
See Also:
Constant Field Values

STATE_BACKWARD

public static final int STATE_BACKWARD
See Also:
Constant Field Values

STATE_RIGHT

public static final int STATE_RIGHT
See Also:
Constant Field Values

STATE_LEFT

public static final int STATE_LEFT
See Also:
Constant Field Values
Constructor Detail

SimRCX

public SimRCX(SimWorld w,
              Controller c)
Constructor: sets up the robot with some predefined parameters

Parameters:
w - the SimWorld where this SimRCX resides
c - the Controller of this SimRCX

SimRCX

public SimRCX(SimWorld w,
              Controller c,
              double height,
              double width,
              double length,
              java.lang.String type,
              double x,
              double y,
              double z,
              double bearingXY,
              double bearingXZ,
              int battery)
Constructor: sets up the robot according to the parameters

Method Detail

getSelected

public boolean getSelected()

setSelected

public void setSelected(boolean selected)

getWorld

public SimWorld getWorld()

forward

public void forward()
Sets the robot moving forwards, this will continue until some other method is called to stop it.

Specified by:
forward in interface AbstractRobot

forward

public void forward(int time)
Makes the robot move forwards for the given amount of time

Specified by:
forward in interface AbstractRobot
Parameters:
time - the time in milliseconds

backward

public void backward()
Sets the robot moving backwards, this will continue until some other method is called to stop it.

Specified by:
backward in interface AbstractRobot

backward

public void backward(int time)
Makes the robot move backwards for the given amount of time

Specified by:
backward in interface AbstractRobot
Parameters:
time - the time in milliseconds

right

public void right()
Sets the robot spinning right, this will continue until some other method is called to stop it.

Specified by:
right in interface AbstractRobot

right

public void right(int time)
Spins the robot right for the given amount of time

Specified by:
right in interface AbstractRobot
Parameters:
time - the time in milliseconds

left

public void left()
Sets the robot spinning left, this will continue until some other method is called to stop it.

Specified by:
left in interface AbstractRobot

left

public void left(int time)
Spins the robot left for the given amount of time

Specified by:
left in interface AbstractRobot
Parameters:
time - the time in milliseconds

singleMotor

public void singleMotor(int motor,
                        int direction)
Sets a single Motor moving, this will continue until some other method is called to stop it

Specified by:
singleMotor in interface AbstractRobot
Parameters:
motor - the motor number (AbstractRobot.MOTOR_A or AbstractRobot.MOTOR_C);
direction - the direction number (AbstractRobot.BACKWARDS or AbstractRobot.FORWARDS

singleMotor

public void singleMotor(int motor,
                        int direction,
                        int time)
Sets a single Motor moving for the given amount of time

Specified by:
singleMotor in interface AbstractRobot
Parameters:
motor - the motor number (AbstractRobot.MOTOR_A or AbstractRobot.MOTOR_C);
time - the time in milliseconds
direction - the direction number (AbstractRobot.BACKWARDS or AbstractRobot.FORWARDS

pivotRotation

public void pivotRotation()

stopMoving

public void stopMoving()
Stops all motors immediately

Specified by:
stopMoving in interface AbstractRobot

beep

public void beep()
Makes the robot beep

Specified by:
beep in interface AbstractRobot

getSensor1

public int getSensor1()
Get the current reading of this sensor

Specified by:
getSensor1 in interface AbstractRobot
Returns:
the current value

getSensor2

public int getSensor2()
Get the current reading of this sensor

Specified by:
getSensor2 in interface AbstractRobot
Returns:
the current value

getSensor3

public int getSensor3()
Get the current reading of this sensor

Specified by:
getSensor3 in interface AbstractRobot
Returns:
the current value

clearLCD

public void clearLCD()
Clears the display on the LCD Modified by: Simon Zienkiewicz

Specified by:
clearLCD in interface AbstractRobot

displayNumberLCD

public void displayNumberLCD(int num)
Display numbers on the LCD Modified by: Simon Zienkiewicz

Specified by:
displayNumberLCD in interface AbstractRobot
Parameters:
num - the number to display

displayTextLCD

public void displayTextLCD(java.lang.String word)
Display text on the LCD Modified by: Simon Zienkiewicz

Specified by:
displayTextLCD in interface AbstractRobot
Parameters:
word - string to display

getLCDOutput

public java.lang.String getLCDOutput()

setMotorPower

public void setMotorPower(int power)
Sets the power of the motors for the robot Modified by: Simon Zienkiewicz

Specified by:
setMotorPower in interface AbstractRobot
Parameters:
power - the desired power

getMotorPower

public int getMotorPower()
Gets the power of the motors for the robot Modified by: Simon Zienkiewicz

Specified by:
getMotorPower in interface AbstractRobot
Returns:
the power of the motor 0-7

getTouchSensorStatus

public boolean[] getTouchSensorStatus()
Gets an array of boolean values for the touch sensors Modified by: Simon Zienkiewicz

Specified by:
getTouchSensorStatus in interface AbstractRobot
Returns:
boolean values of the status of the sensors

getVoltage

public int getVoltage()
Gets the voltage of the RCX battery in MilliVolts Modified by: Simon Zienkiewicz

Specified by:
getVoltage in interface AbstractRobot
Returns:
int voltage in the battery of the RCX

createTimer

public int createTimer(int time)
Description copied from interface: AbstractRobot
Creates a timer Created by: Simon Zienkiewicz

Specified by:
createTimer in interface AbstractRobot
Parameters:
time - the delay for the timer
Returns:
int the timer number

startTimer

public void startTimer(int num)
Description copied from interface: AbstractRobot
Starts the requested timer Created by: Simon Zienkiewicz

Specified by:
startTimer in interface AbstractRobot
Parameters:
num - the timer number

stopTimer

public void stopTimer(int num)
Description copied from interface: AbstractRobot
Stops the requested timer Created by: Simon Zienkiewicz

Specified by:
stopTimer in interface AbstractRobot
Parameters:
num - the timer number

stopAllTimers

public void stopAllTimers()
Description copied from interface: AbstractRobot
Stops all timers Created by: Simon Zienkiewicz

Specified by:
stopAllTimers in interface AbstractRobot

getDelay

public int getDelay(int num)
Description copied from interface: AbstractRobot
Gets the delay from the requested timer Created by: Simon Zienkiewicz

Specified by:
getDelay in interface AbstractRobot
Parameters:
num - the timer number
Returns:
int the timer delay

setDelay

public void setDelay(int num,
                     int time)
Description copied from interface: AbstractRobot
Sets the delay for the requested timer Created by: Simon Zienkiewicz

Specified by:
setDelay in interface AbstractRobot
Parameters:
num - the timer number
time - the new delay time

pause

public void pause(int num)
Description copied from interface: AbstractRobot
Pauses the simulation Created by: Simon Zienkiewicz

Specified by:
pause in interface AbstractRobot
Parameters:
num - the number of milliseconds

activate

public void activate()
Description copied from interface: AbstractRobot
Activates the light and touch sensors Created by: Simon Zienkiewicz

Specified by:
activate in interface AbstractRobot

lightEvent

public void lightEvent(int index)

touchEvent

public void touchEvent(int index)

playTune

public void playTune(int frequency,
                     int duration)
Description copied from interface: AbstractRobot
Plays a sound Created by: Simon Zienkiewicz

Specified by:
playTune in interface AbstractRobot
Parameters:
frequency - the sound frequency
duration - the duration of the sound in milliseconds