RIT VEXU Core API
Loading...
Searching...
No Matches
core::BangBang Class Reference

#include <bang_bang.h>

Public Member Functions

 BangBang (double tolerance, double setpoint)
 
double calculate (double measurement, double setpoint)
 
double calculate (double measurement)
 
bool at_setpoint ()
 

Detailed Description

A BangBang controller is a simple feedback controller that outputs either 1 or 0, 1 if the measurement is less than the setpoint, and 0 otherwise. Multiply by the maximum voltage you're willing to use.

This should really only be used for velocity control of high inertia systems like flywheels, where high acceleration is most important. For anything else don't use this.

DO NOT use this with a motor that isn't in coast mode since it will oscillate very fast and probably burn it out.

Author
Jack Cammarata
Date
6/27/2025

Constructor & Destructor Documentation

◆ BangBang()

core::BangBang::BangBang ( double tolerance,
double setpoint )
inline

Constructs a BangBang controller with the given tolerance and setpoint.

Parameters
toleranceThe tolerance for the setpoint.
setpointThe setpoint to compare against.

Member Function Documentation

◆ at_setpoint()

bool core::BangBang::at_setpoint ( )
inline

Checks if the current measurement is at the setpoint within the tolerance.

Returns
True if the measurement is within the tolerance of the setpoint.

◆ calculate() [1/2]

double core::BangBang::calculate ( double measurement)
inline

Calculates the output based on the current measurement and setpoint.

Parameters
measurementThe current measurement value.
Returns
1 if the measurement is less than the setpoint, 0 otherwise.

◆ calculate() [2/2]

double core::BangBang::calculate ( double measurement,
double setpoint )
inline

Calculates the output based on the current measurement and setpoint.

Parameters
measurementThe current measurement value.
setpointThe setpoint to compare against.
Returns
1 if the measurement is less than the setpoint, 0 otherwise.

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