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
Class ScanAction

    java.lang.Object
      PER.rover.ScanAction

All Implemented Interfaces:
  Action, java.io.Serializable

public class ScanAction
extends java.lang.Object
implements Action

ScanAction.java uses the IR rangefinder to search for "rocks" near the rover. If multiple rocks are found, preference is given to the one closest to the front of the rover.

See Also:
  Serialized Form

Field Summary
`static int` | `DISTANCE_THRESHOLD` An object needs to be at least this close to be called a rock.
`static int` | `IR_HEIGHT` The height of the IR range finger, in cm.
`static int` | `MAX_ROCK_WIDTH` A rock can be at most this wide, otherwise I call it a wall.

Constructor Summary
`ScanAction()` Creates a new instance of ScanAction with default scan parameters of tilt -10, minimum pan angle -135, maximum pan angle 135, and step 5.
`ScanAction(int tilt, int minPan, int maxPan, int step)` Scans the area around where the rover is.

Method Summary
`int` | `closestReading()`
`boolean` | `doAction(Rover r)` Tries to start the action.
`int[]` | `getClosestPoint()` Finds and returns the closest point from the recent scan
`long` | `getImageUpdateTime()` Lets you know when the last image was taken by this action.
`int` | `getMaxRockAngle()`
`int` | `getMinRockAngle()`
`java.awt.image.BufferedImage` | `getRecentImage()` Returns the most recent image taken by this Action.
`int` | `getReturnValue()` The return value of the Action.
`int` | `getRockAngle()` Getter for property rockAngle.
`int` | `getRockDist()` Getter for property rockDist.
`java.lang.String` | `getShortSummary()` Provides a shortened version of the summary returned by getSummary.
`java.lang.String` | `getSummary()` Provides a textual explanation of the Action, such as "turn 90 degrees"
`int` | `getTime()` How long the action will take, in milliseconds.
`int` | `getTimeRemaining()` How much time until the action finishes (in milliseconds), if it has already started.
`boolean` | `hasDetectedWall()` Returns whether or not a wall was detected.
`boolean` | `hasFoundRock()` Getter for property foundRock.
`boolean` | `isCompleted()` Whether the action has completed.
`boolean` | `isSuccess()` Whether the action completed successfully.
`void` | `kill()` this action can't currently be killed
`int` | `moveFromRock(Rover rov, int turnAngle)` If the rover is near a rock and will turn into it, this function should make it so that the rover won't hit the rock
`void` | `setBorderRocks(boolean allow)`
`static int` | `translateScan(int scan)`

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

Field Detail

### DISTANCE_THRESHOLD

    public static final int DISTANCE_THRESHOLD

  An object needs to be at least this close to be called a rock.

  See Also:
    Constant Field Values

### MAX_ROCK_WIDTH

    public static final int MAX_ROCK_WIDTH

  A rock can be at most this wide, otherwise I call it a wall.

  See Also:
    Constant Field Values

### IR_HEIGHT

    public static final int IR_HEIGHT

  The height of the IR range finger, in cm.

  See Also:
    Constant Field Values

Constructor Detail

### ScanAction

    public ScanAction()

  Creates a new instance of ScanAction with default scan parameters of tilt -10, minimum pan angle -135, maximum pan angle 135, and step 5.

### ScanAction

    public ScanAction(int tilt,
                      int minPan,
                      int maxPan,
                      int step)

  Scans the area around where the rover is. The scan is done starting with the minPan and increments to maxPan. Scans are done at positions from minPan to maxPan inclusive.

Parameters:
  `tilt` - The tilt at which the scan is done.
  `minPan` - The pan angle at which the scan starts
  `maxPan` - The pan angle at which the scan ends.
  `step` - The angle difference between successive scan points.

Method Detail

### doAction

    public boolean doAction(Rover r)

  Description copied from interface: `Action`
  Tries to start the action. Returns whether the action started.

  Specified by:
    `doAction` in interface `Action`

### getReturnValue

    public int getReturnValue()

  Description copied from interface: `Action`
  The return value of the Action. Zero is a success. Negative implies one of this class's constants. Other values should be interpreted as appropriate.

  Specified by:
    `getReturnValue` in interface `Action`
  See Also:
    `RoverState`, `ActionConstants`

### getShortSummary

    public java.lang.String getShortSummary()

  Description copied from interface: `Action`
  Provides a shortened version of the summary returned by getSummary. For example, getSummary may return something like "Turn left and drive about 39 inches toward the red landmark," whereas getShortSummary might just return "Drive toward a landmark."

  Specified by:
    `getShortSummary` in interface `Action`

### getSummary

    public java.lang.String getSummary()

  Description copied from interface: `Action`
  Provides a textual explanation of the Action, such as "turn 90 degrees"

  Specified by:
    `getSummary` in interface `Action`

### getTime

    public int getTime()

  Description copied from interface: `Action`
  How long the action will take, in milliseconds.

  Specified by:
    `getTime` in interface `Action`

### getTimeRemaining

    public int getTimeRemaining()

  Description copied from interface: `Action`
  How much time until the action finishes (in milliseconds), if it has already started. Undefined behavior if the action has not yet begun, or has finished.

  Specified by:
    `getTimeRemaining` in interface `Action`

### isCompleted

    public boolean isCompleted()

  Description copied from interface: `Action`
  Whether the action has completed. Undefined until doAction has been called.

  Specified by:
    `isCompleted` in interface `Action`

### isSuccess

    public boolean isSuccess()

  Description copied from interface: `Action`
  Whether the action completed successfully. Undefined until isCompleted() returns true.

  Specified by:
    `isSuccess` in interface `Action`

### kill

    public void kill()

  this action can't currently be killed

  Specified by:
    `kill` in interface `Action`

### hasFoundRock

    public boolean hasFoundRock()

  Getter for property foundRock.

  Returns:
    Whether or not a rock has been detected, only valid once action is complete.

### getRockAngle

    public int getRockAngle()

  Getter for property rockAngle.

  Returns:
    The angle to the nearest rock, but only if a rock was found.

### getRockDist

    public int getRockDist()

  Getter for property rockDist.

  Returns:
    The cm distance to a detected rock.

### getMinRockAngle

    public int getMinRockAngle()

### getMaxRockAngle

    public int getMaxRockAngle()

### closestReading

    public int closestReading()

### getClosestPoint

    public int[] getClosestPoint()

  Finds and returns the closest point from the recent scan

  Returns:
    an array containing the distance in position 0 and the angle in position 1, or null if nothing was detected.

### translateScan

    public static int translateScan(int scan)

### setBorderRocks

    public void setBorderRocks(boolean allow)

### hasDetectedWall

    public boolean hasDetectedWall()

  Returns whether or not a wall was detected. Only valid once the action is completed.

### moveFromRock

    public int moveFromRock(Rover rov,
                            int turnAngle)

  If the rover is near a rock and will turn into it, this function should make it so that the rover won't hit the rock

  Parameters:
    `rov` - An active instantion of a Rover
    `turnAngle` - the angle that the rover is about to turn

### getImageUpdateTime

    public long getImageUpdateTime()

  Description copied from interface: `Action`
  Lets you know when the last image was taken by this action. If the Action does not take pictures or the first picture has not yet been taken, will return 0.

  Specified by:
    `getImageUpdateTime` in interface `Action`
  Returns:
    the system time in milliseconds when the last image was taken or 0 if no images have been taken

### getRecentImage

    public java.awt.image.BufferedImage getRecentImage()

  Description copied from interface: `Action`
  Returns the most recent image taken by this Action. The image will be null if the Action does not take pictures or the first picture has not yet been taken.

  Specified by:
    `getRecentImage` in interface `Action`
  Returns:
    the most recent picture taken by the Action.

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