roomba.roombanetwork.services.userservice
Class Roomba

java.lang.Object
  extended by roomba.roombanetwork.services.userservice.Roomba
All Implemented Interfaces:
ClientListener

public class Roomba
extends java.lang.Object
implements ClientListener

A User Service representation of a Roomba. This class will get a lock on a Roomba, send commands to the Roomba via the RNS, and receive sensor data back from the Roomba via the RNS.

Author:
Drew Housten

Constructor Summary
Roomba()
          Constructor - gets a lock on a Roomba service
Roomba(boolean lockNeeded)
          Constructor - connects to a Roomba service
Roomba(java.lang.String roombaName)
          Constructor - gets a lock on a specific Roomba, specified by the name
Roomba(java.lang.String roombaName, boolean lockNeeded)
          Constructor - connects on a specific Roomba, specified by the name
 
Method Summary
 void addSongNote(int notenum, int duration)
          Adds a note to the current song.
 void clearSong()
          Clears the current song without playing it
 void drive(double distance)
          Command the Roomba to drive a distance (in Meters)
 void forwardForTime(double speed, double duration)
          Command the Roomba to drive straight for the specified time duration (in seconds) at the speed specified
 void forwardSpeed(double speed)
          Command the Roomba to drive straight at the specified speed
 int getAngle()
          Gets the rotational distance traveled from the initial position
 int getBattery()
          Gets the battery charge level
 boolean getCenterWheelDrop()
          Gets the status of the center wheel drop sensor
 boolean getCliffFrontLeft()
          Gets the status of the cliff front left sensor
 boolean getCliffFrontRight()
          Gets the status of the cliff front right sensor
 boolean getCliffLeft()
          Gets the status of the cliff left sensor
 boolean getCliffRight()
          Gets the status of the cliff right sensor
 int getDistance()
          Gets the translational distance traveled from the initial position
 boolean getLeftBump()
          Gets the status of the left bump sensor
 boolean getLeftWheelDrop()
          Gets the status of the left wheel drop sensor
 double getLocalizedX()
          Gets the x position reported by localization.
 double getLocalizedY()
          Gets the y position reported by localization.
 double getOdometryX()
          Gets the x position reported by odometry
 double getOdometryY()
          Gets the y position reported by odometry
 boolean getRightBump()
          Gets the status of the right bump sensor
 boolean getRightWheelDrop()
          Gets the status of the right wheel drop sensor
 boolean getVirtualWall()
          Gets the status of the virtual wall sensor
 boolean getWall()
          Gets the status of the wall sensor
 void messageReceived(java.lang.String messageType, java.lang.String[] messageComponents)
          Processes a message received.
 void pause(double duration)
          Command the Roomba to not process any other commands for the specified duration (in seconds)
 void playSong()
          Command the Roomba to play the current song.
 void setStatusGreenLED(boolean statusGreenLED)
          Command the Roomba to set the green status LED
 void setStatusRedLED(boolean statusRedLED)
          Command the Roomba to set the red status LED
 void turn(double angle)
          Command the Roomba to turn an angle (in degrees)
 void turnForTime(double speed, double duration)
          Command the Roomba to turn for the specified time duration (in seconds) at the speed specified
 void turnSpeed(double speed)
          Command the Roomba to turn at the specified speed
 void waitForBump()
          This method will block until either bump sensor is detected
 void waitForVirtualWall()
          This method will block until a virtual wall is detected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Roomba

public Roomba()
Constructor - gets a lock on a Roomba service


Roomba

public Roomba(boolean lockNeeded)
Constructor - connects to a Roomba service

Parameters:
lockNeeded - True iff the client needs a lock on the roomba

Roomba

public Roomba(java.lang.String roombaName)
Constructor - gets a lock on a specific Roomba, specified by the name

Parameters:
roombaName - The roomba service name to lock

Roomba

public Roomba(java.lang.String roombaName,
              boolean lockNeeded)
Constructor - connects on a specific Roomba, specified by the name

Parameters:
roombaName - The roomba service name to lock
lockNeeded - True iff the client needs a lock on the roomba
Method Detail

messageReceived

public void messageReceived(java.lang.String messageType,
                            java.lang.String[] messageComponents)
Processes a message received.

Specified by:
messageReceived in interface ClientListener
Parameters:
messageType - The message type
messageComponents - The components of the received message

drive

public void drive(double distance)
Command the Roomba to drive a distance (in Meters)

Parameters:
distance - The distance in Meters to drive

turn

public void turn(double angle)
Command the Roomba to turn an angle (in degrees)

Parameters:
angle - The angle in degrees to turn

forwardSpeed

public void forwardSpeed(double speed)
Command the Roomba to drive straight at the specified speed

Parameters:
speed - The drive speed

forwardForTime

public void forwardForTime(double speed,
                           double duration)
Command the Roomba to drive straight for the specified time duration (in seconds) at the speed specified

Parameters:
speed - Speed to move at. If this is positive, the robot will move forward. Otherwise it will move in reverse.
duration - Time to move forward in seconds

turnSpeed

public void turnSpeed(double speed)
Command the Roomba to turn at the specified speed

Parameters:
speed - The turn speed

turnForTime

public void turnForTime(double speed,
                        double duration)
Command the Roomba to turn for the specified time duration (in seconds) at the speed specified

Parameters:
speed - Speed to turn at. If this is positive, the robot will turn to the right. Otherwise it will turn to the left.
duration - Time to move forward in seconds

pause

public void pause(double duration)
Command the Roomba to not process any other commands for the specified duration (in seconds)

Parameters:
duration - The duration to wait in seconds

setStatusGreenLED

public void setStatusGreenLED(boolean statusGreenLED)
Command the Roomba to set the green status LED

Parameters:
statusGreenLED - True iff the green status LED should be on

setStatusRedLED

public void setStatusRedLED(boolean statusRedLED)
Command the Roomba to set the red status LED

Parameters:
statusRedLED - True iff the red status LED should be on

addSongNote

public void addSongNote(int notenum,
                        int duration)
Adds a note to the current song. This does not play the song until playSong() is called. The current song can also be cleared with the clearSong() method.

Parameters:
notenum - The note number
duration - The note duration

clearSong

public void clearSong()
Clears the current song without playing it


playSong

public void playSong()
Command the Roomba to play the current song. Use the addSongNote() method to build the song. This method will clear the current song.


getLeftBump

public boolean getLeftBump()
Gets the status of the left bump sensor

Returns:
true iff the left bump sensor is pressed

getRightBump

public boolean getRightBump()
Gets the status of the right bump sensor

Returns:
true iff the right bump sensor is pressed

getCliffFrontLeft

public boolean getCliffFrontLeft()
Gets the status of the cliff front left sensor

Returns:
true iff the cliff front left sensor detects a cliff

getCliffFrontRight

public boolean getCliffFrontRight()
Gets the status of the cliff front right sensor

Returns:
true iff the cliff front right sensor detects a cliff

getCliffLeft

public boolean getCliffLeft()
Gets the status of the cliff left sensor

Returns:
true iff the cliff left sensor detects a cliff

getCliffRight

public boolean getCliffRight()
Gets the status of the cliff right sensor

Returns:
true iff the cliffright sensor detects a cliff

getWall

public boolean getWall()
Gets the status of the wall sensor

Returns:
true iff the wall sensor detects a wall

getVirtualWall

public boolean getVirtualWall()
Gets the status of the virtual wall sensor

Returns:
true iff the virtual sensor detects a wall

getLeftWheelDrop

public boolean getLeftWheelDrop()
Gets the status of the left wheel drop sensor

Returns:
true iff the left wheel drop sensor is triggered

getRightWheelDrop

public boolean getRightWheelDrop()
Gets the status of the right wheel drop sensor

Returns:
true iff the right wheel drop sensor is triggered

getCenterWheelDrop

public boolean getCenterWheelDrop()
Gets the status of the center wheel drop sensor

Returns:
true iff the center wheel drop sensor is triggered

getBattery

public int getBattery()
Gets the battery charge level

Returns:
the battery charge level in mAh

getDistance

public int getDistance()
Gets the translational distance traveled from the initial position

Returns:
the translational distance traveled

getAngle

public int getAngle()
Gets the rotational distance traveled from the initial position

Returns:
the rotational distance traveled

getOdometryX

public double getOdometryX()
Gets the x position reported by odometry

Returns:
The odometry x position in meters

getOdometryY

public double getOdometryY()
Gets the y position reported by odometry

Returns:
The odometry y position in meters

getLocalizedX

public double getLocalizedX()
Gets the x position reported by localization. If localization has not reported a position, this will return the odometry x

Returns:
The localized x position in meters

getLocalizedY

public double getLocalizedY()
Gets the y position reported by localization. If localization has not reported a position, this will return the odometry y

Returns:
The localized y position in meters

waitForVirtualWall

public void waitForVirtualWall()
This method will block until a virtual wall is detected


waitForBump

public void waitForBump()
This method will block until either bump sensor is detected