Class FlyWheel
java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.velocity.SmartVelocityMechanism
yams.core.mechanisms.velocity.FlyWheel
yams.commands3.mechanisms.FlyWheel
- All Implemented Interfaces:
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));
-
Field Summary
Fields inherited from class SmartVelocityMechanism
mechanismLigament, mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsConstructorDescriptionFlyWheel(FlyWheelConfig config, SmartMotorController smc) Construct the FlyWheel class -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.command3.Triggerbetween(org.wpilib.units.measure.AngularVelocity start, org.wpilib.units.measure.AngularVelocity end) Between two velocities.org.wpilib.command3.MechanismMechanism the mechanism's commands should require.org.wpilib.command3.Triggergte(org.wpilib.units.measure.AngularVelocity speed) Greater than or equal to angular velocity.org.wpilib.command3.Triggerlte(org.wpilib.units.measure.AngularVelocity speed) Less than or equal to angular velocityorg.wpilib.command3.Triggernear(org.wpilib.units.measure.AngularVelocity speed, org.wpilib.units.measure.AngularVelocity within) FlyWheel is near a speed.<T> org.wpilib.command3.CommandRun the FlyWheel to a given velocityorg.wpilib.command3.Commandrun(org.wpilib.units.measure.AngularVelocity velocity) Set the FlyWheel to the given speed.org.wpilib.command3.Commandrun(org.wpilib.units.measure.LinearVelocity speed) Set the FlyWheel to the given speed.org.wpilib.command3.CommandrunTo(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.org.wpilib.command3.CommandrunTo(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.org.wpilib.command3.CommandrunTo(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.org.wpilib.command3.CommandrunTo(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.Methods inherited from class FlyWheel
getLinearVelocity, getMechanismSetpointVelocity, getName, getPose3d, getShooterConfig, getSpeed, isBetween, isGte, isLte, isNear, setMeasurementVelocitySetpoint, simIterate, updateTelemetry, visualizationUpdateMethods inherited from class SmartVelocityMechanism
getMechanismLigament, getMechanismRoot, getMotorMethods inherited from class SmartMechanism
getMeasurementSetpoint, getMechanismSetpoint, getMechanismWindow, getMotorController, publishMechanismWindow, setDutyCycleSetpoint, setMeasurementPositionSetpoint, setMechanismPositionSetpoint, setMechanismVelocitySetpoint, setVoltageSetpointMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CommandMechanism
getMotorController, set, set, setVoltage, setVoltage
-
Constructor Details
-
FlyWheel
Construct the FlyWheel class- Parameters:
config- FlyWheel configuration.smc-SmartMotorControllerfor the Mechanism- Throws:
SmartMotorControllerConfigurationException- ifsmc's config does not have aMechanismset viawithMechanism(Mechanism).- Implementation Note:
smc's config must be aSmartMotorControllerConfigwith aMechanismset viawithMechanism(Mechanism).
-
-
Method Details
-
getMechanism
public org.wpilib.command3.Mechanism getMechanism()Description copied from interface:CommandMechanismMechanism the mechanism's commands should require.- Specified by:
getMechanismin interfaceCommandMechanism- Returns:
Mechanismfor 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-AngularVelocityto check against.- Returns:
Triggerfor FlyWheel.
-
lte
public org.wpilib.command3.Trigger lte(org.wpilib.units.measure.AngularVelocity speed) Less than or equal to angular velocity- Parameters:
speed-AngularVelocityto 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-AngularVelocityto be near.within-AngularVelocitywithin.- Returns:
- Trigger on when the FlyWheel is near another speed.
-
run
Run the FlyWheel to a given velocity- Type Parameters:
T- Must be aLinearVelocityorAngularVelocity- Parameters:
velocity-SupplierofLinearVelocityorAngularVelocity- Returns:
Commandwhich runs the FlyWheel to the desired velocity with the closed loop controller.- Throws:
IllegalArgumentException- if the value returned byvelocitywhen this method is called is neither anAngularVelocitynor aLinearVelocity.FlyWheelConfigurationException- if the value returned byvelocityis aLinearVelocityand 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:
Commandthat 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-SupplierofAngularVelocitytolerance-AngularVelocitytolerance- Returns:
Commandthat 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-AngularVelocityto go to.tolerance-AngularVelocitytolerance- Returns:
Commandthat 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-LinearVelocityto go to.tolerance-LinearVelocitytolerance- Returns:
Commandthat 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-LinearVelocityto go to.tolerance-LinearVelocitytolerance- Returns:
Commandthat 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:
Commandthat 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.
-