Stanley takes path curvature into error correction. This is why Stanley control is better suited for higher speed driving when compared to Pure Pursuit.
With Pure Pursuit, you are only considering a single point ahead of you, and computing a curvature path to reach that point (NO alignment with target trajectory).
However, with Stanley Method, you compute the heading of the target trajectory. So you compare you car’s heading with the heading of the target trajectory.
This way, you get better stability guarantees. As opposed to oscillating back and forth.
The equation is given by
θ(t)=ϕ(t)+tan−1(v(t)Ke∗e(t))
where