SubZero Common
Common library components for an FRC CommandRobot
|
Combines a motor, motor drvier, relative encoder, and absolute encoder into a single wrapper; helpful for absolute positioning, setting velocities, or tuning PID values. More...
#include <PidMotorController.h>
Public Member Functions | |
PidMotorController (std::string name, TMotor &motor, TRelativeEncoder &encoder, TController &controller, PidSettings pidSettings, TAbsoluteEncoder *absEncoder, units::revolutions_per_minute_t maxRpm) | |
Construct a new PidMotorController. | |
void | Set (double percentage) override |
Set the motor to a percentage of max voltage. | |
void | Set (units::volt_t volts) override |
Set a motor to a voltage. | |
void | SetPidTolerance (double tolerance) override |
Absolute positioning is considered 'Done' when within this zone. | |
void | Update () override |
! Call this every loop in Periodic ! | |
void | RunWithVelocity (units::revolutions_per_minute_t rpm) override |
Set to this velocity. | |
void | RunWithVelocity (double percentage) override |
Set to a percentage of max RPM. | |
void | RunToPosition (double position) override |
Enables absolute positioning and sets the target to the position. | |
virtual void | ResetEncoder () override |
double | GetEncoderPosition () override |
std::optional< double > | GetAbsoluteEncoderPosition () override |
void | SetEncoderConversionFactor (double factor) override |
Sets the multiplier for going between encoder ticks and actual distance. | |
void | SetAbsoluteEncoderConversionFactor (double factor) override |
Sets the multiplier for going between encoder ticks and actual distance. | |
void | Stop () override |
Disable absolute positioning and stop the motor. | |
const PidSettings & | GetPidSettings () override |
void | UpdatePidSettings (PidSettings settings) override |
Public Member Functions inherited from subzero::IPidMotorController | |
IPidMotorController (std::string name) | |
Protected Attributes | |
TMotor & | m_motor |
TController & | m_controller |
TRelativeEncoder & | m_encoder |
TAbsoluteEncoder * | m_absEncoder |
PidSettings | m_settings |
frc::PIDController | m_pidController |
bool | m_absolutePositionEnabled = false |
double | m_absoluteTarget = 0 |
const units::revolutions_per_minute_t | m_maxRpm |
Additional Inherited Members | |
Public Attributes inherited from subzero::IPidMotorController | |
const std::string | m_name |
Combines a motor, motor drvier, relative encoder, and absolute encoder into a single wrapper; helpful for absolute positioning, setting velocities, or tuning PID values.
TMotor | |
TController | |
TRelativeEncoder | |
TAbsoluteEncoder |
Definition at line 28 of file PidMotorController.h.
|
explicit |
Construct a new PidMotorController.
name | Display name in SmartDashboard |
motor | |
encoder | |
controller | |
pidSettings | Initial PID settings |
absEncoder | Set to nullptr for a disconnected encoder |
maxRpm | Max RPM of the motor; used to set velocity based on percentage |
|
overridevirtual |
Implements subzero::IPidMotorController.
|
inlineoverridevirtual |
Implements subzero::IPidMotorController.
Definition at line 101 of file PidMotorController.h.
|
inlineoverridevirtual |
Implements subzero::IPidMotorController.
Definition at line 135 of file PidMotorController.h.
|
inlineoverridevirtual |
Implements subzero::IPidMotorController.
Definition at line 96 of file PidMotorController.h.
|
overridevirtual |
Enables absolute positioning and sets the target to the position.
position |
Implements subzero::IPidMotorController.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Set the motor to a percentage of max voltage.
percentage |
Implements subzero::IPidMotorController.
|
overridevirtual |
|
inlineoverridevirtual |
Sets the multiplier for going between encoder ticks and actual distance.
factor |
Implements subzero::IPidMotorController.
Definition at line 123 of file PidMotorController.h.
|
inlineoverridevirtual |
Sets the multiplier for going between encoder ticks and actual distance.
factor |
Implements subzero::IPidMotorController.
Definition at line 113 of file PidMotorController.h.
|
overridevirtual |
Absolute positioning is considered 'Done' when within this zone.
tolerance |
Implements subzero::IPidMotorController.
|
overridevirtual |
Disable absolute positioning and stop the motor.
Implements subzero::IPidMotorController.
|
overridevirtual |
! Call this every loop in Periodic !
Implements subzero::IPidMotorController.
|
overridevirtual |
Implements subzero::IPidMotorController.
|
protected |
Definition at line 143 of file PidMotorController.h.
|
protected |
Definition at line 146 of file PidMotorController.h.
|
protected |
Definition at line 147 of file PidMotorController.h.
|
protected |
Definition at line 141 of file PidMotorController.h.
|
protected |
Definition at line 142 of file PidMotorController.h.
|
protected |
Definition at line 148 of file PidMotorController.h.
|
protected |
Definition at line 140 of file PidMotorController.h.
|
protected |
Definition at line 145 of file PidMotorController.h.
|
protected |
Definition at line 144 of file PidMotorController.h.