Package edu.tufts.hrilab.nao
Class NaoComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.nao.NaoComponent
- All Implemented Interfaces:
SpeechProductionInterface,VelocityInterface,NaoInterface
- Direct Known Subclasses:
NaoWizardComponent
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.Objectprotected final org.slf4j.Loggerprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.Objectprotected Stringprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.Objectprotected com.aldebaran.qimessaging.ObjectFields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>Override this method to define command line options available in sub-class.voidangleInterpolation(String name, float angle, float time, boolean isAbsolute) Move NAO joint to a particular angle.voidangleInterpolation(List<String> names, List<Float> angles, float time, boolean isAbsolute) Move NAO joints to a particular angle.voidMove NAO joints to a particular angle.booleanblink()booleanChecks if there is floor support in front of the robot.booleanChecks if there is an obstacle in front of the robot.booleanCloses the handfloatGet NAO joint angle.intdouble[]Get the default velocities used by VelocityComponent functions.javax.vecmath.Point3dgetPixelPositionInRobotFrame(int pX, int pY, int width, int height, int camID) Computes position of pixel in robot frame.Get current posture.Get list of all possible postures.doublegetRV()Get rotational velocity.doublegetTV()Get translational velocity.double[]getVels()Get translational and rotational velocity.booleangoToPosture(String targetPosture) Move into specified posture.protected voidinit()Perform any component initialization.booleanisMoving()Query whether or not robot is moving.booleanChecks if speech is being produced.booleanbooleanbooleanmoveTo(float x, float y, float theta) Makes the robot move to the given pose in the ground plane, relative to FRAME_ROBOT.booleanmoveToBlocking(float x, float y, float theta) Makes the robot move to the given pose in the ground plane, relative to FRAME_ROBOT.booleanOpens the handvoidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.voidPlay the specified audio filebooleanpointHeadTo(float x, float y, float z) Points head to the (x,y,z) location in the robot's base coordinate frame.booleanpointTo(float x, float y, float z) Points to the (x,y,z) location in the robot's base coordinate frame.booleanrest()Puts the nao in the rest position, relaxing all motors.booleanRests robot's left/right arm by placing thr hands on its lap and turning the motors off.booleanbooleansayAnimated(String annotatedText) booleanPerform text-to-speech on input text.booleanSpeaks appropriate textbooleanTo save tts output to file instead of saying it outloud.booleansetBreathEnabled(String par, boolean enable) booleansetRV(double v) Set rotational velocity.booleansetStiffness(String name, float stiffness) Sets joint/actuator stiffnessbooleansetTV(double tv) Set translational velocity.booleansetVels(double tv, double rv) Set both velocities.voidAny component that needs particular shutdown logic needs to override this method andbooleanvoidstop()Stop the motors.booleanStops an ongoing utterance.double[]booleanwelcome()Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, shutdown
-
Field Details
-
log
protected final org.slf4j.Logger log -
asr
protected com.aldebaran.qimessaging.Object asr -
audioPlayer
protected com.aldebaran.qimessaging.Object audioPlayer -
soundDetect
protected com.aldebaran.qimessaging.Object soundDetect -
memory
protected com.aldebaran.qimessaging.Object memory -
tts
protected com.aldebaran.qimessaging.Object tts -
sonar
protected com.aldebaran.qimessaging.Object sonar -
motion
protected com.aldebaran.qimessaging.Object motion -
posture
protected com.aldebaran.qimessaging.Object posture -
battery
protected com.aldebaran.qimessaging.Object battery -
world
protected com.aldebaran.qimessaging.Object world -
naoURL
-
-
Constructor Details
-
NaoComponent
public NaoComponent()
-
-
Method Details
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
shutdownComponent
public void shutdownComponent()Description copied from class:DiarcComponentAny component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponentin classDiarcComponent
-
parseArgs
public void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
additionalUsageInfo
Description copied from class:DiarcComponentOverride this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
getPostureList
Description copied from interface:NaoInterfaceGet list of all possible postures.- Specified by:
getPostureListin interfaceNaoInterface- Returns:
-
getPosture
Description copied from interface:NaoInterfaceGet current posture.- Specified by:
getPosturein interfaceNaoInterface- Returns:
-
getBatteryCharge
public int getBatteryCharge() -
takeSonarReadings
public double[] takeSonarReadings() -
isMoving
public boolean isMoving()Description copied from interface:NaoInterfaceQuery whether or not robot is moving.- Specified by:
isMovingin interfaceNaoInterface- Returns:
-
playFile
Description copied from interface:NaoInterfacePlay the specified audio file- Specified by:
playFilein interfaceNaoInterface- Parameters:
tmpfilename- : the path of the file to play
-
stopUtterance
public boolean stopUtterance()Description copied from interface:SpeechProductionInterfaceStops an ongoing utterance.- Specified by:
stopUtterancein interfaceSpeechProductionInterface- Returns:
- true if speech is interrupted, false otherwise.
-
sayToFile
Description copied from interface:NaoInterfaceTo save tts output to file instead of saying it outloud.- Specified by:
sayToFilein interfaceNaoInterface- Returns:
-
sayText
Description copied from interface:NaoInterfacePerform text-to-speech on input text.- Specified by:
sayTextin interfaceNaoInterface- Specified by:
sayTextin interfaceSpeechProductionInterface- Parameters:
text- the text to be spoken
-
sayText
Description copied from interface:SpeechProductionInterfaceSpeaks appropriate text- Specified by:
sayTextin interfaceSpeechProductionInterface- Parameters:
text- the text to be spokenwait- whether or not to block until speaking call returns
-
isSpeaking
public boolean isSpeaking()Description copied from interface:SpeechProductionInterfaceChecks if speech is being produced.- Specified by:
isSpeakingin interfaceSpeechProductionInterface- Returns:
trueif speech is being produced,falseotherwise
-
moveTo
public boolean moveTo(float x, float y, float theta) Description copied from interface:NaoInterfaceMakes the robot move to the given pose in the ground plane, relative to FRAME_ROBOT. This is a not a blocking call. TODO: this needs to be generalized into a DIARC interface so that it's not specific to the nao component.- Specified by:
moveToin interfaceNaoInterface- Parameters:
x- Distance along the X axis in meters.y- Distance along the Y axis in meters.theta- Rotation around the Z axis in radians [-3.1415 to 3.1415].- Returns:
-
moveToBlocking
public boolean moveToBlocking(float x, float y, float theta) Description copied from interface:NaoInterfaceMakes the robot move to the given pose in the ground plane, relative to FRAME_ROBOT. This is a blocking call. TODO: this needs to be generalized into a DIARC interface so that it's not specific to the nao component.- Specified by:
moveToBlockingin interfaceNaoInterface- Parameters:
x- Distance along the X axis in meters.y- Distance along the Y axis in meters.theta- Rotation around the Z axis in radians [-3.1415 to 3.1415].- Returns:
-
angleInterpolation
Description copied from interface:NaoInterfaceMove NAO joint to a particular angle.- Specified by:
angleInterpolationin interfaceNaoInterface- Parameters:
name- - joint name to moveangle- -time- - how long to take to move to desired joint angle
-
angleInterpolation
public void angleInterpolation(List<String> names, List<Float> angles, float time, boolean isAbsolute) Description copied from interface:NaoInterfaceMove NAO joints to a particular angle. A single time value is used for all joints.- Specified by:
angleInterpolationin interfaceNaoInterface- Parameters:
names- - joint name to moveangles- - angles for jointstime- - how long to take to move to desired joint angles
-
angleInterpolation
public void angleInterpolation(List<String> names, List<Float> angles, List<Float> times, boolean isAbsolute) Description copied from interface:NaoInterfaceMove NAO joints to a particular angle. A different time values can be used for each joint.- Specified by:
angleInterpolationin interfaceNaoInterface- Parameters:
names- - joint name to moveangles- - angles for jointstimes- - how long to take to move to desired joint angles
-
getAngle
Description copied from interface:NaoInterfaceGet NAO joint angle.- Specified by:
getAnglein interfaceNaoInterface- Parameters:
name- - joint name- Returns:
-
pointTo
public boolean pointTo(float x, float y, float z) Description copied from interface:NaoInterfacePoints to the (x,y,z) location in the robot's base coordinate frame. Units are in meters.- Specified by:
pointToin interfaceNaoInterface- Returns:
-
restLeftArm
public boolean restLeftArm()Description copied from interface:NaoInterfaceRests robot's left/right arm by placing thr hands on its lap and turning the motors off. Takes 1500ms to complete (blocking). Also disables hip motors!!!- Specified by:
restLeftArmin interfaceNaoInterface- Returns:
-
restRightArm
public boolean restRightArm()- Specified by:
restRightArmin interfaceNaoInterface
-
pointHeadTo
public boolean pointHeadTo(float x, float y, float z) Description copied from interface:NaoInterfacePoints head to the (x,y,z) location in the robot's base coordinate frame. Units are in meters.- Specified by:
pointHeadToin interfaceNaoInterface- Returns:
-
sonarCheckFloorSupport
public boolean sonarCheckFloorSupport() -
checkFloorSupport
public boolean checkFloorSupport()Description copied from interface:NaoInterfaceChecks if there is floor support in front of the robot. TODO: this needs to be generalized into a DIARC interface so that it's not specific to the nao component.- Specified by:
checkFloorSupportin interfaceNaoInterface- Returns:
- true if it's safe to move forward, false otherwise
-
checkObstacle
public boolean checkObstacle()Description copied from interface:NaoInterfaceChecks if there is an obstacle in front of the robot. TODO: this needs to be generalized into a DIARC interface so that it's not specific to the nao component.- Specified by:
checkObstaclein interfaceNaoInterface- Returns:
- true if it's safe to move forward, false otherwise
-
goToPosture
Description copied from interface:NaoInterfaceMove into specified posture.- Specified by:
goToPosturein interfaceNaoInterface- Returns:
-
openHand
Description copied from interface:NaoInterfaceOpens the hand- Specified by:
openHandin interfaceNaoInterface- Parameters:
name- Name of joint/actuator (LHand or RHand).- Returns:
-
closeHand
Description copied from interface:NaoInterfaceCloses the hand- Specified by:
closeHandin interfaceNaoInterface- Parameters:
name- Name of joint/actuator (LHand or RHand).- Returns:
-
getPixelPositionInRobotFrame
public javax.vecmath.Point3d getPixelPositionInRobotFrame(int pX, int pY, int width, int height, int camID) Description copied from interface:NaoInterfaceComputes position of pixel in robot frame.- Specified by:
getPixelPositionInRobotFramein interfaceNaoInterface- Parameters:
pX- x position of pixelpY- y position of pixelwidth- Width of imageheight- Height of imagecamID- Camera ID (0 [top], 1 [bottom])- Returns:
- Position of pixel projected on floor/table.
-
setVels
public boolean setVels(double tv, double rv) Description copied from interface:VelocityInterfaceSet both velocities.- Specified by:
setVelsin interfaceVelocityInterface- Parameters:
tv- the new TV (m/sec)rv- the new RV (rad/sec)- Returns:
- true if there's nothing in front of the robot, false otherwise.
-
setRV
public boolean setRV(double v) Description copied from interface:VelocityInterfaceSet rotational velocity.- Specified by:
setRVin interfaceVelocityInterface- Parameters:
v- the new RV (rad/sec)- Returns:
- true if there's nothing on that side, false otherwise.
-
setTV
public boolean setTV(double tv) Description copied from interface:VelocityInterfaceSet translational velocity.- Specified by:
setTVin interfaceVelocityInterface- Parameters:
tv- the new TV (m/sec)- Returns:
- true if there's nothing in front of the robot, false otherwise.
-
getDefaultVels
public double[] getDefaultVels()Description copied from interface:VelocityInterfaceGet the default velocities used by VelocityComponent functions.- Specified by:
getDefaultVelsin interfaceVelocityInterface- Returns:
- the default velocities (m/sec and rad/sec).
-
getVels
public double[] getVels()Description copied from interface:VelocityInterfaceGet translational and rotational velocity.- Specified by:
getVelsin interfaceVelocityInterface- Returns:
- the most recent velocity readings (m/sec and rad/sec).
-
getRV
public double getRV()Description copied from interface:VelocityInterfaceGet rotational velocity.- Specified by:
getRVin interfaceVelocityInterface- Returns:
- the most recent RV reading (rad/sec).
-
getTV
public double getTV()Description copied from interface:VelocityInterfaceGet translational velocity.- Specified by:
getTVin interfaceVelocityInterface- Returns:
- the most recent TV reading (m/sec).
-
stop
public void stop()Stop the motors.- Specified by:
stopin interfaceVelocityInterface
-
setStiffness
Description copied from interface:NaoInterfaceSets joint/actuator stiffness- Specified by:
setStiffnessin interfaceNaoInterface- Parameters:
name- Name of joint/actuator. See nao doc.stiffness- Value between 0 and 1- Returns:
-
rest
public boolean rest()Description copied from interface:NaoInterfacePuts the nao in the rest position, relaxing all motors.- Specified by:
restin interfaceNaoInterface- Returns:
-
sayAnimated
- Specified by:
sayAnimatedin interfaceNaoInterface
-
welcome
public boolean welcome()- Specified by:
welcomein interfaceNaoInterface
-
setBreathEnabled
- Specified by:
setBreathEnabledin interfaceNaoInterface
-
ledOn
- Specified by:
ledOnin interfaceNaoInterface
-
ledOff
- Specified by:
ledOffin interfaceNaoInterface
-
blink
public boolean blink()- Specified by:
blinkin interfaceNaoInterface
-