Valkyrie 2026
Loading...
Searching...
No Matches
valor::CorePhoenixController Class Reference
Inheritance diagram for valor::CorePhoenixController:
valor::BaseController valor::Loggable valor::PhoenixController< VelocityOutput, PositionOutput >

Public Member Functions

 CorePhoenixController (valor::PhoenixControllerType controllerType, int canID, valor::NeutralMode neutralMode, bool inverted, std::string canbus="")
 CorePhoenixController (valor::PhoenixControllerType controllerType)
void ApplyConfig () override
void Reset () override
 Resets the motor and any state.
void SetNeutralMode (valor::NeutralMode mode, bool saveImmediately=false) override
 Set the neutral mode of the motor.
void SetCurrentLimits (units::ampere_t statorCurrentLimit, units::ampere_t supplyCurrentLimit, units::ampere_t supplyCurrentThreshold, units::second_t supplyTimeThreshold, bool saveImmediately=false)
void SetVoltageLimits (units::volt_t reverseLimit, units::volt_t forwardLimit, bool saveImmediately=false)
units::turn_t GetPosition () const override
 Get the motors position.
ctre::phoenix6::StatusSignal< units::turn_t > & GetPositionSignal (bool refresh=true)
units::turns_per_second_t GetSpeed () const override
 Get the motors speed.
units::ampere_t GetCurrent () const override
 Get the motors output current.
void SetEncoderPosition (units::turn_t position) override
void SetContinuousWrap (bool continuousWrap, bool saveImmediately=false)
void PowerSetter (Output out) override
void SetupFollower (int canID, bool followerInverted=false) override
 If a motor is paired with another motor, setup that other motor as a follower.
void SetupReverseHardwareLimit (int canID, ctre::phoenix6::signals::ReverseLimitTypeValue type, units::turn_t autosetPosition=0_tr, bool saveImmediately=false)
void SetupForwardHardwareLimit (int canID, ctre::phoenix6::signals::ForwardLimitTypeValue type, units::turn_t autosetPosition=0_tr, bool saveImmediately=false)
void SetForwardLimit (units::turn_t forward, bool saveImmediately=false) override
 Set the forward soft limit for the motor.
void SetReverseLimit (units::turn_t reverse, bool saveImmediately=false) override
 Set the reverse soft limit for the motor.
void SetGearRatios (double _rotorToSensor, double _sensorToMech, bool saveImmediately=false) override
 Set the gear ratios for the motor.
ctre::phoenix6::signals::MagnetHealthValue GetMagnetHealth ()
units::turn_t GetAbsoluteEncoderPosition () const override
void SetupCANcoder (int deviceId, units::turn_t offset, bool clockwise, std::string canbus="", units::turn_t absoluteRange=1_tr, bool saveImmediately=false)
ctre::phoenix6::hardware::CANcoder * GetCANcoder ()
void SetOpenLoopRamp (units::second_t time, bool saveImmediately=false) override
units::volt_t CalculateAppliedVoltage () override
void SetSimState (units::turn_t pos, units::turns_per_second_t vel, units::turns_per_second_squared_t accel)
void LoggablePeriodic () override
 Periodic callback for logging updates.
virtual void SetSimState (frc::sim::DCMotorSim &sim)
virtual void SetSimState (frc::sim::FlywheelSim &sim)
virtual void SetSimState (frc::sim::SingleJointedArmSim &sim)
Public Member Functions inherited from valor::BaseController
 BaseController (frc::DCMotor _motorSpec)
 Construct a new Valor Controller object.
void OnLoggingStart () override
 Hook invoked when logging is started for this object.
OperationalMode GetOperationalMode () const
TuningMode GetTuningMode () const
constexpr units::turns_per_second_t GetMaxMechanismSpeed ()
 Get the mechanisms's maximum speed.
constexpr void SetVoltageCompensation (units::volt_t _voltageCompensation)
 Setup the voltage compensation for the motor.
constexpr units::volt_t GetVoltageCompensation ()
void SetPosition (units::turn_t position, Output feedforward=0, int slot=0)
void SetSpeed (units::turns_per_second_t speed, Output feedforward=0, int slot=0)
void SetPower (Output power)
virtual void SetPIDF (valor::PIDF<> pidf, int slot=0, bool saveImmediately=false)=0
 Change the PIDF values for the motor.
void SetLimits (units::turn_t reverse, units::turn_t forward, bool saveImmediately=false)
 Set both soft limits for the motor.
constexpr void SetDefaultTuningMode (TuningMode mode)
Public Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 Loggable (std::shared_ptr< nt::NetworkTable > table)
 Construct a Loggable that uses an existing NetworkTable.
 Loggable ()
 Default construct an uninitialized Loggable.
void LogChild (std::string_view name, Loggable *child)
 Register a child Loggable under a named subtree.
void LogChild (std::string_view name, wpi::Sendable *child)
 Register a child Sendable under a named subtree.
void SetPeriodicLevel (LogLevel level)
 Set the logging level for LoggablePeriodic.
template<typename T>
WriteLog (std::string_view field, const T &data, LogLevel level=LogLevel::Normal)
 Publish a value to NetworkTables under the given field.
template<typename T>
ReadLog (std::string_view field, const T &defaultValue={})
 Read a value from NetworkTables for the given field.
template<>
decltype(Loggable::subscribers) ::iterator addSubscriber (std::string_view field, const std::vector< bool > &defaultValue)
template<>
void WriteLogImpl (nt::Publisher *pub, const std::vector< bool > &data)
template<>
std::vector< bool > ReadLogImpl (nt::Subscriber *sub)

Protected Attributes

std::unique_ptr< CorePhoenixController > followerMotor
std::unique_ptr< ctre::phoenix6::hardware::CANcoder > cancoder
std::unique_ptr< ctre::phoenix6::configs::MagnetSensorConfigs > cancoderConfig
ctre::phoenix6::configs::TalonFXConfiguration config
ctre::phoenix6::controls::VoltageOut voltageRequest {0_V}
ctre::phoenix6::controls::DutyCycleOut dutyCycleRequest {0}
ctre::phoenix6::controls::TorqueCurrentFOC currentRequest {0_A}
Protected Attributes inherited from valor::BaseController
units::volt_t voltageCompensation

Static Protected Attributes

static constexpr units::ampere_t STATOR_CURRENT_LIMIT = 40_A
static constexpr units::ampere_t SUPPLY_CURRENT_LIMIT = 30_A
static constexpr units::ampere_t SUPPLY_CURRENT_THRESHOLD = 30_A
static constexpr units::millisecond_t SUPPLY_TIME_THRESHOLD = 1_s
static constexpr units::ampere_t PEAK_TORQUE_CURRENT = 100_A
static constexpr units::turn_t DEADBAND = 0.01_tr

Additional Inherited Members

Public Types inherited from valor::BaseController
enum class  OperationalMode { NonOperational , Tuning , Operational }
enum class  TuningMode {
  Voltage , Current , DutyCycle , Speed ,
  Position
}
using Output = std::variant<units::volt_t, units::ampere_t, units::scalar_t>
Static Public Member Functions inherited from valor::Loggable
static units::millisecond_t GetLoggingTime ()
static constexpr LoggableGetRoot ()
Public Attributes inherited from valor::BaseController
frc::DCMotor motorSpec
double rotorToSensor
double sensorToMech
Protected Member Functions inherited from valor::BaseController
virtual void PositionSetter (units::turn_t position, Output feedforward=0, int slot=0)=0
 Send the motor to a specific position.
virtual void SpeedSetter (units::turns_per_second_t speed, Output feedforward=0, int slot=0)=0
 Send the motor to a specific speed.

Member Function Documentation

◆ ApplyConfig()

void valor::CorePhoenixController::ApplyConfig ( )
inlineoverridevirtual

Implements valor::BaseController.

◆ CalculateAppliedVoltage()

units::volt_t valor::CorePhoenixController::CalculateAppliedVoltage ( )
overridevirtual

Implements valor::BaseController.

◆ GetAbsoluteEncoderPosition()

units::turn_t valor::CorePhoenixController::GetAbsoluteEncoderPosition ( ) const
overridevirtual

Implements valor::BaseController.

◆ GetCurrent()

units::ampere_t valor::CorePhoenixController::GetCurrent ( ) const
overridevirtual

Get the motors output current.

Get the instantaneous current of the motor that the controller owns

Returns
units::ampere_t Instantaneous amperage of the motor

Implements valor::BaseController.

◆ GetPosition()

units::turn_t valor::CorePhoenixController::GetPosition ( ) const
overridevirtual

Get the motors position.

To be defined by the implemented BaseController class

Returns
units::turn_t Position of the motor

Implements valor::BaseController.

◆ GetSpeed()

units::turns_per_second_t valor::CorePhoenixController::GetSpeed ( ) const
overridevirtual

Get the motors speed.

To be defined by the implemented BaseController class

Returns
units::turns_per_second_t Speed of the motor

Implements valor::BaseController.

◆ LoggablePeriodic()

void valor::CorePhoenixController::LoggablePeriodic ( )
overridevirtual

Periodic callback for logging updates.

If a derived class needs to perform periodic updates to published values, override this method. It is intended to be called by the logging framework; this base class provides an empty implementation.

Reimplemented from valor::Loggable.

◆ PowerSetter()

void valor::CorePhoenixController::PowerSetter ( Output out)
overridevirtual

Implements valor::BaseController.

◆ Reset()

void valor::CorePhoenixController::Reset ( )
inlineoverridevirtual

Resets the motor and any state.

Clear the encoders for the motor and set to 0.

Additionally, should be called by the constructor to set default values before any logic is run.

To be defined by the implemented BaseController class

Reimplemented from valor::BaseController.

◆ SetEncoderPosition()

void valor::CorePhoenixController::SetEncoderPosition ( units::turn_t position)
inlineoverridevirtual

Implements valor::BaseController.

◆ SetForwardLimit()

void valor::CorePhoenixController::SetForwardLimit ( units::turn_t forward,
bool saveImmediately = false )
overridevirtual

Set the forward soft limit for the motor.

Soft limits restrict the reverse and forward direction to a certain range.

Parameters
forwardThe forward soft limit
saveImmediatelySend the config change immediately to the motor controller

Implements valor::BaseController.

◆ SetGearRatios()

void valor::CorePhoenixController::SetGearRatios ( double rotorToSensor,
double sensorToMech,
bool saveImmediately = false )
overridevirtual

Set the gear ratios for the motor.

Used to convert between the motor's rotor and the output shaft of the mechanism

To be defined by the implemented BaseController class

Parameters
rotorToSensorThe gear ratio from rotor to where the sensor is. Should be 1 if no external sensor
sensorToMechThe gear ratio from the sensor to the mechanism's output shaft. Should be the gear ratio if no external sensor
saveImmediatelyTell the underlying controller to apply the changes immediately, or to wait until a manual apply has been called

Implements valor::BaseController.

◆ SetNeutralMode()

void valor::CorePhoenixController::SetNeutralMode ( valor::NeutralMode mode,
bool saveImmediately = false )
overridevirtual

Set the neutral mode of the motor.

Parameters
modeThe neutral mode of the motor
saveImmediatelySend the config change immediately to the motor controller

Implements valor::BaseController.

Reimplemented in valor::PhoenixController< VelocityOutput, PositionOutput >.

◆ SetOpenLoopRamp()

void valor::CorePhoenixController::SetOpenLoopRamp ( units::second_t time,
bool saveImmediately = false )
overridevirtual

Implements valor::BaseController.

◆ SetReverseLimit()

void valor::CorePhoenixController::SetReverseLimit ( units::turn_t reverse,
bool saveImmediately = false )
overridevirtual

Set the reverse soft limit for the motor.

Soft limits restrict the reverse and reverse direction to a certain range.

Parameters
reverseThe reverse soft limit
saveImmediatelySend the config change immediately to the motor controller

Implements valor::BaseController.

◆ SetSimState() [1/4]

virtual void valor::BaseController::SetSimState ( frc::sim::DCMotorSim & sim)
inlinevirtual

Reimplemented from valor::BaseController.

◆ SetSimState() [2/4]

virtual void valor::BaseController::SetSimState ( frc::sim::FlywheelSim & sim)
inlinevirtual

Reimplemented from valor::BaseController.

◆ SetSimState() [3/4]

virtual void valor::BaseController::SetSimState ( frc::sim::SingleJointedArmSim & sim)
inlinevirtual

Reimplemented from valor::BaseController.

◆ SetSimState() [4/4]

void valor::CorePhoenixController::SetSimState ( units::turn_t pos,
units::turns_per_second_t vel,
units::turns_per_second_squared_t accel )
virtual

Implements valor::BaseController.

◆ SetupFollower()

void valor::CorePhoenixController::SetupFollower ( int canID,
bool followerInverted = false )
overridevirtual

If a motor is paired with another motor, setup that other motor as a follower.

The follower motor will need a CAN ID, and then it will mimic and assume all other parameters of the lead motor

To be defined by the implemented BaseController class

Parameters
canIDThe CAN ID of the follower motor
followerInvertedWhether the follower is inverted or not. This is an absolute inversion, NOT relative to the master.

Implements valor::BaseController.


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