mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-03 20:25:20 +08:00
Preserve the Enhanced Stop Light Approach
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Force Stop's model approach, commitment, distance and driver-release policy."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, replace
|
||||
import math
|
||||
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
@@ -206,6 +206,12 @@ class ForceStop:
|
||||
self.reset()
|
||||
return StopPlan()
|
||||
available = frame.perception_available
|
||||
if (tune.distance_control and self.forcing and self.from_light and not self.sign_confirmed and
|
||||
frame.dashboard_sign and frame.vision_distance_m is None and self.dash_distance is not None and
|
||||
self.dash_distance <= max(0.0, speed) * dt and 0 < now - self.sign_evidence_ns <= SIGN_ESTIMATE_HOLD_NS):
|
||||
# A repeated dashboard sign cannot relocate a committed light stop to an exhausted estimate.
|
||||
self.sign_evidence_ns = now
|
||||
frame = replace(frame, sign=False, dashboard_sign=False)
|
||||
sign_estimate = self._sign_estimate(frame, now, max(0.0, speed) * dt)
|
||||
lead = (frame.lead_present and frame.lead_distance_m < tune.lead_veto_m and frame.lead_speed_mps < speed + 2)
|
||||
self._queue_step(frame, now, max(0.0, speed) * dt, lead or frame.tracking_lead)
|
||||
|
||||
@@ -385,6 +385,20 @@ class ForceStopTests(unittest.TestCase):
|
||||
plan = self.owner.step(frame(17, horizon_m=60., sign=True, vision_distance_m=31.), self.tune)
|
||||
self.assertAlmostEqual(plan.tracked_distance_m, 32.5)
|
||||
|
||||
def test_expired_dashboard_distance_does_not_relocate_light_stop(self):
|
||||
owner = ForceStop()
|
||||
tune = vehicle_tune('HYUNDAI_IONIQ_6')
|
||||
for tick in range(45):
|
||||
plan = owner.step(frame(tick, speed_mps=15., horizon_m=90., moving_preview=True,
|
||||
sign=True, dashboard_sign=True), tune)
|
||||
self.assertTrue(plan.forcing)
|
||||
self.assertEqual(owner.dash_distance, 0.)
|
||||
plan = owner.step(frame(45, speed_mps=9.47, horizon_m=49.9, moving_preview=True,
|
||||
sign=True, dashboard_sign=True), tune)
|
||||
self.assertTrue(plan.forcing)
|
||||
self.assertFalse(plan.should_stop or owner.sign_confirmed)
|
||||
self.assertAlmostEqual(plan.tracked_distance_m, 49.9)
|
||||
|
||||
def test_dashboard_and_vision_distances_are_averaged(self):
|
||||
for tick in range(15):
|
||||
self.owner.step(frame(tick, horizon_m=60.), self.tune)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "03778267410308b6b027aa5396f11a9a91bdaf32a2709d86d28581391893424c", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "f88b81aa2df89928b9d32b68436bd1046d743a539235fa686419ec232033a5f6", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user