Package ftclib.motor

Class FtcServo

All Implemented Interfaces:
TrcExclusiveSubsystem

public class FtcServo extends TrcServo
This class implements a platform dependent servo extending TrcServo. It provides implementation of the abstract methods in TrcServo.
  • Field Details

    • servo

      private final com.qualcomm.robotcore.hardware.Servo servo
    • controller

      private final com.qualcomm.robotcore.hardware.ServoController controller
    • timer

      private final TrcTimer timer
  • Constructor Details

    • FtcServo

      public FtcServo(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, TrcServo.Params params)
      Constructor: Creates an instance of the object.
      Parameters:
      hardwareMap - specifies the global hardware map.
      instanceName - specifies the instance name.
      params - specifies the parameters of the servo.
    • FtcServo

      public FtcServo(String instanceName, TrcServo.Params params)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      params - specifies the parameters of the servo.
    • FtcServo

      public FtcServo(String instanceName)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
  • Method Details

    • getController

      public com.qualcomm.robotcore.hardware.ServoController getController()
      This method returns the servo controller object that this servo is plugged into.
      Returns:
      servo controller object.
    • cancel

      public void cancel()
      This method cancels the holdTimer and stops the state machine if it is running.
      Overrides:
      cancel in class TrcServo
    • setPositionWithOnTime

      public void setPositionWithOnTime(double pos, double onTime)
      This method sets the servo position but will cut power to the servo when done. Since servo motors can't really take a lot of loads, it would stress out and may burn out the servo if it is held against a heavy load for extended period of time. This method allows us to set the position and only hold it long enough for it to reach target position and then we will cut the servo controller power off. Note that by doing so, all servos on the same controller will go limp.
      Parameters:
      pos - specifies the target position.
      onTime - specifies the time in seconds to wait before disabling servo controller.
    • onTimeExpired

      private void onTimeExpired(Object context)
      This method is called when the onTime has expired. It disables the servo controller.
      Parameters:
      context - specifies callback context (not used).
    • setControllerOn

      public void setControllerOn(boolean on)
      The method enables/disables the servo controller. If the servo controller is disabled, all servos on the controller will go limp. This is useful for preventing the servos from burning up if it is held against a heavy load.
      Parameters:
      on - specifies true to enable the servo controller, false otherwise.
    • setInverted

      public void setInverted(boolean inverted)
      This method inverts the servo direction.
      Specified by:
      setInverted in class TrcServo
      Parameters:
      inverted - specifies true to invert the servo direction, false otherwise.
    • isInverted

      public boolean isInverted()
      This method checks if the servo direction is inverted.
      Specified by:
      isInverted in class TrcServo
      Returns:
      true if the servo direction is inverted, false otherwise.
    • setLogicalPosition

      public void setLogicalPosition(double position)
      This method sets the logical position of the servo.
      Specified by:
      setLogicalPosition in class TrcServo
      Parameters:
      position - specifies the logical position of the servo in the range of [0.0, 1.0].
    • getLogicalPosition

      public double getLogicalPosition()
      This method returns the logical position of the servo. In general, servo do not provide real time position feedback. Therefore, it will return the position set by the last setLogicalPosition call.
      Specified by:
      getLogicalPosition in class TrcServo
      Returns:
      logical position of the servo in the range of [0.0, 1.0].