Package ca.team3161.lib.robot.pid
Class RampingSpeedController.Builder
- java.lang.Object
-
- ca.team3161.lib.robot.pid.RampingSpeedController.Builder
-
- Enclosing class:
- RampingSpeedController
public static class RampingSpeedController.Builder extends java.lang.Object
A Builder for RampingSpeedControllers. Provides an easy way to make RampingSpeedControllers without having to remember parameter order.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RampingSpeedController
build()
Use the given parameters to construct a RampingSpeedController.RampingSpeedController.Builder
controller(edu.wpi.first.wpilibj.SpeedController controller)
Set the SpeedController to use.RampingSpeedController.Builder
firstFilter(double firstFilter)
The first filter value.RampingSpeedController.Builder
maxStep(double maxStep)
Set the maximum step size to use.RampingSpeedController.Builder
rampRatio(double rampRatio)
Set the ramp ratio.RampingSpeedController.Builder
secondFilter(double secondFilter)
The second filter value.
-
-
-
Method Detail
-
build
public RampingSpeedController build()
Use the given parameters to construct a RampingSpeedController.- Returns:
- a RampingSpeedController instance
-
controller
public RampingSpeedController.Builder controller(edu.wpi.first.wpilibj.SpeedController controller)
Set the SpeedController to use.- Parameters:
controller
- the controller- Returns:
- this builder
-
maxStep
public RampingSpeedController.Builder maxStep(double maxStep)
Set the maximum step size to use. Any changes in target speed greater than this will be limited to this. For example, if the composed SpeedController is set to 1.0, the maxStep given is 0.2, and the next call toRampingSpeedController.set(double)
is given the parameter 0.5, then the composed SpeedController will actually be set to 0.8.- Parameters:
maxStep
- the maximum step size- Returns:
- this builder
-
rampRatio
public RampingSpeedController.Builder rampRatio(double rampRatio)
Set the ramp ratio. When the controller is between the firstFilter and secondFilter values, this ratio is used to continue governing the stepdown speed to reduce hard braking events.- Parameters:
rampRatio
- the rampRatio- Returns:
- this builder
-
firstFilter
public RampingSpeedController.Builder firstFilter(double firstFilter)
The first filter value. When the new target speed is less than this value, the controller goes into rampdown mode rather than normal operation - maxStep is ignored and either rampRatio is used to compute the next speed, or the controller is stopped entirely.- Parameters:
firstFilter
- the first filter- Returns:
- this builder
-
secondFilter
public RampingSpeedController.Builder secondFilter(double secondFilter)
The second filter value. When the new target speed is less than this value, the controller is immediately set to 0 rather than continuing to slowly ramp down. This is effectively a deadband value.- Parameters:
secondFilter
- the second filter- Returns:
- this builder
-
-