Package org.chsrobotics.lib.controllers
Interface FeedbackController
- All Known Implementing Classes:
ComposedFeedbackController,PID
public interface FeedbackController
Interface for the feedback (past state-dependent and -varying) controllers of the library.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final double -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the controller has reached the setpoint with minimal velocity.doublecalculate(double measurement) Returns an output from the controller with the default robot loop time.doublecalculate(double measurement, double dt) Returns an output from the controller with a given dt.doubleReturns the last output of the controller without updating with a new value.doubleReturns the current setpoint (target) of the controller.voidreset()Resets the controller.voidsetSetpoint(double newSetpoint) Sets the setpoint (target) of the controller.voidsetSetpointTolerance(double positionErrorProportion, double velocityErrorProportion) Sets the maximum error of both position and velocity allowed foratSetpoint()to return true.
-
Field Details
-
defaultPositionErrorToleranceProportion
static final double defaultPositionErrorToleranceProportion- See Also:
-
defaultVelocityErrorToleranceProportion
static final double defaultVelocityErrorToleranceProportion- See Also:
-
-
Method Details
-
reset
void reset()Resets the controller. -
setSetpoint
void setSetpoint(double newSetpoint) Sets the setpoint (target) of the controller.- Parameters:
newSetpoint- The new target of the controller.
-
getSetpoint
double getSetpoint()Returns the current setpoint (target) of the controller.- Returns:
- The current setpoint.
-
setSetpointTolerance
void setSetpointTolerance(double positionErrorProportion, double velocityErrorProportion) Sets the maximum error of both position and velocity allowed foratSetpoint()to return true.- Parameters:
positionErrorProportion- The maximum allowed position error, as a proportion of the setpoint.velocityErrorProportion- The maximum allowed absolute velocity per second, as a proportion of the setpoint / second.
-
calculate
double calculate(double measurement) Returns an output from the controller with the default robot loop time.This must be called at a rate of once every robot loop to be consistent.
- Parameters:
measurement- The value of the measured feedback.- Returns:
- The output of the controller.
-
calculate
double calculate(double measurement, double dt) Returns an output from the controller with a given dt.- Parameters:
measurement- The value of the measured feedback.dt- The time, in seconds, since the last update of this controller.- Returns:
- The output of the controller.
-
getCurrentValue
double getCurrentValue()Returns the last output of the controller without updating with a new value.- Returns:
- The last ouptut of the controller.
-
atSetpoint
boolean atSetpoint()Returns whether the controller has reached the setpoint with minimal velocity.- Returns:
- Whether the controller is within the minimum position and velocity errors.
-