Tracking differentiator.
Written by FRC Team 8331, who contributed active disturbance rejection control to YAMS.
A tracking differentiator turns a raw reference into a smooth reference y together with its first and second derivatives yd and ydd. Feeding the smoothed reference to a controller avoids the large output spikes a step setpoint would otherwise produce: the controller follows a trajectory the mechanism can track instead of demanding an instantaneous change.
Mechanisms rarely construct this class directly; they configure one with ADRCConfig::WithTrackingDifferentiator and the controller applies it to every setpoint.
Five methods are supported, selected with Method. Each takes a short list of parameters; a parameter left out uses its default:
- EULER, first order smoothing: alpha in [0, 1], default 0.9. Higher is smoother and slower; the time constant is about dt / (1 - alpha), and yd jumps on a step.
- TOD, bang-bang: r greater than 0, default 1, the acceleration bound in the loop's units per second squared. yd chatters at rest at a 20 ms period.
- LD, linear: lambda greater than 0, default 1, a time constant in seconds; the sample time must stay below 2 * lambda. No overshoot; a step is followed to 98% in about 5.8 * lambda. The best default.
- RED, super-twisting: lambda1 (how hard the error pulls) and lambda2 (the bound on how quickly yd changes), greater than 0, default 1 each. Overshoots, and yd chatters at rest at a 20 ms period.
- INTD, saturating: alpha in [0, 1) default 0.5, then beta and gamma in the loop's units and r per second, greater than 0, default 1 each. Cruises at r * beta / (1 - alpha), then lands like LD with natural frequency r * sqrt(beta / gamma) and damping 0.5 * sqrt(gamma / beta); gamma = 4 * beta is critically damped.
ADRCGuide.md explains how to choose and tune each method.
Invalid parameters throw std::invalid_argument.
double smoothSetpoint = td.
GetY();
double setpointVelocity = td.
GetYd();
Definition TrackingDifferentiator.hpp:51
void Update(double reference)
double GetY() const
Definition TrackingDifferentiator.hpp:103
@ LD
Linear differentiator; lambda greater than 0, default 1.
Definition TrackingDifferentiator.hpp:57
double GetYd() const
Definition TrackingDifferentiator.hpp:105