WPILibC++ 2025.2.1
|
Implements a bang-bang controller, which outputs either 0 or 1 depending on whether the measurement is less than the setpoint. More...
#include <frc/controller/BangBangController.h>
Public Member Functions | |
constexpr | BangBangController (double tolerance=std::numeric_limits< double >::infinity()) |
Creates a new bang-bang controller. | |
constexpr void | SetSetpoint (double setpoint) |
Sets the setpoint for the bang-bang controller. | |
constexpr double | GetSetpoint () const |
Returns the current setpoint of the bang-bang controller. | |
constexpr bool | AtSetpoint () const |
Returns true if the error is within the tolerance of the setpoint. | |
constexpr void | SetTolerance (double tolerance) |
Sets the error within which AtSetpoint will return true. | |
constexpr double | GetTolerance () const |
Returns the current tolerance of the controller. | |
constexpr double | GetMeasurement () const |
Returns the current measurement of the process variable. | |
constexpr double | GetError () const |
Returns the current error. | |
constexpr double | Calculate (double measurement, double setpoint) |
Returns the calculated control output. | |
constexpr double | Calculate (double measurement) |
Returns the calculated control output. | |
void | InitSendable (wpi::SendableBuilder &builder) override |
Initializes this Sendable object. | |
Public Member Functions inherited from wpi::Sendable | |
virtual constexpr | ~Sendable ()=default |
Public Member Functions inherited from wpi::SendableHelper< BangBangController > | |
constexpr | SendableHelper (const SendableHelper &rhs)=default |
constexpr | SendableHelper (SendableHelper &&rhs) |
constexpr SendableHelper & | operator= (const SendableHelper &rhs)=default |
constexpr SendableHelper & | operator= (SendableHelper &&rhs) |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< BangBangController > | |
constexpr | SendableHelper ()=default |
constexpr | ~SendableHelper () |
Implements a bang-bang controller, which outputs either 0 or 1 depending on whether the measurement is less than the setpoint.
This maximally-aggressive control approach works very well for velocity control of high-inertia mechanisms, and poorly on most other things.
Note that this is an asymmetric bang-bang controller - it will not exert any control effort in the reverse direction (e.g. it won't try to slow down an over-speeding shooter wheel). This asymmetry is extremely important. Bang-bang control is extremely simple, but also potentially hazardous. Always ensure that your motor controllers are set to "coast" before attempting to control them with a bang-bang controller.
|
inlineexplicitconstexpr |
Creates a new bang-bang controller.
Always ensure that your motor controllers are set to "coast" before attempting to control them with a bang-bang controller.
tolerance | Tolerance for atSetpoint. |
|
inlineconstexpr |
Returns true if the error is within the tolerance of the setpoint.
|
inlineconstexpr |
Returns the calculated control output.
measurement | The most recent measurement of the process variable. |
|
inlineconstexpr |
Returns the calculated control output.
Always ensure that your motor controllers are set to "coast" before attempting to control them with a bang-bang controller.
measurement | The most recent measurement of the process variable. |
setpoint | The setpoint for the process variable. |
|
inlineconstexpr |
Returns the current error.
|
inlineconstexpr |
Returns the current measurement of the process variable.
|
inlineconstexpr |
Returns the current setpoint of the bang-bang controller.
|
inlineconstexpr |
Returns the current tolerance of the controller.
|
overridevirtual |
|
inlineconstexpr |
Sets the setpoint for the bang-bang controller.
setpoint | The desired setpoint. |
|
inlineconstexpr |
Sets the error within which AtSetpoint will return true.
tolerance | Position error which is tolerable. |