dLife Home Page

dlife.robot.scribbler
Class Scribbler

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Robot
          extended by dlife.robot.scribbler.Scribbler

public class Scribbler
extends Robot

Class for Communicating with the Scribbler robot with an IPRE Fluke.

Version:
Mar 9, 2012
Author:
Grant Braught, Dickinson College

Field Summary
static int FLUKE_AT_FRONT
          Constant representing an orientation in which the Fluke end of the Scribbler is interpreted as the front.
static int FLUKE_AT_REAR
          Constant representing an orientation in which the Fluke end of the Scribbler is interpreted as the rear.
 
Constructor Summary
Scribbler()
          Construct a new Scribbler robot.
Scribbler(String btAddr)
          Construct a new Scribbler using a known bluetooth address.
 
Method Summary
protected  int[] getBaseSensorData()
          Get the data from the readAll command to the robot.
(package private)  myrojava.Scribbler getMyroScribbler()
          Get the Scribbler object from the Myro Java package.
 int getOrientation()
          Returns the current orientation of the Scribbler as either FLUKE_AT_REAR or FLUKE_AT_FRONT.
 String getRobotInfo()
          Get information about the Scribbler and Fluke version numbers.
protected  void restartDeviceAutoReadTimers()
           
 String sendMessage(String msg)
          This is an unsupported operation for the Scribbler.
 void setOrientation(int orientation)
          Set the orientation of the Scribbler.
 void shutDown()
          Invoked to shut down the Scribbler.
 void shutDown(boolean playShutDownSequence)
          Invoked to shut down the Scribbler.
 void startUp()
          This method establishes a connection to the Scribbler robot, marks it as alive and then plays a startup sequence on the Scribbler's speaker and LEDs to indicate that it is ready to go.
 void startUp(boolean playStartupSequence)
          This method establishes a connection to the Scribbler robot, marks it as alive and then if the parameter is true it plays a startup sequence on the Scribbler's speaker and LEDs to indicate that it is ready to go.
protected  void stopDeviceAutoReadTimers()
          Stop the autoRead threads for all of the devices currently attached to the robot.
 
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
 

Field Detail

FLUKE_AT_FRONT

public static final int FLUKE_AT_FRONT
Constant representing an orientation in which the Fluke end of the Scribbler is interpreted as the front.

See Also:
Constant Field Values

FLUKE_AT_REAR

public static final int FLUKE_AT_REAR
Constant representing an orientation in which the Fluke end of the Scribbler is interpreted as the rear.

See Also:
Constant Field Values
Constructor Detail

Scribbler

public Scribbler()
Construct a new Scribbler robot. This constructor will prompt the user to select a robot from a list of those discovered using the bluetooth discovery protocol.

Throws:
RobotCreationCanceledException - if the user cancels the creation while being asked to pick the device to use for communication.

Scribbler

public Scribbler(String btAddr)
Construct a new Scribbler using a known bluetooth address.

Parameters:
btAddr - the bluetooth address of the Scribbler.
Method Detail

getMyroScribbler

myrojava.Scribbler getMyroScribbler()
Get the Scribbler object from the Myro Java package. This object will handle all of the actual communication with the robot. It provides an API for accessing the main features of the robot and does the work of translating them into the actual commands to be sent to the robot. It also handles translating the responses from the robot into Java data structures.

Returns:
The Scribbler object from the Myro Java package.

startUp

public void startUp(boolean playStartupSequence)
This method establishes a connection to the Scribbler robot, marks it as alive and then if the parameter is true it plays a startup sequence on the Scribbler's speaker and 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 Scribbler.

startUp

public void startUp()
This method establishes a connection to the Scribbler robot, marks it as alive and then plays a startup sequence on the Scribbler's speaker and LEDs to indicate that it is ready to go.

Overrides:
startUp in class Robot
Throws:
RobotCommunicationException - if unable to communicate with the Scribbler.

shutDown

public void shutDown(boolean playShutDownSequence)
Invoked to shut down the Scribbler. This method invokes the Robot's shutDown method to remove all sensors and effectors, then if the parameter is true it plays a shutdown sequence on the Scribbler's speaker and LEDs to provide an audio/visual cue that the shutdown has occurred, it then closes the connection to the hemisson and invokes Robot.shutDown().

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

shutDown

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

Overrides:
shutDown in class Robot
Throws:
RobotCommunicationException - if unable to communicate with the Scribbler.

sendMessage

public String sendMessage(String msg)
This is an unsupported operation for the Scribbler. All devices should obtain the myrojava.Scribbler object using the getMyroScribbler method and use that object to communicate directly with the robot.

Specified by:
sendMessage in class Robot
Parameters:
msg - the message to be sent to the robot.
Returns:
the robot's response to the message or null.

getRobotInfo

public String getRobotInfo()
Get information about the Scribbler and Fluke version numbers. The response will be something similar to "fluke:2.9.1,Robot-Version:2.6.1,Robot:Scribbler,Mode:Serial"

Returns:
a string describing the Scribbler and Fluke.
Throws:
RobotCommunicationException - if the message cannot be sent or the if the response is not recieved within the delay specified by maxDelayMSB and maxDelayLSB.

setOrientation

public void setOrientation(int orientation)
Set the orientation of the Scribbler. The orientation affects the interpretation of the motion commands to the Scribbler as well as the left-right ordering of many of the sensors.

If the orientation is FLUKE_AT_FRONT then positive translation values will move the robot forward with the fluke leading the way. In this orientation the obstacle and light sensors are rear-facing.

If the orientation is FLUKE_AT_REAR then positive translation values will move the robot with the fluke bringing up the rear. In this orientation the obstacle and light sensors are rear-facing.

When this method is invoked, and the orientation is changed, the readStateFromRobot method of each device attached to the robot will be invoked. This provides each device with an immediate opportunity to adjust its sensor values to reflect the change in orientation.

Parameters:
orientation - one of the constants FLUKE_AT_REAR or FLUKE_AT_FRONT indicating the orientation of the Scribbler.

getOrientation

public int getOrientation()
Returns the current orientation of the Scribbler as either FLUKE_AT_REAR or FLUKE_AT_FRONT.

Returns:
the orientation of the Scribbler.

getBaseSensorData

protected int[] getBaseSensorData()
Get the data from the readAll command to the robot. The returned array contains the base robot sensor data at the indicated indices:

Returns:
the last read array of values.

stopDeviceAutoReadTimers

protected void stopDeviceAutoReadTimers()
Stop the autoRead threads for all of the devices currently attached to the robot. This is necessary when playing tones on the robot. The robot cannot respond to any other commands while it is playing tones. Thus, all of the read timers would timeout and mark the robot as not alive, resulting in the controller being terminated. Instead, we just stop all of the auto read timers before playing the tone and then restart them after.


restartDeviceAutoReadTimers

protected void restartDeviceAutoReadTimers()

dLife Home Page