Class Elevator

All Implemented Interfaces:
CommandMechanism

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

Usage Example

SmartMotorController motor = new TalonFXWrapper(
    new TalonFX(4), DCMotor.getKrakenX60(1),
    new SmartMotorControllerConfig(this).withClosedLoopController(0.5,0,0).withFeedforward(new
ElevatorFeedforward(0.4,0,0)); Elevator elevator = new Elevator( new
ElevatorConfig(motor).withDrumRadius(Inches.of(1.0)));

// Move to heights
Command toHigh = elevator.setHeight(Meters.of(1.2));
Command toLow  = elevator.runTo(Meters.of(0.05), Meters.of(0.01));

// Trigger bindings
elevator.near(Meters.of(1.2), Meters.of(0.02)).onTrue(shooter.shoot());
elevator.max().onTrue(Commands.print("Elevator at max"));

// In periodic():
elevator.simIterate();
elevator.updateTelemetry();
  • 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.
    • setHeight

      public org.wpilib.command2.Command setHeight(org.wpilib.units.measure.Distance height)
      Set the height of the elevator.
      Parameters:
      height - Height of the elevator to reach.
      Returns:
      Command that sets the elevator height, stops immediately.
    • setHeight

      public org.wpilib.command2.Command setHeight(Supplier<org.wpilib.units.measure.Distance> height)
      Set the height of the elevator.
      Parameters:
      height - Height of the elevator to reach.
      Returns:
      Command that sets the elevator height, stops immediately.
    • run

      public org.wpilib.command2.Command run(org.wpilib.units.measure.Distance height)
      Set the height of the elevator.
      Parameters:
      height - Height of the elevator to reach.
      Returns:
      Command that sets the elevator height, does not stop.
    • run

      public org.wpilib.command2.Command run(Supplier<org.wpilib.units.measure.Distance> height)
      Set the height of the elevator.
      Parameters:
      height - Height of the elevator to reach.
      Returns:
      Command that sets the elevator height, stops immediately.
    • runTo

      public org.wpilib.command2.Command runTo(org.wpilib.units.measure.Distance height, org.wpilib.units.measure.Distance tolerance)
      Run the elevator to the desired height with a tolerance, then move on.
      Parameters:
      height - Height to reach.
      tolerance - The acceptable tolerance
      Returns:
      Command which will run the elevator to the desired height with a tolerance, then move on.
      Implementation Note:
      This should NOT be used with a default command, the mechanism will not stop running after this to allow for easy chaining.
    • runTo

      public org.wpilib.command2.Command runTo(Supplier<org.wpilib.units.measure.Distance> height, org.wpilib.units.measure.Distance tolerance)
      Run the elevator to the desired height with a tolerance, then move on.
      Parameters:
      height - Height to reach.
      tolerance - The acceptable tolerance
      Returns:
      Command which will run the elevator to the desired height with a tolerance, then move on.
      Implementation Note:
      This should NOT be used with a default command, the mechanism will not stop running after this to allow for easy chaining.
    • near

      public org.wpilib.command2.button.Trigger near(org.wpilib.units.measure.Distance height, org.wpilib.units.measure.Distance within)
      Elevator is near a height.
      Parameters:
      height - Distance to be near.
      within - Distance within.
      Returns:
      Trigger on when the elevator is near another height.
    • max

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

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

      public org.wpilib.command2.button.Trigger between(org.wpilib.units.measure.Distance start, org.wpilib.units.measure.Distance end)
      Between two heights.
      Parameters:
      start - Start height.
      end - End height.
      Returns:
      Trigger
    • lte

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

      public org.wpilib.command2.button.Trigger gte(org.wpilib.units.measure.Distance height)
      Greater than or equal to height.
      Parameters:
      height - Height to check against.
      Returns:
      Trigger for elevator.