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


Public Member Functions | |
| virtual | ~SmartMotorController () |
| virtual bool | ApplyConfig (const SmartMotorControllerConfig &config)=0 |
| virtual void | SetupSimulation ()=0 |
| virtual void | SimIterate ()=0 |
| void | SetSimSupplier (std::shared_ptr< SimSupplier > supplier) |
| SimSupplier * | GetSimSupplier () const |
| virtual void | SeedRelativeEncoder ()=0 |
| virtual void | SynchronizeRelativeEncoder ()=0 |
| virtual void | SetDutyCycle (double dutyCycle)=0 |
| virtual double | GetDutyCycle ()=0 |
| virtual void | SetVoltage (wpi::units::volt_t voltage)=0 |
| virtual wpi::units::volt_t | GetVoltage ()=0 |
| virtual void | SetPosition (wpi::units::turn_t angle)=0 |
| virtual void | SetPosition (wpi::units::meter_t distance)=0 |
| virtual void | SetVelocity (wpi::units::turns_per_second_t velocity)=0 |
| virtual void | SetVelocity (wpi::units::meters_per_second_t velocity)=0 |
| virtual void | SetVelocity (wpi::units::turns_per_second_t velocity, wpi::units::newton_t feedforwardForce) |
| void | SetVelocity (wpi::units::meters_per_second_t velocity, wpi::units::newton_t feedforwardForce) |
| virtual void | SetEncoderPosition (wpi::units::turn_t angle)=0 |
| virtual void | SetEncoderPosition (wpi::units::meter_t distance)=0 |
| virtual void | SetEncoderVelocity (wpi::units::turns_per_second_t velocity)=0 |
| virtual void | SetEncoderVelocity (wpi::units::meters_per_second_t velocity)=0 |
| virtual wpi::units::turn_t | GetMechanismPosition ()=0 |
| virtual wpi::units::turns_per_second_t | GetMechanismVelocity ()=0 |
| virtual wpi::units::turn_t | GetRelativeMechanismPosition ()=0 |
| virtual wpi::units::turns_per_second_t | GetRelativeMechanismVelocity ()=0 |
| virtual wpi::units::turns_per_second_squared_t | GetMechanismAcceleration ()=0 |
| virtual wpi::units::turn_t | GetRotorPosition ()=0 |
| virtual wpi::units::turns_per_second_t | GetRotorVelocity ()=0 |
| virtual wpi::units::meter_t | GetMeasurementPosition ()=0 |
| virtual wpi::units::meters_per_second_t | GetMeasurementVelocity ()=0 |
| virtual wpi::units::meters_per_second_squared_t | GetMeasurementAcceleration ()=0 |
| virtual std::optional< wpi::units::turn_t > | GetExternalEncoderMechanismPosition ()=0 |
| virtual std::optional< wpi::units::turns_per_second_t > | GetExternalEncoderMechanismVelocity ()=0 |
| virtual std::optional< wpi::units::ampere_t > | GetSupplyCurrent ()=0 |
| virtual wpi::units::ampere_t | GetStatorCurrent ()=0 |
| virtual wpi::units::celsius_t | GetTemperature ()=0 |
| virtual wpi::math::DCMotor | GetDCMotor ()=0 |
| virtual void | SetZeroPower (MotorMode mode)=0 |
| virtual void | SetMotorInverted (bool inverted)=0 |
| virtual void | SetEncoderInverted (bool inverted)=0 |
| virtual void | SetKp (double kP)=0 |
| virtual void | SetKi (double kI)=0 |
| virtual void | SetKd (double kD)=0 |
| virtual void | SetFeedback (double kP, double kI, double kD)=0 |
| virtual void | SetKs (double kS)=0 |
| virtual void | SetKv (double kV)=0 |
| virtual void | SetKa (double kA)=0 |
| virtual void | SetKg (double kG)=0 |
| virtual void | SetFeedforward (double kS, double kV, double kA, double kG)=0 |
| virtual void | SetStatorCurrentLimit (wpi::units::ampere_t currentLimit)=0 |
| virtual void | SetSupplyCurrentLimit (wpi::units::ampere_t currentLimit)=0 |
| virtual void | SetClosedLoopRampRate (wpi::units::second_t rampRate)=0 |
| virtual void | SetOpenLoopRampRate (wpi::units::second_t rampRate)=0 |
| virtual void | SetMechanismUpperLimit (wpi::units::turn_t upperLimit)=0 |
| virtual void | SetMechanismLowerLimit (wpi::units::turn_t lowerLimit)=0 |
| virtual void | SetMechanismLimits (wpi::units::turn_t lower, wpi::units::turn_t upper)=0 |
| virtual void | SetMechanismLimitsEnabled (bool enabled)=0 |
| virtual void | SetMeasurementUpperLimit (wpi::units::meter_t upperLimit)=0 |
| virtual void | SetMeasurementLowerLimit (wpi::units::meter_t lowerLimit)=0 |
| virtual void | SetMotionProfileMaxVelocity (wpi::units::turns_per_second_t maxVelocity)=0 |
| virtual void | SetMotionProfileMaxVelocity (wpi::units::meters_per_second_t maxVelocity)=0 |
| virtual void | SetMotionProfileMaxAcceleration (wpi::units::turns_per_second_squared_t maxAcc)=0 |
| virtual void | SetMotionProfileMaxAcceleration (wpi::units::meters_per_second_squared_t maxAcc)=0 |
| virtual void | SetMotionProfileMaxJerk (wpi::units::angular_jerk::turns_per_second_cubed_t maxJerk)=0 |
| virtual void | SetExponentialProfile (std::optional< double > kV, std::optional< double > kA, std::optional< wpi::units::volt_t > maxInput)=0 |
| virtual void | SetClosedLoopSlot (ClosedLoopControllerSlot slot)=0 |
| virtual void | SetMechanismGearing (const gearing::MechanismGearing &gearing) |
| virtual void | SetMechanismCircumference (wpi::units::meter_t circumference) |
| wpi::units::second_t | GetClosedLoopControllerPeriod () const |
| virtual std::optional< wpi::units::second_t > | GetVelocityMeasurementDelay () const |
| void | StartClosedLoopController () |
| void | StopClosedLoopController () |
| void | IterateClosedLoopController () |
| void | SetupTelemetry (std::shared_ptr< wpi::nt::NetworkTable > dataTable, std::shared_ptr< wpi::nt::NetworkTable > tuningTable) |
| void | SetupTelemetry () |
| void | SetupLiveTuning () |
| void | UpdateTelemetry () |
| bool | TuningEnabled () const |
| void | ApplyTuningValues () |
| void | StopLiveTuning () |
| const std::vector< SmartMotorController * > & | GetLooselyCoupledFollowers () const |
| void | AddCloseHook (std::function< void()> hook) |
| SmartMotorController & | WithTelemetry (telemetry::SmartMotorControllerTelemetryConfig config) |
| virtual telemetry::UnsupportedTelemetryFields | GetUnsupportedTelemetryFields () |
| ClosedLoopControllerSlot | GetClosedLoopControllerSlot () const |
| std::optional< wpi::units::turn_t > | GetMechanismPositionSetpoint () const |
| std::optional< wpi::units::turns_per_second_t > | GetMechanismSetpointVelocity () const |
| std::optional< wpi::units::meter_t > | GetMeasurementPositionSetpoint () const |
| std::optional< wpi::units::meters_per_second_t > | GetMeasurementSetpointVelocity () const |
| std::optional< wpi::units::newton_t > | GetSetpointFeedforwardForce () const |
| virtual SmartMotorControllerConfig & | GetConfig ()=0 |
| virtual void * | GetMotorController ()=0 |
| virtual void * | GetMotorControllerConfig ()=0 |
| std::string | GetName () const |
| bool | IsMotor (const wpi::math::DCMotor &a, const wpi::math::DCMotor &b) const |
| void | CheckConfigSafety () |
| void | Close () |
Protected Member Functions | |
| void | LoadLooselyCoupledFollowers () |
| void | ConfigureSoftwarePID (const SmartMotorControllerConfig &config) |
| void | ForwardPositionToFollowers (wpi::units::turn_t pos) |
| void | ForwardPositionToFollowers (wpi::units::meter_t dist) |
| void | ForwardVelocityToFollowers (wpi::units::turns_per_second_t vel) |
| void | ForwardVelocityToFollowers (wpi::units::meters_per_second_t vel) |
| const void * | BatterySimKey () const |
Protected Attributes | |
| SmartMotorControllerConfig * | m_config {nullptr} |
| ClosedLoopControllerSlot | m_slot {ClosedLoopControllerSlot::SLOT_0} |
| std::shared_ptr< SimSupplier > | m_simSupplier |
| std::vector< SmartMotorController * > | m_looseFollowers |
| std::optional< wpi::math::PIDController > | m_pid |
| std::optional< math::LQRController > | m_lqr |
| std::optional< wpi::math::TrapezoidProfile< wpi::units::turns >::State > | m_trapState |
| std::optional< wpi::math::ExponentialProfile< wpi::units::turns, wpi::units::volts >::State > | m_expoState |
| std::optional< wpi::math::TrapezoidProfile< wpi::units::meters >::State > | m_linearTrapState |
| std::optional< wpi::math::ExponentialProfile< wpi::units::meters, wpi::units::volts >::State > | m_linearExpoState |
| std::optional< wpi::units::turn_t > | m_lastClosedLoopMechanismPosition |
| std::optional< wpi::units::turn_t > | m_setpointPosition |
| std::optional< wpi::units::turns_per_second_t > | m_setpointVelocity |
| std::optional< wpi::units::newton_t > | m_setpointFeedforwardForce |
| std::vector< std::function< void()> > | m_closeHooks |
| std::unique_ptr< wpi::Notifier > | m_closedLoopControllerThread |
| bool | m_closedLoopControllerRunning {false} |
| std::shared_ptr< wpi::nt::NetworkTable > | m_parentTable |
| std::shared_ptr< wpi::nt::NetworkTable > | m_telemetryTable |
| std::shared_ptr< wpi::nt::NetworkTable > | m_tuningTable |
| telemetry::SmartMotorControllerTelemetry | m_telemetry |
| telemetry::SmartMotorControllerTelemetryConfig | m_telemetryConfig |
| bool | m_telemetryConfigExplicit {false} |
| std::shared_ptr< telemetry::SmartMotorControllerTelemetryConfig > | m_specifiedTelemetryConfig |
| bool | m_liveTuningRegistered {false} |
| bool | m_closed {false} |
Abstract base class for all YAMS motor controller wrappers.
Provides a hardware-agnostic interface for open-loop control, closed-loop setpoints, encoder reads/writes, simulation, telemetry, and SysId characterization. Concrete implementations wrap CTRE TalonFX/TalonFXS and REV SPARK Max/Flex.
| using yams::motorcontrollers::SmartMotorController::ClosedLoopControllerSlot = SmartMotorControllerConfig::ClosedLoopControllerSlot |
| using yams::motorcontrollers::SmartMotorController::ControlMode = SmartMotorControllerConfig::ControlMode |
| using yams::motorcontrollers::SmartMotorController::MotorMode = SmartMotorControllerConfig::MotorMode |
|
virtual |
Calls Close() so telemetry, battery-sim state and close hooks are always released.
| void yams::motorcontrollers::SmartMotorController::AddCloseHook | ( | std::function< void()> | hook | ) |
|
pure virtual |
Apply a SmartMotorControllerConfig to the underlying hardware.
| config | Configuration to apply. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| void yams::motorcontrollers::SmartMotorController::ApplyTuningValues | ( | ) |
Apply the live-tuned values from the Tuning NetworkTable to this motor controller.
Throws SmartMotorControllerConfigurationException if the control mode is not CLOSED_LOOP.
|
inlineprotected |
Key this controller's current draw is tracked under in simulation::BatterySim. Sim suppliers built from this controller use the same key.
| void yams::motorcontrollers::SmartMotorController::CheckConfigSafety | ( | ) |
Validate the current configuration and throw if safety constraints are violated.
| void yams::motorcontrollers::SmartMotorController::Close | ( | ) |
Release resources held by this controller: stops the closed-loop thread, closes telemetry, removes this controller's current from BatterySim, and runs the close hooks. Safe to call more than once.
|
protected |
Configure the software PID controller (m_pid) from config: continuous input over the continuous wrapping range and the closed-loop tolerance. Call in ApplyConfig() right after m_pid is (re)created; consumes the ClosedLoopTolerance and ContinuousWrapping options.
| config | Config being applied. |
|
protected |
Forward a linear position setpoint to all loosely coupled followers. Call at the end of SetPosition(meter_t) in each concrete wrapper.
|
protected |
Forward a position setpoint to all loosely coupled followers. Call at the end of SetPosition(turn_t) in each concrete wrapper.
|
protected |
Forward a linear velocity setpoint to all loosely coupled followers. Call at the end of SetVelocity(meters_per_second_t) in each concrete wrapper.
|
protected |
Forward a velocity setpoint to all loosely coupled followers. Call at the end of SetVelocity(turns_per_second_t) in each concrete wrapper.
| wpi::units::second_t yams::motorcontrollers::SmartMotorController::GetClosedLoopControllerPeriod | ( | ) | const |
Get the period the closed-loop controller runs at. A closed-loop controller run on the SystemCore, such as an LQR or an exponential profile, runs at SmartMotorControllerConfig::WithClosedLoopControlPeriod(), 20 ms by default. One run on the motor controller runs at 1 kHz.
| ClosedLoopControllerSlot yams::motorcontrollers::SmartMotorController::GetClosedLoopControllerSlot | ( | ) | const |
Get the active closed-loop gain slot.
|
pure virtual |
Get a mutable reference to the current configuration.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the DC motor model associated with this controller.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the current motor duty cycle.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the mechanism position from the external (absolute) encoder (applies the external encoder gearing). Available whether or not the external encoder is used for feedback.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the mechanism velocity from the external (absolute) encoder (applies the external encoder gearing). Available whether or not the external encoder is used for feedback.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
inline |
Get the loosely coupled followers, which are sent the leader's setpoints and run their own closed-loop controllers.
|
pure virtual |
Get the linear measurement acceleration.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the linear measurement position (applies circumference conversion).
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| std::optional< wpi::units::meter_t > yams::motorcontrollers::SmartMotorController::GetMeasurementPositionSetpoint | ( | ) | const |
Get the last commanded linear measurement position setpoint. Converts the internal mechanism-angle setpoint using the configured circumference.
| std::optional< wpi::units::meters_per_second_t > yams::motorcontrollers::SmartMotorController::GetMeasurementSetpointVelocity | ( | ) | const |
Get the last commanded linear measurement velocity setpoint. Converts the internal mechanism-velocity setpoint using the configured circumference.
|
pure virtual |
Get the linear measurement velocity (applies circumference conversion).
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the mechanism acceleration (derived from velocity).
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the mechanism position (applies gearing). Uses the external (absolute) encoder when one is configured with SmartMotorControllerConfig::WithUseExternalFeedbackEncoder(), otherwise the relative encoder. Use GetRelativeMechanismPosition() to only read the relative encoder.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| std::optional< wpi::units::turn_t > yams::motorcontrollers::SmartMotorController::GetMechanismPositionSetpoint | ( | ) | const |
Get the last commanded mechanism position setpoint.
| std::optional< wpi::units::turns_per_second_t > yams::motorcontrollers::SmartMotorController::GetMechanismSetpointVelocity | ( | ) | const |
Get the last commanded mechanism velocity setpoint.
|
pure virtual |
Get the mechanism velocity (applies gearing). Uses the external (absolute) encoder when one is configured with SmartMotorControllerConfig::WithUseExternalFeedbackEncoder(), otherwise the relative encoder. Use GetRelativeMechanismVelocity() to only read the relative encoder.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get a type-erased pointer to the underlying hardware motor controller object.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get a type-erased pointer to the underlying hardware configuration object.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| std::string yams::motorcontrollers::SmartMotorController::GetName | ( | ) | const |
Get the telemetry name of this motor controller.
|
pure virtual |
Get the mechanism position from the relative encoder in the motor (applies gearing). Never uses the external (absolute) encoder.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the mechanism velocity from the relative encoder in the motor (applies gearing). Never uses the external (absolute) encoder.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the raw rotor position (no gearing applied).
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the raw rotor velocity (no gearing applied).
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| std::optional< wpi::units::newton_t > yams::motorcontrollers::SmartMotorController::GetSetpointFeedforwardForce | ( | ) | const |
Get the feedforward force last supplied to SetVelocity(velocity, force).
| SimSupplier * yams::motorcontrollers::SmartMotorController::GetSimSupplier | ( | ) | const |
Get the attached SimSupplier, or nullptr if none is set.
|
pure virtual |
Get the stator (output) current draw.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the supply (input) current draw.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the motor controller temperature.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
virtual |
Return telemetry fields not supported by this motor controller implementation.
Subclasses override this to disable fields for hardware that lacks certain signals (e.g. SPARK controllers do not expose supply current).
Reimplemented in yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
virtual |
Get how far behind the mechanism the measured velocity is, from how the motor controller filters it, as WPILib's SysId works it out for its presets. Feedback gains worked out for the closed loop depend on it. In simulation, the simulation period, since the simulated sensor is updated once a period.
Reimplemented in yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Get the voltage currently applied to the motor.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| bool yams::motorcontrollers::SmartMotorController::IsMotor | ( | const wpi::math::DCMotor & | a, |
| const wpi::math::DCMotor & | b | ||
| ) | const |
Check whether two DCMotor models describe the same motor type.
| a | First motor model. |
| b | Second motor model. |
| void yams::motorcontrollers::SmartMotorController::IterateClosedLoopController | ( | ) |
Run one iteration of the closed-loop controller on the calling thread.
|
protected |
Populate m_looseFollowers from the current m_config. Call this at the end of each concrete ApplyConfig() implementation.
|
pure virtual |
Seed the relative encoder from the absolute sensor position (one-shot on startup).
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the closed-loop output ramp rate.
| rampRate | Time to ramp from 0 to full output. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Select the active closed-loop gain slot.
| slot | Gain slot to activate. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Command a duty-cycle output to the motor.
| dutyCycle | Normalized duty cycle in [-1, 1]. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the encoder count direction.
| inverted | true to invert the encoder. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Write a linear distance into the encoder (seeds the position).
| distance | Linear distance to write. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Write a mechanism angle into the encoder (seeds the position).
| angle | Mechanism angle to write. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Write a linear velocity into the encoder.
| velocity | Linear velocity to write. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Write a mechanism angular velocity into the encoder.
| velocity | Angular velocity to write. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Configure or update the exponential motion profile parameters.
| kV | Optional velocity constant (empty keeps the current value). |
| kA | Optional acceleration constant (empty keeps the current value). |
| maxInput | Optional maximum voltage input (empty keeps the current value). |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set all three PID feedback gains at once (live update).
| kP | Proportional gain. |
| kI | Integral gain. |
| kD | Derivative gain. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set all four feedforward gains at once (live update).
| kS | Static friction voltage. |
| kV | Velocity feedforward coefficient. |
| kA | Acceleration feedforward coefficient. |
| kG | Gravity feedforward coefficient. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the acceleration feedforward coefficient (live update).
| kA | Acceleration feedforward coefficient. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the derivative gain (live update).
| kD | Derivative gain. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the gravity feedforward coefficient (live update).
| kG | Gravity feedforward coefficient. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the integral gain (live update).
| kI | Integral gain. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the proportional gain (live update).
| kP | Proportional gain. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the static friction feedforward (live update).
| kS | Static friction voltage. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the velocity feedforward coefficient (live update).
| kV | Velocity feedforward coefficient. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the lower linear soft limit for the measurement.
| lowerLimit | Lower distance limit. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the upper linear soft limit for the measurement.
| upperLimit | Upper distance limit. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
virtual |
Update the mechanism circumference used for linear position/velocity conversions.
The base implementation updates the config; wrappers override it to also reconfigure the hardware.
| circumference | New mechanism circumference. |
Reimplemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
virtual |
Update the mechanism gearing used for position/velocity conversions.
The base implementation updates the config and forwards the gearing to loosely coupled followers; wrappers override it to also reconfigure the hardware.
| gearing | New mechanism gearing. |
Reimplemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set both angular soft limits for the mechanism.
| lower | Lower angle limit. |
| upper | Upper angle limit. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Enable or disable the mechanism angular soft limits.
| enabled | true to enforce the limits. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the lower angular soft limit for the mechanism.
| lowerLimit | Lower angle limit. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the upper angular soft limit for the mechanism.
| upperLimit | Upper angle limit. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the maximum linear acceleration for the motion profile.
| maxAcc | Maximum linear acceleration. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the maximum angular acceleration for the motion profile.
| maxAcc | Maximum mechanism angular acceleration. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the maximum angular jerk for the motion profile.
| maxJerk | Maximum angular jerk (degrees/s²/s). |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the maximum linear velocity for the motion profile.
| maxVelocity | Maximum linear velocity. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the maximum angular velocity for the motion profile.
| maxVelocity | Maximum mechanism angular velocity. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the motor output direction.
| inverted | true to invert the motor direction. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the open-loop output ramp rate.
| rampRate | Time to ramp from 0 to full output. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Command a linear measurement position setpoint (closed-loop).
| distance | Target linear distance. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Command a mechanism angle position setpoint (closed-loop).
| angle | Target mechanism angle. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| void yams::motorcontrollers::SmartMotorController::SetSimSupplier | ( | std::shared_ptr< SimSupplier > | supplier | ) |
Attach a SimSupplier that provides physics-model position and velocity for simulation. When set, mechanism SimIterate() calls will use this supplier instead of the internal DCMotorSim.
| supplier | Shared SimSupplier instance, or nullptr to detach. |
|
pure virtual |
Set the stator (output) current limit.
| currentLimit | Maximum stator current. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the supply (input) current limit.
| currentLimit | Maximum supply current. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| void yams::motorcontrollers::SmartMotorController::SetupLiveTuning | ( | ) |
Set up live tuning for this motor controller when its telemetry verbosity is HIGH, so the values under the Tuning table are applied while the "Live Tuning" command runs. Only sets it up once, however many times it is called.
|
pure virtual |
Initialize the DCMotorSim used for simulation.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| void yams::motorcontrollers::SmartMotorController::SetupTelemetry | ( | ) |
Set up NetworkTables telemetry using the name configured in the SmartMotorControllerConfig.
| void yams::motorcontrollers::SmartMotorController::SetupTelemetry | ( | std::shared_ptr< wpi::nt::NetworkTable > | dataTable, |
| std::shared_ptr< wpi::nt::NetworkTable > | tuningTable | ||
| ) |
Set up NetworkTables telemetry using explicit table references.
| dataTable | Table for sensor and state data. |
| tuningTable | Table for live gain tuning entries. |
|
pure virtual |
Command a linear measurement velocity setpoint (closed-loop).
| velocity | Target linear velocity. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, yams::motorcontrollers::remote::TalonFXWrapper, yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| void yams::motorcontrollers::SmartMotorController::SetVelocity | ( | wpi::units::meters_per_second_t | velocity, |
| wpi::units::newton_t | feedforwardForce | ||
| ) |
Command a linear velocity setpoint with an additional feedforward force applied on top.
Throws SmartMotorControllerConfigurationException if the mechanism circumference is not configured.
| velocity | Target linear velocity. |
| feedforwardForce | Additional feedforward force at the mechanism. |
|
pure virtual |
Command a mechanism angular velocity setpoint (closed-loop).
| velocity | Target mechanism angular velocity. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, yams::motorcontrollers::remote::TalonFXWrapper, yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
virtual |
Command a mechanism angular velocity setpoint with an additional feedforward force applied on top, e.g. from a path-following set-point generator.
The force is converted to a voltage with SmartMotorControllerConfig::ConvertToVoltage and added by the RoboRIO closed-loop controller, so the mechanism circumference must be set.
| velocity | Target mechanism angular velocity. |
| feedforwardForce | Additional feedforward force at the mechanism. |
Reimplemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, yams::motorcontrollers::remote::TalonFXWrapper, yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Command a voltage output to the motor.
| voltage | Voltage to apply. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Set the idle (neutral) mode of the motor.
| mode | COAST or BRAKE. |
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
|
pure virtual |
Advance the motor simulation by one loop iteration.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| void yams::motorcontrollers::SmartMotorController::StartClosedLoopController | ( | ) |
Start the background closed-loop controller thread, and the loosely coupled followers'.
| void yams::motorcontrollers::SmartMotorController::StopClosedLoopController | ( | ) |
Stop the background closed-loop controller thread, and the loosely coupled followers'. The followers are stopped too, as they are not sent the duty cycle or voltage the leader is driven at.
| void yams::motorcontrollers::SmartMotorController::StopLiveTuning | ( | ) |
Stop live tuning, as when the "Live Tuning" command ends. A tuning voltage stops, it is turned off in the Tuning table, and the closed-loop controller holds the setpoint again.
|
pure virtual |
Periodically re-synchronize the relative encoder to the absolute sensor.
Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.
| bool yams::motorcontrollers::SmartMotorController::TuningEnabled | ( | ) | const |
Whether live tuning is enabled, i.e. whether tunable setpoints are published.
| void yams::motorcontrollers::SmartMotorController::UpdateTelemetry | ( | ) |
Publish the current sensor readings and setpoints to NetworkTables.
Does nothing unless a telemetry verbosity is configured; sets telemetry up on first use. Live-tuned values are not applied here, only by the "Live Tuning" command (or ApplyTuningValues()).
| SmartMotorController & yams::motorcontrollers::SmartMotorController::WithTelemetry | ( | telemetry::SmartMotorControllerTelemetryConfig | config | ) |
Override the telemetry configuration used when publishing data to NetworkTables.
Call before SetupTelemetry() or UpdateTelemetry() to apply fine-grained control over which fields are published.
| config | SmartMotorControllerTelemetryConfig to apply. |
|
protected |
|
protected |
|
protected |
|
protected |
Hooks run once by Close().
|
protected |
Config used by this controller (owned by the caller; set by the wrapper constructor before anything else uses it).
|
protected |
|
protected |
Mechanism position the closed-loop controller last used, unwrapped across the continuous wrapping point.
|
protected |
|
protected |
|
protected |
|
protected |
Loosely coupled followers populated by LoadLooselyCoupledFollowers().
|
protected |
|
protected |
|
protected |
|
protected |
Feedforward force applied on top of the velocity setpoint (see SetVelocity(vel, force)).
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Telemetry config given to SmartMotorControllerConfig::WithTelemetry(name, config), if any.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |