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

public class NaoComponent extends DiarcComponent implements NaoInterface
  • 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

      protected String 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 class DiarcComponent
    • 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 class DiarcComponent
    • 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 class DiarcComponent
    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Description copied from class: DiarcComponent
      Command line options available in sub-class. This should be paired with a parseArgs implementation.
      Overrides:
      additionalUsageInfo in class DiarcComponent
      Returns:
    • getPostureList

      public ArrayList<String> getPostureList()
      Description copied from interface: NaoInterface
      Get list of all possible postures.
      Specified by:
      getPostureList in interface NaoInterface
      Returns:
    • getPosture

      public String getPosture()
      Description copied from interface: NaoInterface
      Get current posture.
      Specified by:
      getPosture in interface NaoInterface
      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 interface NaoInterface
      Returns:
    • playFile

      public void playFile(String tmpfilename)
      Description copied from interface: NaoInterface
      Play the specified audio file
      Specified by:
      playFile in interface NaoInterface
      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 interface SpeechProductionInterface
      Returns:
      true if speech is interrupted, false otherwise.
    • sayToFile

      public boolean sayToFile(String text, String filename)
      Description copied from interface: NaoInterface
      To save tts output to file instead of saying it outloud.
      Specified by:
      sayToFile in interface NaoInterface
      Returns:
    • sayText

      public boolean sayText(String text)
      Description copied from interface: NaoInterface
      Perform text-to-speech on input text.
      Specified by:
      sayText in interface NaoInterface
      Specified by:
      sayText in interface SpeechProductionInterface
      Parameters:
      text - the text to be spoken
    • sayText

      public boolean sayText(String text, boolean wait)
      Description copied from interface: SpeechProductionInterface
      Speaks appropriate text
      Specified by:
      sayText in interface SpeechProductionInterface
      Parameters:
      text - the text to be spoken
      wait - 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 interface SpeechProductionInterface
      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 interface NaoInterface
      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 interface NaoInterface
      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

      public void angleInterpolation(String name, float angle, float time, boolean isAbsolute)
      Description copied from interface: NaoInterface
      Move NAO joint to a particular angle.
      Specified by:
      angleInterpolation in interface NaoInterface
      Parameters:
      name - - joint name to move
      angle - -
      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 interface NaoInterface
      Parameters:
      names - - joint name to move
      angles - - angles for joints
      time - - 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 interface NaoInterface
      Parameters:
      names - - joint name to move
      angles - - angles for joints
      times - - how long to take to move to desired joint angles
    • getAngle

      public float getAngle(String name)
      Description copied from interface: NaoInterface
      Get NAO joint angle.
      Specified by:
      getAngle in interface NaoInterface
      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 interface NaoInterface
      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 interface NaoInterface
      Returns:
    • restRightArm

      public boolean restRightArm()
      Specified by:
      restRightArm in interface NaoInterface
    • 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 interface NaoInterface
      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 interface NaoInterface
      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 interface NaoInterface
      Returns:
      true if it's safe to move forward, false otherwise
    • goToPosture

      public boolean goToPosture(String targetPosture)
      Description copied from interface: NaoInterface
      Move into specified posture.
      Specified by:
      goToPosture in interface NaoInterface
      Returns:
    • openHand

      public boolean openHand(String name)
      Description copied from interface: NaoInterface
      Opens the hand
      Specified by:
      openHand in interface NaoInterface
      Parameters:
      name - Name of joint/actuator (LHand or RHand).
      Returns:
    • closeHand

      public boolean closeHand(String name)
      Description copied from interface: NaoInterface
      Closes the hand
      Specified by:
      closeHand in interface NaoInterface
      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 interface NaoInterface
      Parameters:
      pX - x position of pixel
      pY - y position of pixel
      width - Width of image
      height - Height of image
      camID - 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 interface VelocityInterface
      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 interface VelocityInterface
      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 interface VelocityInterface
      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 interface VelocityInterface
      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 interface VelocityInterface
      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 interface VelocityInterface
      Returns:
      the most recent RV reading (rad/sec).
    • getTV

      public double getTV()
      Description copied from interface: VelocityInterface
      Get translational velocity.
      Specified by:
      getTV in interface VelocityInterface
      Returns:
      the most recent TV reading (m/sec).
    • stop

      public void stop()
      Stop the motors.
      Specified by:
      stop in interface VelocityInterface
    • setStiffness

      public boolean setStiffness(String name, float stiffness)
      Description copied from interface: NaoInterface
      Sets joint/actuator stiffness
      Specified by:
      setStiffness in interface NaoInterface
      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 interface NaoInterface
      Returns:
    • sayAnimated

      public boolean sayAnimated(String annotatedText)
      Specified by:
      sayAnimated in interface NaoInterface
    • welcome

      public boolean welcome()
      Specified by:
      welcome in interface NaoInterface
    • setBreathEnabled

      public boolean setBreathEnabled(String par, boolean enable)
      Specified by:
      setBreathEnabled in interface NaoInterface
    • ledOn

      public boolean ledOn(String name)
      Specified by:
      ledOn in interface NaoInterface
    • ledOff

      public boolean ledOff(String name)
      Specified by:
      ledOff in interface NaoInterface
    • blink

      public boolean blink()
      Specified by:
      blink in interface NaoInterface