|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.cmu.ri.createlab.hummingbird.HummingbirdRobot
public class HummingbirdRobot
Constructor Summary | |
---|---|
HummingbirdRobot()
Creates the Hummingbird object and automatically connects to a Hummingbird (if no Hummingbird is attached, this will hang until you attach one) |
Method Summary | |
---|---|
void |
disconnect()
Disconnects the Hummingbird from your program. |
boolean |
emergencyStop()
Turns off all motors, vibrations motors, LEDs, and full-color LEDs. |
java.lang.Integer |
getSensorValue(int analogInputPortId)
Returns the value of the given port id; returns -1 if an error occurred while trying to read the value. |
int[] |
getSensorValues()
Gets all of the sensor values state. |
byte[] |
getSpeech(java.lang.String whatToSay)
Converts the given text into speech, and returns the resulting WAV sound clip as a byte array. |
boolean |
isMotorPowerEnabled()
Returns true if motor power is plugged in; false otherwise. |
void |
playClip(byte[] data)
Plays the sound clip contained in the given byte array. |
void |
playTone(int frequency,
int volume,
int duration)
Plays a tone having the given frequency , volume , and duration . |
boolean |
setFullColorLED(int ledId,
int red,
int green,
int blue)
Sets the full-color LED specified by the given ledId to the given red, green, and blue intensities. |
java.awt.Color[] |
setFullColorLEDs(boolean[] mask,
java.awt.Color[] colors)
Sets the full-color LEDs specified by the given mask to the given colors . |
boolean |
setLED(int ledId,
int intensity)
Sets the LED specified by the given ledId to the given intensity . |
int[] |
setLEDs(boolean[] mask,
int[] intensities)
Sets the LEDs specified by the given mask to the given intensities . |
int[] |
setMotorVelocities(boolean[] mask,
int[] velocities)
Sets the motors specified by the given mask to the given velocities . |
boolean |
setMotorVelocity(int motorId,
int velocity)
Sets the motor specified by the given motorId to the given (signed) velocity . |
boolean |
setServoPosition(int servoId,
int position)
Sets the servo specified by the given servoId to the given position . |
int[] |
setServoPositions(boolean[] mask,
int[] positions)
Sets the servo motors specified by the given mask to the given positions . |
boolean |
setVibrationMotorSpeed(int motorId,
int intensity)
Sets the vibration motor specified by the given motorId to the given intensity . |
int[] |
setVibrationMotorSpeeds(boolean[] mask,
int[] intensities)
Sets the vibration motors specified by the given mask to the given intensities . |
void |
speak(java.lang.String whatToSay)
Converts the given text into audio and plays it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HummingbirdRobot()
Method Detail |
---|
public int[] setLEDs(boolean[] mask, int[] intensities)
mask
to the given intensities
.
Returns the current intensities as an array of integers if the command succeeded, null
otherwise.
mask
- boolean array signifying which LEDs to activate (array element 0 is servo port 1)intensities
- array signifying LED intensity (range is 0 to 255)public boolean isMotorPowerEnabled()
true
if motor power is plugged in; false
otherwise.
public int[] setMotorVelocities(boolean[] mask, int[] velocities)
mask
to the given velocities
. Returns
the current velocities as an array of integers if the command succeeded, null
otherwise.
mask
- boolean array signifying which motors to activate (array element 0 is motor port 1)velocities
- array signifying motor velocity (range is -255 to 255)public int[] setServoPositions(boolean[] mask, int[] positions)
mask
to the given positions
. Returns
the current positions as an array of integers if the command succeeded, null
otherwise.
mask
- boolean array signifying which servos to activate (array element 0 is servo port 1)positions
- array signifying servo position (range is 0 to 255)public void playClip(byte[] data)
byte
array.
data
- array of bytes containing sound datepublic boolean setMotorVelocity(int motorId, int velocity)
motorId
to the given (signed) velocity
. Returns
true
if the command succeeded, false
otherwise.
motorId
- the motor to control [1 or 2]velocity
- the signed velocity [-255 to 255]
java.lang.IllegalArgumentException
- if the motorId
specifies an invalid portpublic int[] getSensorValues()
null
if an error occurred while getting the state.
public void playTone(int frequency, int volume, int duration)
frequency
, volume
, and duration
.
frequency
- the frequency in Hertz to play the tonevolume
- how loud to play the clip, range is 1 to 10duration
- how long to play the clip in millisecondspublic boolean setFullColorLED(int ledId, int red, int green, int blue)
ledId
to the given red, green, and blue intensities.
Returns true
if the command succeeded, false
otherwise.
ledId
- the LED to control [1 or 2]red
- the intensity of the LED's red component [0 to 255]green
- the intensity of the LED's green component [0 to 255]blue
- the intensity of the LED's blue component [0 to 255]
java.lang.IllegalArgumentException
- if the ledId
specifies an invalid portpublic void disconnect()
public boolean setVibrationMotorSpeed(int motorId, int intensity)
motorId
to the given intensity
. Returns
true
if the command succeeded, false
otherwise.
motorId
- the motor to control [1 or 2]intensity
- the intensity of vibration [0 to 255]
java.lang.IllegalArgumentException
- if the motorId
specifies an invalid portpublic void speak(java.lang.String whatToSay)
whatToSay
- a String specifying what should be setpublic int[] setVibrationMotorSpeeds(boolean[] mask, int[] intensities)
mask
to the given intensities
. Returns
the current intensities as an array of integers if the command succeeded, null
otherwise.
mask
- boolean array signifying which motors to activate (array element 0 is vibration motor port 1)intensities
- array signifying motor intensities position (range is 0 to 255)public boolean setServoPosition(int servoId, int position)
servoId
to the given position
. Returns
true
if the command succeeded, false
otherwise.
servoId
- the servo to control [0 to 3]position
- the position [0 to 255]
java.lang.IllegalArgumentException
- if the servoId
specifies an invalid portpublic java.lang.Integer getSensorValue(int analogInputPortId)
-1
if an error occurred while trying to read the value.
public java.awt.Color[] setFullColorLEDs(boolean[] mask, java.awt.Color[] colors)
mask
to the given colors
. Returns the
current colors as an array of colors
if the command succeeded, null
otherwise.
public byte[] getSpeech(java.lang.String whatToSay)
whatToSay
- String to convert into a wav file
public boolean setLED(int ledId, int intensity)
ledId
to the given intensity
. Returns
true
if the command succeeded, false
otherwise.
ledId
- the LED to control [1, 2, 3, or 4]intensity
- the intensity [0 to 255]
java.lang.IllegalArgumentException
- if the ledId
specifies an invalid portpublic boolean emergencyStop()
true
if the command
succeeded, false
otherwise.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |