|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cmu.ri.createlab.terk.application.TerkApplication
edu.cmu.ri.createlab.terk.robot.finch.BaseFinchApplication
edu.cmu.ri.createlab.terk.robot.finch.Finch
public final class Finch
Contains all methods necessary to program for the Finch robot
Field Summary |
---|
Fields inherited from class edu.cmu.ri.createlab.terk.application.TerkApplication |
---|
CONNECTION_STRATEGY_CLASS_NAME_PROPERTY |
Constructor Summary | |
---|---|
Finch()
|
Method Summary | |
---|---|
void |
buzz(int frequency,
int duration)
Plays a tone at the specified frequency for the specified duration on the Finch's internal buzzer. |
void |
closeAccelerometerGraph()
Closes the opened Accelerometer Graph |
void |
closeLightSensorGraph()
Closes the opened Light sensor Graph |
void |
closeTemperatureGraph()
Closes the opened temperature Graph |
double[] |
getAccelerations()
Use this method to simultaneously return the current X, Y, and Z accelerations experienced by the robot. |
int |
getLeftLightSensor()
Returns the value of the left light sensor. |
int[] |
getLightSensors()
Returns a 2 integer array containing the current values of both light sensors. |
boolean[] |
getObstacleSensors()
Returns the value of both obstacle sensors as 2 element boolean array. |
int |
getRightLightSensor()
Returns the value of the right light sensor. |
double |
getTemperature()
The current temperature reading at the temperature probe. |
double |
getXAcceleration()
This method returns the current X-axis acceleration value experienced by the robot. |
double |
getYAcceleration()
This method returns the current Y-axis acceleration value experienced by the robot. |
double |
getZAcceleration()
This method returns the current Z-axis acceleration value experienced by the robot. |
boolean |
isBeakDown()
This method returns true if the beak is pointed at the floor, false otherwise |
boolean |
isBeakUp()
This method returns true if the beak is up (Finch sitting on its tail), false otherwise |
boolean |
isFinchLevel()
This method returns true if the Finch is on a flat surface |
boolean |
isFinchUpsideDown()
This method returns true if the Finch is upside down, false otherwise |
boolean |
isLeftLightSensor(int limit)
Returns true if the left light sensor is less than the value specified by limit, false otherwise. |
boolean |
isLeftWingDown()
This method returns true if the Finch's left wing is pointed at the ground |
boolean |
isObstacle()
Returns true if either left or right obstacle sensor detect an obstacle. |
boolean |
isObstacleLeftSide()
Returns true if there is an obstruction in front of the left side of the robot. |
boolean |
isObstacleRightSide()
Returns true if there is an obstruction in front of the right side of the robot. |
boolean |
isRightLightSensor(int limit)
Returns true if the right light sensor is less than the value specified by limit, false otherwise. |
boolean |
isRightWingDown()
This method returns true if the Finch's right wing is pointed at the ground |
boolean |
isShaken()
Returns true if the Finch has been shaken since the last accelerometer read |
boolean |
isTapped()
Returns true if the Finch has been tapped since the last accelerometer read |
boolean |
isTemperature(double limit)
Returns true if the temperature is less than the value specified by limit, false otherwise. |
void |
playClip(String fileLocation)
Plays a wav file over computer speakers at the specificied fileLocation path. |
void |
playTone(int frequency,
int duration)
Plays a tone over the computer speakers or headphones at a given frequency (in Hertz) for a specified duration in milliseconds. |
void |
playTone(int frequency,
int volume,
int duration)
Plays a tone over the computer speakers or headphones at a given frequency (in Hertz) for a specified duration in milliseconds at a specified volume. |
void |
quit()
This method properly closes the connection with the Finch and resets the Finch so that it is immediately ready to be controlled by subsequent programs. |
void |
saySomething(String sayThis)
Takes the text of 'sayThis' and synthesizes it into a sound file and plays the sound file over computer speakers. |
void |
saySomething(String sayThis,
int duration)
Takes the text of 'sayThis' and synthesizes it into a sound file and plays the sound file over computer speakers. |
void |
setLED(Color color)
Sets the color of the LED in the Finch's beak using a Color object. |
void |
setLED(Color color,
int duration)
Sets the color of the LED in the Finch's beak using a Color object for the length of time specified by duration. |
void |
setLED(int red,
int green,
int blue)
Sets the color of the LED in the Finch's beak. |
void |
setLED(int red,
int green,
int blue,
int duration)
Sets the color of the LED in the Finch's beak for the length of time specified by duration. |
void |
setWheelVelocities(int leftVelocity,
int rightVelocity)
This method simultaneously sets the velocities of both wheels. |
void |
setWheelVelocities(int leftVelocity,
int rightVelocity,
int timeToHold)
This method simultaneously sets the velocities of both wheels. |
void |
showAccelerometerGraph()
Displays a graph of the X, Y, and Z accelerometer values. |
void |
showLightSensorGraph()
Displays a graph of the left and right light sensor values. |
void |
showTemperatureGraph()
Displays a graph of the temperature value. |
void |
sleep(int ms)
This method uses Thread.sleep to cause the currently running program to sleep for the specified number of seconds. |
void |
stopWheels()
Stops both wheels. |
void |
updateAccelerometerGraph(double xVal,
double yVal,
double zVal)
updates the accelerometer graph with accelerometer data specified by xVal, yVal, and zVal. |
void |
updateLightSensorGraph(int leftSensor,
int rightSensor)
Updates the light sensor graph with the left and right light sensor data. |
void |
updateTemperatureGraph(double temp)
Updates the temperature graph with the most recent temperature data. |
Methods inherited from class edu.cmu.ri.createlab.terk.robot.finch.BaseFinchApplication |
---|
getAccelerometerService, getAudioService, getBuzzerService, getFullColorLEDService, getOpenLoopVelocityControllableMotorService, getPhotoresistorService, getSimpleObstacleDetectorService, getThermistorService |
Methods inherited from class edu.cmu.ri.createlab.terk.application.TerkApplication |
---|
addConnectionStrategyEventHandler, cancelConnect, connect, disconnect, getServiceManager, isConnected, isConnecting, shutdown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Finch()
Method Detail |
---|
public void setLED(Color color)
color
- is a Color object that determines the beaks colorpublic void setLED(int red, int green, int blue)
red
- sets the intensity of the red element of the LEDgreen
- sets the intensity of the green element of the LEDblue
- sets the intensity of the blue element of the LEDpublic void setLED(Color color, int duration)
color
- is a Color object that determines the beaks colorduration
- is the length of time the color will display on the beakpublic void setLED(int red, int green, int blue, int duration)
red
- sets the intensity of the red element of the LEDgreen
- sets the intensity of the green element of the LEDblue
- sets the intensity of the blue element of the LEDduration
- is the length of time the color will display on the beakpublic void stopWheels()
public void setWheelVelocities(int leftVelocity, int rightVelocity)
leftVelocity
- The velocity at which to move the left wheelrightVelocity
- The velocity at which to move the right wheelpublic void setWheelVelocities(int leftVelocity, int rightVelocity, int timeToHold)
timeToHold
is positive, this method blocks further program execution for the amount
of time specified by timeToHold, and then stops the wheels once time has elapsed.
leftVelocity
- The velocity in native units at which to move the left wheelrightVelocity
- The velocity in native units at which to move the right wheeltimeToHold
- The amount of time in milliseconds to hold the velocity for; if 0 or negative, program
execution is not blocked and the wheels are not stopped.public void sleep(int ms)
ms
- - the number of milliseconds to sleep for. Valid values are all positive integers.public double getXAcceleration()
public double getYAcceleration()
public double getZAcceleration()
public double[] getAccelerations()
public boolean isBeakUp()
public boolean isBeakDown()
public boolean isFinchLevel()
public boolean isFinchUpsideDown()
public boolean isLeftWingDown()
public boolean isRightWingDown()
public boolean isShaken()
public boolean isTapped()
public void playTone(int frequency, int duration)
frequency
- The frequency of the tone in Hertzduration
- The time to play the tone in millisecondspublic void playTone(int frequency, int volume, int duration)
frequency
- The frequency of the tone in Hertzvolume
- The volume of the tone on a 1 to 10 scaleduration
- The time to play the tone in millisecondspublic void playClip(String fileLocation)
fileLocation
- Absolute path of the file or name of the file if located in some directory as source codepublic void saySomething(String sayThis)
sayThis
- The string of text that will be spoken by the computerpublic void saySomething(String sayThis, int duration)
sayThis
- The string of text that will be spoken by the computerduration
- The time in milliseconds to halt further program executionpublic void buzz(int frequency, int duration)
frequency
- Frequency in Hertz of the tone to be playedduration
- Duration in milliseconds of the tonepublic int getLeftLightSensor()
public int getRightLightSensor()
public int[] getLightSensors()
public boolean isLeftLightSensor(int limit)
limit
- The value the light sensor needs to exceed
public boolean isRightLightSensor(int limit)
limit
- The value the light sensor needs to exceed
public boolean isObstacleLeftSide()
public boolean isObstacleRightSide()
public boolean isObstacle()
public boolean[] getObstacleSensors()
public double getTemperature()
public boolean isTemperature(double limit)
limit
- The value the temperature needs to exceed
public void showAccelerometerGraph()
public void updateAccelerometerGraph(double xVal, double yVal, double zVal)
xVal
- The X axis acceleration valueyVal
- The Y axis acceleration valuezVal
- The Z axis acceleration valuepublic void closeAccelerometerGraph()
public void showLightSensorGraph()
public void updateLightSensorGraph(int leftSensor, int rightSensor)
leftSensor
- Variable containing left light sensor valuerightSensor
- Variable containing right light sensor valuepublic void closeLightSensorGraph()
public void showTemperatureGraph()
public void updateTemperatureGraph(double temp)
temp
- variable containing a temperature valuepublic void closeTemperatureGraph()
public void quit()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |