Class Drive.Builder

java.lang.Object
org.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Drive.Builder>
org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
org.edu_nation.easy_ftc.mechanism.Drive.Builder
Enclosing class:
Drive

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

Basic Usage:


 Drive drive = new Drive.Builder(this, hardwareMap).build();
 
Defaults:
  • reverse = false
  • reverseDevices = {}
  • gamepad = null
  • encoder = false
  • diameter = 0.0
  • gearing = 0.0
  • deadzone = 0.0
  • logo = UP
  • usb = FORWARD
  • count = 2
  • names = {"driveLeft", "driveRight"}
  • behavior = FLOAT
  • type = DIFFERENTIAL
  • layout = TANK
  • 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 Drive.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<Drive.Builder>
      Returns:
      builder instance
    • reverse

      public Drive.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<Drive.Builder>
      Parameters:
      deviceName - name of the device to be reversed
      Returns:
      builder instance
      Throws:
      NullPointerException - if deviceName is null
    • reverse

      public Drive.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<Drive.Builder>
      Parameters:
      deviceNames - an array of the names of devices to be reversed
      Returns:
      builder instance
      Throws:
      NullPointerException - if deviceNames is null
    • gamepad

      public Drive.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<Drive.Builder>
      Parameters:
      gamepad - instance of the gamepad
      Returns:
      builder instance
      Throws:
      NullPointerException - if gamepad is null
    • encoder

      public Drive.Builder encoder()
      Description copied from class: org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
      Whether to enable encoders (time-based)
      Overrides:
      encoder in class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
      Returns:
      builder instance
    • diameter

      public Drive.Builder diameter(double diameter)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
      Specify the diameter for encoder control (distance-based)
      Overrides:
      diameter in class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
      Parameters:
      diameter - measurement of the wheel or axel attached to the motor
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if diameter <= 0
    • gearing

      public Drive.Builder gearing(double gearing)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
      Specify the gearing of the motors (increases accuracy of distance-based movement)
      Overrides:
      gearing in class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
      Parameters:
      gearing - gearing of the motors in the mechanism
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if gearing <= 0
    • deadzone

      public Drive.Builder deadzone(double deadzone)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
      Specify the joystick deadzone
      Overrides:
      deadzone in class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
      Parameters:
      deadzone - minimum joystick/trigger value registered as input
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if deadzone < 0
    • logo

      public Drive.Builder logo(com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logo)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
      Specify the logo direction of the IMU/gyro
      Overrides:
      logo in class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
      Parameters:
      logo - direction of the Hub's logo
      Returns:
      builder instance
      Throws:
      NullPointerException - if logo is null
    • usb

      public Drive.Builder usb(com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usb)
      Description copied from class: org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
      Specify the logo direction of the IMU/gyro
      Overrides:
      usb in class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>
      Parameters:
      usb - direction of the Hub's usb ports
      Returns:
      builder instance
      Throws:
      NullPointerException - if usb is null
    • count

      public Drive.Builder count(int count)
      Specify the number of motors
      Parameters:
      count - the number of motors in the drive mechanism
      Returns:
      builder instance
      Throws:
      IllegalArgumentException - if count isn't 2 or 4
    • names

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

      public Drive.Builder behavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior behavior)
      Specify the zero-power behavior of the motors
      Parameters:
      behavior - the zero-power behavior, one of ZeroPowerBehavior.BRAKE or FLOAT
      Returns:
      builder instance
      Throws:
      NullPointerException - if behavior is null
    • type

      public Drive.Builder type(Drive.Type type)
      Specify the drivetrain type
      Parameters:
      type - drivetrain type, one of DIFFERENTIAL or MECANUM
      Returns:
      builder instance
      Throws:
      NullPointerException - if type is null
      See Also:
    • layout

      public Drive.Builder layout(Drive.Layout layout)
      Specify the drivetrain layout
      Parameters:
      layout - drivetrain layout
      Returns:
      builder instance
      Throws:
      NullPointerException - if layout is null
      See Also:
    • build

      public Drive build()
      Build the drivetrain
      Returns:
      drive instance
      Throws:
      IllegalStateException - if count != names.length
      IllegalStateException - if encoder = false and one of: diameter, length, or gearing has been set
      IllegalStateException - if type = DIFFERENTIAL and layout is one of: ROBOT, FIELD
      IllegalStateException - if type = MECANUM and count != 4
      IllegalStateException - if type = MECANUM and layout is one of: ARCADE, TANK