|
|||||||
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 |
buzzBlocking(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 greater 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 greater 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 greater 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)
setLED
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
color
- is a Color object that determines the beaks colorpublic void setLED(int red, int green, int blue)
setLED
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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)
setLED
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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)
setLED
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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()
stopWheels
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void setWheelVelocities(int leftVelocity, int rightVelocity)
setWheelVelocities
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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.
setWheelVelocities
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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)
sleep
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
ms
- - the number of milliseconds to sleep for. Valid values are all positive integers.public double getXAcceleration()
getXAcceleration
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public double getYAcceleration()
getYAcceleration
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public double getZAcceleration()
getZAcceleration
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public double[] getAccelerations()
getAccelerations
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isBeakUp()
isBeakUp
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isBeakDown()
isBeakDown
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isFinchLevel()
isFinchLevel
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isFinchUpsideDown()
isFinchUpsideDown
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isLeftWingDown()
isLeftWingDown
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isRightWingDown()
isRightWingDown
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isShaken()
isShaken
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isTapped()
isTapped
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void playTone(int frequency, int duration)
playTone
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
frequency
- The frequency of the tone in Hertzduration
- The time to play the tone in millisecondspublic void playTone(int frequency, int volume, int duration)
playTone
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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)
playClip
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
fileLocation
- Absolute path of the file or name of the file if located in some directory as source codepublic void saySomething(String sayThis)
saySomething
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
sayThis
- The string of text that will be spoken by the computerpublic void saySomething(String sayThis, int duration)
saySomething
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
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)
buzz
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
frequency
- Frequency in Hertz of the tone to be playedduration
- Duration in milliseconds of the tonepublic void buzzBlocking(int frequency, int duration)
buzzBlocking
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
frequency
- Frequency in Hertz of the tone to be playedduration
- Duration in milliseconds of the tonepublic int getLeftLightSensor()
getLeftLightSensor
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public int getRightLightSensor()
getRightLightSensor
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public int[] getLightSensors()
getLightSensors
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isLeftLightSensor(int limit)
isLeftLightSensor
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
limit
- The value the light sensor needs to exceed
public boolean isRightLightSensor(int limit)
isRightLightSensor
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
limit
- The value the light sensor needs to exceed
public boolean isObstacleLeftSide()
isObstacleLeftSide
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isObstacleRightSide()
isObstacleRightSide
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isObstacle()
isObstacle
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean[] getObstacleSensors()
getObstacleSensors
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public double getTemperature()
getTemperature
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public boolean isTemperature(double limit)
isTemperature
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
limit
- The value the temperature needs to exceed
public void showAccelerometerGraph()
showAccelerometerGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void updateAccelerometerGraph(double xVal, double yVal, double zVal)
updateAccelerometerGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
xVal
- The X axis acceleration valueyVal
- The Y axis acceleration valuezVal
- The Z axis acceleration valuepublic void closeAccelerometerGraph()
closeAccelerometerGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void showLightSensorGraph()
showLightSensorGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void updateLightSensorGraph(int leftSensor, int rightSensor)
updateLightSensorGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
leftSensor
- Variable containing left light sensor valuerightSensor
- Variable containing right light sensor valuepublic void closeLightSensorGraph()
closeLightSensorGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void showTemperatureGraph()
showTemperatureGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void updateTemperatureGraph(double temp)
updateTemperatureGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
temp
- variable containing a temperature valuepublic void closeTemperatureGraph()
closeTemperatureGraph
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
public void quit()
quit
in interface edu.cmu.ri.createlab.terk.robot.finch.FinchInterface
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |