Central engineering reference and operations manual for the MRDT Autonomy Software.
View the Project on GitHub MissouriMRDT/Autonomy_Software
Return to RoveSoDocs Guides for Today, Tomorrow, and Forever.
The PIDController class (src/algorithms/controllers/PIDController.h) implements a Proportional-Integral-Derivative controller with Feedforward support, anti-windup limits, continuous input wraparound, output slew rate limiting, and output low-pass filtering.
The primary application in Autonomy Software is Heading and Steering Control:
At discrete timestep $k$ with time delta $\Delta t = t_k - t_{k-1}$, the control signal $u(k)$ is computed as:
\[u(k) = u_P(k) + u_I(k) + u_D(k) + u_{FF}(k)\]The PIDController class includes several features designed for physical ground robots:
Compass headings wrap from $360^\circ$ to $0^\circ$. Without handling, navigating from $355^\circ$ to $5^\circ$ would compute an error of $-350^\circ$, causing a full counter-clockwise rotation instead of a $10^\circ$ clockwise turn.
EnableContinuousInput(0.0, 360.0) automatically detects the shortest angular distance across the boundary.If the rover is physically obstructed, the integral term can accumulate unbounded error, causing massive overshoot or violent motor spin once the obstacle clears.
SetMaxIntegralEffort(double dMaxEffort) clamps the maximum contribution of $u_I$:
\(|u_I(k)| \le \text{constants::DRIVE\_PID\_MAX\_INTEGRAL\_TERM}\)Instantaneous step changes from $0.0$ to $1.0$ effort can strip motor gearbox teeth or trigger overcurrent cutoffs.
SetOutputRampRate(double dMaxRatePerSecond) limits the rate of change of the output:
\(|u(k) - u(k-1)| \le \text{constants::DRIVE\_PID\_MAX\_RAMP\_RATE} \cdot \Delta t\)Noisy IMU data can cause high-frequency derivative chatter.
SetOutputFilter(double dFilterAlpha) applies an exponential moving average to smooth output signals before passing them to motor drivers:
\(u_{\text{filtered}}(k) = \alpha \cdot u(k) + (1 - \alpha) \cdot u_{\text{filtered}}(k-1)\)AutonomyConstants.cpp| Constant Name | Type | Purpose | Tuning Directive |
|---|---|---|---|
DRIVE_PID_PROPORTIONAL |
double |
$K_p$ gain | Increase for faster heading response; decrease if the rover oscillates around the setpoint. |
DRIVE_PID_INTEGRAL |
double |
$K_i$ gain | Increase if the rover stalls before finishing a turn; decrease if slow hunting oscillations occur. |
DRIVE_PID_DERIVATIVE |
double |
$K_d$ gain | Increase to damp overshoot; decrease if high-frequency jitter occurs due to network/actuation delay. |
DRIVE_PID_FEEDFORWARD |
double |
$K_{ff}$ gain | Baseline effort scaling; typically 0.0 for pure heading tracking. |
DRIVE_PID_MAX_INTEGRAL_TERM |
double |
Ceiling on $u_I$ | Clamps integral effort to prevent windup during extended stalls. |
DRIVE_PID_MAX_RAMP_RATE |
double |
Output slew limit | Caps maximum acceleration of commanded effort per second. |
DRIVE_PID_OUTPUT_FILTER |
double |
Filter factor $\alpha$ | Controls output smoothing against IMU noise. |
DRIVE_PID_TOLERANCE |
double |
Deadband tolerance | Error threshold within which the controller declares alignment achieved. |