Package trclib.archive
Class TrcCascadePidController
java.lang.Object
trclib.robotcore.TrcPidController
trclib.archive.TrcCascadePidController
This class implements a Cascade PID Controller. A Cascade PID controller consists of two PID controllers in cascade.
The output of the primary PID controller feeds into the input of the secondary PID controller. If the motor is not
linear, it may be very difficult to get good performance out of a single PID controller. In Cascade PID control,
the distance set-point, for example, will produce a speed control as the primary output and feeds into the
secondary PID controller as input that will try to compensate for the non-linearity of the motor or even battery
level changes. The TrcCascadePidController class extends a regular PID control as its primary PID controller and
creates a second PID controller as its secondary controller.
-
Nested Class Summary
Nested classes/interfaces inherited from class trclib.robotcore.TrcPidController
TrcPidController.PidCoefficients, TrcPidController.PidInput
-
Field Summary
FieldsFields inherited from class trclib.robotcore.TrcPidController
DEF_SETTLING_TIME, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionTrcCascadePidController
(String instanceName, TrcPidController.PidCoefficients primaryPidCoefficients, TrcPidController.PidCoefficients secondaryPidCoefficients, TrcPidController.PidInput primaryInput, TrcPidController.PidInput secondaryInput) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
This method calculates the Cascade PID control output by calling the primary PID controller, feeding its output to the secondary PID controller and finally returning the output of the secondary PID controller.void
reset()
This method is called to reset the Cascade PID controller.Methods inherited from class trclib.robotcore.TrcPidController
displayPidInfo, endStallDetection, getCurrentInput, getError, getOutput, getOutputLimit, getPidCoefficients, getPidInput, getTarget, hasAbsoluteSetPoint, isOnTarget, isOnTarget, isStalled, printPidInfo, printPidInfo, printPidInfo, printPidInfo, restoreOutputLimit, saveAndSetOutputLimit, setAbsoluteSetPoint, setInverted, setNoOscillation, setOutputLimit, setOutputRange, setPidCoefficients, setRampRate, setStallDetectionEnabled, setStallDetectionEnabled, setTarget, setTarget, setTarget, setTarget, setTraceLevel, setTraceLevel, setTraceLevel, startStallDetection, toString
-
Field Details
-
secondaryCtrl
-
-
Constructor Details
-
TrcCascadePidController
public TrcCascadePidController(String instanceName, TrcPidController.PidCoefficients primaryPidCoefficients, TrcPidController.PidCoefficients secondaryPidCoefficients, TrcPidController.PidInput primaryInput, TrcPidController.PidInput secondaryInput) Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.primaryPidCoefficients
- specifies the PID coefficients of the primary PID controller.secondaryPidCoefficients
- specifies the PID coefficients of the secondary PID controller.primaryInput
- specifies the supplier of the primary PID input.secondaryInput
- specifies the supplier of the secondary PID input.
-
-
Method Details
-
reset
public void reset()This method is called to reset the Cascade PID controller. It resets both the primary and secondary PID controller.- Overrides:
reset
in classTrcPidController
-
getOutput
public double getOutput()This method calculates the Cascade PID control output by calling the primary PID controller, feeding its output to the secondary PID controller and finally returning the output of the secondary PID controller.- Overrides:
getOutput
in classTrcPidController
- Returns:
- output of the Cascade PID controller.
-