Skip to main content

RST Pole Placement

Harddifficulty

System identification measures kSk_S, kVk_V, and kAk_A 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.

Prerequisites and a starting path

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:

  1. Feedforward: what kSk_S, kVk_V, and kAk_A describe.
  2. System Identification: measure them on your mechanism.
  3. From Math to a Loop: understand sampled time, measured Δt\Delta t, and one-loop delay.

You should recognize a first-order time constant and be comfortable reading q−1q^{-1} 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 e−Δt/τe^{-\Delta t / \tau}. 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 Δt\Delta t, 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, τ\tau, 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, τcl\tau_{cl}, and the design produces whatever coefficients that requires.

Live demoPole placement: the time constant you ask for, and what it costs
velocity referenceT cancels the integral poleT is a plain gainvolts commanded (polynomial T)supply limit
polynomial T reaches 63% in: measuringplain gain T reaches 63% in: measuringreference-step voltage increment: 0.0 Vsaturating: no

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 tauClosedLoop down. The lower plot is the price. For a reference change Δv\Delta v, the first-loop reference increment is

    Δuref=1−e−Δt/τclkdc(1−e−Δt/τ) Δv\Delta u_{ref} = \frac{1 - e^{-\Delta t / \tau_{cl}}}{k_{dc}(1 - e^{-\Delta t / \tau})}\,\Delta v

    When Δt\Delta t is small relative to both time constants, that approaches (τ/τcl)(Δv/kdc)(\tau/\tau_{cl})(\Delta v/k_{dc}), so halving τcl\tau_{cl} 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 vv while accelerating at aa is u=kSsgn⁡(v)+kVv+kAau = k_S\operatorname{sgn}(v) + k_V v + k_A a. Set the static term aside for a moment, since it is not linear and is handled separately below, and rearrange what is left:

kAkV v˙+v=1kV u\frac{k_A}{k_V}\,\dot v + v = \frac{1}{k_V}\,u

That is a first-order lag, so the same measurement serves both purposes:

τ=kAkV,kdc=1kV\tau = \frac{k_A}{k_V}, \qquad k_{dc} = \frac{1}{k_V}

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:

vk=a vk−1+b uk−1,a=e−Δt/τ,b=kdc (1−a)v_k = a\,v_{k-1} + b\,u_{k-1}, \qquad a = e^{-\Delta t/\tau}, \qquad b = k_{dc}\,(1 - a)

Written with q−1q^{-1} as a one-loop delay, that is A(q−1) v=B(q−1) uA(q^{-1})\,v = B(q^{-1})\,u with A=1−aq−1A = 1 - a q^{-1} and B=bq−1B = b q^{-1}. See Discretization for why the exponential appears where a naive Euler step would put 1−Δt/τ1 - \Delta t/\tau.

The three polynomials​

An RST controller is one equation:

S(q−1) u=T(q−1) v∗−R(q−1) vS(q^{-1})\,u = T(q^{-1})\,v^{*} - R(q^{-1})\,v

That gives two separate choices, which a plain PID doesn't: RR decides how the controller fights disturbances, and TT decides how it follows the target. Putting the mechanism model into the controller gives the closed loop:

(AS+BR) v=B T v∗\bigl(A S + B R\bigr)\,v = B\,T\,v^{*}

So AS+BRA S + B R is the closed-loop denominator. Pole placement is choosing what it should be and then solving for RR and SS, which is a Diophantine equation.

Placing two real poles​

Take S=1−q−1S = 1 - q^{-1} for integral action, and ask for two real closed-loop poles:

Acl=(1−p1q−1)(1−p2q−1)=1+α1q−1+α2q−2A_{cl} = (1 - p_1 q^{-1})(1 - p_2 q^{-1}) = 1 + \alpha_1 q^{-1} + \alpha_2 q^{-2}

with p1=e−Δt/τclp_1 = e^{-\Delta t/\tau_{cl}} the tracking pole and p2=e−Δt/τip_2 = e^{-\Delta t/\tau_{i}} the integral pole, α1=−(p1+p2)\alpha_1 = -(p_1 + p_2) and α2=p1p2\alpha_2 = p_1 p_2. 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 AS=1−(1+a)q−1+aq−2A S = 1 - (1 + a) q^{-1} + a q^{-2} and taking R=r0+r1q−1R = r_0 + r_1 q^{-1}, matching coefficients of q−1q^{-1} and q−2q^{-2} gives the whole controller in closed form:

r0=α1+1+ab,r1=α2−abr_0 = \frac{\alpha_1 + 1 + a}{b}, \qquad r_1 = \frac{\alpha_2 - a}{b}

There is no iteration and nothing to search. Two time constants in, two coefficients out.

Why T is not just a gain​

TT is unconstrained by the pole placement, so the obvious choice is the scalar that makes the steady state come out right, t0=Acl(1)/B(1)t_0 = A_{cl}(1)/B(1). That choice is wrong in a way that is easy to miss, because the closed-loop reference response is

vv∗=B TAcl\frac{v}{v^{*}} = \frac{B\,T}{A_{cl}}

and with a scalar TT 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 TT to cancel the integral pole from the reference path fixes it:

T=1−p1b (1−p2q−1)⟹vv∗=(1−p1) q−11−p1q−1T = \frac{1 - p_1}{b}\,\bigl(1 - p_2 q^{-1}\bigr) \qquad\Longrightarrow\qquad \frac{v}{v^{*}} = \frac{(1 - p_1)\,q^{-1}}{1 - p_1 q^{-1}}

Tracking is now first order with exactly the time constant asked for, while AclA_{cl} still contains p2p_2, 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 TT have the same DC gain, since t0(1−p2)t_0(1 - p_2) is the scalar choice. They do not produce the same step response. For a genuine zero-to-step change of size Δv∗\Delta v^{*}, the scalar filter contributes an initial increment of (1−p1)(1−p2)Δv∗/b(1-p_1)(1-p_2)\Delta v^{*}/b, while the polynomial filter contributes (1−p1)Δv∗/b(1-p_1)\Delta v^{*}/b. 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.

ExerciseWhat the slow pole costs a scalar T

At Δt=0.02\Delta t = 0.02 s, with τcl=0.08\tau_{cl} = 0.08 s and τi=0.4\tau_i = 0.4 s, compute p1p_1 and p2p_2. 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?

Show solution

p1=e−0.25=0.779p_1 = e^{-0.25} = 0.779 and p2=e−0.05=0.951p_2 = e^{-0.05} = 0.951. The pole nearer 1 is the slow one, so the response is governed by τi=0.4\tau_i = 0.4 s rather than the 0.08 s requested. The simulation above measures 0.48 s against 0.08 s, a factor of six.

The loop, as a recurrence​

Because S=1−q−1S = 1 - q^{-1}, the controller equation is uk−uk−1=…u_k - u_{k-1} = \ldots, which rearranges into an incremental form:

uk=uk−1+t0(vk∗−p2vk−1∗)−r0vk−r1vk−1u_k = u_{k-1} + t_0\bigl(v^{*}_k - p_2 v^{*}_{k-1}\bigr) - r_0 v_k - r_1 v_{k-1}

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 Δt\Delta t, so all of them are computed inside the loop from the Δt\Delta t 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.

One RST loop, coefficients solved from the measured dt
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 bb check matters most: b=kdc(1−a)b = k_{dc}(1 - a) goes to zero as Δt\Delta t does, so on a very short loop, or with a mistyped kVk_V, every coefficient divides by nearly zero. Returning the previous command is better than an enormous gain. The 4 * dt floor on τcl\tau_{cl} 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.

ExerciseHow aggressive tauClosedLoop can be

A drivetrain measures kV=0.15k_V = 0.15 V per in/s and kA=0.03k_A = 0.03 V per in/s², so τ=0.2\tau = 0.2 s and kdc=6.7k_{dc} = 6.7 in/s per volt. The loop runs every Δt=0.02\Delta t = 0.02 s, and kS=1.4k_S = 1.4 V. For τcl=0.1\tau_{cl} = 0.1 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?

Show solution

a=e−0.02/0.2=0.905a = e^{-0.02/0.2} = 0.905, p1=e−0.02/0.1=0.819p_1 = e^{-0.02/0.1} = 0.819, and b=6.7(1−a)=0.634b = 6.7(1-a) = 0.634. Therefore

Δuref=1−p1b(40)=11.43 V\Delta u_{ref} = \frac{1-p_1}{b}(40) = 11.43\ \text{V}

Adding kSk_S asks for about 12.83 V, so the command saturates. Solving kS+Δuref≤12k_S + \Delta u_{ref} \le 12 gives τcl≳0.109\tau_{cl} \gtrsim 0.109 s before leaving any extra margin. The continuous approximation gives a 12 V reference increment at τcl=0.1\tau_{cl} = 0.1 s, but the discrete calculation is the value the implemented controller actually uses.

Volts are the output, power is the boundary​

The controller returns volts, because volts are what kVk_V and kSk_S 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.

FTCVolts to wheel power, scaled rather than clipped
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.

Static friction is not part of this plant

The model solved above is linear, and kSk_S 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 kSk_S 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 kSsgn⁡(v)k_S\operatorname{sgn}(v) 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 kSk_S turns each of those tiny corrections into a full kSk_S push, and the robot weaves back and forth.

Log the reference against the measurement

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 τcl\tau_{cl} is asking for more than the pack can supply. A gap that oscillates means τcl\tau_{cl} is too small for the loop rate. Nothing else distinguishes those two, and the three coefficients will not tell you.

The measurement sets a floor of its own

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​

  • b=kdc(1−a)b = k_{dc}(1 - a) appears in the denominator of every coefficient. What happens to r0r_0, r1r_1 and t0t_0 as Δt\Delta t 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.
  • τi\tau_i is deliberately slower than τcl\tau_{cl}. If you set them equal, AclA_{cl} has a repeated pole and TT 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 τcl\tau_{cl} 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 RR, SS, TT naming, the Diophantine design, and the treatment of TT 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 τ\tau and kdck_{dc} come from, and why a fit that scores well can still be unusable.
  • Feedforward: the same three constants, and what kSk_S is doing outside the linear plant.
  • Actuator Saturation and Anti-Windup: what the clamped previousOutput is standing in for.