Skip to content

test: check lateral error and arrival in the Pure Pursuit and Stanley tests - #319

Merged
ShisatoYano merged 1 commit into
ShisatoYano:mainfrom
ADAMAMZAR:test/path-tracking-scenario-checks
Nov 28, 2026
Merged

ShisatoYano merged 1 commit into
ShisatoYano:mainfrom
ADAMAMZAR:test/path-tracking-scenario-checks

Conversation

@ADAMAMZAR

Copy link
Copy Markdown
Contributor

Summary

Part of #261 (path tracking). Part of #174.

The Pure Pursuit and Stanley tests now check the result of the simulation, not only that it runs. main() in both scripts returns the vehicle and the course, so the existing test run is reused and no extra simulation is needed. Each test asserts that:

  • the largest lateral error over the whole trajectory (distance from each vehicle position to the nearest course point) stays under 1.5 m, half of a narrow 3 m lane;
  • the vehicle ends within 5 m of the end of the course and has stopped.

The limits come from measured values with a margin of about 2x, as the issue asks. The course is fixed and these two simulations have no random input, so the values are the same on every run:

Simulation Largest lateral error Distance to course end Final speed
Pure Pursuit 0.75 m 2.30 m 0
Stanley 0.60 m 1.99 m 0

The controllers stop short of the last course point by their look-ahead, so the end check uses a distance rather than the last point.

How I checked it works

  • python -m pytest test on the current main: 175 passed, and git status is clean afterwards.
  • I broke each controller on purpose to check that the assertions catch it, then restored it:
    • Pure Pursuit steering 40% too weak: lateral error 2.18 m, fails
    • Pure Pursuit never slowing down at the end: it overshoots, lateral error 19.7 m, fails
    • Pure Pursuit at half speed: it ends 15.8 m from the course end, fails
    • Stanley without its cross-track term: lateral error 2.60 m, fails
  • I measured all seven path tracking simulations before choosing these two. The others (LQR, MPC, MPPI, rear wheel feedback, adaptive Pure Pursuit) can follow in later PRs for this category.

Images

None needed, I think: the change under src/ only makes main() return the vehicle and the course at the end. The simulations and their plots are unchanged.

Book

  • This PR doesn't change code that the book describes, or I updated those pages

The book includes the controller and course code by :pyobject:, not these simulation scripts.

… tests

main() in both path tracking simulations now returns the vehicle and the course. The tests assert that the maximum lateral error stays within 1.5 m, that the vehicle stops within 5 m of the end of the course, and that its final speed is zero. Part of ShisatoYano#261.
Copilot AI balanced review requested due to automatic review settings November 27, 2026 00:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@ShisatoYano ShisatoYano added the enhancement New feature or request label Nov 28, 2026
@ShisatoYano
ShisatoYano self-requested a review November 28, 2026 03:39
@ShisatoYano ShisatoYano added the no images needed A change under src/ with nothing to show in images (checked by PR_Evidence) label Nov 28, 2026

@ShisatoYano ShisatoYano left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @ADAMAMZAR! This is exactly what #261 asked for, and the PR is easy to review.

What I liked:

  • main() only returns the vehicle and the course, so the existing test run is reused and no second simulation is needed.
  • The limits have a physical meaning (half of a 3 m lane) and a margin of about 2x over measured values, as the issue asked. I reproduced your table locally: max lateral error 0.750 m / 0.603 m, distance to the course end 2.303 m / 1.991 m, final speed 0.0 for Pure Pursuit / Stanley.
  • You broke the controllers on purpose to show the tests catch it. I also flipped the sign of the yaw rate command (the example in #261): Pure Pursuit then drifts 126.6 m and Stanley 19.3 m from the course and neither stops, so all assertions fail. Scaling it to 0.6x gave 2.18 m for Pure Pursuit, matching your number.
  • Comparing the final speed with == 0.0 is safe, since State clamps speeds below the stop threshold to exactly 0.0, so it won't differ between platforms.

About the failing PR description has evidence check: it only asks for images because src/ changed. Your explanation under "Images" is right (the change only adds a return after vis.draw(), so the plots and GIFs are unchanged), so I've added the no images needed label, and the check passes now.

One suggestion for the next PRs in this category, not needed here:

  1. The lateral error and arrival checks are the same block in both test files. When you add the other five path tracking simulations, consider moving them into a small shared helper (for example test/path_tracking_checks.py), so the limits and the check live in one place.

Looking forward to the next part of #261!

🤖 Generated with Claude Code

@ShisatoYano
ShisatoYano merged commit 8947609 into ShisatoYano:main Nov 28, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request no images needed A change under src/ with nothing to show in images (checked by PR_Evidence)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants