Class FlyWheel

Direct Known Subclasses:
FlyWheel, FlyWheel

public class FlyWheel extends SmartVelocityMechanism
FlyWheel mechanism.

This core class holds flywheel state, physics simulation, and measurement/predicate logic only. Command and Trigger factories live on FlyWheel, which extends this class and has a full usage example in its Javadoc.

Velocity mechanisms have no max()/min() concept; use isNear(org.wpilib.units.measure.AngularVelocity, org.wpilib.units.measure.AngularVelocity), isGte(org.wpilib.units.measure.AngularVelocity), or isLte(org.wpilib.units.measure.AngularVelocity) instead.

  • Constructor Details

  • Method Details

    • isBetween

      public boolean isBetween(org.wpilib.units.measure.AngularVelocity start, org.wpilib.units.measure.AngularVelocity end)
      Between two velocities.
      Parameters:
      start - Start Velocity.
      end - End velocity
      Returns:
      True if the FlyWheel's speed is between the given velocities.
    • isGte

      public boolean isGte(org.wpilib.units.measure.AngularVelocity speed)
      Greater than or equal to angular velocity.
      Parameters:
      speed - AngularVelocity to check against.
      Returns:
      True if the FlyWheel's speed is greater than or equal to the given speed.
    • isLte

      public boolean isLte(org.wpilib.units.measure.AngularVelocity speed)
      Less than or equal to angular velocity
      Parameters:
      speed - AngularVelocity to check against
      Returns:
      True if the FlyWheel's speed is less than or equal to the given speed.
    • getSpeed

      public org.wpilib.units.measure.AngularVelocity getSpeed()
      Get the SmartMotorController Mechanism velocity representing the FlyWheel.
      Returns:
      FlyWheel AngularVelocity
    • getLinearVelocity

      public org.wpilib.units.measure.LinearVelocity getLinearVelocity()
      Get the LinearVelocity of the FlyWheel.
      Returns:
      FlyWheel LinearVelocity
      Throws:
      FlyWheelConfigurationException - if the FlyWheel diameter is not set in the FlyWheelConfig.
    • isNear

      public boolean isNear(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:
      True if the FlyWheel is near another speed.
    • getMechanismSetpointVelocity

      public Optional<org.wpilib.units.measure.AngularVelocity> getMechanismSetpointVelocity()
      Mechanism velocity setpoint.
      Returns:
      AngularVelocity setpoint of the FlyWheel.
    • setMeasurementVelocitySetpoint

      public void setMeasurementVelocitySetpoint(org.wpilib.units.measure.LinearVelocity speed)
      Set the FlyWheel to the given speed.
      Overrides:
      setMeasurementVelocitySetpoint in class SmartMechanism
      Parameters:
      speed - LinearVelocity to go to.
      Throws:
      FlyWheelConfigurationException - if the FlyWheel diameter is not set in the FlyWheelConfig.
    • simIterate

      public void simIterate()
      Description copied from class: SmartMechanism
      Iterate sim
      Specified by:
      simIterate in class SmartMechanism
    • updateTelemetry

      public void updateTelemetry()
      Description copied from class: SmartMechanism
      Update the mechanism's telemetry.
      Specified by:
      updateTelemetry in class SmartMechanism
    • visualizationUpdate

      public void visualizationUpdate()
      Updates the angle of the mechanism ligament to match the current angle of the FlyWheel.
      Specified by:
      visualizationUpdate in class SmartMechanism
    • getPose3d

      public org.wpilib.math.geometry.Pose3d getPose3d()
      Get the flywheel's pose, for publishing to AdvantageScope as a component of a robot model: where its axle is mounted, as set in its MechanismPositionConfig, turned by the wheel's position about the axis normal to its movement plane.
      Specified by:
      getPose3d in class SmartMechanism
      Returns:
      The flywheel's Pose3d, relative to the robot.
    • getName

      public String getName()
      Description copied from class: SmartMechanism
      Get the name of the mechanism.
      Specified by:
      getName in class SmartMechanism
      Returns:
      String name.
    • getShooterConfig

      public FlyWheelConfig getShooterConfig()
      Get the FlyWheelConfig object for this FlyWheel
      Returns:
      The FlyWheelConfig object for this FlyWheel