Class Claw.Builder

java.lang.Object
org.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Claw.Builder>
org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
org.edu_nation.easy_ftc.mechanism.Claw.Builder
Enclosing class:
Claw

public static class Claw.Builder extends org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
Construct a Claw object using the builder design pattern

Basic Usage:


 Claw claw = new Claw.Builder(this, hardwareMap).build();
 
Defaults:
  • reverse = false
  • reverseDevices = {}
  • gamepad = null
  • smooth = false
  • increment = 0.02
  • incrementDelay = 0.02
  • delay = 2
  • count = 1
  • names = {"claw"}
  • open = 1.0
  • close = 0.0
  • Constructor Details

    • Builder

      public Builder(com.qualcomm.robotcore.eventloop.opmode.LinearOpMode opMode, com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
      Builder constructor
      Parameters:
      opMode - instance of the calling opMode
      hardwareMap - instance of the calling opMode's hardwareMap
      Throws:
      NullPointerException - if opMode or hardwareMap are null
  • Method Details

    • reverse

      public Claw.Builder reverse()
      Description copied from class: org.edu_nation.easy_ftc.mechanism.Mechanism.Builder
      Whether to reverse devices
      Overrides:
      reverse in class org.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Claw.Builder>
      Returns:
      builder instance
    • reverse

      public Claw.Builder reverse(String deviceName)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.Mechanism.Builder
      Reverse the specified device
      Overrides:
      reverse in class org.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Claw.Builder>
      Parameters:
      deviceName - name of the device to be reversed
      Returns:
      builder instance
      Throws:
      NullPointerException - if deviceName is null
    • reverse

      public Claw.Builder reverse(String[] deviceNames)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.Mechanism.Builder
      Reverse the specified devices
      Overrides:
      reverse in class org.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Claw.Builder>
      Parameters:
      deviceNames - an array of the names of devices to be reversed
      Returns:
      builder instance
      Throws:
      NullPointerException - if deviceNames is null
    • gamepad

      public Claw.Builder gamepad(com.qualcomm.robotcore.hardware.Gamepad gamepad)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.Mechanism.Builder
      Pass gamepad for teleop control
      Overrides:
      gamepad in class org.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Claw.Builder>
      Parameters:
      gamepad - instance of the gamepad
      Returns:
      builder instance
      Throws:
      NullPointerException - if gamepad is null
    • smooth

      public Claw.Builder smooth()
      Description copied from class: org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder
      Whether to enable smooth-servo control
      Overrides:
      smooth in class org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
      Returns:
      builder instance
    • increment

      public Claw.Builder increment(double increment)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder
      Specify the increment to move by for smooth-servo control
      Overrides:
      increment in class org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
      Parameters:
      increment - portion of total range-of-motion moved in each iteration
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if increment is not in the interval (0, 1]
    • incrementDelay

      public Claw.Builder incrementDelay(double incrementDelay)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder
      Specify the increment delay for smooth-servo control
      Overrides:
      incrementDelay in class org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
      Parameters:
      incrementDelay - the time (in s) to wait between each increment
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if incrementDelay <= 0
    • delay

      public Claw.Builder delay(double delay)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder
      Specify the delay for normal servo control
      Overrides:
      delay in class org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
      Parameters:
      delay - the time to wait (in s) for servo movements to complete
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if delay <= 0
    • count

      public Claw.Builder count(int count)
      Specify the number of servos
      Parameters:
      count - the number of servos in the claw mechanism
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if count isn't 1 or 2
    • names

      public Claw.Builder names(String[] names)
      Change the names of the hardware devices
      Specified by:
      names in class org.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>
      Parameters:
      names - an array of the names for the hardware devices
      Returns:
      builder instance
      Throws:
      NullPointerException - if names is null
    • open

      public Claw.Builder open(double open)
      Specify the position for OPEN
      Parameters:
      open - position for OPEN
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if open not in the interval [0, 1]
    • close

      public Claw.Builder close(double close)
      Specify the position for CLOSE
      Parameters:
      close - position for CLOSE
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if close not in the interval [0, 1]
    • build

      public Claw build()
      Build the claw
      Returns:
      claw instance
      Throws:
      IllegalStateException - if count != names.length
      IllegalStateException - if smooth = false and one of: increment, incrementDelay has been set
      IllegalStateException - if open <= close