Class FlyWheel

All Implemented Interfaces:
CommandMechanism

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

Usage Example

// Construct using a fully configured FlyWheelConfig
FlyWheel shooter = new FlyWheel(config);

// Spin at a fixed target RPM (runs continuously as a repeated command)
Command spinUp = shooter.run(RPM.of(3000));

// Block until the wheel reaches 3000 RPM within ±50 RPM, then finish
Command spinToSpeed = shooter.runTo(RPM.of(3000), RPM.of(50));

// Trigger that is true whenever the wheel is within ±50 RPM of target
Trigger atSpeed = shooter.near(RPM.of(3000), RPM.of(50));
  • Constructor Details

  • Method Details

    • getMechanism

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

      public org.wpilib.command3.Trigger between(org.wpilib.units.measure.AngularVelocity start, org.wpilib.units.measure.AngularVelocity end)
      Between two velocities.
      Parameters:
      start - Start Velocity.
      end - End velocity
      Returns:
      Trigger
    • gte

      public org.wpilib.command3.Trigger gte(org.wpilib.units.measure.AngularVelocity speed)
      Greater than or equal to angular velocity.
      Parameters:
      speed - AngularVelocity to check against.
      Returns:
      Trigger for FlyWheel.
    • lte

      public org.wpilib.command3.Trigger lte(org.wpilib.units.measure.AngularVelocity speed)
      Less than or equal to angular velocity
      Parameters:
      speed - AngularVelocity to check against
      Returns:
      Trigger
    • near

      public org.wpilib.command3.Trigger near(org.wpilib.units.measure.AngularVelocity speed, org.wpilib.units.measure.AngularVelocity within)
      FlyWheel is near a speed.
      Parameters:
      speed - AngularVelocity to be near.
      within - AngularVelocity within.
      Returns:
      Trigger on when the FlyWheel is near another speed.
    • run

      public <T> org.wpilib.command3.Command run(Supplier<T> velocity)
      Run the FlyWheel to a given velocity
      Type Parameters:
      T - Must be a LinearVelocity or AngularVelocity
      Parameters:
      velocity - Supplier of LinearVelocity or AngularVelocity
      Returns:
      Command which runs the FlyWheel to the desired velocity with the closed loop controller.
      Throws:
      IllegalArgumentException - if the value returned by velocity when this method is called is neither an AngularVelocity nor a LinearVelocity.
      FlyWheelConfigurationException - if the value returned by velocity is a LinearVelocity and the FlyWheel diameter is not configured.
    • run

      public org.wpilib.command3.Command run(org.wpilib.units.measure.AngularVelocity velocity)
      Set the FlyWheel to the given speed.
      Parameters:
      velocity - FlyWheel speed to go to.
      Returns:
      Command that sets the FlyWheel to the desired speed.
    • runTo

      public org.wpilib.command3.Command runTo(Supplier<org.wpilib.units.measure.AngularVelocity> velocity, org.wpilib.units.measure.AngularVelocity tolerance)
      Run the FlyWheel to a velocity within a tolerance, then end the command.
      Parameters:
      velocity - Supplier of AngularVelocity
      tolerance - AngularVelocity tolerance
      Returns:
      Command that runs the FlyWheel to the desired velocity then moves on.
      Implementation Note:
      If you are using this function, try not to have a default command or else the default command will override the setting after this command ends.
    • runTo

      public org.wpilib.command3.Command runTo(org.wpilib.units.measure.AngularVelocity velocity, org.wpilib.units.measure.AngularVelocity tolerance)
      Run the FlyWheel to a velocity within a tolerance, then end the command.
      Parameters:
      velocity - AngularVelocity to go to.
      tolerance - AngularVelocity tolerance
      Returns:
      Command that runs the FlyWheel to the desired velocity then moves on.
      Implementation Note:
      If you are using this function, try not to have a default command or else the default command will override the setting after this command ends.
    • runTo

      public org.wpilib.command3.Command runTo(org.wpilib.units.measure.LinearVelocity velocity, org.wpilib.units.measure.LinearVelocity tolerance)
      Run the FlyWheel to a velocity within a tolerance then end the command.
      Parameters:
      velocity - LinearVelocity to go to.
      tolerance - LinearVelocity tolerance
      Returns:
      Command that runs the FlyWheel to the desired velocity then moves on.
      Throws:
      FlyWheelConfigurationException - if the FlyWheel diameter is not configured, since it is needed to convert the linear velocity to an angular velocity.
      Implementation Note:
      If you are using this function, try not to have a default command or else the default command will override the setting after this command ends.
    • runTo

      public org.wpilib.command3.Command runTo(Supplier<org.wpilib.units.measure.LinearVelocity> velocity, org.wpilib.units.measure.LinearVelocity tolerance)
      Run the FlyWheel to a velocity within a tolerance then end the command.
      Parameters:
      velocity - LinearVelocity to go to.
      tolerance - LinearVelocity tolerance
      Returns:
      Command that runs the FlyWheel to the desired velocity then moves on.
      Throws:
      FlyWheelConfigurationException - if the FlyWheel diameter is not configured, since it is needed to convert the linear velocity to an angular velocity.
      Implementation Note:
      If you are using this function, try not to have a default command or else the default command will override the setting after this command ends.
    • run

      public org.wpilib.command3.Command run(org.wpilib.units.measure.LinearVelocity speed)
      Set the FlyWheel to the given speed.
      Parameters:
      speed - FlyWheel speed to go to.
      Returns:
      Command that sets the FlyWheel to the desired speed.
      Throws:
      FlyWheelConfigurationException - if the FlyWheel diameter is not configured, since it is needed to convert the linear velocity to an angular velocity.