Class FlyWheelConfig

java.lang.Object
yams.core.mechanisms.config.FlyWheelConfig

public class FlyWheelConfig extends Object
FlyWheel configuration class.

Configuration Example

// 1. Build the motor config with kV and kS feedforward (critical for velocity mechanisms)
SmartMotorControllerConfig motorConfig = new SmartMotorControllerConfig()
    .withFeedforward(new SimpleMotorFeedforward(0.15, 0.12))   // kS=0.15, kV=0.12 kV dominates
at steady-state RPM .withClosedLoopController(0.0005, 0.0, 0.0) // kP .withTelemetry("Shooter",
TelemetryVerbosity.HIGH);

// 2. Create a TalonFXWrapper for a Kraken X60 on CAN ID 1
SmartMotorController motor = new TalonFXWrapper(new TalonFX(1), DCMotor.getKrakenX60(1),
motorConfig);

// 3. Assemble the FlyWheelConfig and mechanism
FlyWheelConfig config = new FlyWheelConfig()
    .withDiameter(Inches.of(4))
    .withSpeedometerSimulation(RPM.of(6000))  // optional: sim speedometer up to 6000 RPM
    .withTelemetry("Shooter", TelemetryVerbosity.HIGH);

FlyWheel flywheel = new FlyWheel(config, motor);
  • Constructor Details

    • FlyWheelConfig

      public FlyWheelConfig()
      FlyWheel Configuration class
  • Method Details

    • clone

      public FlyWheelConfig clone()
      Overrides:
      clone in class Object
    • withSpeedometerSimulation

      public FlyWheelConfig withSpeedometerSimulation(org.wpilib.units.measure.AngularVelocity maxVelocity)
      Enables the use of the speedometer simulation for the shooter.

      The speedometer simulation is a simulation of a speedometer that is used to simulate the behavior of the shooter. This is useful for testing and debugging the shooter without having to physically move it.

      Parameters:
      maxVelocity - The maximum velocity of the shooter.
      Returns:
      FlyWheelConfig for chaining.
    • withSpeedometerSimulation

      public FlyWheelConfig withSpeedometerSimulation()
      Enables the use of the speedometer simulation for the shooter.

      The speedometer simulation is a simulation of a speedometer that is used to simulate the behavior of the shooter. This is useful for testing and debugging the shooter without having to physically move it.

      Returns:
      FlyWheelConfig for chaining.
      Throws:
      FlyWheelConfigurationException - if the speedometer max velocity has not been set with withSpeedometerSimulation(AngularVelocity).
    • disableSpeedometerSimulation

      public FlyWheelConfig disableSpeedometerSimulation()
      Disable the use of the speedometer simulation for the shooter.

      The speedometer simulation is a simulation of a speedometer that is used to simulate the behavior of the shooter. This is useful for testing and debugging the shooter without having to physically move it.

      Returns:
      FlyWheelConfig for chaining.
    • isUsingSpeedometerSimulation

      public boolean isUsingSpeedometerSimulation()
      Check if the shooter is using the speedometer simulation.

      The speedometer simulation is a simulation of the speedometer that is used to simulate the behavior of the shooter. This is useful for testing and debugging the shooter without having to physically move it.

      Returns:
      True if the shooter is using the speedometer simulation.
    • getSpeedometerMaxVelocity

      public Optional<org.wpilib.units.measure.AngularVelocity> getSpeedometerMaxVelocity()
      Get the maximum velocity of the speedometer simulation.

      If the speedometer simulation is not enabled, this will return an empty Optional.

      Returns:
      The maximum velocity of the speedometer simulation, or an empty Optional if the speedometer simulation is not enabled.
    • withSimColor

      public FlyWheelConfig withSimColor(org.wpilib.util.Color8Bit simColor)
      Publish the color in sim as this.
      Parameters:
      simColor - Color8Bit to show.
      Returns:
      FlyWheelConfig for chaining.
    • withDiameter

      public FlyWheelConfig withDiameter(org.wpilib.units.measure.Distance distance)
      Configure the FlyWheels diameter for simulation.
      Parameters:
      distance - Length of the FlyWheel.
      Returns:
      FlyWheelConfig for chaining.
    • withMechanismPositionConfig

      public FlyWheelConfig withMechanismPositionConfig(MechanismPositionConfig mechanismPositionConfig)
      Set the shooter mechanism position configuration.
      Parameters:
      mechanismPositionConfig - MechanismPositionConfig for the FlyWheel
      Returns:
      FlyWheelConfig for chaining
    • withTelemetry

      public FlyWheelConfig withTelemetry(String telemetryName, TelemetryVerbosity telemetryVerbosity)
      Configure telemetry for the FlyWheel mechanism.
      Parameters:
      telemetryName - Telemetry NetworkTable name to appear under "SmartDashboard/"
      telemetryVerbosity - Telemetry verbosity to apply.
      Returns:
      FlyWheelConfig for chaining.
    • getDiameter

      public Optional<org.wpilib.units.measure.Distance> getDiameter()
      Get the Length of the FlyWheel
      Returns:
      Distance of the FlyWheel or an empty Optional if not set.
    • getTelemetryVerbosity

      public Optional<TelemetryVerbosity> getTelemetryVerbosity()
      Get the telemetry verbosity of the FlyWheel
      Returns:
      TelemetryVerbosity of the FlyWheel
    • getTelemetryName

      public Optional<String> getTelemetryName()
      Network Tables name for the FlyWheel
      Returns:
      Network Tables name.
    • getSimColor

      public org.wpilib.util.Color8Bit getSimColor()
      Get sim color
      Returns:
      sim color.
    • getMechanismPositionConfig

      public MechanismPositionConfig getMechanismPositionConfig()
      Get the MechanismPositionConfig associated with this FlyWheelConfig.
      Returns:
      An Optional containing the MechanismPositionConfig if present, otherwise an empty Optional.
    • getCircumference

      public org.wpilib.units.measure.Distance getCircumference()
      Get the circumference of the FlyWheel.
      Returns:
      Distance representing the circumference of the FlyWheel.
      Throws:
      FlyWheelConfigurationException - if the diameter is not set with withDiameter(Distance).
    • getLinearVelocity

      public org.wpilib.units.measure.LinearVelocity getLinearVelocity(org.wpilib.units.measure.AngularVelocity velocity)
      Get the LinearVelocity of the FlyWheel given an AngularVelocity
      Parameters:
      velocity - AngularVelocity to convert to LinearVelocity
      Returns:
      LinearVelocity of the FlyWheel
      Throws:
      FlyWheelConfigurationException - if the diameter is not set with withDiameter(Distance).
    • getAngularVelocity

      public org.wpilib.units.measure.AngularVelocity getAngularVelocity(org.wpilib.units.measure.LinearVelocity velocity)
      Get the AngularVelocity of the FlyWheel given a LinearVelocity
      Parameters:
      velocity - LinearVelocity to convert to AngularVelocity
      Returns:
      AngularVelocity of the FlyWheel
      Throws:
      FlyWheelConfigurationException - if the diameter is not set with withDiameter(Distance).