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 Summary
ConstructorsConstructorDescriptionBuilder(com.qualcomm.robotcore.eventloop.opmode.LinearOpMode opMode, com.qualcomm.robotcore.hardware.HardwareMap hardwareMap) Builder constructor -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the clawclose(double close) Specify the position forCLOSEcount(int count) Specify the number of servosdelay(double delay) Specify the delay for normal servo controlgamepad(com.qualcomm.robotcore.hardware.Gamepad gamepad) Pass gamepad for teleop controlincrement(double increment) Specify the increment to move by for smooth-servo controlincrementDelay(double incrementDelay) Specify the increment delay for smooth-servo controlChange the names of the hardware devicesopen(double open) Specify the position forOPENreverse()Whether to reverse devicesReverse the specified deviceReverse the specified devicessmooth()Whether to enable smooth-servo control
-
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<Claw.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<Claw.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<Claw.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<Claw.Builder>- Parameters:
gamepad- instance of the gamepad- Returns:
- builder instance
- Throws:
NullPointerException- if gamepad is null
-
smooth
Description copied from class:org.edu_nation.easy_ftc.mechanism.ServoMechanism.BuilderWhether to enable smooth-servo control- Overrides:
smoothin classorg.edu_nation.easy_ftc.mechanism.ServoMechanism.Builder<Claw.Builder>- Returns:
- builder instance
-
increment
Description copied from class:org.edu_nation.easy_ftc.mechanism.ServoMechanism.BuilderSpecify the increment to move by for smooth-servo control- Overrides:
incrementin classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.ServoMechanism.BuilderSpecify the increment delay for smooth-servo control- Overrides:
incrementDelayin classorg.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
Description copied from class:org.edu_nation.easy_ftc.mechanism.ServoMechanism.BuilderSpecify the delay for normal servo control- Overrides:
delayin classorg.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
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
Change the names of the hardware devices- Specified by:
namesin classorg.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
Specify the position forOPEN- Parameters:
open- position forOPEN- Returns:
- builder instance
- Throws:
IllegalArgumentException- if open not in the interval [0, 1]
-
close
Specify the position forCLOSE- Parameters:
close- position forCLOSE- Returns:
- builder instance
- Throws:
IllegalArgumentException- if close not in the interval [0, 1]
-
build
Build the claw- Returns:
- claw instance
- Throws:
IllegalStateException- if count != names.lengthIllegalStateException- if smooth = false and one of: increment, incrementDelay has been setIllegalStateException- if open <= close
-