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 Summary
ConstructorsConstructorDescriptionBuilder(com.qualcomm.robotcore.eventloop.opmode.LinearOpMode opMode, com.qualcomm.robotcore.hardware.HardwareMap hardwareMap) Builder constructor -
Method Summary
Modifier and TypeMethodDescriptionbehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior behavior) Specify the zero-power behavior of the motorsbuild()Build the drivetraincount(int count) Specify the number of motorsdeadzone(double deadzone) Specify the joystick deadzonediameter(double diameter) Specify the diameter for encoder control (distance-based)encoder()Whether to enable encoders (time-based)gamepad(com.qualcomm.robotcore.hardware.Gamepad gamepad) Pass gamepad for teleop controlgearing(double gearing) Specify the gearing of the motors (increases accuracy of distance-based movement)layout(Drive.Layout layout) Specify the drivetrain layoutlogo(com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logo) Specify the logo direction of the IMU/gyroChange the names of the hardware devicesreverse()Whether to reverse devicesReverse the specified deviceReverse the specified devicestype(Drive.Type type) Specify the drivetrain typeusb(com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usb) Specify the logo direction of the IMU/gyroMethods inherited from class org.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder
length
-
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 opModehardwareMap- instance of the calling opMode's hardwareMap- Throws:
NullPointerException- if opMode or hardwareMap are null
-
-
Method Details
-
reverse
Description copied from class:org.edu_nation.easy_ftc.mechanism.Mechanism.BuilderWhether to reverse devices- Overrides:
reversein classorg.edu_nation.easy_ftc.mechanism.Mechanism.Builder<Drive.Builder>- Returns:
- builder instance
-
reverse
Description copied from class:org.edu_nation.easy_ftc.mechanism.Mechanism.BuilderReverse the specified device- Overrides:
reversein classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.Mechanism.BuilderReverse the specified devices- Overrides:
reversein classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.Mechanism.BuilderPass gamepad for teleop control- Overrides:
gamepadin classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.MotorMechanism.BuilderWhether to enable encoders (time-based)- Overrides:
encoderin classorg.edu_nation.easy_ftc.mechanism.MotorMechanism.Builder<Drive.Builder>- Returns:
- builder instance
-
diameter
Description copied from class:org.edu_nation.easy_ftc.mechanism.MotorMechanism.BuilderSpecify the diameter for encoder control (distance-based)- Overrides:
diameterin classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.MotorMechanism.BuilderSpecify the gearing of the motors (increases accuracy of distance-based movement)- Overrides:
gearingin classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.MotorMechanism.BuilderSpecify the joystick deadzone- Overrides:
deadzonein classorg.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.BuilderSpecify the logo direction of the IMU/gyro- Overrides:
logoin classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.MotorMechanism.BuilderSpecify the logo direction of the IMU/gyro- Overrides:
usbin classorg.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
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
Change the names of the hardware devices- Specified by:
namesin classorg.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
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
Specify the drivetrain type- Parameters:
type- drivetrain type, one ofDIFFERENTIALorMECANUM- Returns:
- builder instance
- Throws:
NullPointerException- if type is null- See Also:
-
layout
Specify the drivetrain layout- Parameters:
layout- drivetrain layout- Returns:
- builder instance
- Throws:
NullPointerException- if layout is null- See Also:
-
build
Build the drivetrain- Returns:
- drive instance
- Throws:
IllegalStateException- if count != names.lengthIllegalStateException- if encoder = false and one of: diameter, length, or gearing has been setIllegalStateException- if type = DIFFERENTIAL and layout is one of: ROBOT, FIELDIllegalStateException- if type = MECANUM and count != 4IllegalStateException- if type = MECANUM and layout is one of: ARCADE, TANK
-