Valor 6800 1.0
Loading...
Searching...
No Matches
valor::PhoenixController< VelocityOutput, PositionOutput > Class Template Reference
Inheritance diagram for valor::PhoenixController< VelocityOutput, PositionOutput >:
valor::BaseController valor::Loggable

Public Member Functions

 PhoenixController (valor::PhoenixControllerType controllerType, int canID, valor::NeutralMode neutralMode, bool inverted, std::string canbus="", units::millisecond_t _loggingPeriod=100_ms)
 
void enableFOC (bool enableFOC)
 
void applyConfig () override
 
void reset () override
 Resets the motor and any state.
 
void setNeutralMode (valor::NeutralMode mode, bool saveImmediately=false)
 
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 () override
 Get the motors position.
 
units::turns_per_second_t getSpeed () override
 Get the motors speed.
 
units::ampere_t getCurrent () override
 Get the motors output current.
 
void setEncoderPosition (units::turn_t position) override
 
void setContinuousWrap (bool continuousWrap, bool saveImmediately=false)
 
void positionSetter (units::turn_t position, int slot=0) override
 Send the motor to a specific position.
 
void setPositionWithFeedForward (units::turn_t position, units::turns_per_second_t feedforwardVelocity, int slot=0) override
 Send the motor to a specific position with a velocity feedforward.
 
void setPosition (units::turn_t position, units::turns_per_second_t maxVelocity, units::turns_per_second_squared_t maxAcceleration, units::turns_per_second_cubed_t maxJerk, int slot=0)
 
void speedSetter (units::turns_per_second_t velocity, int slot=0) override
 Send the motor to a specific speed.
 
void powerSetter (double out) override
 
void powerSetter (units::volt_t out) override
 
void powerSetter (units::ampere_t out) override
 
void useTimesync (units::hertz_t controlFreq, bool saveImmediately=false)
 
void setupFollower (int canID, bool followerInverted=false) override
 If a motor is paired with another motor, setup that other motor as a follower.
 
void setPIDF (valor::PIDF pidf, int slot=0, bool saveImmediately=false) override
 Change the PIDF values for the motor.
 
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 getAbsEncoderPosition () 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 ()
 
float getBusUtil (const char *canBusName)
 
void setOpenLoopRamp (units::second_t time, bool saveImmediately=false) override
 
units::volt_t calculateAppliedVoltage () override
 
void setSimState (frc::sim::DCMotorSim &sim) override
 
bool GetFault_BadMagnet (bool refresh=true)
 
void LoggablePeriodic () override
 Periodic callback for logging updates.
 
void setPosition (units::turn_t position, int slot=0)
 
- 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 getOpMode ()
 
TuningMode getTuneMode ()
 
units::turns_per_second_t getMaxMechSpeed ()
 Get the mechanisms's maximum speed.
 
void setVoltageCompensation (units::volt_t _voltageCompensation)
 Setup the voltage compensation for the motor.
 
units::volt_t getVoltageCompensation ()
 
void setPosition (units::turn_t position, int slot=0)
 
void setSpeed (units::turns_per_second_t speed, int slot=0)
 
template<typename T >
void setPower (T power)
 
void setLimits (units::turn_t reverse, units::turn_t forward, bool saveImmediately=false)
 Set both soft limits for the motor.
 
- Public Member Functions inherited from valor::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 setLoggingPeriod (units::millisecond_t period)
 Set the minimum period between LoggablePeriodic() invocations.
 
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< boolReadLogImpl (nt::Subscriber *sub)
 

Additional Inherited Members

- Public Types inherited from valor::BaseController
enum class  OperationalMode { NonOperational , Tuning , Operational }
 
enum class  TuningMode {
  Voltage , Current , DutyCycle , Speed ,
  Position
}
 
- Static Public Member Functions inherited from valor::Loggable
static units::millisecond_t GetLoggingTime ()
 
- Public Attributes inherited from valor::BaseController
frc::DCMotor motorSpec
 
double rotorToSensor
 
double sensorToMech
 
- Protected Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 
 Loggable ()
 Default construct an uninitialized Loggable.
 
virtual ~Loggable ()=default
 Virtual destructor.
 
template<typename T >
T WriteLog (std::string_view field, const T &data)
 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.
 
- Protected Attributes inherited from valor::BaseController
units::volt_t voltageCompensation
 

Member Function Documentation

◆ applyConfig()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::applyConfig ( )
inlineoverridevirtual

Implements valor::BaseController.

◆ calculateAppliedVoltage()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
units::volt_t valor::PhoenixController< VelocityOutput, PositionOutput >::calculateAppliedVoltage ( )
inlineoverridevirtual

Implements valor::BaseController.

◆ getAbsEncoderPosition()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
units::turn_t valor::PhoenixController< VelocityOutput, PositionOutput >::getAbsEncoderPosition ( )
inlineoverridevirtual

Implements valor::BaseController.

◆ getCurrent()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
units::ampere_t valor::PhoenixController< VelocityOutput, PositionOutput >::getCurrent ( )
inlineoverridevirtual

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

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
units::turn_t valor::PhoenixController< VelocityOutput, PositionOutput >::getPosition ( )
inlineoverridevirtual

Get the motors position.

To be defined by the implemented BaseController class

Returns
units::turn_t Position of the motor

Implements valor::BaseController.

◆ getSpeed()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
units::turns_per_second_t valor::PhoenixController< VelocityOutput, PositionOutput >::getSpeed ( )
inlineoverridevirtual

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

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::LoggablePeriodic ( )
inlineoverridevirtual

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.

◆ positionSetter()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::positionSetter ( units::turn_t position,
int slot = 0 )
inlineoverridevirtual

Send the motor to a specific position.

Will use the motor's native trapezoidal motion profile to get the motor to that position. Can be tuned using the velocity and acceleration components of valor::PIDF via setPIDF

To be defined by the implemented BaseController class

Parameters
positionThe position to send the motor to

Implements valor::BaseController.

◆ powerSetter() [1/3]

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::powerSetter ( double out)
inlineoverridevirtual

Reimplemented from valor::BaseController.

◆ powerSetter() [2/3]

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::powerSetter ( units::ampere_t out)
inlineoverridevirtual

Reimplemented from valor::BaseController.

◆ powerSetter() [3/3]

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::powerSetter ( units::volt_t out)
inlineoverridevirtual

Reimplemented from valor::BaseController.

◆ reset()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::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

Implements valor::BaseController.

◆ setEncoderPosition()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setEncoderPosition ( units::turn_t position)
inlineoverridevirtual

Implements valor::BaseController.

◆ setForwardLimit()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setForwardLimit ( units::turn_t forward,
bool saveImmediately = false )
inlineoverridevirtual

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

Implements valor::BaseController.

◆ setGearRatios()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setGearRatios ( double rotorToSensor,
double sensorToMech,
bool saveImmediately = false )
inlineoverridevirtual

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.

◆ setOpenLoopRamp()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setOpenLoopRamp ( units::second_t time,
bool saveImmediately = false )
inlineoverridevirtual

Implements valor::BaseController.

◆ setPIDF()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setPIDF ( valor::PIDF pidf,
int slot = 0,
bool saveImmediately = false )
inlineoverridevirtual

Change the PIDF values for the motor.

valor::PIDF has some default values already set and tested, but if the system requires some changes, use this method to change those defaults.

Parameters
pidfThe new PIDF values to use for the system
slotSet which slot of the motor to apply the PIDF. 0 if slots aren't compatible

Implements valor::BaseController.

◆ setPositionWithFeedForward()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setPositionWithFeedForward ( units::turn_t position,
units::turns_per_second_t feedforwardVelocity,
int slot = 0 )
inlineoverridevirtual

Send the motor to a specific position with a velocity feedforward.

The controller converts the desired mechanism velocity to a feedforward voltage using its own kV and kS gains, then adds it to the closed-loop output. Useful when the setpoint is known to be moving (e.g. a turret tracking a field-stationary target while the chassis rotates).

Reimplemented from valor::BaseController.

◆ setReverseLimit()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setReverseLimit ( units::turn_t reverse,
bool saveImmediately = false )
inlineoverridevirtual

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

Implements valor::BaseController.

◆ setSimState()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setSimState ( frc::sim::DCMotorSim & sim)
inlineoverridevirtual

Implements valor::BaseController.

◆ setupFollower()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::setupFollower ( int canID,
bool followerInverted = false )
inlineoverridevirtual

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

Implements valor::BaseController.

◆ speedSetter()

template<class VelocityOutput = ctre::phoenix6::controls::VelocityVoltage, class PositionOutput = ctre::phoenix6::controls::DynamicMotionMagicVoltage>
void valor::PhoenixController< VelocityOutput, PositionOutput >::speedSetter ( units::turns_per_second_t speed,
int slot = 0 )
inlineoverridevirtual

Send the motor to a specific speed.

Will use the motor's native trapezoidal motion profile to get the motor to that position. Can be tuned using the PIDF components of valor::PIDF via setPIDF

To be defined by the implemented BaseController class

Parameters
speedThe speed to set the motor to

Implements valor::BaseController.


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