nao
Class BasicNao

java.lang.Object
  extended by nao.BasicNao
Direct Known Subclasses:
ExtendedNao

public class BasicNao
extends java.lang.Object

Wrapper class for accessing a Nao robot remotely using jnaoqi.jar version 1.12.5. The BasicNao abstracts the much of the core functionality (ignoring offline training tasks), while the ExtendedNao provides new functionality.


Constructor Summary
BasicNao(java.lang.String ip, int port)
          Connect to a Nao robot at the specified IP address and port number.
 
Method Summary
 void closeLeftHand()
          Close the left hand (blocking method).
 void closeRightHand()
          Close the right hand (blocking method).
 AccelerationVector getAcceleration()
          Read the accelerometer to get the current acceleration (there is always acceleration due to gravity) in metres per second squared.
 java.util.List<java.lang.String> getAvailableRecognitionLanguages()
          Get a list of the available speech recognition languages.
 java.util.List<java.lang.String> getAvailableSpeakingLanguages()
          Get a list of the available speaking languages.
 double getBatteryLevel()
          Get the battery charge level.
 CameraImage getCameraImage()
          Retrieve a 640x480px RGB image from the camera.
 CameraImage getCameraImage(boolean topCamera)
          Retrieve a 640x480px RGB image from the camera.
 NaoLocation getDeadReckonedLocation()
           
 double getJointPosition(java.lang.String jointName)
          Get the current angle of a joint (in radians).
 double getMotorTemperature(java.lang.String jointName)
          Get the current temperature of a joint motor (in degrees Celcius).
 Pose getPose()
          Get the current pose of the Nao, consisting of an angle for each joint (in radians).
 java.lang.String getPoseName()
          Get the name of the Nao's current pose, if there is one.
 java.lang.String getRecognitionLanguage()
          Get the current speech recognition (listening) language.
 java.lang.String getSpeakingLanguage()
          Get the current speaking language.
 double getSpeed()
          Get the speed in the X direction (forwards) in metres per second.
 Location getTrackedBallLocation()
          Get the location relative to the Nao of the tracked ball, if one has been seen.
 Location getTrackedFaceLocation()
          Get the location relative to the Nao of the tracked face, if one has been seen.
 boolean hasFallen()
           
 DetectedBallInfo isBallDetected()
          If a red ball has been detected, its location in the image is returned.
 DetectedFaceInfo isFaceDetected()
          If a face has been detected, its location in the image is returned.
 boolean isHeadTouched()
          Check if the head is being touched (by a human).
 java.util.List<DetectedLandmarkInfo> isLandmarkDetected()
          If a landmark (naomark) has been detected, its number is returned.
 boolean isLeftHandClosed()
          Check if the left hand is closed.
 boolean isLeftHandTouched()
          Check if the left hand is being touched (by a human).
 boolean isLeftToeTouched()
          Check if the left toe bumper is being pressed.
 java.lang.String isObjectDetected()
          If a learned object has been detected, its name is returned.
 boolean isPowerSupplyConnected()
          Check if the power supply cable is connected.
 boolean isRightHandClosed()
          Check if the right hand is closed.
 boolean isRightHandTouched()
          Check if the right hand is being touched (by a human).
 boolean isRightToeTouched()
          Check if the right toe bumper is being pressed.
 SoundLocation isSoundDetected()
          If a loud sound has been heard, its location relative to the Nao is returned.
 java.util.List<java.lang.String> isSpeechDetected()
          If a recognised word has been heard, it is returned in the list.
 void moveJoint(java.lang.String jointName, double angle)
          Turns the specified joint to the given angle.
 void moveJoint(java.lang.String jointName, double angle, double speed)
          Turns the specified joint to the given angle.
 void moveLeftHandTo(Location loc)
          Move the left hand to the specified target location (using the whole left arm).
 void moveRightHandTo(Location loc)
          Move the right hand to the specified target location (using the whole right arm).
 void openLeftHand()
          Open the left hand (blocking method).
 void openRightHand()
          Open the right hand (blocking method).
 void performMotion(BodyMotionFrameSet bodyMotion)
          Performs motion (an 'animation') consisting of a set of target positions ('frames') for each joint.
 void playAudio(java.lang.String filename)
          Play an audio recording.
 void playWebAudio(java.lang.String url)
          Play an internet radio stream.
 double readLeftSonar()
          Get the distance reading from the left sonar (in metres, up to 2.55m).
 double readRightSonar()
          Get the distance reading from the right sonar (in metres, up to 2.55m).
 void say(java.lang.String phrase)
          Use the text-to-speech engine to say a phrase.
 void send32BitsIR(byte b1, byte b2, byte b3, byte b4)
          Send 32 bits using the infra-red transmitter.
 void send8BitsIR(byte b)
          Send 8 bits using the infra-red transmitter.
 void setChestLEDColour(int red, int green, int blue)
          Set the colour (and brightness) of the chest LED.
 void setEarLEDBrightness(int level)
          Set the brightness of the ear LEDs (0 to 255).
 void setEyeLEDColour(java.awt.Color c)
          Set the colour (and brightness) of the eye LEDs.
 void setEyeLEDColour(int red, int green, int blue)
          Set the colour (and brightness) of the eye LEDs.
 void setFeetLEDColour(int red, int green, int blue)
          Set the colour (and brightness) of the feet LEDs.
 void setHeadLEDBrightness(int level)
          Set the brightness of the LEDs on the top of the head (0 to 255).
 void setRecognitionLanguage(java.lang.String language)
          Set the speech recognition (listening) language.
 void setSpeakingLanguage(java.lang.String language)
          Set the language that the Nao speaks.
 void startBallDetection()
          Enable red ball detection.
 void startBallTracking()
          Enable red ball tracking.
 void startFaceDetection()
          Enable face detection.
 void startFaceTracking()
          Enable face tracking.
 void startLandmarkDetection()
          Enable landmark (naomark) detection.
 void startObjectDetection()
          Enable detection of previously learned objects.
 void startRecordingAudio(java.lang.String filename, boolean oggCompressed)
          Start recording audio to the specified file.
 void startSoundLocalisation()
          Enable (loud) sound localisation.
 void startSpeechRecognition(java.util.List<java.lang.String> words)
          Enable speech recognition.
 void startWalking(double speedX, double speedY, double speedTheta)
          Start walking at a given speed.
 void stopAudioPlayback()
          Stop all playback of recordings or an internet stream.
 void stopBallDetection()
          Disable red ball detection.
 void stopBallTracking()
          Disable red ball tracking.
 void stopFaceDetection()
          Disable face detection.
 void stopFaceTracking()
          Disable face tracking.
 void stopLandmarkDetection()
          Disable landmark detection.
 void stopObjectDetection()
          Disable object detection.
 void stopRecordingAudio()
          Stop recording audio.
 void stopSoundLocalisation()
          Disable sound localisation.
 void stopSpeechRecognition()
          Disable speech recognition.
 void stopWalking()
          Stop walking.
 void subscribeToEvents(NaoEventListener nel)
          Subscribe to receive events for the touch sensors, or ball, face, object and speech detection.
 void turnChestLEDOff()
          Turn the chest LED off.
 void turnEarLEDsOff()
          Turn the ear LEDs off.
 void turnEyeLEDsOff()
          Turn the eye LEDs off.
 void turnFeetLEDsOff()
          Turn the feet LEDs off.
 void turnHeadLEDsOff()
          Turn the head LEDs off.
 void walkFor(int milliseconds, double speedX)
          Walk for a certain length of time.
 void walkSteadilyTo(double x, double y, double theta)
          Walk to a point relative to the Nao's current location, without using the arms, and ensuring maximum stability (useful when the Nao is carrying something).
 void walkTo(double x, double y, double theta)
          Walk to a point relative to the Nao's current location.
 void walkTo(double x, double y, double theta, boolean useLeftArm, boolean useRightArm)
          Walk to a point relative to the Nao's current location, optionally without using the arms.
 void walkTo(Location loc)
          Walk to a point relative to the Nao's current location.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicNao

public BasicNao(java.lang.String ip,
                int port)
         throws java.net.ConnectException
Connect to a Nao robot at the specified IP address and port number.

Throws:
java.net.ConnectException
Method Detail

subscribeToEvents

public void subscribeToEvents(NaoEventListener nel)
Subscribe to receive events for the touch sensors, or ball, face, object and speech detection.


say

public void say(java.lang.String phrase)
Use the text-to-speech engine to say a phrase.


setSpeakingLanguage

public void setSpeakingLanguage(java.lang.String language)
Set the language that the Nao speaks.


getSpeakingLanguage

public java.lang.String getSpeakingLanguage()
Get the current speaking language.


getAvailableSpeakingLanguages

public java.util.List<java.lang.String> getAvailableSpeakingLanguages()
Get a list of the available speaking languages.


getRecognitionLanguage

public java.lang.String getRecognitionLanguage()
Get the current speech recognition (listening) language.


setRecognitionLanguage

public void setRecognitionLanguage(java.lang.String language)
Set the speech recognition (listening) language.


getAvailableRecognitionLanguages

public java.util.List<java.lang.String> getAvailableRecognitionLanguages()
Get a list of the available speech recognition languages.


startSpeechRecognition

public void startSpeechRecognition(java.util.List<java.lang.String> words)
Enable speech recognition.

Parameters:
words - The list of words to listen for.

stopSpeechRecognition

public void stopSpeechRecognition()
Disable speech recognition.


isSpeechDetected

public java.util.List<java.lang.String> isSpeechDetected()
If a recognised word has been heard, it is returned in the list. Obviously speech recognition must be enabled.


startSoundLocalisation

public void startSoundLocalisation()
Enable (loud) sound localisation.


stopSoundLocalisation

public void stopSoundLocalisation()
Disable sound localisation.


isSoundDetected

public SoundLocation isSoundDetected()
If a loud sound has been heard, its location relative to the Nao is returned. Obviously localisation must be enabled.


startRecordingAudio

public void startRecordingAudio(java.lang.String filename,
                                boolean oggCompressed)
Start recording audio to the specified file. Audio can be stored in compressed OGG format, or uncompressed WAV format.

Parameters:
filename - The filename in which to store the audio (onboard the Nao).
oggCompressed - True if the audio should be compressed in OGG format.

stopRecordingAudio

public void stopRecordingAudio()
Stop recording audio.


playAudio

public void playAudio(java.lang.String filename)
               throws java.io.FileNotFoundException
Play an audio recording. This method blocks (until the end of the recording).

Parameters:
filename - The filename (onboard the Nao) from which to play the audio.
Throws:
java.io.FileNotFoundException

playWebAudio

public void playWebAudio(java.lang.String url)
                  throws java.net.ConnectException
Play an internet radio stream.

Parameters:
url - The URL of the radio stream.
Throws:
java.net.ConnectException

stopAudioPlayback

public void stopAudioPlayback()
Stop all playback of recordings or an internet stream.


performMotion

public void performMotion(BodyMotionFrameSet bodyMotion)
Performs motion (an 'animation') consisting of a set of target positions ('frames') for each joint. This method blocks.

Parameters:
bodyMotion - The set of frames to iterate through

moveJoint

public void moveJoint(java.lang.String jointName,
                      double angle)
Turns the specified joint to the given angle. Joint names are defined in Pose. Consult the documentation to see the range of each joint. This method waits until the specified joint is available (if it is engaged in other motion), but once motion has begun, the method does NOT block.

Parameters:
jointName - The joint to move
angle - The destination angle (in radians)

moveJoint

public void moveJoint(java.lang.String jointName,
                      double angle,
                      double speed)
Turns the specified joint to the given angle. Joint names are defined in Pose. Consult the documentation to see the range of each joint. This method waits until the specified joint is available (if it is engaged in other motion), but once motion has begun, the method does NOT block.

Parameters:
jointName - The joint to move
angle - The destination angle (in radians)
speed - The speed to move the joint at (between 0 and 1)

walkTo

public void walkTo(double x,
                   double y,
                   double theta)
Walk to a point relative to the Nao's current location. This method blocks.

Parameters:
x - The distance forwards or backwards (in metres)
y - The distance left or right (in metres)
theta - The amount to turn (in radians)

walkTo

public void walkTo(Location loc)
Walk to a point relative to the Nao's current location. This method blocks.

Parameters:
loc - The location

walkTo

public void walkTo(double x,
                   double y,
                   double theta,
                   boolean useLeftArm,
                   boolean useRightArm)
Walk to a point relative to the Nao's current location, optionally without using the arms. This method blocks.

Parameters:
x - The distance forwards or backwards (in metres)
y - The distance left or right (in metres)
theta - The amount to turn (in radians)
useLeftArm - Use the left arm while walking
useRightArm - Use the right arm while walking

walkSteadilyTo

public void walkSteadilyTo(double x,
                           double y,
                           double theta)
Walk to a point relative to the Nao's current location, without using the arms, and ensuring maximum stability (useful when the Nao is carrying something). This method blocks.

Parameters:
x - The distance forwards or backwards (in metres)
y - The distance left or right (in metres)
theta - The amount to turn (in radians)

startWalking

public void startWalking(double speedX,
                         double speedY,
                         double speedTheta)
Start walking at a given speed.

Parameters:
speedX - The speed in the X direction (forwards) (in metres per second)
speedY - The speed in the Y direction (sideways) (in metres per second)
speedTheta - The angular speed (in radians per second)

stopWalking

public void stopWalking()
Stop walking.


walkFor

public void walkFor(int milliseconds,
                    double speedX)
Walk for a certain length of time.

Parameters:
milliseconds - The time to walk for (in milliseconds)
speedX - The speed in X (in metres per second)

getSpeed

public double getSpeed()
Get the speed in the X direction (forwards) in metres per second.


openLeftHand

public void openLeftHand()
Open the left hand (blocking method).


openRightHand

public void openRightHand()
Open the right hand (blocking method).


closeLeftHand

public void closeLeftHand()
Close the left hand (blocking method).


closeRightHand

public void closeRightHand()
Close the right hand (blocking method).


isLeftHandClosed

public boolean isLeftHandClosed()
Check if the left hand is closed.


isRightHandClosed

public boolean isRightHandClosed()
Check if the right hand is closed.


moveLeftHandTo

public void moveLeftHandTo(Location loc)
Move the left hand to the specified target location (using the whole left arm). This method makes use of inverse kinematics and will block. Not all locations can be reached because of the range limits of the motors, and potential collision with the rest of the robot.


moveRightHandTo

public void moveRightHandTo(Location loc)
Move the right hand to the specified target location (using the whole right arm). This method makes use of inverse kinematics and will block. Not all locations can be reached because of the range limits of the motors, and potential collision with the rest of the robot.


hasFallen

public boolean hasFallen()

getCameraImage

public CameraImage getCameraImage()
Retrieve a 640x480px RGB image from the camera.


getCameraImage

public CameraImage getCameraImage(boolean topCamera)
Retrieve a 640x480px RGB image from the camera.

Parameters:
topCamera - True to get the image from the top camera, false to get the image from the bottom camera.

setEyeLEDColour

public void setEyeLEDColour(java.awt.Color c)
Set the colour (and brightness) of the eye LEDs.


setEyeLEDColour

public void setEyeLEDColour(int red,
                            int green,
                            int blue)
Set the colour (and brightness) of the eye LEDs.


turnEyeLEDsOff

public void turnEyeLEDsOff()
Turn the eye LEDs off.


setChestLEDColour

public void setChestLEDColour(int red,
                              int green,
                              int blue)
Set the colour (and brightness) of the chest LED.


turnChestLEDOff

public void turnChestLEDOff()
Turn the chest LED off.


setFeetLEDColour

public void setFeetLEDColour(int red,
                             int green,
                             int blue)
Set the colour (and brightness) of the feet LEDs.


turnFeetLEDsOff

public void turnFeetLEDsOff()
Turn the feet LEDs off.


setEarLEDBrightness

public void setEarLEDBrightness(int level)
Set the brightness of the ear LEDs (0 to 255).


turnEarLEDsOff

public void turnEarLEDsOff()
Turn the ear LEDs off.


setHeadLEDBrightness

public void setHeadLEDBrightness(int level)
Set the brightness of the LEDs on the top of the head (0 to 255).


turnHeadLEDsOff

public void turnHeadLEDsOff()
Turn the head LEDs off.


getBatteryLevel

public double getBatteryLevel()
Get the battery charge level. 0.0 means 0% and 1.0 means 100%.


isPowerSupplyConnected

public boolean isPowerSupplyConnected()
Check if the power supply cable is connected. Warning: the result may not be accurate.


getPoseName

public java.lang.String getPoseName()
Get the name of the Nao's current pose, if there is one. According to the documentation, the known poses are "Stand", "Knee", "Crouch", "Back", "Sit", "Left", "Frog" and "HeadBack".


getPose

public Pose getPose()
Get the current pose of the Nao, consisting of an angle for each joint (in radians).


getJointPosition

public double getJointPosition(java.lang.String jointName)
Get the current angle of a joint (in radians). Joint names are specified in the Pose class.


getMotorTemperature

public double getMotorTemperature(java.lang.String jointName)
Get the current temperature of a joint motor (in degrees Celcius). Joint names are specified in the Pose class.


getAcceleration

public AccelerationVector getAcceleration()
Read the accelerometer to get the current acceleration (there is always acceleration due to gravity) in metres per second squared.


readLeftSonar

public double readLeftSonar()
Get the distance reading from the left sonar (in metres, up to 2.55m).


readRightSonar

public double readRightSonar()
Get the distance reading from the right sonar (in metres, up to 2.55m).


isLeftHandTouched

public boolean isLeftHandTouched()
Check if the left hand is being touched (by a human).


isRightHandTouched

public boolean isRightHandTouched()
Check if the right hand is being touched (by a human).


isHeadTouched

public boolean isHeadTouched()
Check if the head is being touched (by a human).


isLeftToeTouched

public boolean isLeftToeTouched()
Check if the left toe bumper is being pressed.


isRightToeTouched

public boolean isRightToeTouched()
Check if the right toe bumper is being pressed.


send32BitsIR

public void send32BitsIR(byte b1,
                         byte b2,
                         byte b3,
                         byte b4)
Send 32 bits using the infra-red transmitter.


send8BitsIR

public void send8BitsIR(byte b)
Send 8 bits using the infra-red transmitter.


startFaceDetection

public void startFaceDetection()
Enable face detection. Note that this functionality is distinct from face tracking which additionally involves motion.


stopFaceDetection

public void stopFaceDetection()
Disable face detection.


isFaceDetected

public DetectedFaceInfo isFaceDetected()
If a face has been detected, its location in the image is returned. Obviously face detection must be enabled.


startBallDetection

public void startBallDetection()
Enable red ball detection. Note that this functionality is distinct from red ball tracking which additionally involves motion.


stopBallDetection

public void stopBallDetection()
Disable red ball detection.


isBallDetected

public DetectedBallInfo isBallDetected()
If a red ball has been detected, its location in the image is returned. Obviously ball detection must be enabled.


startObjectDetection

public void startObjectDetection()
Enable detection of previously learned objects.


stopObjectDetection

public void stopObjectDetection()
Disable object detection.


isObjectDetected

public java.lang.String isObjectDetected()
If a learned object has been detected, its name is returned. Obviously object detection must be enabled.


startLandmarkDetection

public void startLandmarkDetection()
Enable landmark (naomark) detection.


stopLandmarkDetection

public void stopLandmarkDetection()
Disable landmark detection.


isLandmarkDetected

public java.util.List<DetectedLandmarkInfo> isLandmarkDetected()
If a landmark (naomark) has been detected, its number is returned. Obviously landmark detection must be enabled.


startBallTracking

public void startBallTracking()
Enable red ball tracking. The API is restricted to using the top camera.


stopBallTracking

public void stopBallTracking()
Disable red ball tracking.


getTrackedBallLocation

public Location getTrackedBallLocation()
Get the location relative to the Nao of the tracked ball, if one has been seen.


startFaceTracking

public void startFaceTracking()
Enable face tracking. The API is restricted to using the top camera.


stopFaceTracking

public void stopFaceTracking()
Disable face tracking.


getTrackedFaceLocation

public Location getTrackedFaceLocation()
Get the location relative to the Nao of the tracked face, if one has been seen.


getDeadReckonedLocation

public NaoLocation getDeadReckonedLocation()