From e38f9208b66e39d625230fd2f0768e322e4241bc Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:19:35 -0600 Subject: [PATCH] Retain bounded single-line corrections through path disagreement --- openpilot/starpilot/lateral/lane_centering.py | 2 ++ openpilot/starpilot/lateral/lane_tracking.py | 4 +-- .../lateral/tests/test_lane_centering.py | 25 +++++++++++++++++++ prebuilt.json | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/openpilot/starpilot/lateral/lane_centering.py b/openpilot/starpilot/lateral/lane_centering.py index 09363a397e..692bb3897d 100644 --- a/openpilot/starpilot/lateral/lane_centering.py +++ b/openpilot/starpilot/lateral/lane_centering.py @@ -232,6 +232,8 @@ def raw_correction(model: Any, speed_mps: float, offset_m: float, e2e_authority: if target_y is None: return None error = target_y - model_y + if not all(qualified) and _single_target is not None: + error = clip_scalar(error, -SingleLineTracker.MAX_PATH_DISAGREEMENT, SingleLineTracker.MAX_PATH_DISAGREEMENT) error_abs = abs(error) deadband = CENTER_ERROR_DEADBAND if not all(qualified) and _single_target is not None: diff --git a/openpilot/starpilot/lateral/lane_tracking.py b/openpilot/starpilot/lateral/lane_tracking.py index 7464bbc769..77fb708ae8 100644 --- a/openpilot/starpilot/lateral/lane_tracking.py +++ b/openpilot/starpilot/lateral/lane_tracking.py @@ -170,9 +170,7 @@ class SingleLineTracker: raise ValueError self.path = target_x, target_y target = self._target(lookahead, offset) - model_y = self._at(position, lookahead) - # Allow for Float32 model-coordinate rounding at the disagreement bound. - if target.y is None or abs(target.y - model_y) > self.MAX_PATH_DISAGREEMENT + 1e-6: + if target.y is None: raise ValueError # An observed road edge vetoes a conflicting target. A distant edge is # not interpreted as the missing lane line or a lane-width measurement. diff --git a/openpilot/starpilot/lateral/tests/test_lane_centering.py b/openpilot/starpilot/lateral/tests/test_lane_centering.py index d2a3609d10..daef6fecc3 100644 --- a/openpilot/starpilot/lateral/tests/test_lane_centering.py +++ b/openpilot/starpilot/lateral/tests/test_lane_centering.py @@ -619,6 +619,31 @@ class TestSingleBoundary(unittest.TestCase): class TestSingleLineTracking(unittest.TestCase): + def test_large_single_line_disagreement_stays_bounded_without_dropping_tracking(self): + from openpilot.starpilot.lateral.lane_tracking import SingleLineTracker + for missing_right, sign in ((True, 1), (False, -1)): + with self.subTest(missing_right=missing_right): + m = single(missing_right=missing_right, line=-.7, edge=10.) + m.laneLineStds[1 if missing_right else 2] = .02 + controller = LaneCenteringController() + source = observation(m, base_curvature=0., measured_curvature=0., lateral_delay_s=.1, + settings=LaneCenteringSettings(True, e2e_authority=.5)) + for frame in range(10): + result = controller.update(replace(source, model_sample_id=frame + 1, elapsed_seconds=.05)) + self.assertEqual(result.reason, 'qualified') + self.assertGreater(sign * result.correction, 0.) + self.assertIsNotNone(controller._tracker.path) + assert controller._tracker.spacing is not None + self.assertAlmostEqual(controller._tracker.spacing, 1.7) + raw = raw_correction(m, 20., 0., .5, _single_target=sign * 1.) + assert raw is not None + self.assertAlmostEqual(sign * raw, (SingleLineTracker.MAX_PATH_DISAGREEMENT - .04) / 20. ** 2) + self.assertEqual(raw_correction(m, 20., 0., 1., _single_target=sign * 1.), 0.) + m.laneLineProbs = [0., .1, .1, 0.] + released = controller.update(replace(source, model_sample_id=11, elapsed_seconds=.05)) + self.assertEqual(released.reason, 'unqualified_model') + self.assertLess(abs(released.correction), abs(result.correction)) + def test_two_line_guard_rejects_auxiliary_path_bias_when_command_is_centered(self): for direction in (-1., 1.): m = model(left=-1.8, right=1.8, path=direction * .5) diff --git a/prebuilt.json b/prebuilt.json index d1779f50f7..fb2ba1ba71 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "0900e456a7922ffcd9c77651f2d1c3bafb1a754fa1fab83f1cad600160be3b7b", "schema_version": 1} +{"protected_inventory_sha256": "478e42860dca77c3cab26de6c5e7b2d2b3e0d6f2739c5eb67d7fa3309903ba39", "schema_version": 1}