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.Object
protected com.aldebaran.qimessaging.Object
protected com.aldebaran.qimessaging.Object
protected final org.slf4j.Logger
protected com.aldebaran.qimessaging.Object
protected com.aldebaran.qimessaging.Object
protected String
protected com.aldebaran.qimessaging.Object
protected com.aldebaran.qimessaging.Object
protected com.aldebaran.qimessaging.Object
protected com.aldebaran.qimessaging.Object
protected com.aldebaran.qimessaging.Object
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, shouldRunExecutionLoop
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>
Command line options available in sub-class.void
angleInterpolation
(String name, float angle, float time, boolean isAbsolute) Move NAO joint to a particular angle.void
angleInterpolation
(List<String> names, List<Float> angles, float time, boolean isAbsolute) Move NAO joints to a particular angle.void
Move NAO joints to a particular angle.boolean
blink()
boolean
Checks if there is floor support in front of the robot.boolean
Checks if there is an obstacle in front of the robot.boolean
Closes the handfloat
Get NAO joint angle.int
double[]
Get the default velocities used by VelocityComponent functions.javax.vecmath.Point3d
getPixelPositionInRobotFrame
(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.double
getRV()
Get rotational velocity.double
getTV()
Get translational velocity.double[]
getVels()
Get translational and rotational velocity.boolean
goToPosture
(String targetPosture) Move into specified posture.protected void
init()
Perform any component initialization.boolean
isMoving()
Query whether or not robot is moving.boolean
Checks if speech is being produced.boolean
boolean
boolean
moveTo
(float x, float y, float theta) Makes the robot move to the given pose in the ground plane, relative to FRAME_ROBOT.boolean
moveToBlocking
(float x, float y, float theta) Makes the robot move to the given pose in the ground plane, relative to FRAME_ROBOT.boolean
Opens the handvoid
parseArgs
(org.apache.commons.cli.CommandLine cmdLine) Called directly after construction to pass runtime values that will override default values.void
Play the specified audio fileboolean
pointHeadTo
(float x, float y, float z) Points head to the (x,y,z) location in the robot's base coordinate frame.boolean
pointTo
(float x, float y, float z) Points to the (x,y,z) location in the robot's base coordinate frame.boolean
rest()
Puts the nao in the rest position, relaxing all motors.boolean
Rests robot's left/right arm by placing thr hands on its lap and turning the motors off.boolean
boolean
sayAnimated
(String annotatedText) boolean
Perform text-to-speech on input text.boolean
Speaks appropriate textboolean
To save tts output to file instead of saying it outloud.boolean
setBreathEnabled
(String par, boolean enable) boolean
setRV
(double v) Set rotational velocity.boolean
setStiffness
(String name, float stiffness) Sets joint/actuator stiffnessboolean
setTV
(double tv) Set translational velocity.boolean
setVels
(double tv, double rv) Set both velocities.void
Any component that needs particular shutdown logic needs to override this method andboolean
void
stop()
Stop the motors.boolean
Stops an ongoing utterance.double[]
boolean
welcome()
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:DiarcComponent
Perform 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:
init
in classDiarcComponent
-
shutdownComponent
public void shutdownComponent()Description copied from class:DiarcComponent
Any component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponent
in classDiarcComponent
-
parseArgs
public void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponent
Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.zs- Overrides:
parseArgs
in classDiarcComponent
-
additionalUsageInfo
Description copied from class:DiarcComponent
Command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfo
in classDiarcComponent
- Returns:
-
getPostureList
Description copied from interface:NaoInterface
Get list of all possible postures.- Specified by:
getPostureList
in interfaceNaoInterface
- Returns:
-
getPosture
Description copied from interface:NaoInterface
Get current posture.- Specified by:
getPosture
in interfaceNaoInterface
- Returns:
-
getBatteryCharge
public int getBatteryCharge() -
takeSonarReadings
public double[] takeSonarReadings() -
isMoving
public boolean isMoving()Description copied from interface:NaoInterface
Query whether or not robot is moving.- Specified by:
isMoving
in interfaceNaoInterface
- Returns:
-
playFile
Description copied from interface:NaoInterface
Play the specified audio file- Specified by:
playFile
in interfaceNaoInterface
- Parameters:
tmpfilename
- : the path of the file to play
-
stopUtterance
public boolean stopUtterance()Description copied from interface:SpeechProductionInterface
Stops an ongoing utterance.- Specified by:
stopUtterance
in interfaceSpeechProductionInterface
- Returns:
- true if speech is interrupted, false otherwise.
-
sayToFile
Description copied from interface:NaoInterface
To save tts output to file instead of saying it outloud.- Specified by:
sayToFile
in interfaceNaoInterface
- Returns:
-
sayText
Description copied from interface:NaoInterface
Perform text-to-speech on input text.- Specified by:
sayText
in interfaceNaoInterface
- Specified by:
sayText
in interfaceSpeechProductionInterface
- Parameters:
text
- the text to be spoken
-
sayText
Description copied from interface:SpeechProductionInterface
Speaks appropriate text- Specified by:
sayText
in 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:SpeechProductionInterface
Checks if speech is being produced.- Specified by:
isSpeaking
in interfaceSpeechProductionInterface
- Returns:
true
if speech is being produced,false
otherwise
-
moveTo
public boolean moveTo(float x, float y, float theta) Description copied from interface:NaoInterface
Makes 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:
moveTo
in 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:NaoInterface
Makes 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:
moveToBlocking
in 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:NaoInterface
Move NAO joint to a particular angle.- Specified by:
angleInterpolation
in 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:NaoInterface
Move NAO joints to a particular angle. A single time value is used for all joints.- Specified by:
angleInterpolation
in 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:NaoInterface
Move NAO joints to a particular angle. A different time values can be used for each joint.- Specified by:
angleInterpolation
in 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:NaoInterface
Get NAO joint angle.- Specified by:
getAngle
in interfaceNaoInterface
- Parameters:
name
- - joint name- Returns:
-
pointTo
public boolean pointTo(float x, float y, float z) Description copied from interface:NaoInterface
Points to the (x,y,z) location in the robot's base coordinate frame. Units are in meters.- Specified by:
pointTo
in interfaceNaoInterface
- Returns:
-
restLeftArm
public boolean restLeftArm()Description copied from interface:NaoInterface
Rests 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:
restLeftArm
in interfaceNaoInterface
- Returns:
-
restRightArm
public boolean restRightArm()- Specified by:
restRightArm
in interfaceNaoInterface
-
pointHeadTo
public boolean pointHeadTo(float x, float y, float z) Description copied from interface:NaoInterface
Points head to the (x,y,z) location in the robot's base coordinate frame. Units are in meters.- Specified by:
pointHeadTo
in interfaceNaoInterface
- Returns:
-
sonarCheckFloorSupport
public boolean sonarCheckFloorSupport() -
checkFloorSupport
public boolean checkFloorSupport()Description copied from interface:NaoInterface
Checks 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:
checkFloorSupport
in interfaceNaoInterface
- Returns:
- true if it's safe to move forward, false otherwise
-
checkObstacle
public boolean checkObstacle()Description copied from interface:NaoInterface
Checks 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:
checkObstacle
in interfaceNaoInterface
- Returns:
- true if it's safe to move forward, false otherwise
-
goToPosture
Description copied from interface:NaoInterface
Move into specified posture.- Specified by:
goToPosture
in interfaceNaoInterface
- Returns:
-
openHand
Description copied from interface:NaoInterface
Opens the hand- Specified by:
openHand
in interfaceNaoInterface
- Parameters:
name
- Name of joint/actuator (LHand or RHand).- Returns:
-
closeHand
Description copied from interface:NaoInterface
Closes the hand- Specified by:
closeHand
in 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:NaoInterface
Computes position of pixel in robot frame.- Specified by:
getPixelPositionInRobotFrame
in 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:VelocityInterface
Set both velocities.- Specified by:
setVels
in 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:VelocityInterface
Set rotational velocity.- Specified by:
setRV
in 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:VelocityInterface
Set translational velocity.- Specified by:
setTV
in 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:VelocityInterface
Get the default velocities used by VelocityComponent functions.- Specified by:
getDefaultVels
in interfaceVelocityInterface
- Returns:
- the default velocities (m/sec and rad/sec).
-
getVels
public double[] getVels()Description copied from interface:VelocityInterface
Get translational and rotational velocity.- Specified by:
getVels
in interfaceVelocityInterface
- Returns:
- the most recent velocity readings (m/sec and rad/sec).
-
getRV
public double getRV()Description copied from interface:VelocityInterface
Get rotational velocity.- Specified by:
getRV
in interfaceVelocityInterface
- Returns:
- the most recent RV reading (rad/sec).
-
getTV
public double getTV()Description copied from interface:VelocityInterface
Get translational velocity.- Specified by:
getTV
in interfaceVelocityInterface
- Returns:
- the most recent TV reading (m/sec).
-
stop
public void stop()Stop the motors.- Specified by:
stop
in interfaceVelocityInterface
-
setStiffness
Description copied from interface:NaoInterface
Sets joint/actuator stiffness- Specified by:
setStiffness
in 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:NaoInterface
Puts the nao in the rest position, relaxing all motors.- Specified by:
rest
in interfaceNaoInterface
- Returns:
-
sayAnimated
- Specified by:
sayAnimated
in interfaceNaoInterface
-
welcome
public boolean welcome()- Specified by:
welcome
in interfaceNaoInterface
-
setBreathEnabled
- Specified by:
setBreathEnabled
in interfaceNaoInterface
-
ledOn
- Specified by:
ledOn
in interfaceNaoInterface
-
ledOff
- Specified by:
ledOff
in interfaceNaoInterface
-
blink
public boolean blink()- Specified by:
blink
in interfaceNaoInterface
-