diff --git a/selfdrive/controls/tests/test_speed_limit_controller.py b/selfdrive/controls/tests/test_speed_limit_controller.py index edb7ee573..bf34dfd74 100644 --- a/selfdrive/controls/tests/test_speed_limit_controller.py +++ b/selfdrive/controls/tests/test_speed_limit_controller.py @@ -62,7 +62,7 @@ def make_sm(*, gas_pressed, enabled=True, accel_pressed=False, decel_pressed=Fal "carControl": SimpleNamespace(longActive=True), "carState": SimpleNamespace(gasPressed=gas_pressed, steeringAngleDeg=0.0), "liveParameters": SimpleNamespace(angleOffsetDeg=0.0), - "mapdOut": SimpleNamespace(nextSpeedLimitDistance=0.0, nextSpeedLimit=0.0, speedLimit=0.0), + "mapdOut": SimpleNamespace(nextSpeedLimitDistance=0.0, nextSpeedLimit=0.0, speedLimit=0.0, waySelectionType=0), "selfdriveState": SimpleNamespace(enabled=enabled), "starpilotCarState": SimpleNamespace(accelPressed=accel_pressed, decelPressed=decel_pressed), } diff --git a/starpilot/controls/lib/speed_limit_controller.py b/starpilot/controls/lib/speed_limit_controller.py index 915f37ebf..1e89cc22c 100644 --- a/starpilot/controls/lib/speed_limit_controller.py +++ b/starpilot/controls/lib/speed_limit_controller.py @@ -10,6 +10,7 @@ from concurrent.futures import ThreadPoolExecutor from openpilot.common.constants import CV from openpilot.common.realtime import DT_MDL +from cereal import custom from openpilot.starpilot.common.starpilot_utilities import calculate_bearing_offset, calculate_distance_to_point, is_url_pingable FREE_MAPBOX_REQUESTS = 100_000 @@ -424,8 +425,14 @@ class SpeedLimitController: self.map_speed_limit = 0 self.next_speed_limit = 0 else: - self.map_speed_limit = sm["mapdOut"].speedLimit - self.next_speed_limit = sm["mapdOut"].nextSpeedLimit + way_sel = sm["mapdOut"].waySelectionType + if way_sel in (custom.WaySelectionType.current, + custom.WaySelectionType.predicted, + custom.WaySelectionType.extended): + self.map_speed_limit = sm["mapdOut"].speedLimit + self.next_speed_limit = sm["mapdOut"].nextSpeedLimit + else: + self.next_speed_limit = 0 if self.next_speed_limit > 0: if self.map_speed_limit < self.next_speed_limit: