RST Pole Placement
Harddifficulty
System identification measures , , and from your robot. A velocity PID can use those constants as feedforward and use feedback to correct the remaining error. RST is an optional alternative when you want to specify and verify a closed-loop response with a time constant instead of selecting controller coefficients directly.
RST is a discrete-time polynomial controller, so it is a next step, not a PID replacement for a first mechanism. Start in this order:
- Feedforward: what , , and describe.
- System Identification: measure them on your mechanism.
- From Math to a Loop: understand sampled time, measured , and one-loop delay.
You should recognize a first-order time constant and be comfortable reading as “one loop ago.” If not, finish those pages first; the RST derivation will then have a physical meaning instead of becoming polynomial manipulation.
Math used: exponential decay for discretization, algebra on first-order polynomials, and the idea that a closed-loop pole sets response speed. If transfer functions and poles are new, watch Brian Douglas's Transfer Functions lecture, then read the “Continuous to discrete pole mapping” section of Tyler Veness's Controls Engineering in FRC for why a sampled pole is . You do not need complex-plane pole calculations for this real, first-order plant.
A response target is easier to verify than a gain
Velocity PID can work well with measured , suitable feedforward, and validation on the real
mechanism. The problem starts when a gain is chosen only by feel: kP = 0.004 does not say how quickly
the mechanism should settle or how much overshoot is acceptable. If code assumes a fixed loop period,
then its integral and derivative scaling also change when the loop time changes. A duty-cycle-only
feedforward similarly changes physical effect as battery voltage changes. Those are implementation and
modeling problems to catch by measurement, not flaws inherent to PID.
The symptom on a real robot is a mechanism that was tuned crisply on Friday, feels sluggish in the third match on Saturday, and rings when a teammate adds a vision pipeline to the loop.
Build the intuition
Pole placement means choosing the closed-loop response instead of discovering it. The plant has one time constant, , which is how long it takes to reach 63% of a new speed on its own. The controller is asked to make the closed loop have a different time constant, , and the design produces whatever coefficients that requires.
The target switches every 1.6 s, because the interesting part is how it responds to a change. Drag
tauClosedLoop and watch the readout: the green trace reaches 63% of each change in about the time you
asked for, measured from the simulation. tauClosedLoop = 0.1 is something you can check on a graph,
which kP = 0.004 isn't.
Two things are worth doing before reading the derivation:
-
Drag
tauClosedLoopdown. The lower plot is the price. For a reference change , the first-loop reference increment isWhen is small relative to both time constants, that approaches , so halving roughly doubles the increment. The readout uses the exact discrete coefficients, including the four-loop floor. The total command also includes the voltage already holding the previous speed. Once it saturates, the response stops matching the request no matter what the slider says.
-
Compare the two traces. They are the same poles on the same plant, differing only in how the reference enters. Press Slow the integral pole and watch the pink one fall behind while the green one does not move.
Solve the controller from the plant and the response you want
The plant a feedforward already describes
The feedforward model says the voltage to hold velocity while accelerating at is . Set the static term aside for a moment, since it is not linear and is handled separately below, and rearrange what is left:
That is a first-order lag, so the same measurement serves both purposes:
Nothing new was measured. The feedforward constants already describe the mechanism's response.
Discretise it once, in the loop
The Control Hub runs a loop, not an integral, so the design happens in discrete time. For a first-order lag under a held voltage the discretisation is exact rather than approximate:
Written with as a one-loop delay, that is with and . See Discretization for why the exponential appears where a naive Euler step would put .
The three polynomials
An RST controller is one equation:
That gives two separate choices, which a plain PID doesn't: decides how the controller fights disturbances, and decides how it follows the target. Putting the mechanism model into the controller gives the closed loop:
So is the closed-loop denominator. Pole placement is choosing what it should be and then solving for and , which is a Diophantine equation.
Placing two real poles
Take for integral action, and ask for two real closed-loop poles:
with the tracking pole and the integral pole, and . Real poles rather than complex ones because a drivetrain that overshoots its velocity reference on a path is worse than one that arrives slightly late.
Expanding and taking , matching coefficients of and gives the whole controller in closed form:
There is no iteration and nothing to search. Two time constants in, two coefficients out.
Why T is not just a gain
is unconstrained by the pole placement, so the obvious choice is the scalar that makes the steady state come out right, . That choice is wrong in a way that is easy to miss, because the closed-loop reference response is
and with a scalar both poles remain in it. The integral pole is deliberately slow, so it dominates. On the plant in the simulation above, a 0.08 s closed loop against a 0.4 s integral pole answers a change of reference in about 0.48 s, six times slower than asked. The loop is not broken and disturbance rejection is fine. It simply does not track at the speed it was asked to, and the number you set does not describe the behaviour you get.
Choosing to cancel the integral pole from the reference path fixes it:
Tracking is now first order with exactly the time constant asked for, while still contains
, so the integral pole keeps doing the job it was there for: rejecting the steady offsets a model
cannot know about. For a held reference after the transient, the two versions of have the same DC
gain, since is the scalar choice. They do not produce the same step response. For a
genuine zero-to-step change of size , the scalar filter contributes an initial increment
of , while the polynomial filter contributes
. The difference can be hidden at controller startup if previousReference is
primed to the current reference, because that initialization deliberately avoids treating the first
sample as a real command step. Test tracking with a reference change after the controller is primed.
At s, with s and s, compute and . Which
is the slow mode, and roughly how long does a reference step take to settle if that mode is present in
the tracking response? and . The pole nearer 1 is the slow one, so the
response is governed by s rather than the 0.08 s requested. The simulation above
measures 0.48 s against 0.08 s, a factor of six.Show solution
The loop, as a recurrence
Because , the controller equation is , which rearranges into an incremental form:
The previous output is the integrator state. That single observation is worth more than it looks, because it makes anti-windup free: clamp the value before storing it and a saturated axis cannot accumulate a command it will later have to unwind. There is no separate integral term to freeze.
One method, recomputed from the measured loop time
Every coefficient above depends on , so all of them are computed inside the loop from the that actually elapsed. A fixed-coefficient discrete controller quietly retunes itself when the loop jitters, which is the failure mode a robot with a vision pipeline runs into first.
private double previousOutput;
private double previousMeasurement;
private double previousReference;
private boolean primed;
double calculate(double reference, double measurement, double dt) {
if (!Double.isFinite(dt) || dt <= 0 || dt > MAX_DT) dt = NOMINAL_DT;
if (!primed) {
previousMeasurement = measurement;
previousReference = reference;
primed = true;
}
double a = Math.exp(-dt / Math.max(tau, 1e-3));
double b = kDc * (1 - a);
if (Math.abs(b) < 1e-9) return previousOutput;
double p1 = Math.exp(-dt / Math.max(tauClosedLoop, 4 * dt));
double p2 = Math.exp(-dt / Math.max(tauIntegral, 1e-3));
double alpha1 = -(p1 + p2);
double alpha2 = p1 * p2;
double r0 = (alpha1 + 1 + a) / b;
double r1 = (alpha2 - a) / b;
double t0 = (1 - p1) / b;
double output = previousOutput
+ t0 * (reference - p2 * previousReference)
- r0 * measurement - r1 * previousMeasurement;
output = clamp(output, -availableVolts, availableVolts);
previousOutput = output;
previousMeasurement = measurement;
previousReference = reference;
return output;
}
Three of those lines are guards. The check matters most: goes to zero as
does, so on a very short loop, or with a mistyped , every coefficient divides by nearly
zero. Returning the previous command is better than an enormous gain. The 4 * dt floor on
stops you asking for a response faster than a few loop periods, which no model can deliver.
Storing the clamped output is the anti-windup, and it is the only anti-windup this controller needs.
A drivetrain measures V per in/s and V per in/s², so s and
in/s per volt. The loop runs every s, and V. For
s, calculate the exact reference-step voltage increment for a settled step from 0 to
40 in/s. Does the total command fit on a 12 V battery after adding the static-friction voltage? , , and
. Therefore Adding asks for about 12.83 V, so the command saturates. Solving
gives s before leaving any extra margin. The
continuous approximation gives a 12 V reference increment at s, but the discrete
calculation is the value the implemented controller actually uses.Show solution
Volts are the output, power is the boundary
The controller returns volts, because volts are what and were measured in. Dividing by the battery is the last thing that happens, at the hardware boundary, for the reason Voltage Compensation gives: a controller working in duty cycle silently retunes itself as the pack sags.
void applyVolts(double forwardVolts, double turnVolts) {
double battery = voltageSensor.getVoltage();
if (!Double.isFinite(battery) || battery < 6) return;
double f = forwardVolts / battery;
double t = turnVolts / battery;
double peak = Math.max(1, Math.max(Math.abs(f + t), Math.abs(f - t)));
setWheelPowers((f + t) / peak, (f - t) / peak);
}
The peak division keeps the ratio between the two sides, which is what sets the direction. Clipping
each side on its own would change the ratio, so the robot would curve off course, and more so the harder
it's pushed. Scaling gives up speed and keeps the direction.
The model solved above is linear, and is not: it is a fixed voltage that must be paid before anything moves at all, and no choice of poles produces it. The controller can only discover it by integrating error, which means waiting. Feed forward ahead of the loop and leave the rest to the design; the integrator absorbs whatever the estimate got wrong.
On a mecanum drive, apply it as one push in the direction of travel, not as on each axis separately. A robot following a path makes small sideways corrections that flip direction as it wanders across the line. A separate sideways turns each of those tiny corrections into a full push, and the robot weaves back and forth.
The one plot worth having is the velocity reference and the measured velocity on the same axes. A gap that persists means the loop cannot keep up, so either the constants are wrong or is asking for more than the pack can supply. A gap that oscillates means is too small for the loop rate. Nothing else distinguishes those two, and the three coefficients will not tell you.
A velocity that comes from differencing encoder counts over a window lags by roughly half that window. That delay adds to the loop period when deciding how fast a pole can usefully be placed, so a 25 ms differencing window on a 20 ms loop leaves less headroom than the loop rate alone suggests. See Low-Pass Filtering for the trade between that lag and noise.
Check your understanding
- appears in the denominator of every coefficient. What happens to , and as becomes small, and which guard in the block covers it?
- Suppose you store the unclamped output and clamp only what you send to the motors. Describe what the first command after a long saturated stretch looks like, and why the mechanism does not move at first.
- is deliberately slower than . If you set them equal, has a repeated pole and cancels one copy from the reference path. What pole remains in the tracking response, and what design freedom do you lose by giving tracking and disturbance rejection the same time constant?
- Your velocity comes from a 25 ms differencing window and your loop runs at 20 ms. Argue for a and say what evidence would change your mind.
Sources and further reading
- Landau, I. D. and Zito, G. (2006). Digital Control Systems: Design, Identification and Implementation. Springer. The , , naming, the Diophantine design, and the treatment of as a separate degree of freedom follow this text.
- Åström, K. J. and Wittenmark, B. (1997). Computer-Controlled Systems: Theory and Design, 3rd edition. Prentice Hall. Polynomial pole-placement design and the exact discretisation of a first-order lag.
- System Identification: where and come from, and why a fit that scores well can still be unusable.
- Feedforward: the same three constants, and what is doing outside the linear plant.
- Actuator Saturation and Anti-Windup: what the clamped
previousOutputis standing in for.