Package edu.tufts.hrilab.nao
Class MockNaoComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.nao.MockNaoComponent
- All Implemented Interfaces:
SpeechProductionInterface
,VelocityInterface
,MockNaoInterface
,NaoInterface
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, 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.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.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) void
setFloorSupport
(boolean value) To set if there's floor support.void
setObstacle
(boolean value) To set if there's an obstacle.boolean
setRV
(double rv) 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
stop()
Stop.boolean
Stops an ongoing utterance.boolean
welcome()
Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, init, main, shutdown, shutdownComponent
-
Constructor Details
-
MockNaoComponent
public MockNaoComponent()
-
-
Method Details
-
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:
-
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
-
isMoving
public boolean isMoving()Description copied from interface:NaoInterface
Query whether or not robot is moving.- Specified by:
isMoving
in interfaceNaoInterface
- Returns:
-
goToPosture
Description copied from interface:NaoInterface
Move into specified posture.- Specified by:
goToPosture
in interfaceNaoInterface
- Returns:
-
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:
-
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:
-
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:
-
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
-
setFloorSupport
public void setFloorSupport(boolean value) Description copied from interface:MockNaoInterface
To set if there's floor support. Allows mocking the sensor checks done from the real robot.- Specified by:
setFloorSupport
in interfaceMockNaoInterface
-
setObstacle
public void setObstacle(boolean value) Description copied from interface:MockNaoInterface
To set if there's an obstacle. Allows mocking the sensor checks done from the real robot.- Specified by:
setObstacle
in interfaceMockNaoInterface
-
getPosture
Description copied from interface:NaoInterface
Get current posture.- Specified by:
getPosture
in interfaceNaoInterface
- Returns:
-
getPostureList
Description copied from interface:NaoInterface
Get list of all possible postures.- Specified by:
getPostureList
in interfaceNaoInterface
- Returns:
-
playFile
Description copied from interface:NaoInterface
Play the specified audio file- Specified by:
playFile
in interfaceNaoInterface
- Parameters:
fileName
- : the path of the file to play
-
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:
-
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 rv) Description copied from interface:VelocityInterface
Set rotational velocity.- Specified by:
setRV
in interfaceVelocityInterface
- Parameters:
rv
- 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()Description copied from interface:VelocityInterface
Stop.- Specified by:
stop
in interfaceVelocityInterface
-
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
-
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:
-
welcome
public boolean welcome()- Specified by:
welcome
in interfaceNaoInterface
-
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.
-
sayAnimated
- Specified by:
sayAnimated
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
-
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
-
sayToFile
Description copied from interface:NaoInterface
To save tts output to file instead of saying it outloud.- Specified by:
sayToFile
in interfaceNaoInterface
- 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
-
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.
-