YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
yams::motorcontrollers::SmartMotorController Class Referenceabstract

#include <SmartMotorController.hpp>

Inheritance diagram for yams::motorcontrollers::SmartMotorController:
Inheritance graph
[legend]
Collaboration diagram for yams::motorcontrollers::SmartMotorController:
Collaboration graph
[legend]

Public Types

using ClosedLoopControllerSlot = SmartMotorControllerConfig::ClosedLoopControllerSlot
 
using MotorMode = SmartMotorControllerConfig::MotorMode
 
using ControlMode = SmartMotorControllerConfig::ControlMode
 

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}
 

Detailed Description

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.

Member Typedef Documentation

◆ ClosedLoopControllerSlot

◆ ControlMode

◆ MotorMode

Constructor & Destructor Documentation

◆ ~SmartMotorController()

virtual yams::motorcontrollers::SmartMotorController::~SmartMotorController ( )
virtual

Calls Close() so telemetry, battery-sim state and close hooks are always released.

Member Function Documentation

◆ AddCloseHook()

void yams::motorcontrollers::SmartMotorController::AddCloseHook ( std::function< void()>  hook)

Register a hook to run when Close() is called, so helpers (e.g. live tuning) can clean up resources they registered elsewhere.

Parameters
hookCallable run once on Close().

◆ ApplyConfig()

virtual bool yams::motorcontrollers::SmartMotorController::ApplyConfig ( const SmartMotorControllerConfig &  config)
pure virtual

Apply a SmartMotorControllerConfig to the underlying hardware.

Parameters
configConfiguration to apply.
Returns
true if the configuration was applied successfully.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ ApplyTuningValues()

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.

◆ BatterySimKey()

const void * yams::motorcontrollers::SmartMotorController::BatterySimKey ( ) const
inlineprotected

Key this controller's current draw is tracked under in simulation::BatterySim. Sim suppliers built from this controller use the same key.

Returns
Battery simulation key.

◆ CheckConfigSafety()

void yams::motorcontrollers::SmartMotorController::CheckConfigSafety ( )

Validate the current configuration and throw if safety constraints are violated.

◆ Close()

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.

◆ ConfigureSoftwarePID()

void yams::motorcontrollers::SmartMotorController::ConfigureSoftwarePID ( const SmartMotorControllerConfig &  config)
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.

Parameters
configConfig being applied.

◆ ForwardPositionToFollowers() [1/2]

void yams::motorcontrollers::SmartMotorController::ForwardPositionToFollowers ( wpi::units::meter_t  dist)
protected

Forward a linear position setpoint to all loosely coupled followers. Call at the end of SetPosition(meter_t) in each concrete wrapper.

◆ ForwardPositionToFollowers() [2/2]

void yams::motorcontrollers::SmartMotorController::ForwardPositionToFollowers ( wpi::units::turn_t  pos)
protected

Forward a position setpoint to all loosely coupled followers. Call at the end of SetPosition(turn_t) in each concrete wrapper.

◆ ForwardVelocityToFollowers() [1/2]

void yams::motorcontrollers::SmartMotorController::ForwardVelocityToFollowers ( wpi::units::meters_per_second_t  vel)
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.

◆ ForwardVelocityToFollowers() [2/2]

void yams::motorcontrollers::SmartMotorController::ForwardVelocityToFollowers ( wpi::units::turns_per_second_t  vel)
protected

Forward a velocity setpoint to all loosely coupled followers. Call at the end of SetVelocity(turns_per_second_t) in each concrete wrapper.

◆ GetClosedLoopControllerPeriod()

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.

Returns
The closed-loop controller's period.

◆ GetClosedLoopControllerSlot()

ClosedLoopControllerSlot yams::motorcontrollers::SmartMotorController::GetClosedLoopControllerSlot ( ) const

Get the active closed-loop gain slot.

Returns
Current ClosedLoopControllerSlot.

◆ GetConfig()

virtual SmartMotorControllerConfig & yams::motorcontrollers::SmartMotorController::GetConfig ( )
pure virtual

◆ GetDCMotor()

virtual wpi::math::DCMotor yams::motorcontrollers::SmartMotorController::GetDCMotor ( )
pure virtual

◆ GetDutyCycle()

virtual double yams::motorcontrollers::SmartMotorController::GetDutyCycle ( )
pure virtual

◆ GetExternalEncoderMechanismPosition()

virtual std::optional< wpi::units::turn_t > yams::motorcontrollers::SmartMotorController::GetExternalEncoderMechanismPosition ( )
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.

Returns
Mechanism position in turns from the external encoder, or empty if none is attached.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetExternalEncoderMechanismVelocity()

virtual std::optional< wpi::units::turns_per_second_t > yams::motorcontrollers::SmartMotorController::GetExternalEncoderMechanismVelocity ( )
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.

Returns
Mechanism velocity in turns per second from the external encoder, or empty if none is attached.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetLooselyCoupledFollowers()

const std::vector< SmartMotorController * > & yams::motorcontrollers::SmartMotorController::GetLooselyCoupledFollowers ( ) const
inline

Get the loosely coupled followers, which are sent the leader's setpoints and run their own closed-loop controllers.

Returns
The loosely coupled followers, empty if there are none.

◆ GetMeasurementAcceleration()

virtual wpi::units::meters_per_second_squared_t yams::motorcontrollers::SmartMotorController::GetMeasurementAcceleration ( )
pure virtual

Get the linear measurement acceleration.

Returns
Linear acceleration in meters per second squared.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMeasurementPosition()

virtual wpi::units::meter_t yams::motorcontrollers::SmartMotorController::GetMeasurementPosition ( )
pure virtual

Get the linear measurement position (applies circumference conversion).

Returns
Linear position in meters.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMeasurementPositionSetpoint()

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.

Returns
Optional linear position setpoint, or empty if no setpoint has been commanded or no circumference is configured.

◆ GetMeasurementSetpointVelocity()

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.

Returns
Optional linear velocity setpoint, or empty if no setpoint has been commanded or no circumference is configured.

◆ GetMeasurementVelocity()

virtual wpi::units::meters_per_second_t yams::motorcontrollers::SmartMotorController::GetMeasurementVelocity ( )
pure virtual

Get the linear measurement velocity (applies circumference conversion).

Returns
Linear velocity in meters per second.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMechanismAcceleration()

virtual wpi::units::turns_per_second_squared_t yams::motorcontrollers::SmartMotorController::GetMechanismAcceleration ( )
pure virtual

Get the mechanism acceleration (derived from velocity).

Returns
Mechanism acceleration in turns per second squared.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMechanismPosition()

virtual wpi::units::turn_t yams::motorcontrollers::SmartMotorController::GetMechanismPosition ( )
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.

Returns
Mechanism position in turns.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMechanismPositionSetpoint()

std::optional< wpi::units::turn_t > yams::motorcontrollers::SmartMotorController::GetMechanismPositionSetpoint ( ) const

Get the last commanded mechanism position setpoint.

Returns
Optional mechanism angle setpoint.

◆ GetMechanismSetpointVelocity()

std::optional< wpi::units::turns_per_second_t > yams::motorcontrollers::SmartMotorController::GetMechanismSetpointVelocity ( ) const

Get the last commanded mechanism velocity setpoint.

Returns
Optional mechanism angular velocity setpoint.

◆ GetMechanismVelocity()

virtual wpi::units::turns_per_second_t yams::motorcontrollers::SmartMotorController::GetMechanismVelocity ( )
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.

Returns
Mechanism velocity in turns per second.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMotorController()

virtual void * yams::motorcontrollers::SmartMotorController::GetMotorController ( )
pure virtual

Get a type-erased pointer to the underlying hardware motor controller object.

Returns
void* that can be cast to the concrete motor controller type.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetMotorControllerConfig()

virtual void * yams::motorcontrollers::SmartMotorController::GetMotorControllerConfig ( )
pure virtual

Get a type-erased pointer to the underlying hardware configuration object.

Returns
void* that can be cast to the concrete motor controller config type.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetName()

std::string yams::motorcontrollers::SmartMotorController::GetName ( ) const

Get the telemetry name of this motor controller.

Returns
Name string from the configuration.

◆ GetRelativeMechanismPosition()

virtual wpi::units::turn_t yams::motorcontrollers::SmartMotorController::GetRelativeMechanismPosition ( )
pure virtual

Get the mechanism position from the relative encoder in the motor (applies gearing). Never uses the external (absolute) encoder.

Returns
Mechanism position in turns from the relative encoder.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetRelativeMechanismVelocity()

virtual wpi::units::turns_per_second_t yams::motorcontrollers::SmartMotorController::GetRelativeMechanismVelocity ( )
pure virtual

Get the mechanism velocity from the relative encoder in the motor (applies gearing). Never uses the external (absolute) encoder.

Returns
Mechanism velocity in turns per second from the relative encoder.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetRotorPosition()

virtual wpi::units::turn_t yams::motorcontrollers::SmartMotorController::GetRotorPosition ( )
pure virtual

◆ GetRotorVelocity()

virtual wpi::units::turns_per_second_t yams::motorcontrollers::SmartMotorController::GetRotorVelocity ( )
pure virtual

Get the raw rotor velocity (no gearing applied).

Returns
Rotor velocity in turns per second.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetSetpointFeedforwardForce()

std::optional< wpi::units::newton_t > yams::motorcontrollers::SmartMotorController::GetSetpointFeedforwardForce ( ) const

Get the feedforward force last supplied to SetVelocity(velocity, force).

Returns
Optional feedforward force.

◆ GetSimSupplier()

SimSupplier * yams::motorcontrollers::SmartMotorController::GetSimSupplier ( ) const

Get the attached SimSupplier, or nullptr if none is set.

Returns
Raw pointer to the SimSupplier (valid as long as the shared_ptr is held).

◆ GetStatorCurrent()

virtual wpi::units::ampere_t yams::motorcontrollers::SmartMotorController::GetStatorCurrent ( )
pure virtual

◆ GetSupplyCurrent()

virtual std::optional< wpi::units::ampere_t > yams::motorcontrollers::SmartMotorController::GetSupplyCurrent ( )
pure virtual

Get the supply (input) current draw.

Returns
Supply current, or empty if not supported by the hardware.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetTemperature()

virtual wpi::units::celsius_t yams::motorcontrollers::SmartMotorController::GetTemperature ( )
pure virtual

◆ GetUnsupportedTelemetryFields()

virtual telemetry::UnsupportedTelemetryFields yams::motorcontrollers::SmartMotorController::GetUnsupportedTelemetryFields ( )
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).

Returns
Struct with optional lists of unsupported boolean and double fields.

Reimplemented in yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetVelocityMeasurementDelay()

virtual std::optional< wpi::units::second_t > yams::motorcontrollers::SmartMotorController::GetVelocityMeasurementDelay ( ) const
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.

Returns
The delay, or nullopt if it is not known for this motor controller.

Reimplemented in yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ GetVoltage()

virtual wpi::units::volt_t yams::motorcontrollers::SmartMotorController::GetVoltage ( )
pure virtual

◆ IsMotor()

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.

Parameters
aFirst motor model.
bSecond motor model.
Returns
true if the models have matching electrical constants.

◆ IterateClosedLoopController()

void yams::motorcontrollers::SmartMotorController::IterateClosedLoopController ( )

Run one iteration of the closed-loop controller on the calling thread.

◆ LoadLooselyCoupledFollowers()

void yams::motorcontrollers::SmartMotorController::LoadLooselyCoupledFollowers ( )
protected

Populate m_looseFollowers from the current m_config. Call this at the end of each concrete ApplyConfig() implementation.

◆ SeedRelativeEncoder()

virtual void yams::motorcontrollers::SmartMotorController::SeedRelativeEncoder ( )
pure virtual

◆ SetClosedLoopRampRate()

virtual void yams::motorcontrollers::SmartMotorController::SetClosedLoopRampRate ( wpi::units::second_t  rampRate)
pure virtual

Set the closed-loop output ramp rate.

Parameters
rampRateTime 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.

◆ SetClosedLoopSlot()

virtual void yams::motorcontrollers::SmartMotorController::SetClosedLoopSlot ( ClosedLoopControllerSlot  slot)
pure virtual

◆ SetDutyCycle()

virtual void yams::motorcontrollers::SmartMotorController::SetDutyCycle ( double  dutyCycle)
pure virtual

Command a duty-cycle output to the motor.

Parameters
dutyCycleNormalized duty cycle in [-1, 1].

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetEncoderInverted()

virtual void yams::motorcontrollers::SmartMotorController::SetEncoderInverted ( bool  inverted)
pure virtual

◆ SetEncoderPosition() [1/2]

virtual void yams::motorcontrollers::SmartMotorController::SetEncoderPosition ( wpi::units::meter_t  distance)
pure virtual

Write a linear distance into the encoder (seeds the position).

Parameters
distanceLinear distance to write.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetEncoderPosition() [2/2]

virtual void yams::motorcontrollers::SmartMotorController::SetEncoderPosition ( wpi::units::turn_t  angle)
pure virtual

Write a mechanism angle into the encoder (seeds the position).

Parameters
angleMechanism angle to write.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetEncoderVelocity() [1/2]

virtual void yams::motorcontrollers::SmartMotorController::SetEncoderVelocity ( wpi::units::meters_per_second_t  velocity)
pure virtual

◆ SetEncoderVelocity() [2/2]

virtual void yams::motorcontrollers::SmartMotorController::SetEncoderVelocity ( wpi::units::turns_per_second_t  velocity)
pure virtual

Write a mechanism angular velocity into the encoder.

Parameters
velocityAngular velocity to write.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetExponentialProfile()

virtual void yams::motorcontrollers::SmartMotorController::SetExponentialProfile ( std::optional< double >  kV,
std::optional< double >  kA,
std::optional< wpi::units::volt_t >  maxInput 
)
pure virtual

Configure or update the exponential motion profile parameters.

Parameters
kVOptional velocity constant (empty keeps the current value).
kAOptional acceleration constant (empty keeps the current value).
maxInputOptional 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.

◆ SetFeedback()

virtual void yams::motorcontrollers::SmartMotorController::SetFeedback ( double  kP,
double  kI,
double  kD 
)
pure virtual

Set all three PID feedback gains at once (live update).

Parameters
kPProportional gain.
kIIntegral gain.
kDDerivative gain.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetFeedforward()

virtual void yams::motorcontrollers::SmartMotorController::SetFeedforward ( double  kS,
double  kV,
double  kA,
double  kG 
)
pure virtual

Set all four feedforward gains at once (live update).

Parameters
kSStatic friction voltage.
kVVelocity feedforward coefficient.
kAAcceleration feedforward coefficient.
kGGravity feedforward coefficient.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetKa()

virtual void yams::motorcontrollers::SmartMotorController::SetKa ( double  kA)
pure virtual

Set the acceleration feedforward coefficient (live update).

Parameters
kAAcceleration feedforward coefficient.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetKd()

virtual void yams::motorcontrollers::SmartMotorController::SetKd ( double  kD)
pure virtual

◆ SetKg()

virtual void yams::motorcontrollers::SmartMotorController::SetKg ( double  kG)
pure virtual

Set the gravity feedforward coefficient (live update).

Parameters
kGGravity feedforward coefficient.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetKi()

virtual void yams::motorcontrollers::SmartMotorController::SetKi ( double  kI)
pure virtual

◆ SetKp()

virtual void yams::motorcontrollers::SmartMotorController::SetKp ( double  kP)
pure virtual

◆ SetKs()

virtual void yams::motorcontrollers::SmartMotorController::SetKs ( double  kS)
pure virtual

◆ SetKv()

virtual void yams::motorcontrollers::SmartMotorController::SetKv ( double  kV)
pure virtual

Set the velocity feedforward coefficient (live update).

Parameters
kVVelocity feedforward coefficient.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMeasurementLowerLimit()

virtual void yams::motorcontrollers::SmartMotorController::SetMeasurementLowerLimit ( wpi::units::meter_t  lowerLimit)
pure virtual

Set the lower linear soft limit for the measurement.

Parameters
lowerLimitLower distance limit.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMeasurementUpperLimit()

virtual void yams::motorcontrollers::SmartMotorController::SetMeasurementUpperLimit ( wpi::units::meter_t  upperLimit)
pure virtual

Set the upper linear soft limit for the measurement.

Parameters
upperLimitUpper distance limit.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMechanismCircumference()

virtual void yams::motorcontrollers::SmartMotorController::SetMechanismCircumference ( wpi::units::meter_t  circumference)
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.

Parameters
circumferenceNew mechanism circumference.

Reimplemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMechanismGearing()

virtual void yams::motorcontrollers::SmartMotorController::SetMechanismGearing ( const gearing::MechanismGearing &  gearing)
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.

Parameters
gearingNew mechanism gearing.

Reimplemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMechanismLimits()

virtual void yams::motorcontrollers::SmartMotorController::SetMechanismLimits ( wpi::units::turn_t  lower,
wpi::units::turn_t  upper 
)
pure virtual

Set both angular soft limits for the mechanism.

Parameters
lowerLower angle limit.
upperUpper angle limit.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMechanismLimitsEnabled()

virtual void yams::motorcontrollers::SmartMotorController::SetMechanismLimitsEnabled ( bool  enabled)
pure virtual

Enable or disable the mechanism angular soft limits.

Parameters
enabledtrue to enforce the limits.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMechanismLowerLimit()

virtual void yams::motorcontrollers::SmartMotorController::SetMechanismLowerLimit ( wpi::units::turn_t  lowerLimit)
pure virtual

Set the lower angular soft limit for the mechanism.

Parameters
lowerLimitLower angle limit.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMechanismUpperLimit()

virtual void yams::motorcontrollers::SmartMotorController::SetMechanismUpperLimit ( wpi::units::turn_t  upperLimit)
pure virtual

Set the upper angular soft limit for the mechanism.

Parameters
upperLimitUpper angle limit.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMotionProfileMaxAcceleration() [1/2]

virtual void yams::motorcontrollers::SmartMotorController::SetMotionProfileMaxAcceleration ( wpi::units::meters_per_second_squared_t  maxAcc)
pure virtual

Set the maximum linear acceleration for the motion profile.

Parameters
maxAccMaximum linear acceleration.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMotionProfileMaxAcceleration() [2/2]

virtual void yams::motorcontrollers::SmartMotorController::SetMotionProfileMaxAcceleration ( wpi::units::turns_per_second_squared_t  maxAcc)
pure virtual

Set the maximum angular acceleration for the motion profile.

Parameters
maxAccMaximum mechanism angular acceleration.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMotionProfileMaxJerk()

virtual void yams::motorcontrollers::SmartMotorController::SetMotionProfileMaxJerk ( wpi::units::angular_jerk::turns_per_second_cubed_t  maxJerk)
pure virtual

Set the maximum angular jerk for the motion profile.

Parameters
maxJerkMaximum angular jerk (degrees/s²/s).

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMotionProfileMaxVelocity() [1/2]

virtual void yams::motorcontrollers::SmartMotorController::SetMotionProfileMaxVelocity ( wpi::units::meters_per_second_t  maxVelocity)
pure virtual

Set the maximum linear velocity for the motion profile.

Parameters
maxVelocityMaximum linear velocity.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMotionProfileMaxVelocity() [2/2]

virtual void yams::motorcontrollers::SmartMotorController::SetMotionProfileMaxVelocity ( wpi::units::turns_per_second_t  maxVelocity)
pure virtual

Set the maximum angular velocity for the motion profile.

Parameters
maxVelocityMaximum mechanism angular velocity.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetMotorInverted()

virtual void yams::motorcontrollers::SmartMotorController::SetMotorInverted ( bool  inverted)
pure virtual

◆ SetOpenLoopRampRate()

virtual void yams::motorcontrollers::SmartMotorController::SetOpenLoopRampRate ( wpi::units::second_t  rampRate)
pure virtual

Set the open-loop output ramp rate.

Parameters
rampRateTime 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.

◆ SetPosition() [1/2]

virtual void yams::motorcontrollers::SmartMotorController::SetPosition ( wpi::units::meter_t  distance)
pure virtual

Command a linear measurement position setpoint (closed-loop).

Parameters
distanceTarget linear distance.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetPosition() [2/2]

virtual void yams::motorcontrollers::SmartMotorController::SetPosition ( wpi::units::turn_t  angle)
pure virtual

Command a mechanism angle position setpoint (closed-loop).

Parameters
angleTarget mechanism angle.

Implemented in yams::motorcontrollers::local::NovaWrapper, yams::motorcontrollers::local::SparkWrapper, yams::motorcontrollers::remote::TalonFXSWrapper, and yams::motorcontrollers::remote::TalonFXWrapper.

◆ SetSimSupplier()

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.

Parameters
supplierShared SimSupplier instance, or nullptr to detach.

◆ SetStatorCurrentLimit()

virtual void yams::motorcontrollers::SmartMotorController::SetStatorCurrentLimit ( wpi::units::ampere_t  currentLimit)
pure virtual

◆ SetSupplyCurrentLimit()

virtual void yams::motorcontrollers::SmartMotorController::SetSupplyCurrentLimit ( wpi::units::ampere_t  currentLimit)
pure virtual

◆ SetupLiveTuning()

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.

◆ SetupSimulation()

virtual void yams::motorcontrollers::SmartMotorController::SetupSimulation ( )
pure virtual

◆ SetupTelemetry() [1/2]

void yams::motorcontrollers::SmartMotorController::SetupTelemetry ( )

Set up NetworkTables telemetry using the name configured in the SmartMotorControllerConfig.

◆ SetupTelemetry() [2/2]

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.

Parameters
dataTableTable for sensor and state data.
tuningTableTable for live gain tuning entries.

◆ SetVelocity() [1/4]

virtual void yams::motorcontrollers::SmartMotorController::SetVelocity ( wpi::units::meters_per_second_t  velocity)
pure virtual

◆ SetVelocity() [2/4]

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.

Parameters
velocityTarget linear velocity.
feedforwardForceAdditional feedforward force at the mechanism.

◆ SetVelocity() [3/4]

virtual void yams::motorcontrollers::SmartMotorController::SetVelocity ( wpi::units::turns_per_second_t  velocity)
pure virtual

◆ SetVelocity() [4/4]

virtual void yams::motorcontrollers::SmartMotorController::SetVelocity ( wpi::units::turns_per_second_t  velocity,
wpi::units::newton_t  feedforwardForce 
)
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.

Parameters
velocityTarget mechanism angular velocity.
feedforwardForceAdditional 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.

◆ SetVoltage()

virtual void yams::motorcontrollers::SmartMotorController::SetVoltage ( wpi::units::volt_t  voltage)
pure virtual

◆ SetZeroPower()

virtual void yams::motorcontrollers::SmartMotorController::SetZeroPower ( MotorMode  mode)
pure virtual

◆ SimIterate()

virtual void yams::motorcontrollers::SmartMotorController::SimIterate ( )
pure virtual

◆ StartClosedLoopController()

void yams::motorcontrollers::SmartMotorController::StartClosedLoopController ( )

Start the background closed-loop controller thread, and the loosely coupled followers'.

◆ StopClosedLoopController()

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.

◆ StopLiveTuning()

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.

◆ SynchronizeRelativeEncoder()

virtual void yams::motorcontrollers::SmartMotorController::SynchronizeRelativeEncoder ( )
pure virtual

◆ TuningEnabled()

bool yams::motorcontrollers::SmartMotorController::TuningEnabled ( ) const

Whether live tuning is enabled, i.e. whether tunable setpoints are published.

Returns
true if live tuning is enabled.

◆ UpdateTelemetry()

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()).

◆ WithTelemetry()

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.

Parameters
configSmartMotorControllerTelemetryConfig to apply.
Returns
*this for chaining.

Member Data Documentation

◆ m_closed

bool yams::motorcontrollers::SmartMotorController::m_closed {false}
protected

◆ m_closedLoopControllerRunning

bool yams::motorcontrollers::SmartMotorController::m_closedLoopControllerRunning {false}
protected

◆ m_closedLoopControllerThread

std::unique_ptr<wpi::Notifier> yams::motorcontrollers::SmartMotorController::m_closedLoopControllerThread
protected

◆ m_closeHooks

std::vector<std::function<void()> > yams::motorcontrollers::SmartMotorController::m_closeHooks
protected

Hooks run once by Close().

◆ m_config

SmartMotorControllerConfig* yams::motorcontrollers::SmartMotorController::m_config {nullptr}
protected

Config used by this controller (owned by the caller; set by the wrapper constructor before anything else uses it).

◆ m_expoState

std::optional<wpi::math::ExponentialProfile<wpi::units::turns, wpi::units::volts>::State> yams::motorcontrollers::SmartMotorController::m_expoState
protected

◆ m_lastClosedLoopMechanismPosition

std::optional<wpi::units::turn_t> yams::motorcontrollers::SmartMotorController::m_lastClosedLoopMechanismPosition
protected

Mechanism position the closed-loop controller last used, unwrapped across the continuous wrapping point.

◆ m_linearExpoState

std::optional<wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>::State> yams::motorcontrollers::SmartMotorController::m_linearExpoState
protected

◆ m_linearTrapState

std::optional<wpi::math::TrapezoidProfile<wpi::units::meters>::State> yams::motorcontrollers::SmartMotorController::m_linearTrapState
protected

◆ m_liveTuningRegistered

bool yams::motorcontrollers::SmartMotorController::m_liveTuningRegistered {false}
protected

◆ m_looseFollowers

std::vector<SmartMotorController*> yams::motorcontrollers::SmartMotorController::m_looseFollowers
protected

Loosely coupled followers populated by LoadLooselyCoupledFollowers().

◆ m_lqr

std::optional<math::LQRController> yams::motorcontrollers::SmartMotorController::m_lqr
protected

◆ m_parentTable

std::shared_ptr<wpi::nt::NetworkTable> yams::motorcontrollers::SmartMotorController::m_parentTable
protected

◆ m_pid

std::optional<wpi::math::PIDController> yams::motorcontrollers::SmartMotorController::m_pid
protected

◆ m_setpointFeedforwardForce

std::optional<wpi::units::newton_t> yams::motorcontrollers::SmartMotorController::m_setpointFeedforwardForce
protected

Feedforward force applied on top of the velocity setpoint (see SetVelocity(vel, force)).

◆ m_setpointPosition

std::optional<wpi::units::turn_t> yams::motorcontrollers::SmartMotorController::m_setpointPosition
protected

◆ m_setpointVelocity

std::optional<wpi::units::turns_per_second_t> yams::motorcontrollers::SmartMotorController::m_setpointVelocity
protected

◆ m_simSupplier

std::shared_ptr<SimSupplier> yams::motorcontrollers::SmartMotorController::m_simSupplier
protected

◆ m_slot

ClosedLoopControllerSlot yams::motorcontrollers::SmartMotorController::m_slot {ClosedLoopControllerSlot::SLOT_0}
protected

◆ m_specifiedTelemetryConfig

std::shared_ptr<telemetry::SmartMotorControllerTelemetryConfig> yams::motorcontrollers::SmartMotorController::m_specifiedTelemetryConfig
protected

Telemetry config given to SmartMotorControllerConfig::WithTelemetry(name, config), if any.

◆ m_telemetry

telemetry::SmartMotorControllerTelemetry yams::motorcontrollers::SmartMotorController::m_telemetry
protected

◆ m_telemetryConfig

telemetry::SmartMotorControllerTelemetryConfig yams::motorcontrollers::SmartMotorController::m_telemetryConfig
protected

◆ m_telemetryConfigExplicit

bool yams::motorcontrollers::SmartMotorController::m_telemetryConfigExplicit {false}
protected

◆ m_telemetryTable

std::shared_ptr<wpi::nt::NetworkTable> yams::motorcontrollers::SmartMotorController::m_telemetryTable
protected

◆ m_trapState

std::optional<wpi::math::TrapezoidProfile<wpi::units::turns>::State> yams::motorcontrollers::SmartMotorController::m_trapState
protected

◆ m_tuningTable

std::shared_ptr<wpi::nt::NetworkTable> yams::motorcontrollers::SmartMotorController::m_tuningTable
protected

The documentation for this class was generated from the following file: