Class FlyWheel
java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.velocity.SmartVelocityMechanism
yams.core.mechanisms.velocity.FlyWheel
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.
-
Field Summary
Fields inherited from class SmartVelocityMechanism
mechanismLigament, mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFlyWheel(FlyWheelConfig config, SmartMotorController smc) Construct the FlyWheel class -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.units.measure.LinearVelocityGet theLinearVelocityof the FlyWheel.Optional<org.wpilib.units.measure.AngularVelocity> Mechanism velocity setpoint.getName()Get the name of the mechanism.org.wpilib.math.geometry.Pose3dGet the flywheel's pose, for publishing to AdvantageScope as a component of a robot model: where its axle is mounted, as set in itsMechanismPositionConfig, turned by the wheel's position about the axis normal to its movement plane.Get theFlyWheelConfigobject for thisFlyWheelorg.wpilib.units.measure.AngularVelocitygetSpeed()Get theSmartMotorControllerMechanism velocity representing the FlyWheel.booleanisBetween(org.wpilib.units.measure.AngularVelocity start, org.wpilib.units.measure.AngularVelocity end) Between two velocities.booleanisGte(org.wpilib.units.measure.AngularVelocity speed) Greater than or equal to angular velocity.booleanisLte(org.wpilib.units.measure.AngularVelocity speed) Less than or equal to angular velocitybooleanisNear(org.wpilib.units.measure.AngularVelocity speed, org.wpilib.units.measure.AngularVelocity within) FlyWheel is near a speed.voidsetMeasurementVelocitySetpoint(org.wpilib.units.measure.LinearVelocity speed) Set the FlyWheel to the given speed.voidIterate simvoidUpdate the mechanism's telemetry.voidUpdates the angle of the mechanism ligament to match the current angle of the FlyWheel.Methods inherited from class SmartVelocityMechanism
getMechanismLigament, getMechanismRoot, getMotor
-
Constructor Details
-
FlyWheel
Construct the FlyWheel class- Parameters:
config- FlyWheel configuration.smc-SmartMotorControllerfor the Mechanism- Implementation Note:
- Protected so only
FlyWheelcan construct this.
-
-
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-AngularVelocityto 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-AngularVelocityto 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 theSmartMotorControllerMechanism velocity representing the FlyWheel.- Returns:
- FlyWheel
AngularVelocity
-
getLinearVelocity
public org.wpilib.units.measure.LinearVelocity getLinearVelocity()Get theLinearVelocityof the FlyWheel.- Returns:
- FlyWheel
LinearVelocity - Throws:
FlyWheelConfigurationException- if the FlyWheel diameter is not set in theFlyWheelConfig.
-
isNear
public boolean isNear(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:
- True if the FlyWheel is near another speed.
-
getMechanismSetpointVelocity
Mechanism velocity setpoint.- Returns:
AngularVelocitysetpoint of the FlyWheel.
-
setMeasurementVelocitySetpoint
public void setMeasurementVelocitySetpoint(org.wpilib.units.measure.LinearVelocity speed) Set the FlyWheel to the given speed.- Overrides:
setMeasurementVelocitySetpointin classSmartMechanism- Parameters:
speed-LinearVelocityto go to.- Throws:
FlyWheelConfigurationException- if the FlyWheel diameter is not set in theFlyWheelConfig.
-
simIterate
public void simIterate()Description copied from class:SmartMechanismIterate sim- Specified by:
simIteratein classSmartMechanism
-
updateTelemetry
public void updateTelemetry()Description copied from class:SmartMechanismUpdate the mechanism's telemetry.- Specified by:
updateTelemetryin classSmartMechanism
-
visualizationUpdate
public void visualizationUpdate()Updates the angle of the mechanism ligament to match the current angle of the FlyWheel.- Specified by:
visualizationUpdatein classSmartMechanism
-
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 itsMechanismPositionConfig, turned by the wheel's position about the axis normal to its movement plane.- Specified by:
getPose3din classSmartMechanism- Returns:
- The flywheel's
Pose3d, relative to the robot.
-
getName
Description copied from class:SmartMechanismGet the name of the mechanism.- Specified by:
getNamein classSmartMechanism- Returns:
Stringname.
-
getShooterConfig
Get theFlyWheelConfigobject for thisFlyWheel- Returns:
- The
FlyWheelConfigobject for thisFlyWheel
-