orbotix.robot.base
Class RobotControl

java.lang.Object
  extended by orbotix.robot.base.RobotControl
All Implemented Interfaces:
java.util.Observer

public class RobotControl
extends java.lang.Object
implements java.util.Observer

Provides services for controlling a robot.


Field Summary
static float LED_STATE_OFF
          Off state constant used in commands requiring on/off state.
static float LED_STATE_ON
          On state constant used in commands requiring on/off state.
static float MAX_JUMP_TIME
          Maximum time for running the motors for the boostUncontrolled method.
 
Constructor Summary
RobotControl(Robot robot)
          Constructs a robot control for the given robot.
 
Method Summary
 void boostUncontrolled(float timeInterval)
          An un-controlled boost to the motors with the control system turned off.
 void boostUnderControl(float timeInterval)
           
 void drive(double x, double y, double z)
          Takes accelerometer values and converts them into drive commands.
 DeviceConnection getDeviceConnecction()
          Accessor to the DeviceConnection object.
 DriveAlgorithm getDriveAlgorithm()
          Accessor to get the driveAlgorithm used for the drive method.
 Robot getRobot()
          Accessor to the robot that is under control.
 void resetHeading()
           
 void roll(float heading, float speed)
          Sends a robot moving at the given speed and heading.
 void rotate(float heading)
          Allow you to rotate the ball without giving any speed.
 void setDriveAlgorithm(DriveAlgorithm algorithm)
          Accessor to set the driveAlgorithm to be used in the drive method.
 void setRGBColor(int red, int green, int blue)
          Sets a RGB LED on the robot to match the given RGB color values.
 void start()
          Starts controlling the robotic device.
 void startCalibration()
          Method to start the calibration sequence.
 void stop()
          Stop controlling the robotic device.
 void stopCalibration(boolean calibrate)
          Method to stop the calibration sequence.
 void stopMotors()
          Stops both motors.
 void update(java.util.Observable observable, java.lang.Object o)
          Observer method that monitors for the Robot's name changes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LED_STATE_OFF

public static final float LED_STATE_OFF
Off state constant used in commands requiring on/off state.

See Also:
Constant Field Values

LED_STATE_ON

public static final float LED_STATE_ON
On state constant used in commands requiring on/off state.

See Also:
Constant Field Values

MAX_JUMP_TIME

public static final float MAX_JUMP_TIME
Maximum time for running the motors for the boostUncontrolled method. Set to 3 seconds.

See Also:
Constant Field Values
Constructor Detail

RobotControl

public RobotControl(Robot robot)
Constructs a robot control for the given robot.

Parameters:
robot - is the robot to control.
Method Detail

getRobot

public Robot getRobot()
Accessor to the robot that is under control.

Returns:
The robot.

getDeviceConnecction

public DeviceConnection getDeviceConnecction()
Accessor to the DeviceConnection object.


getDriveAlgorithm

public DriveAlgorithm getDriveAlgorithm()
Accessor to get the driveAlgorithm used for the drive method.

Returns:
The DriveAlgorithm object being used.

setDriveAlgorithm

public void setDriveAlgorithm(DriveAlgorithm algorithm)
Accessor to set the driveAlgorithm to be used in the drive method.

Parameters:
algorithm - A DriveAlgorithm object.

start

public void start()
Starts controlling the robotic device. This method blocks while setting up the connection. You can check the Robot object to check if it actually is under control.


stop

public void stop()
Stop controlling the robotic device. Stops the motors and closes the connection.


stopMotors

public void stopMotors()
Stops both motors.


drive

public void drive(double x,
                  double y,
                  double z)
Takes accelerometer values and converts them into drive commands.

Parameters:
x - The x-axis acceleration.
y - The y-axis acceleration.
z - The z-axis acceleration.

startCalibration

public void startCalibration()
Method to start the calibration sequence. Calibration is used to start a Sphero out in a known heading compared to the Android device.

See Also:
RobotControl.stopCalibration(boolean)

stopCalibration

public void stopCalibration(boolean calibrate)
Method to stop the calibration sequence.

Parameters:
calibrate - true to send the calibration command and false to abort the calibration.
See Also:
RobotControl.startCalibration()

resetHeading

public void resetHeading()

rotate

public void rotate(float heading)
Allow you to rotate the ball without giving any speed.

Parameters:
heading - The heading in degrees to change the heading to.

roll

public void roll(float heading,
                 float speed)
Sends a robot moving at the given speed and heading.

Parameters:
heading - An angle from 0.0 to 360.0 degrees.
speed - A value from 0.0 to 1.0 for speed of the robot.

setRGBColor

public void setRGBColor(int red,
                        int green,
                        int blue)
Sets a RGB LED on the robot to match the given RGB color values.

Parameters:
red - A value from 0 to 255 for the red component.
green - A value from 0 to 255 for the green component.
blue - A value from 0 to 255 for the blue component.

boostUnderControl

public void boostUnderControl(float timeInterval)

boostUncontrolled

public void boostUncontrolled(float timeInterval)
An un-controlled boost to the motors with the control system turned off. It just goes fast and out of control. There is up to 4.5 seconds to ramp up the speed and a ramp down time to turn back on the control system.

Parameters:
timeInterval - A value from 0 to 1 seconds for the boost.

update

public void update(java.util.Observable observable,
                   java.lang.Object o)
Observer method that monitors for the Robot's name changes.

Specified by:
update in interface java.util.Observer