dLife Home Page

dlife.robot.khepera2
Class Khepera2

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Robot
          extended by dlife.robot.util.kteam.KTeamRobot
              extended by dlife.robot.khepera2.Khepera2

public class Khepera2
extends KTeamRobot

Class for communicating with a Khepera2 robot. The Khepera2 can be communicated either via a serial device file (unix) or via bluetooth wireless (requires a bluetooth turret). When running with the bluetooth turret, setting its communications with the Khepera to 38400 bits/s gives more reliable communications than the 115200 bits/s setting.

Version:
Jan 13, 2011
Author:
Grant Braught, Dickinson College

Field Summary
 
Fields inherited from class dlife.robot.util.kteam.KTeamRobot
BLUETOOTH, SERIAL
 
Constructor Summary
Khepera2()
          Create a new Khepera2 robot.
Khepera2(KTeamCommDelegate delegate)
          Create a new Khepera2 robot that uses the provided delegate to communicate with the robot.
Khepera2(String device, int type)
          Create a new Khepera2 robot.
 
Method Summary
 String getBluetoothNamePatternRegEx()
          Return a regular expression that matches the bluetooth name of all of the Khepera2 bluetooth modules.
 String getRobotTypeName()
          Return the name of the robot - "Khepera2"
 void shutDown()
          Invoked to shut down the Khepera2.
 void shutDown(boolean playShutDownSequence)
          Invoked to shut down the Khepera2.
 void startUp()
          This method establishes a connection to the Khepera2 robot, marks it as alive and then flashes the Khepera2 LED's to indicate that it is ready to go.
 void startUp(boolean playStartupSequence)
          This method establishes a connection to the Khepera2 robot, marks it as alive and then if the parameter is true it flashes the Khepera2's LEDs to indicate that it is ready to go.
 
Methods inherited from class dlife.robot.util.kteam.KTeamRobot
sendMessage, sendMessage
 
Methods inherited from class dlife.robot.Robot
addDevice, freeze, getDevices, getRunTime, isAlive, removeDevice, setAlive
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Khepera2

public Khepera2()
Create a new Khepera2 robot. When a new Khepera2 robot is created using this constructor it prompts the user to select the khepera2 with which to communicate. The dialog that appears allows the user to establish either a serial connection (via a device file. e.g. /dev/ttys0) or a bluetooth connection.

Throws:
RobotCreationCanceledException - if the user cancels the creation while being asked to pick the device to use for communication.
RobotCommunicationException - if communication cannot be established with the robot elected by the user.

Khepera2

public Khepera2(String device,
                int type)
Create a new Khepera2 robot. This constructor accepts either the name of the device file (e.g. /dev/ttys0) or the bluetooth address to be used for communication with the robot. The type parameter must be one of the class constants (SERIAL or BLUETOOTH) indicating which type of connection is to be made.

Parameters:
device - the full path to the device file or the bluetooth address to be used to communicate with the Khepera2.
type - the type of connection (SERIAL or BLUETOOTH).
Throws:
RobotCommunicationException - if communication cannot be established with the robot on the device file selected by user.

Khepera2

public Khepera2(KTeamCommDelegate delegate)
Create a new Khepera2 robot that uses the provided delegate to communicate with the robot. This constructor is included primarily for testing purposes. It allows junit tests to create a mock delegate to facilitate testing. However, it can also be used with other KTeamCommDelegate implementations as well (e.g. KTeamSerialDelegate or KTeamBluetoothDelegate).

Parameters:
delegate - the KTeamCommDelegate to use to communicate with the robot.
Method Detail

startUp

public void startUp(boolean playStartupSequence)
This method establishes a connection to the Khepera2 robot, marks it as alive and then if the parameter is true it flashes the Khepera2's LEDs to indicate that it is ready to go.

Parameters:
playStartupSequence - true to play startup sequence, false to startup silently.
Throws:
RobotCommunicationException - if unable to communicate with the Khepera2.

startUp

public void startUp()
This method establishes a connection to the Khepera2 robot, marks it as alive and then flashes the Khepera2 LED's to indicate that it is ready to go.

Overrides:
startUp in class KTeamRobot
Throws:
RobotCommunicationException - if unable to communicate with the Khepera2.

shutDown

public void shutDown(boolean playShutDownSequence)
Invoked to shut down the Khepera2. This method invokes the Robot's shutDown method to remove all sensors and effectors, then if the parameter is true if flashes the Khepera2's LEDs to provide a visual cue that the shutdown has occurred, it then closes the connection to the Khepera2 and invokes Robot.shutDown().

Parameters:
playShutDownSequence - true to play the shutdown sequence, false to shutdown silently.
Throws:
RobotCommunicationException - if unable to communicate with the Khepera2.

shutDown

public void shutDown()
Invoked to shut down the Khepera2. This method invokes the Robot's shutDown method to remove all sensors and effectors, it then flashes the Khepera2's LEDs to provide an audio/visual cue that the shutdown has occurred, it then closes the connection to the Khepera2 and sets it as not alive.

Overrides:
shutDown in class KTeamRobot
Throws:
RobotCommunicationException - if unable to communicate with the Khepera2.

getBluetoothNamePatternRegEx

public String getBluetoothNamePatternRegEx()
Return a regular expression that matches the bluetooth name of all of the Khepera2 bluetooth modules.

Specified by:
getBluetoothNamePatternRegEx in class KTeamRobot
Returns:
"kheradio.*";

getRobotTypeName

public String getRobotTypeName()
Return the name of the robot - "Khepera2"

Specified by:
getRobotTypeName in class KTeamRobot
Returns:
"Khepera2"

dLife Home Page