Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## PER.rover.control
Class RoverState

    java.lang.Object
      PER.rover.control.RoverState

Direct Known Subclasses:
  ActionConstants

public class RoverState
extends java.lang.Object

Allows one to determine the current status of the rover. The state is updated when commands are sent to the rover or by calling refresh in RoverController. The constants in this class are used to represent the rovers current status as well as used as Action return values.

See Also:
  `RoverController.refresh()`, `Action.getReturnValue()`

Field Summary
`static int` | `BAD_INPUT` Function call to the Stayton with bad input arguments.
`static int` | `BATTERY_LOW` Battery voltage low.
`static int` | `CAMERA_TIMEOUT` The cameara failed to respond.
`static int` | `CEREB_DRIVETO`
`static int` | `CEREB_IDLE`
`static int` | `CEREB_SCAN`
`static int` | `CEREB_STARTING`
`static int` | `CEREB_TIMEOUT` The cerebeluum failed to respond.
`static int` | `CEREB_TURNTO`
`int` | `cerebThreadState` The state of the cerebellum thread
`static int` | `COMM_DEAD` Wireless communication not working.
`static int` | `FULL_PACKET_LENGTH` Length of a packet from the rover.
`static int` | `HIT_WALL` Came too close to a wall.
`static int` | `HL_CONTINUE` This code indicates that the rover is currently doing a DriveTo or TurnTo
`static int` | `INVALID_PACKET_LENGTH` Response from Stayton is the wrong length.
`static int` | `KILLED` Manually terminated.
`static int` | `LEGS_LOCK`
`int` | `locks` A bitmask telling you what parts of the rover are in use
`static int` | `NOT_CONNECTED` Not connected to the robot.
`static int` | `OBSTACLE_DETECTED` IR Rangefinder detected an obstacle.
`static int` | `PAN_LOCK`
`static int` | `RESOURCE_CONFLICT` What you're trying to do can't be done because the resource is already in use.
`static int` | `STAYTON_INVALID_LENGTH` Command to the Stayton is the wrong length.
`static int` | `STAYTON_IO_ERROR` Error on Stayton.
`static int` | `STAYTON_UNKNOWN_TYPE` The Stayton does not recognize the command sent to it.
`static int` | `SUCCESS` Command successful.
`static int` | `TILT_LOCK`
`static int` | `UNKNOWN_PACKET_TYPE` Sent unknown packet type to Stayton.
`static int` | `WEBCAM_CYCLE_PIC`
`static int` | `WEBCAM_CYCLY_NOPIC`
`static int` | `WEBCAM_GRAB`
`static int` | `WEBCAM_IDLE`
`static int` | `WEBCAM_MEAN`
`static int` | `WEBCAM_MOTION`
`static int` | `WEBCAM_PIC`
`static int` | `WEBCAM_PROPERTIES`
`static int` | `WEBCAM_STOP`
`static int` | `WEBCAM_TRACK`
`int` | `webCamThreadState` The state of the web cam thread

Constructor Summary
`RoverState()` Creates new RoverState

Method Summary
`int` | `getDist()` Returns the absolute value of how far the rover has traveled.
`int` | `getPan()` Gets the pan angle.
`double[]` | `getPosition()` Returns the current coordinates of the robot.
`int` | `getRange()` Returns the raw IR rangefinder reading from the cerebellum.
`int` | `getRangeCM()` This function attempts to translate the range from the range sensing output of the sensor to centimeters.
`int` | `getRawVoltage()` Gets the raw voltage reading from the cerebellum.
`double` | `getRealVoltage()` Gets a translated voltage reading on the robot.
`int` | `getStatus()` Gets the last status code that the rover sent back.
`java.lang.String` | `getStatusMessage()` Gives a description of the status of the last command sent.
`int` | `getTilt()` Gets the tilt angle.
`boolean` | `isTerminationCondition()` Function to help with high level commands.
`boolean` | `parsePacket(byte[] packet)` Parses a packet from the rover.
`void` | `setCrabAngle(int cA)` Set the current angle representing the direction of motion of the robot regardless of it's heading.
`void` | `setPan(int pan)` Sets the current status; This should only be done in ReceiveThread.
`void` | `setPosition(double x, double y, double theta)` Sets the current coordinate position.
`void` | `setSign(int sign)` Set the current sign representing the direction of motion of the robot.
`void` | `setStatus(int status)` Sets the current status; This should only be done in RoverController.
`void` | `setTilt(int tilt)` Sets the current status; This should only be done in ReceiveThread.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### locks

    public int locks

  A bitmask telling you what parts of the rover are in use

### cerebThreadState

    public int cerebThreadState

  The state of the cerebellum thread

### webCamThreadState

    public int webCamThreadState

  The state of the web cam thread

### LEGS_LOCK

    public static final int LEGS_LOCK

See Also:
  Constant Field Values

### PAN_LOCK

    public static final int PAN_LOCK

See Also:
  Constant Field Values

### TILT_LOCK

    public static final int TILT_LOCK

See Also:
  Constant Field Values

### CEREB_IDLE

    public static final int CEREB_IDLE

See Also:
  Constant Field Values

### CEREB_STARTING

    public static final int CEREB_STARTING

See Also:
  Constant Field Values

### CEREB_SCAN

    public static final int CEREB_SCAN

See Also:
  Constant Field Values

### CEREB_TURNTO

    public static final int CEREB_TURNTO

See Also:
  Constant Field Values

### CEREB_DRIVETO

    public static final int CEREB_DRIVETO

See Also:
  Constant Field Values

### WEBCAM_IDLE

    public static final int WEBCAM_IDLE

See Also:
  Constant Field Values

### WEBCAM_STOP

    public static final int WEBCAM_STOP

See Also:
  Constant Field Values

### WEBCAM_CYCLE_PIC

    public static final int WEBCAM_CYCLE_PIC

See Also:
  Constant Field Values

### WEBCAM_CYCLY_NOPIC

    public static final int WEBCAM_CYCLY_NOPIC

See Also:
  Constant Field Values

### WEBCAM_PIC

    public static final int WEBCAM_PIC

See Also:
  Constant Field Values

### WEBCAM_GRAB

    public static final int WEBCAM_GRAB

See Also:
  Constant Field Values

### WEBCAM_PROPERTIES

    public static final int WEBCAM_PROPERTIES

See Also:
  Constant Field Values

### WEBCAM_TRACK

    public static final int WEBCAM_TRACK

See Also:
  Constant Field Values

### WEBCAM_MEAN

    public static final int WEBCAM_MEAN

See Also:
  Constant Field Values

### WEBCAM_MOTION

    public static final int WEBCAM_MOTION

See Also:
  Constant Field Values

### FULL_PACKET_LENGTH

    public static final int FULL_PACKET_LENGTH

  Length of a packet from the rover.

  See Also:
    Constant Field Values

### SUCCESS

    public static final int SUCCESS

  Command successful.

  See Also:
    Constant Field Values

### HL_CONTINUE

    public static final int HL_CONTINUE

  This code indicates that the rover is currently doing a DriveTo or TurnTo

  See Also:
    Constant Field Values

### INVALID_PACKET_LENGTH

    public static final int INVALID_PACKET_LENGTH

  Response from Stayton is the wrong length.

  See Also:
    Constant Field Values

### UNKNOWN_PACKET_TYPE

    public static final int UNKNOWN_PACKET_TYPE

  Sent unknown packet type to Stayton.

  See Also:
    Constant Field Values

### COMM_DEAD

    public static final int COMM_DEAD

  Wireless communication not working.

  See Also:
    Constant Field Values

### NOT_CONNECTED

    public static final int NOT_CONNECTED

  Not connected to the robot.

  See Also:
    Constant Field Values

### STAYTON_INVALID_LENGTH

    public static final int STAYTON_INVALID_LENGTH

  Command to the Stayton is the wrong length.

  See Also:
    Constant Field Values

### STAYTON_UNKNOWN_TYPE

    public static final int STAYTON_UNKNOWN_TYPE

  The Stayton does not recognize the command sent to it.

  See Also:
    Constant Field Values

### BAD_INPUT

    public static final int BAD_INPUT

  Function call to the Stayton with bad input arguments.

  See Also:
    Constant Field Values

### CEREB_TIMEOUT

    public static final int CEREB_TIMEOUT

  The cerebeluum failed to respond.

  See Also:
    Constant Field Values

### CAMERA_TIMEOUT

    public static final int CAMERA_TIMEOUT

  The cameara failed to respond.

  See Also:
    Constant Field Values

### STAYTON_IO_ERROR

    public static final int STAYTON_IO_ERROR

  Error on Stayton.

  See Also:
    Constant Field Values

### BATTERY_LOW

    public static final int BATTERY_LOW

  Battery voltage low.

  See Also:
    Constant Field Values

### KILLED

    public static final int KILLED

  Manually terminated.

  See Also:
    Constant Field Values

### OBSTACLE_DETECTED

    public static final int OBSTACLE_DETECTED

  IR Rangefinder detected an obstacle.

  See Also:
    Constant Field Values

### HIT_WALL

    public static final int HIT_WALL

  Came too close to a wall.

  See Also:
    Constant Field Values

### RESOURCE_CONFLICT

    public static final int RESOURCE_CONFLICT

  What you're trying to do can't be done because the resource is already in use. Look at the locks, cerebThreadState, and webCamThreadState variables.

  See Also:
    Constant Field Values

Constructor Detail

### RoverState

    public RoverState()

  Creates new RoverState

Method Detail

### parsePacket

    public boolean parsePacket(byte[] packet)

  Parses a packet from the rover. Computes coordinate changes.

  Parameters:
    `packet` - The packet, which should be FULL_PACKET_LENGTH long.
  Returns:
    true if it is the right length and the status is SUCCESS

### getStatus

    public int getStatus()

  Gets the last status code that the rover sent back.

  Returns:
    the status code
  See Also:
    `getStatusMessage()`

### getStatusMessage

    public java.lang.String getStatusMessage()

  Gives a description of the status of the last command sent.

  Returns:
    the message

### setStatus

    public void setStatus(int status)

  Sets the current status; This should only be done in RoverController.

### setPan

    public void setPan(int pan)

  Sets the current status; This should only be done in ReceiveThread.

### setTilt

    public void setTilt(int tilt)

  Sets the current status; This should only be done in ReceiveThread.

### setSign

    public void setSign(int sign)

  Set the current sign representing the direction of motion of the robot. Used in calculating the coordinates, this should only be called by RoverController.

### setCrabAngle

    public void setCrabAngle(int cA)

  Set the current angle representing the direction of motion of the robot regardless of it's heading. Used in calculating the coordinates, this should only be called by RoverController.

### setPosition

    public void setPosition(double x,
                            double y,
                            double theta)

  Sets the current coordinate position. Call on the highLevelState, as that is where the coordinates are stored. The coordinates are centered on the robot with the X axis running parallel to the rover.

  Parameters:
    `x` - The new X coordinate in centimeters
    `y` - The new Y coordinate in centimeters
    `theta` - The new orientation, in integer degrees

### getRange

    public int getRange()

  Returns the raw IR rangefinder reading from the cerebellum. This is an 8-bit value and typical values range from 0 to 140. A value of 140 means that an object is about 20cm away and the value falls off as the distance increases. The minimum useful reading is about 20 and that corresponds to an object being about 150cm away. For more information, see the data sheet for the sensor at http://www.acroname.com/robotics/parts/gp2y0a02_e.pdf

  Returns:
    The raw reading from the cerebellum.

### getRangeCM

    public int getRangeCM()

  This function attempts to translate the range from the range sensing output of the sensor to centimeters. I'm assuming that the object is more than 15cm away for this converstion. Raw values greater than 135 get mapped to 20cm and raw values less than 25 get mapped to Integer.MAX_VALUE. Other than that, the values returned by this function are very close to the actual distance.

  Returns:
    The distance in centimeters.

### getPan

    public int getPan()

  Gets the pan angle. Positive angles are to the left of center.

  Returns:
    The pan angles in degrees.

### getTilt

    public int getTilt()

  Gets the tilt angle. Positive angles are above level.

  Returns:
    The tilt angle in degrees.

### getRawVoltage

    public int getRawVoltage()

  Gets the raw voltage reading from the cerebellum.

  Returns:
    the raw voltage reading, between 0 and 255.

### getRealVoltage

    public double getRealVoltage()

  Gets a translated voltage reading on the robot. Fully charged batteries should be at about 32V. If the battery voltage falls below about 25V, the rover is programmed to stop accepting commands. As long as the voltage is above 29V, everything's fine.

  Returns:
    the voltage of the batteries in volts

### getDist

    public int getDist()

  Returns the absolute value of how far the rover has traveled. This is in cm is the last command was a goTo and degrees if the last command was a turnTo.

  Returns:
    the absolute value of how far the rover has traveled (cm for goTo or degrees for turnTo)

### getPosition

    public double[] getPosition()

  Returns the current coordinates of the robot. Call on the highLevelState, as that is where the coordinates are stored.

  Returns:
    The current coordinates as doubles in a 3 element array. (x, y, theta in centimeters and degrees). The coordinates are centered on the robot with the X axis running parallel to the rover.

### isTerminationCondition

    public boolean isTerminationCondition()

  Function to help with high level commands.

  Returns:
    true if the status returned caused the high level command to terminate.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD