YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
yams::motorcontrollers::remote::TalonFXSWrapper Class Reference

#include <TalonFXSWrapper.hpp>

Inheritance diagram for yams::motorcontrollers::remote::TalonFXSWrapper:
Inheritance graph
[legend]
Collaboration diagram for yams::motorcontrollers::remote::TalonFXSWrapper:
Collaboration graph
[legend]

Public Types

enum class  MotorArrangement {
  Minion , NEO , NEO550 , NEOVortex ,
  Brushed_2Wire , Brushed_3Wire
}
 
- Public Types inherited from yams::motorcontrollers::SmartMotorController
using ClosedLoopControllerSlot = SmartMotorControllerConfig::ClosedLoopControllerSlot
 
using MotorMode = SmartMotorControllerConfig::MotorMode
 
using ControlMode = SmartMotorControllerConfig::ControlMode
 

Public Member Functions

 TalonFXSWrapper (ctre::phoenix6::hardware::TalonFXS *talon, wpi::math::DCMotor dcMotor, SmartMotorControllerConfig *config)
 
 TalonFXSWrapper (ctre::phoenix6::hardware::TalonFXS *talon, wpi::math::DCMotor dcMotor, MotorArrangement arrangement, SmartMotorControllerConfig *config)
 
 ~TalonFXSWrapper ()
 
TalonFXSWrapper & EnableFOC ()
 
TalonFXSWrapper & DisableFOC ()
 
bool UseCANdiPWM1 () const
 
bool UseCANdiPWM2 () const
 
void SetUpdateFrequency (wpi::units::hertz_t frequency)
 
ctre::phoenix::StatusCode ForceConfigApply ()
 
telemetry::UnsupportedTelemetryFields GetUnsupportedTelemetryFields () override
 
bool ApplyConfig (const SmartMotorControllerConfig &config) override
 
void SetupSimulation () override
 
void SimIterate () override
 
void SeedRelativeEncoder () override
 
void SynchronizeRelativeEncoder () override
 
void SetDutyCycle (double dutyCycle) override
 
double GetDutyCycle () override
 
void SetVoltage (wpi::units::volt_t voltage) override
 
wpi::units::volt_t GetVoltage () override
 
std::optional< wpi::units::second_t > GetVelocityMeasurementDelay () const override
 
void SetPosition (wpi::units::turn_t angle) override
 
void SetPosition (wpi::units::meter_t distance) override
 
void SetVelocity (wpi::units::turns_per_second_t velocity) override
 
void SetVelocity (wpi::units::meters_per_second_t velocity) override
 
void SetVelocity (wpi::units::turns_per_second_t velocity, wpi::units::newton_t feedforwardForce) override
 
void SetEncoderPosition (wpi::units::turn_t angle) override
 
void SetEncoderPosition (wpi::units::meter_t distance) override
 
void SetEncoderVelocity (wpi::units::turns_per_second_t velocity) override
 
void SetEncoderVelocity (wpi::units::meters_per_second_t velocity) override
 
wpi::units::turn_t GetMechanismPosition () override
 
wpi::units::turns_per_second_t GetMechanismVelocity () override
 
wpi::units::turn_t GetRelativeMechanismPosition () override
 
wpi::units::turns_per_second_t GetRelativeMechanismVelocity () override
 
wpi::units::turns_per_second_squared_t GetMechanismAcceleration () override
 
wpi::units::turn_t GetRotorPosition () override
 
wpi::units::turns_per_second_t GetRotorVelocity () override
 
wpi::units::meter_t GetMeasurementPosition () override
 
wpi::units::meters_per_second_t GetMeasurementVelocity () override
 
wpi::units::meters_per_second_squared_t GetMeasurementAcceleration () override
 
std::optional< wpi::units::turn_t > GetExternalEncoderMechanismPosition () override
 
std::optional< wpi::units::turns_per_second_t > GetExternalEncoderMechanismVelocity () override
 
std::optional< wpi::units::ampere_t > GetSupplyCurrent () override
 
wpi::units::ampere_t GetStatorCurrent () override
 
wpi::units::celsius_t GetTemperature () override
 
wpi::math::DCMotor GetDCMotor () override
 
void SetZeroPower (MotorMode mode) override
 
void SetMotorInverted (bool inverted) override
 
void SetEncoderInverted (bool inverted) override
 
void SetKp (double kP) override
 
void SetKi (double kI) override
 
void SetKd (double kD) override
 
void SetFeedback (double kP, double kI, double kD) override
 
void SetKs (double kS) override
 
void SetKv (double kV) override
 
void SetKa (double kA) override
 
void SetKg (double kG) override
 
void SetFeedforward (double kS, double kV, double kA, double kG) override
 
void SetStatorCurrentLimit (wpi::units::ampere_t currentLimit) override
 
void SetSupplyCurrentLimit (wpi::units::ampere_t currentLimit) override
 
void SetClosedLoopRampRate (wpi::units::second_t rampRate) override
 
void SetOpenLoopRampRate (wpi::units::second_t rampRate) override
 
void SetMechanismUpperLimit (wpi::units::turn_t upperLimit) override
 
void SetMechanismLowerLimit (wpi::units::turn_t lowerLimit) override
 
void SetMechanismLimits (wpi::units::turn_t lower, wpi::units::turn_t upper) override
 
void SetMechanismLimitsEnabled (bool enabled) override
 
void SetMeasurementUpperLimit (wpi::units::meter_t upperLimit) override
 
void SetMeasurementLowerLimit (wpi::units::meter_t lowerLimit) override
 
void SetMotionProfileMaxVelocity (wpi::units::turns_per_second_t maxVelocity) override
 
void SetMotionProfileMaxVelocity (wpi::units::meters_per_second_t maxVelocity) override
 
void SetMotionProfileMaxAcceleration (wpi::units::turns_per_second_squared_t maxAcc) override
 
void SetMotionProfileMaxAcceleration (wpi::units::meters_per_second_squared_t maxAcc) override
 
void SetMotionProfileMaxJerk (wpi::units::angular_jerk::turns_per_second_cubed_t maxJerk) override
 
void SetExponentialProfile (std::optional< double > kV, std::optional< double > kA, std::optional< wpi::units::volt_t > maxInput) override
 
void SetClosedLoopSlot (ClosedLoopControllerSlot slot) override
 
void SetMechanismGearing (const gearing::MechanismGearing &gearing) override
 
void SetMechanismCircumference (wpi::units::meter_t circumference) override
 
SmartMotorControllerConfig & GetConfig () override
 
void * GetMotorController () override
 
void * GetMotorControllerConfig () override
 
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)
 
- Public Member Functions inherited from yams::motorcontrollers::SmartMotorController
virtual ~SmartMotorController ()
 
void SetSimSupplier (std::shared_ptr< SimSupplier > supplier)
 
SimSupplier * GetSimSupplier () const
 
void SetVelocity (wpi::units::meters_per_second_t velocity, wpi::units::newton_t feedforwardForce)
 
wpi::units::second_t GetClosedLoopControllerPeriod () 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)
 
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
 
std::string GetName () const
 
bool IsMotor (const wpi::math::DCMotor &a, const wpi::math::DCMotor &b) const
 
void CheckConfigSafety ()
 
void Close ()
 

Additional Inherited Members

- Protected Member Functions inherited from yams::motorcontrollers::SmartMotorController
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 inherited from yams::motorcontrollers::SmartMotorController
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

SmartMotorController implementation for the CTRE TalonFXS motor controller (Phoenix 6).

The TalonFXS supports third-party brushed and brushless motors (e.g. REV NEO, Minion). Wraps a TalonFXS hardware object and exposes the full SmartMotorController interface including MotionMagic profiles, CANcoder/CANdi synchronization, and simulation support.

Example usage (inside a subsystem constructor)

using namespace yams::motorcontrollers;
using namespace yams::gearing;
// Declare as subsystem members:
// ctre::phoenix6::hardware::TalonFXS m_talonFXS{2};
// std::optional<TalonFXSWrapper> m_smc;
cfg.WithSubsystem(this)
.WithFeedback(4.0, 0.0, 0.0)
.WithTrapezoidProfile(wpi::units::turns_per_second_t{0.5},
wpi::units::turns_per_second_squared_t{0.25})
.WithMotorGearing(MechanismGearing{GearBox::FromReductionStages({3.0, 4.0})})
.WithZeroPower(Cfg::MotorMode::BRAKE)
.WithFeedforward(wpi::math::ArmFeedforward{
0.0_V, 0.0_V, wpi::units::unit_t<wpi::math::ArmFeedforward::kv_unit>{0.0},
wpi::units::unit_t<wpi::math::ArmFeedforward::ka_unit>{0.0}})
.WithClosedLoopMode()
.WithTelemetry("HoodMotor", Cfg::TelemetryVerbosity::HIGH);
m_smc.emplace(&m_talonFXS, DCMotor::NEO(1), MotorArrangement::NEO, &cfg);
Definition MechanismGearing.hpp:19
Definition SmartMotorControllerConfig.hpp:65
SmartMotorControllerConfig & WithTelemetry(const std::string &name, TelemetryVerbosity verbosity=TelemetryVerbosity::HIGH)
SmartMotorControllerConfig & WithTrapezoidProfile(wpi::units::turns_per_second_t maxVelocity, wpi::units::turns_per_second_squared_t maxAcceleration)
SmartMotorControllerConfig & WithMotorInverted(bool inverted)
SmartMotorControllerConfig & WithSubsystem(wpi::cmd::SubsystemBase *subsystem)
SmartMotorControllerConfig & WithFeedforward(const wpi::math::ArmFeedforward &ff, ClosedLoopControllerSlot slot=ClosedLoopControllerSlot::SLOT_0)
SmartMotorControllerConfig & WithFeedback(double kP, double kI, double kD, ClosedLoopControllerSlot slot=ClosedLoopControllerSlot::SLOT_0)
SmartMotorControllerConfig & WithStatorCurrentLimit(wpi::units::ampere_t limit)
Definition GearBox.hpp:11
Definition TalonFXSWrapper.hpp:38
Definition SimSensorConfig.hpp:15

Member Enumeration Documentation

◆ MotorArrangement

Motor type attached to the TalonFXS external motor port.

Enumerator
Minion 
NEO 
NEO550 
NEOVortex 
Brushed_2Wire 
Brushed_3Wire 

Constructor & Destructor Documentation

◆ TalonFXSWrapper() [1/2]

yams::motorcontrollers::remote::TalonFXSWrapper::TalonFXSWrapper ( ctre::phoenix6::hardware::TalonFXS *  talon,
wpi::math::DCMotor  dcMotor,
SmartMotorControllerConfig *  config 
)

Construct a TalonFXSWrapper for a brushless motor recognised from dcMotor (Minion, NEO, NEO 550 or NEO Vortex); throws std::invalid_argument for other motors.

Parameters
talonTalonFXS hardware object (must outlive this wrapper).
dcMotorDC motor model; selects the motor arrangement and is used for simulation.
configInitial SmartMotorControllerConfig to apply.

◆ TalonFXSWrapper() [2/2]

yams::motorcontrollers::remote::TalonFXSWrapper::TalonFXSWrapper ( ctre::phoenix6::hardware::TalonFXS *  talon,
wpi::math::DCMotor  dcMotor,
MotorArrangement  arrangement,
SmartMotorControllerConfig *  config 
)

Construct a TalonFXSWrapper.

The arrangement sets the TalonFXS commutation (MotorArrangement, and advanced hall support for a Minion). Throws SmartMotorControllerConfigurationException (or std::invalid_argument) if ApplyConfig() rejects the config; anything already started is released first.

Parameters
talonTalonFXS hardware object (must outlive this wrapper).
dcMotorDC motor model used for simulation.
arrangementMotor type connected to the TalonFXS.
configInitial SmartMotorControllerConfig to apply.

◆ ~TalonFXSWrapper()

yams::motorcontrollers::remote::TalonFXSWrapper::~TalonFXSWrapper ( )

Calls Close() and releases the alerts.

Member Function Documentation

◆ ApplyConfig()

bool yams::motorcontrollers::remote::TalonFXSWrapper::ApplyConfig ( const SmartMotorControllerConfig &  config)
overridevirtual

Apply a SmartMotorControllerConfig to the underlying hardware.

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

Implements yams::motorcontrollers::SmartMotorController.

◆ DisableFOC()

TalonFXSWrapper & yams::motorcontrollers::remote::TalonFXSWrapper::DisableFOC ( )

Disable FOC for the position and velocity control requests.

Throws SmartMotorControllerConfigurationException if a request is a TorqueCurrentFOC request.

Returns
*this for chaining.

◆ EnableFOC()

TalonFXSWrapper & yams::motorcontrollers::remote::TalonFXSWrapper::EnableFOC ( )

Enable FOC for the position and velocity control requests; ignored by unlicensed devices.

Throws SmartMotorControllerConfigurationException if a request is a TorqueCurrentFOC request (set through WithVendorControlRequest), which cannot toggle FOC.

Returns
*this for chaining.

◆ ForceConfigApply()

ctre::phoenix::StatusCode yams::motorcontrollers::remote::TalonFXSWrapper::ForceConfigApply ( )

Apply the whole TalonFXS configuration, retrying every 10 ms up to 10 times.

Returns
Status of the last attempt.

◆ GetConfig()

SmartMotorControllerConfig & yams::motorcontrollers::remote::TalonFXSWrapper::GetConfig ( )
overridevirtual

Get a mutable reference to the current configuration.

Returns
Reference to the SmartMotorControllerConfig.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetDCMotor()

wpi::math::DCMotor yams::motorcontrollers::remote::TalonFXSWrapper::GetDCMotor ( )
overridevirtual

Get the DC motor model associated with this controller.

Returns
wpi::math::DCMotor model.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetDutyCycle()

double yams::motorcontrollers::remote::TalonFXSWrapper::GetDutyCycle ( )
overridevirtual

Get the current motor duty cycle.

Returns
Duty cycle in [-1, 1].

Implements yams::motorcontrollers::SmartMotorController.

◆ GetExternalEncoderMechanismPosition()

std::optional< wpi::units::turn_t > yams::motorcontrollers::remote::TalonFXSWrapper::GetExternalEncoderMechanismPosition ( )
overridevirtual

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.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetExternalEncoderMechanismVelocity()

std::optional< wpi::units::turns_per_second_t > yams::motorcontrollers::remote::TalonFXSWrapper::GetExternalEncoderMechanismVelocity ( )
overridevirtual

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.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMeasurementAcceleration()

wpi::units::meters_per_second_squared_t yams::motorcontrollers::remote::TalonFXSWrapper::GetMeasurementAcceleration ( )
overridevirtual

Get the linear measurement acceleration.

Returns
Linear acceleration in meters per second squared.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMeasurementPosition()

wpi::units::meter_t yams::motorcontrollers::remote::TalonFXSWrapper::GetMeasurementPosition ( )
overridevirtual

Get the linear measurement position (applies circumference conversion).

Returns
Linear position in meters.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMeasurementVelocity()

wpi::units::meters_per_second_t yams::motorcontrollers::remote::TalonFXSWrapper::GetMeasurementVelocity ( )
overridevirtual

Get the linear measurement velocity (applies circumference conversion).

Returns
Linear velocity in meters per second.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMechanismAcceleration()

wpi::units::turns_per_second_squared_t yams::motorcontrollers::remote::TalonFXSWrapper::GetMechanismAcceleration ( )
overridevirtual

Get the mechanism acceleration (derived from velocity).

Returns
Mechanism acceleration in turns per second squared.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMechanismPosition()

wpi::units::turn_t yams::motorcontrollers::remote::TalonFXSWrapper::GetMechanismPosition ( )
overridevirtual

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.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMechanismVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::remote::TalonFXSWrapper::GetMechanismVelocity ( )
overridevirtual

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.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMotorController()

void * yams::motorcontrollers::remote::TalonFXSWrapper::GetMotorController ( )
overridevirtual

Get a raw pointer to the underlying TalonFXS hardware object.

Returns
Pointer to the ctre::phoenix6::hardware::TalonFXS instance.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMotorControllerConfig()

void * yams::motorcontrollers::remote::TalonFXSWrapper::GetMotorControllerConfig ( )
overridevirtual

Get a raw pointer to the TalonFXSConfiguration used by this wrapper.

Returns
Pointer to the ctre::phoenix6::configs::TalonFXSConfiguration instance.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRelativeMechanismPosition()

wpi::units::turn_t yams::motorcontrollers::remote::TalonFXSWrapper::GetRelativeMechanismPosition ( )
overridevirtual

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.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRelativeMechanismVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::remote::TalonFXSWrapper::GetRelativeMechanismVelocity ( )
overridevirtual

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.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRotorPosition()

wpi::units::turn_t yams::motorcontrollers::remote::TalonFXSWrapper::GetRotorPosition ( )
overridevirtual

Get the raw rotor position (no gearing applied).

Returns
Rotor position in turns.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRotorVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::remote::TalonFXSWrapper::GetRotorVelocity ( )
overridevirtual

Get the raw rotor velocity (no gearing applied).

Returns
Rotor velocity in turns per second.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetStatorCurrent()

wpi::units::ampere_t yams::motorcontrollers::remote::TalonFXSWrapper::GetStatorCurrent ( )
overridevirtual

Get the stator (output) current draw.

Returns
Stator current.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetSupplyCurrent()

std::optional< wpi::units::ampere_t > yams::motorcontrollers::remote::TalonFXSWrapper::GetSupplyCurrent ( )
overridevirtual

Get the supply (input) current draw.

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

Implements yams::motorcontrollers::SmartMotorController.

◆ GetTemperature()

wpi::units::celsius_t yams::motorcontrollers::remote::TalonFXSWrapper::GetTemperature ( )
overridevirtual

Get the motor controller temperature.

Returns
Temperature in degrees Celsius.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetUnsupportedTelemetryFields()

telemetry::UnsupportedTelemetryFields yams::motorcontrollers::remote::TalonFXSWrapper::GetUnsupportedTelemetryFields ( )
overridevirtual

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 from yams::motorcontrollers::SmartMotorController.

◆ GetVelocityMeasurementDelay()

std::optional< wpi::units::second_t > yams::motorcontrollers::remote::TalonFXSWrapper::GetVelocityMeasurementDelay ( ) const
overridevirtual

Phoenix 6 filters velocity with a Kalman filter tuned for the least latency, about 1 ms, as WPILib's SysId takes it for its CTRE Phoenix 6 preset. A closed loop run on the SystemCore reads the velocity from its status signal instead, which on average is half the signal's update period older. Phoenix 6 simulates the Talon in its own thread with the same filtering, so the delay is the same in simulation.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ GetVoltage()

wpi::units::volt_t yams::motorcontrollers::remote::TalonFXSWrapper::GetVoltage ( )
overridevirtual

Get the voltage currently applied to the motor.

Returns
Applied voltage.

Implements yams::motorcontrollers::SmartMotorController.

◆ SeedRelativeEncoder()

void yams::motorcontrollers::remote::TalonFXSWrapper::SeedRelativeEncoder ( )
overridevirtual

TalonFXS uses an absolute sensor internally; has no effect.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetClosedLoopRampRate()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetClosedLoopRampRate ( wpi::units::second_t  rampRate)
overridevirtual

Set the closed-loop output ramp rate.

Parameters
rampRateTime to ramp from 0 to full output.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetClosedLoopSlot()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetClosedLoopSlot ( ClosedLoopControllerSlot  slot)
overridevirtual

Select the active closed-loop gain slot and forward it to loosely coupled followers. TalonFXS supports 3 slots (SLOT_0 through SLOT_2); throws std::invalid_argument for SLOT_3.

Parameters
slotGain slot to activate.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetDutyCycle()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetDutyCycle ( double  dutyCycle)
overridevirtual

Command a duty-cycle output to the motor.

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

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderInverted()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetEncoderInverted ( bool  inverted)
overridevirtual

Set the external feedback sensor phase (SensorPhase Opposed when inverted).

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderPosition() [1/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetEncoderPosition ( wpi::units::meter_t  distance)
overridevirtual

Write a linear distance into the encoder (seeds the position). Converts distance to turns using the configured mechanism circumference.

Parameters
distanceLinear distance to write.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderPosition() [2/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetEncoderPosition ( wpi::units::turn_t  angle)
overridevirtual

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

Parameters
angleMechanism angle to write.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderVelocity() [1/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetEncoderVelocity ( wpi::units::meters_per_second_t  velocity)
overridevirtual

Not applicable to TalonFXS; has no effect.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderVelocity() [2/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetEncoderVelocity ( wpi::units::turns_per_second_t  velocity)
overridevirtual

Not applicable to TalonFXS; has no effect.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetExponentialProfile()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetExponentialProfile ( std::optional< double >  kV,
std::optional< double >  kA,
std::optional< wpi::units::volt_t >  maxInput 
)
overridevirtual

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

Implements yams::motorcontrollers::SmartMotorController.

◆ SetFeedback()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetFeedback ( double  kP,
double  kI,
double  kD 
)
overridevirtual

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

Parameters
kPProportional gain.
kIIntegral gain.
kDDerivative gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetFeedforward()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetFeedforward ( double  kS,
double  kV,
double  kA,
double  kG 
)
overridevirtual

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

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

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKa()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKa ( double  kA)
overridevirtual

Set the acceleration feedforward coefficient (live update).

Parameters
kAAcceleration feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKd()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKd ( double  kD)
overridevirtual

Set the derivative gain (live update).

Parameters
kDDerivative gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKg()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKg ( double  kG)
overridevirtual

Set the gravity feedforward coefficient (live update).

Parameters
kGGravity feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKi()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKi ( double  kI)
overridevirtual

Set the integral gain (live update).

Parameters
kIIntegral gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKp()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKp ( double  kP)
overridevirtual

Set the proportional gain (live update).

Parameters
kPProportional gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKs()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKs ( double  kS)
overridevirtual

Set the static friction feedforward (live update).

Parameters
kSStatic friction voltage.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKv()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetKv ( double  kV)
overridevirtual

Set the velocity feedforward coefficient (live update).

Parameters
kVVelocity feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMeasurementLowerLimit()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMeasurementLowerLimit ( wpi::units::meter_t  lowerLimit)
overridevirtual

Set the lower linear soft limit for the measurement. Converts the lower limit to turns using the configured mechanism circumference.

Parameters
lowerLimitLower distance limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMeasurementUpperLimit()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMeasurementUpperLimit ( wpi::units::meter_t  upperLimit)
overridevirtual

Set the upper linear soft limit for the measurement. Converts the upper limit to turns using the configured mechanism circumference.

Parameters
upperLimitUpper distance limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismCircumference()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMechanismCircumference ( wpi::units::meter_t  circumference)
overridevirtual

Update the mechanism circumference, rewrite the values converted with it (linear gains and motion profile constraints) and forward it to loosely coupled followers.

Parameters
circumferenceNew mechanism circumference.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetMechanismGearing()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMechanismGearing ( const gearing::MechanismGearing &  gearing)
overridevirtual

Update the mechanism gearing and the TalonFXS sensor ratios that depend on it.

Parameters
gearingNew mechanism gearing.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetMechanismLimits()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMechanismLimits ( wpi::units::turn_t  lower,
wpi::units::turn_t  upper 
)
overridevirtual

Set both angular soft limits for the mechanism.

Parameters
lowerLower angle limit.
upperUpper angle limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismLimitsEnabled()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMechanismLimitsEnabled ( bool  enabled)
overridevirtual

Enable or disable the mechanism angular soft limits.

Parameters
enabledtrue to enforce the limits.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismLowerLimit()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMechanismLowerLimit ( wpi::units::turn_t  lowerLimit)
overridevirtual

Set the lower angular soft limit for the mechanism.

Parameters
lowerLimitLower angle limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismUpperLimit()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMechanismUpperLimit ( wpi::units::turn_t  upperLimit)
overridevirtual

Set the upper angular soft limit for the mechanism.

Parameters
upperLimitUpper angle limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxAcceleration() [1/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMotionProfileMaxAcceleration ( wpi::units::meters_per_second_squared_t  maxAcc)
overridevirtual

Set the maximum linear acceleration for the motion profile. Converts linear acceleration to turns per second squared using the configured mechanism circumference.

Parameters
maxAccMaximum linear acceleration.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxAcceleration() [2/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMotionProfileMaxAcceleration ( wpi::units::turns_per_second_squared_t  maxAcc)
overridevirtual

◆ SetMotionProfileMaxJerk()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMotionProfileMaxJerk ( wpi::units::angular_jerk::turns_per_second_cubed_t  maxJerk)
overridevirtual

Set the maximum angular jerk for the motion profile.

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

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxVelocity() [1/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMotionProfileMaxVelocity ( wpi::units::meters_per_second_t  maxVelocity)
overridevirtual

Set the maximum linear velocity for the motion profile. Converts linear velocity to turns per second using the configured mechanism circumference.

Parameters
maxVelocityMaximum linear velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxVelocity() [2/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMotionProfileMaxVelocity ( wpi::units::turns_per_second_t  maxVelocity)
overridevirtual

Set the maximum angular velocity for the motion profile.

Parameters
maxVelocityMaximum mechanism angular velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotorInverted()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetMotorInverted ( bool  inverted)
overridevirtual

Set the motor output direction.

Parameters
invertedtrue to invert the motor direction.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetOpenLoopRampRate()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetOpenLoopRampRate ( wpi::units::second_t  rampRate)
overridevirtual

Set the open-loop output ramp rate.

Parameters
rampRateTime to ramp from 0 to full output.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetPosition() [1/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetPosition ( wpi::units::meter_t  distance)
overridevirtual

Command a linear measurement position setpoint (closed-loop). Converts distance to turns using the configured mechanism circumference.

Parameters
distanceTarget linear distance.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetPosition() [2/2]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetPosition ( wpi::units::turn_t  angle)
overridevirtual

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

Parameters
angleTarget mechanism angle.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetStatorCurrentLimit()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetStatorCurrentLimit ( wpi::units::ampere_t  currentLimit)
overridevirtual

Set the stator (output) current limit.

Parameters
currentLimitMaximum stator current.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetSupplyCurrentLimit()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetSupplyCurrentLimit ( wpi::units::ampere_t  currentLimit)
overridevirtual

Set the supply (input) current limit.

Parameters
currentLimitMaximum supply current.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetUpdateFrequency()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetUpdateFrequency ( wpi::units::hertz_t  frequency)

Set the update frequency of the status signals this controller reads.

Parameters
frequencyUpdate frequency.

◆ SetupSimulation()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetupSimulation ( )
overridevirtual

Initialize the DCMotorSim used for simulation.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [1/7]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetVelocity ( wpi::units::meters_per_second_t  velocity)
overridevirtual

Command a linear measurement velocity setpoint (closed-loop). Converts linear velocity to turns per second using the configured mechanism circumference.

Parameters
velocityTarget linear velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [2/7]

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

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

Parameters
velocityTarget linear velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [3/7]

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() [4/7]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetVelocity ( wpi::units::turns_per_second_t  velocity)
overridevirtual

Command a mechanism angular velocity setpoint (closed-loop).

Parameters
velocityTarget mechanism angular velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [5/7]

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

Command a mechanism angular velocity setpoint (closed-loop).

Parameters
velocityTarget mechanism angular velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [6/7]

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 from yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [7/7]

void yams::motorcontrollers::remote::TalonFXSWrapper::SetVelocity ( wpi::units::turns_per_second_t  velocity,
wpi::units::newton_t  feedforwardForce 
)
overridevirtual

Command a velocity setpoint with an additional feedforward force, applied by the TalonFXS as an arbitrary feedforward (duty cycle, volts or TorqueCurrentFOC amps depending on the request). With an LQR the RoboRIO loop adds it instead.

Throws SmartMotorControllerConfigurationException if the mechanism circumference is not set.

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

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetVoltage()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetVoltage ( wpi::units::volt_t  voltage)
overridevirtual

Command a voltage output to the motor.

Parameters
voltageVoltage to apply.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetZeroPower()

void yams::motorcontrollers::remote::TalonFXSWrapper::SetZeroPower ( MotorMode  mode)
overridevirtual

Set the idle (neutral) mode of the motor.

Parameters
modeCOAST or BRAKE.

Implements yams::motorcontrollers::SmartMotorController.

◆ SimIterate()

void yams::motorcontrollers::remote::TalonFXSWrapper::SimIterate ( )
overridevirtual

Advance the motor simulation by one loop iteration.

Implements yams::motorcontrollers::SmartMotorController.

◆ SynchronizeRelativeEncoder()

void yams::motorcontrollers::remote::TalonFXSWrapper::SynchronizeRelativeEncoder ( )
overridevirtual

The TalonFXS fuses its feedback sources on the device; has no effect.

Implements yams::motorcontrollers::SmartMotorController.

◆ UseCANdiPWM1()

bool yams::motorcontrollers::remote::TalonFXSWrapper::UseCANdiPWM1 ( ) const

Whether CANdi PWM1 is the feedback sensor of the configuration being applied.

Throws std::invalid_argument if it is but no CANdi is configured as the external encoder.

Returns
true if the feedback sensor source is a CANdi PWM1 source.

◆ UseCANdiPWM2()

bool yams::motorcontrollers::remote::TalonFXSWrapper::UseCANdiPWM2 ( ) const

Whether CANdi PWM2 is the feedback sensor of the configuration being applied.

Throws std::invalid_argument if it is but no CANdi is configured as the external encoder.

Returns
true if the feedback sensor source is a CANdi PWM2 source.

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