Class CommandSequence
java.lang.Object
org.edu_nation.easy_ftc.mechanism.CommandSequence
Create a list of commands to execute sequentially in TeleOp, enabling automation of routines
Basic Usage:
// Construction
CommandSequence sequence =
new CommandSequence()
.command(drive, Drive.Direction.FORWARD, 2, 0.2)
.command(drive, Drive.Direction.ROTATE_LEFT, 90, 0.2, AngleUnit.DEGREES)
.command(claw, Claw.Direction.OPEN);
// Usage within main loop
sequence.control();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<E> CommandSequencecommand(org.edu_nation.easy_ftc.mechanism.MotorMechanism<E> mechanism, E direction, double measurement, double power) Add a MotorMechanism command to the sequence via method chaining<E> CommandSequencecommand(org.edu_nation.easy_ftc.mechanism.MotorMechanism<E> mechanism, E direction, double measurement, double power, org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit) Add an angularDrivecommand to the sequence via method chaining<E> CommandSequencecommand(org.edu_nation.easy_ftc.mechanism.ServoMechanism<E> mechanism, E direction) Add a ServoMechanism command to the sequence via method chainingvoidcontrol()Leverage the constructed sequence with gamepad (dpadLeft, dpadRight)
-
Constructor Details
-
CommandSequence
public CommandSequence()Construct a blank sequence of commands
-
-
Method Details
-
command
public <E> CommandSequence command(org.edu_nation.easy_ftc.mechanism.MotorMechanism<E> mechanism, E direction, double measurement, double power) Add a MotorMechanism command to the sequence via method chaining- Type Parameters:
E- mechanism's direction enum implementation- Parameters:
mechanism- instance of the MotorMechanism associated with this commanddirection- direction to move the mechanism; see the passed mechanism's Direction enum for accepted valuesmeasurement- time(s) or distance to move the mechanismpower- fraction of total power/velocity to use for mechanism command- Returns:
- CommandSequence instance
- Throws:
NullPointerException- if mechanism is nullNullPointerException- if direction is null
-
command
public <E> CommandSequence command(org.edu_nation.easy_ftc.mechanism.ServoMechanism<E> mechanism, E direction) Add a ServoMechanism command to the sequence via method chaining- Type Parameters:
E- mechanism's direction enum implementation- Parameters:
mechanism- instance of the ServoMechanism associated with this commanddirection- direction to move the mechanism; see the passed mechanism's Direction enum for accepted values- Returns:
- CommandSequence instance
- Throws:
NullPointerException- if mechanism is nullNullPointerException- if direction is null
-
control
public void control()Leverage the constructed sequence with gamepad (dpadLeft, dpadRight)- Throws:
IllegalArgumentException- if the mechanism is an unknown type