mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 09:03:43 +08:00
Retain bounded single-line corrections through path disagreement
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "0900e456a7922ffcd9c77651f2d1c3bafb1a754fa1fab83f1cad600160be3b7b", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "478e42860dca77c3cab26de6c5e7b2d2b3e0d6f2739c5eb67d7fa3309903ba39", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user