Contents — find the section you need

Change parameters and verify

Open the panel, then press Run to load Python. You can stop execution and reset parameters. Results are computed on this device. No Python installation is required.

Local execution steps below are optional for reproducing the source results; they are not required for the browser experiment.

Open experiment panel in a new tab

Download reproduction source

Check the steering direction on both sides

Run Straight · 1 m offset and save A. Recover from right uses a negative lateral offset and reverses the initial steering direction. The initial offset control places the rear axle. Changing heading also changes the front axle's lateral displacement; inspect Initial heading 30° to see the difference.

Stanley evaluates displacement at the front axle. The axle segment runs rear to front, the dotted line connects the front point to its nearest path projection, and green marks the path tangent there. Beyond an endpoint, displacement also includes longitudinal excess; signed CTE uses only the normal component. Error histories show the front reference in green and rear reference in blue (A uses orange dashes).

Steering request is the sum of two corrections

Positive steering turns left; positive CTE is left of the directed path. Given rear position (x,y), yaw ψ and wheelbase L, front position is (x+L cosψ, y+L sinψ). Project it onto the nearest segment of the open polyline. Let ψp be its tangent and ef the signed left-normal displacement.

The request is δ = wrap(ψp−ψ) − atan(k ef / (v+vs)). Gain k has units 1/s, current speed v and softening speed vs have units m/s. When left of the path with aligned heading, ef>0 gives right steering. With the front axle on the path but the body pointing left, the heading term also steers right.

The positive softening speed is an explicit educational extension of the paper's basic equation; it avoids division by zero and is constrained to at least 0.1 m/s here. Faster speed weakens correction for the same lateral error. High gain strengthens it, but sampled control and steering slew limits mean higher gain need not improve tracking.

Play, pause and step to read heading + cross-track correction = requested → applied steering. The requested sum is separate from actuator constraints. Tight steering limit demonstrates insufficient steering on a tight curve; incomplete runs remain visible outcomes.

Shared vehicle and comparison metrics

The plant is the same forward-only rear-axle kinematic bicycle used by PP/APP/RPP. Intervals are 0.05 s for at most 30 s. Limits are 8 m/s, ±2 m/s² and 0.8 rad/s steering slew, with default steering magnitude ±0.6 rad. Constant desired speed uses a=2(desired−actual), limited by the plant. Each interval holds steering and integrates curved motion. No tyre slip, sensor noise, obstacles or delay compensation is modeled.

The shared numerical table's CTE, heading error and RMS use the rear axle. Distinguish these from the front-axle quantities used by Stanley. Heading error plots show body yaw minus path tangent; heading correction has the opposite sign. RMS uses trapezoidal time integration of squared samples divided by elapsed time.

Endpoint passage requires remaining arclength and rear-axle endpoint distance both ≤0.25 m, plus final-tangent heading error ≤0.15 rad. This is not stopping or parking. Path distance over 10 m ends as off-path; 30 s ends as a time limit. On curves the rear axle can cut inside even when the front tracks, so the shared rear-axle endpoint rule may remain unmet. Incomplete passage time is “—”. Do not rank differing durations or completion states by RMS alone.

Suggested sequence

  1. Compare left and right initial offsets and inspect steering signs.
  2. Change initial heading and distinguish front from rear lateral error.
  3. Change gain and speed separately and compare steering magnitude and history.
  4. Use the tight curve and restricted steering to read front tracking, rear metrics and completion separately.

Execution is in the browser, with playback, A/B, reset, share and JSON download. Compute time describes this browser implementation, not real vehicle control timing. The full Stanley vehicle's steering delay, yaw-rate and tyre compensation are outside this exercise.

References and related Labs

Related reading

Isolate speed regulationRegulated Pure Pursuit Lab — speed through curves and near the goalExplore another aspect of this fieldPath-tracking comparison Lab — run PP, APP, RPP, Stanley and MPC under the same conditions