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

Follow a path in your browser

Press Run in the browser panel above. Gray is the reference path; blue is the rear-axle trajectory. The circle shows lookahead, the dot is the target, and the segment is the wheelbase. Play, pause, step or scrub through the run to inspect where steering begins. The numerical table and downloadable JSON contain the calculated results.

PP: hold distance fixed

PP holds the selected lookahead Ld even when speed changes. Run the nominal curve, save it as A, then try Short lookahead and Long lookahead. Compare steering and completion as well as tracking error.

The controller selector switches PP and APP. Fixed lookahead affects only PP; time and bounds affect only APP. Save a run as A and change only the controller to retain path, initial state, speed command and vehicle. Presets also reset other conditions, so review the displayed parameter differences.

Target geometry

Starting at the nearest path projection, choose the first forward arclength intersection of the path with the radius-Ld circle around the rear axle. For target (xb, yb) in the vehicle frame, curvature κ = 2 yb / (xb² + yb²), then steering δ = atan(L κ). Left is positive.

When there is no intersection, advance Ld in path arclength from the projection and clamp to the endpoint. The display distinguishes circle, recovery and endpoint targets; curvature always uses actual squared target distance. A target behind the vehicle, or coincident with it before completion, ends the run with a reason. These recovery and endpoint rules are educational choices, not Nav2 reproduction.

Common model and fair comparisons

State is rear-axle (x, y) [m], counterclockwise yaw [rad], and forward speed v [m/s]. The equations are dx/dt=v cos(yaw), dy/dt=v sin(yaw), dyaw/dt=v tan(δ)/L. Initial lateral offset is positive left of the first segment; heading offset is relative to that segment. Paths are open polylines: straight, radius-20 m and radius-5 m quarter-circles, or an S curve. Default spacing is 0.1 m (in x for the S curve).

Time step is 0.05 s over at most 30 s. Limits are 8 m/s speed, ±2 m/s² acceleration, ±0.6 rad steering, 0.8 rad/s steering change. Initial steering is zero. Each interval applies a discrete steering slew limit then holds steering fixed. Constant-curvature motion is integrated exactly, including acceleration until zero/max speed and constant speed afterwards. Both controllers use a=2(vtarget−v). No friction, inertia, tyre slip, obstacles or measurement delay is modeled.

Cross-track error is the signed left-normal displacement from the nearest segment. Heading error is vehicle yaw minus projected tangent, wrapped to [-π,π). RMS uses trapezoidal time integration of squared samples divided by elapsed time. Longitudinal endpoint overshoot is excluded from CTE but included in Euclidean path distance. Steering-rate RMS includes the initial transition from zero and describes discrete commands.

Completion means remaining projected arclength and endpoint distance are both ≤0.25 m, with heading within 0.15 rad of the last segment. It is sampled endpoint passage, not stopping or parking; passage between samples can be missed. Distance over 10 m ends a run as off-path; 30 s is the time limit. Incomplete passage time is “—”. Partial runs and different elapsed times must not be ranked by error alone. Equal speed policies can still produce different completion times. This synthetic model does not establish hardware safety or high-speed performance.

Reproducible synthetic examples

These values were generated by native Python from the same code. The gentle curve uses initial and target speed 2 m/s, initial lateral offset 1 m, heading offset zero, and wheelbase 2.5 m.

Setting Status Elapsed [s] CTE RMS [m]
short controller_failed 1.80 0.72123
nominal completed 15.70 0.25996
long completed 15.50 0.37896

References and related Lab

Source download is optional. Browser execution requires no local Python installation. Source + model notes.

Related reading

Read about predictive control and constraintsControl Engineering Primer: Model Predictive Control — Acting Within ConstraintsExplore another aspect of this fieldMPC Lab — re-solve a curvature sequence within a horizon and steering limitsExplore another aspect of this fieldPath-tracking comparison Lab — run PP, APP, RPP, Stanley and MPC under the same conditions