|
YAMS
Yet Another Mechanism System
|
#include <FlyWheel.hpp>


Public Member Functions | |
| FlyWheel (config::FlyWheelConfig *config, motorcontrollers::SmartMotorController *smc) | |
| void | SimIterate () override |
| void | UpdateTelemetry () override |
| void | VisualizationUpdate () override |
| std::string | GetName () const override |
| wpi::cmd::Trigger | Max () override |
| wpi::cmd::Trigger | Min () override |
| wpi::units::degrees_per_second_t | GetVelocity () const |
| wpi::cmd::CommandPtr | Run (wpi::units::degrees_per_second_t velocity) |
| wpi::cmd::CommandPtr | Run (std::function< wpi::units::degrees_per_second_t()> velocity) |
| wpi::cmd::CommandPtr | Run (wpi::units::meters_per_second_t surfaceSpeed) |
| wpi::cmd::CommandPtr | Run (std::function< wpi::units::meters_per_second_t()> surfaceSpeed) |
| wpi::cmd::CommandPtr | RunTo (wpi::units::degrees_per_second_t velocity, wpi::units::degrees_per_second_t tolerance=wpi::units::degrees_per_second_t{5.0}) |
| wpi::cmd::CommandPtr | RunTo (std::function< wpi::units::degrees_per_second_t()> velocity, wpi::units::degrees_per_second_t tolerance=wpi::units::degrees_per_second_t{5.0}) |
| wpi::cmd::CommandPtr | RunTo (wpi::units::meters_per_second_t velocity, wpi::units::meters_per_second_t tolerance) |
| wpi::cmd::CommandPtr | RunTo (std::function< wpi::units::meters_per_second_t()> velocity, wpi::units::meters_per_second_t tolerance) |
| wpi::cmd::Trigger | Gte (wpi::units::degrees_per_second_t velocity) |
| wpi::cmd::Trigger | Lte (wpi::units::degrees_per_second_t velocity) |
| wpi::cmd::Trigger | Between (wpi::units::degrees_per_second_t start, wpi::units::degrees_per_second_t end) |
| wpi::cmd::Trigger | IsNear (wpi::units::degrees_per_second_t velocity, wpi::units::degrees_per_second_t within=wpi::units::degrees_per_second_t{5.0}) const |
| void | SetVelocity (wpi::units::degrees_per_second_t velocity) |
| void | SetSurfaceSpeed (wpi::units::meters_per_second_t speed) |
| void | SetMeasurementVelocitySetpoint (wpi::units::meters_per_second_t velocity) |
| wpi::math::Pose3d | GetPose3d () const override |
| const config::FlyWheelConfig & | GetConfig () const |
Public Member Functions inherited from yams::mechanisms::velocity::SmartVelocityMechanism | |
| SmartVelocityMechanism () | |
| virtual | ~SmartVelocityMechanism ()=default |
| wpi::MechanismLigament2d * | GetMechanismLigament () |
| wpi::MechanismRoot2d * | GetMechanismRoot () |
| motorcontrollers::SmartMotorController * | GetMotor () |
Public Member Functions inherited from yams::mechanisms::SmartMechanism | |
| SmartMechanism () | |
| virtual | ~SmartMechanism ()=default |
| wpi::cmd::CommandPtr | Set (double dutycycle) |
| wpi::cmd::CommandPtr | Set (std::function< double()> dutycycle) |
| wpi::cmd::CommandPtr | SetVoltage (wpi::units::volt_t volts) |
| wpi::cmd::CommandPtr | SetVoltage (std::function< wpi::units::volt_t()> volts) |
| void | SetMechanismVelocitySetpoint (wpi::units::turns_per_second_t velocity) |
| void | SetMeasurementVelocitySetpoint (wpi::units::meters_per_second_t velocity) |
| void | SetMechanismPositionSetpoint (wpi::units::turn_t angle) |
| void | SetMeasurementPositionSetpoint (wpi::units::meter_t distance) |
| void | SetVoltageSetpoint (wpi::units::volt_t voltage) |
| void | SetDutyCycleSetpoint (double dutycycle) |
| motorcontrollers::SmartMotorController * | GetMotorController () |
| std::optional< wpi::units::turn_t > | GetMechanismSetpoint () |
| std::optional< wpi::units::meter_t > | GetMeasurementSetpoint () |
| wpi::Mechanism2d * | GetMechanismWindow () |
Additional Inherited Members | |
Protected Attributes inherited from yams::mechanisms::velocity::SmartVelocityMechanism | |
| wpi::MechanismRoot2d * | m_mechanismRoot {nullptr} |
| wpi::MechanismLigament2d * | m_mechanismLigament {nullptr} |
Protected Attributes inherited from yams::mechanisms::SmartMechanism | |
| wpi::cmd::SubsystemBase * | m_subsystem {nullptr} |
| motorcontrollers::SmartMotorController * | m_smc {nullptr} |
| std::optional< wpi::Mechanism2d > | m_mechanismWindow |
Smart mechanism implementation for a flywheel (velocity-controlled roller).
Drives a spinning element using a SmartMotorController configured for mechanism-space (degrees/second) closed-loop velocity control. If a roller diameter is provided, surface-speed commands and reads are also supported.
| yams::mechanisms::velocity::FlyWheel::FlyWheel | ( | config::FlyWheelConfig * | config, |
| motorcontrollers::SmartMotorController * | smc | ||
| ) |
Construct a FlyWheel from a FlyWheelConfig and a SmartMotorController.
| config | Pointer to the flywheel configuration (must outlive this object). |
| smc | Pointer to the motor controller (must outlive this object). |
| wpi::cmd::Trigger yams::mechanisms::velocity::FlyWheel::Between | ( | wpi::units::degrees_per_second_t | start, |
| wpi::units::degrees_per_second_t | end | ||
| ) |
Trigger that fires while the flywheel angular velocity is between start and end (inclusive).
| start | Lower bound. |
| end | Upper bound. |
| const config::FlyWheelConfig & yams::mechanisms::velocity::FlyWheel::GetConfig | ( | ) | const |
Get the configuration used to construct this flywheel.
|
overridevirtual |
Get the human-readable name of this flywheel.
Implements yams::mechanisms::SmartMechanism.
|
overridevirtual |
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.
Implements yams::mechanisms::SmartMechanism.
| wpi::units::degrees_per_second_t yams::mechanisms::velocity::FlyWheel::GetVelocity | ( | ) | const |
Get the current angular velocity of the flywheel.
| wpi::cmd::Trigger yams::mechanisms::velocity::FlyWheel::Gte | ( | wpi::units::degrees_per_second_t | velocity | ) |
Trigger that fires while the flywheel angular velocity is >= the given velocity.
| velocity | Reference angular velocity. |
| wpi::cmd::Trigger yams::mechanisms::velocity::FlyWheel::IsNear | ( | wpi::units::degrees_per_second_t | velocity, |
| wpi::units::degrees_per_second_t | within = wpi::units::degrees_per_second_t{5.0} |
||
| ) | const |
Trigger that fires while the flywheel is within tolerance of a velocity.
| velocity | Reference angular velocity. |
| within | Tolerance. |
| wpi::cmd::Trigger yams::mechanisms::velocity::FlyWheel::Lte | ( | wpi::units::degrees_per_second_t | velocity | ) |
Trigger that fires while the flywheel angular velocity is <= the given velocity.
| velocity | Reference angular velocity. |
|
overridevirtual |
Trigger that becomes true when the flywheel is at or above its maximum configured velocity.
Implements yams::mechanisms::velocity::SmartVelocityMechanism.
|
overridevirtual |
Trigger that becomes true when the flywheel is at or below its minimum configured velocity (e.g. stalled or reversed).
Implements yams::mechanisms::velocity::SmartVelocityMechanism.
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::Run | ( | std::function< wpi::units::degrees_per_second_t()> | velocity | ) |
Set the flywheel to the given angular velocity via a supplier.
| velocity | Supplier returning the desired angular velocity each loop. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::Run | ( | std::function< wpi::units::meters_per_second_t()> | surfaceSpeed | ) |
Set the flywheel to the given surface speed via a supplier.
Requires that a roller diameter was provided in the config.
| surfaceSpeed | Supplier returning the desired surface speed each loop. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::Run | ( | wpi::units::degrees_per_second_t | velocity | ) |
Set the flywheel to the given angular velocity.
| velocity | FlyWheel angular velocity to go to. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::Run | ( | wpi::units::meters_per_second_t | surfaceSpeed | ) |
Set the flywheel to the given surface speed.
Requires that a roller diameter was provided in the config.
| surfaceSpeed | Desired surface speed in metres per second. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::RunTo | ( | std::function< wpi::units::degrees_per_second_t()> | velocity, |
| wpi::units::degrees_per_second_t | tolerance = wpi::units::degrees_per_second_t{5.0} |
||
| ) |
Run the flywheel to a supplier-provided angular velocity within a tolerance, then end the command.
The supplier is evaluated once when the command is created.
| velocity | Supplier returning the target angular velocity. |
| tolerance | Allowable error. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::RunTo | ( | std::function< wpi::units::meters_per_second_t()> | velocity, |
| wpi::units::meters_per_second_t | tolerance | ||
| ) |
Run the flywheel to a supplier-provided surface speed within a tolerance, then end the command.
Requires that a roller diameter was provided in the config.
| velocity | Supplier returning the target surface speed. |
| tolerance | Allowable error. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::RunTo | ( | wpi::units::degrees_per_second_t | velocity, |
| wpi::units::degrees_per_second_t | tolerance = wpi::units::degrees_per_second_t{5.0} |
||
| ) |
Run the flywheel to an angular velocity within a tolerance, then end the command.
| velocity | Target angular velocity. |
| tolerance | Allowable error. |
| wpi::cmd::CommandPtr yams::mechanisms::velocity::FlyWheel::RunTo | ( | wpi::units::meters_per_second_t | velocity, |
| wpi::units::meters_per_second_t | tolerance | ||
| ) |
Run the flywheel to a surface speed within a tolerance, then end the command.
Requires that a roller diameter was provided in the config.
| velocity | Target surface speed. |
| tolerance | Allowable error. |
| void yams::mechanisms::velocity::FlyWheel::SetMeasurementVelocitySetpoint | ( | wpi::units::meters_per_second_t | velocity | ) |
Set flywheel velocity from a linear surface speed (base-class override).
Converts the surface speed to angular velocity using the configured roller diameter. Requires roller diameter to be configured; no-op otherwise.
| velocity | Desired surface speed. |
| void yams::mechanisms::velocity::FlyWheel::SetSurfaceSpeed | ( | wpi::units::meters_per_second_t | speed | ) |
Directly command the flywheel to a surface speed setpoint (non-command).
Requires roller diameter to be configured; no-op otherwise.
| speed | Desired surface speed. |
| void yams::mechanisms::velocity::FlyWheel::SetVelocity | ( | wpi::units::degrees_per_second_t | velocity | ) |
Directly command the flywheel to an angular velocity setpoint (non-command).
| velocity | Desired angular velocity. |
|
overridevirtual |
Advance the flywheel's simulation by one loop iteration.
Implements yams::mechanisms::SmartMechanism.
|
overridevirtual |
Publish flywheel telemetry to NetworkTables / SmartDashboard.
Implements yams::mechanisms::SmartMechanism.
|
overridevirtual |
Update the Mechanism2d ligament to reflect the current velocity.
Implements yams::mechanisms::SmartMechanism.