Class CommandSequence

java.lang.Object
org.edu_nation.easy_ftc.mechanism.CommandSequence

public class CommandSequence extends Object
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
    Constructor
    Description
    Construct a blank sequence of commands
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    command(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 angular Drive command to the sequence via method chaining
    command(org.edu_nation.easy_ftc.mechanism.ServoMechanism<E> mechanism, E direction)
    Add a ServoMechanism command to the sequence via method chaining
    void
    Leverage the constructed sequence with gamepad (dpadLeft, dpadRight)

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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, org.firstinspires.ftc.robotcore.external.navigation.AngleUnit unit)
      Add an angular Drive command to the sequence via method chaining
      Type Parameters:
      E - Drive's direction enum implementation
      Parameters:
      mechanism - instance of the Drive object associated with this command
      direction - direction to move the mechanism; see the Drive.Direction for accepted values (one of: ROTATE_LEFT, ROTATE_RIGHT)
      measurement - angle to rotate
      power - fraction of total power/velocity to use for mechanism command
      unit - AngleUnit to use for the measurement (one of: DEGREES, RADIANS)
      Returns:
      CommandSequence instance
      Throws:
      IllegalArgumentException - if mechanism is not Drive
      NullPointerException - if mechanism is null
      NullPointerException - if direction is null
      NullPointerException - if unit is null
    • 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 command
      direction - direction to move the mechanism; see the passed mechanism's Direction enum for accepted values
      measurement - time(s) or distance to move the mechanism
      power - fraction of total power/velocity to use for mechanism command
      Returns:
      CommandSequence instance
      Throws:
      NullPointerException - if mechanism is null
      NullPointerException - 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 command
      direction - direction to move the mechanism; see the passed mechanism's Direction enum for accepted values
      Returns:
      CommandSequence instance
      Throws:
      NullPointerException - if mechanism is null
      NullPointerException - 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