Class Pivot

All Implemented Interfaces:
CommandMechanism

public class Pivot extends Pivot implements CommandMechanism
Command-based extension of Pivot that adds the Subsystem binding and Command/Trigger factories.

Usage Example

// --- Instantiation ---
Pivot pivot = new Pivot(pivotConfig, motor);

// --- Commands ---
Command aimHigh = pivot.setAngle(Degrees.of(45));
Command stowPivot = pivot.runTo(Degrees.of(0), Degrees.of(1));

// --- Trigger bindings ---
pivot.near(Degrees.of(45), Degrees.of(2)).onTrue(shooter.runShooter());
pivot.gte(Degrees.of(55)).onTrue(Commands.print("Approaching upper limit!"));
pivot.lte(Degrees.of(5)).onTrue(Commands.print("Pivot near stow position."));
  • Constructor Details

  • Method Details

    • getSubsystem

      public org.wpilib.command2.Subsystem getSubsystem()
      Description copied from interface: CommandMechanism
      Subsystem the mechanism's commands should require.
      Specified by:
      getSubsystem in interface CommandMechanism
      Returns:
      Subsystem for the mechanism.
    • between

      public org.wpilib.command2.button.Trigger between(org.wpilib.units.measure.Angle start, org.wpilib.units.measure.Angle end)
      Between two angles.
      Parameters:
      start - Start angle.
      end - End angle
      Returns:
      Trigger
    • gte

      public org.wpilib.command2.button.Trigger gte(org.wpilib.units.measure.Angle angle)
      Greater than or equal to angle.
      Parameters:
      angle - Angle to check against.
      Returns:
      Trigger for Pivot.
    • lte

      public org.wpilib.command2.button.Trigger lte(org.wpilib.units.measure.Angle angle)
      Less than or equal to angle
      Parameters:
      angle - Angle to check against
      Returns:
      Trigger
    • setAngle

      public org.wpilib.command2.Command setAngle(org.wpilib.units.measure.Angle angle)
      Set the pivot to the given angle.
      Parameters:
      angle - Pivot angle to go to.
      Returns:
      Command that sets the pivot to the desired angle.
    • setAngle

      public org.wpilib.command2.Command setAngle(Supplier<org.wpilib.units.measure.Angle> angle)
      Set the pivot to the given angle.
      Parameters:
      angle - Pivot angle to go to.
      Returns:
      Command that sets the pivot to the desired angle.
    • run

      public org.wpilib.command2.Command run(org.wpilib.units.measure.Angle angle)
      Set the pivot to the given angle.
      Parameters:
      angle - Pivot angle to go to.
      Returns:
      Command that sets the pivot to the desired angle.
    • run

      public org.wpilib.command2.Command run(Supplier<org.wpilib.units.measure.Angle> angle)
      Set the pivot to the given angle via a supplier.
      Parameters:
      angle - Supplier for the pivot angle to go to.
      Returns:
      Command that sets the pivot to the desired angle.
    • runTo

      public org.wpilib.command2.Command runTo(org.wpilib.units.measure.Angle angle, org.wpilib.units.measure.Angle tolerance)
      Set the pivot to the given Angle then end the command.
      Parameters:
      angle - Angle to go to.
      tolerance - Tolerance Angle
      Returns:
      Command that sets the pivot to the desired angle.
      Implementation Note:
      This command will not stop. It should NOT be used when there is a default command on the Subsystem.
    • runTo

      public org.wpilib.command2.Command runTo(Supplier<org.wpilib.units.measure.Angle> angle, org.wpilib.units.measure.Angle tolerance)
      Set the pivot to the given angle then end the command.
      Parameters:
      angle - Angle to go to.
      tolerance - Tolerance Angle
      Returns:
      Command that sets the pivot to the desired angle.
      Implementation Note:
      This command will not stop. It should NOT be used when there is a default command on the Subsystem.
    • near

      public org.wpilib.command2.button.Trigger near(org.wpilib.units.measure.Angle angle, org.wpilib.units.measure.Angle within)
      Pivot is near an angle.
      Parameters:
      angle - Angle to be near.
      within - Angle within.
      Returns:
      Trigger on when the pivot is near another angle.
    • max

      public org.wpilib.command2.button.Trigger max()
      Pivot is at max, defined by the soft limit or hard limit on the pivot.
      Returns:
      Trigger on maximum of the pivot.
      Throws:
      PivotConfigurationException - when the returned trigger is evaluated, if neither a motor controller upper soft limit nor a pivot upper hard limit is configured.
    • min

      public org.wpilib.command2.button.Trigger min()
      Minimum angle of the pivot given by the soft limit or hard limit of the pivot.
      Returns:
      Trigger on minimum of the pivot.
      Throws:
      PivotConfigurationException - when the returned trigger is evaluated, if neither a motor controller lower soft limit nor a pivot lower hard limit is configured.