diff --git a/openpilot/common/libcommon.a b/openpilot/common/libcommon.a index 67798acfe7..bc8f0fa8ef 100644 Binary files a/openpilot/common/libcommon.a and b/openpilot/common/libcommon.a differ diff --git a/openpilot/common/libparams_c.so b/openpilot/common/libparams_c.so index 2a651204d0..53f4f0e9cf 100755 Binary files a/openpilot/common/libparams_c.so and b/openpilot/common/libparams_c.so differ diff --git a/openpilot/common/params_keys.h b/openpilot/common/params_keys.h index 7c28a49e95..aa00c1ac14 100644 --- a/openpilot/common/params_keys.h +++ b/openpilot/common/params_keys.h @@ -258,6 +258,7 @@ inline static std::unordered_map keys = { {"HardwareSerial", {PERSISTENT, STRING}}, {"HasAcceptedTerms", {PERSISTENT, STRING, "0"}}, {"InitialCruiseSpeedKph", {PERSISTENT, INT, "40"}}, + {"LowSpeedCruiseOnSet", {PERSISTENT, BOOL, "0"}}, {"InstallDate", {PERSISTENT, TIME}}, {"IsDriverViewEnabled", {CLEAR_ON_MANAGER_START, BOOL}}, {"IsEngaged", {PERSISTENT, BOOL}}, diff --git a/openpilot/selfdrive/car/card.py b/openpilot/selfdrive/car/card.py index 4b0e7a31c5..db9d881a85 100644 --- a/openpilot/selfdrive/car/card.py +++ b/openpilot/selfdrive/car/card.py @@ -33,7 +33,7 @@ from opendbc.car.hyundai.ioniq6_media import Ioniq6MediaButtons from opendbc.car.hyundai.values import CAR as HYUNDAI_CAR from opendbc.car.interfaces import CarInterfaceBase, RadarInterfaceBase from openpilot.selfdrive.pandad import can_capnp_to_list, can_list_to_can_capnp -from openpilot.selfdrive.car.cruise import SlcWheelContext, VCruiseHelper, slc_target_kph +from openpilot.selfdrive.car.cruise import LOW_SPEED_CRUISE_ON_SET, SlcWheelContext, VCruiseHelper, slc_target_kph from openpilot.starpilot.speed_limits import physical_actions as slc_physical from openpilot.starpilot.aol.intent import AolProcessFaultContext, independent_axis_requested, read_settings from openpilot.starpilot.aol.transport_pause import TransportPauseFeedback, cp_identity @@ -475,6 +475,7 @@ class Car: self.experimental_mode = self.params.get_bool("ExperimentalMode") self.initial_cruise_speed = self.params.get("InitialCruiseSpeedKph", return_default=True) + self.v_cruise_helper.low_speed_on_set = self.params.get_bool(LOW_SPEED_CRUISE_ON_SET) # card is driven by can recv, expected at 100Hz self.rk = Ratekeeper(100, print_delay_threshold=None) @@ -1996,6 +1997,7 @@ class Car: self.aol_card_intent.settings = read_settings(self.params) now = time.monotonic() if now >= next_cruise_read: + self.v_cruise_helper.low_speed_on_set = self.params.get_bool(LOW_SPEED_CRUISE_ON_SET) self.slc_requested_configuration = self.read_slc_configuration() if getattr(self, 'slc_transport_available', False): self.slc_match_on_engage = self.read_slc_match_on_engage() diff --git a/openpilot/selfdrive/car/cruise.py b/openpilot/selfdrive/car/cruise.py index b6cf67184d..10ee1056b2 100644 --- a/openpilot/selfdrive/car/cruise.py +++ b/openpilot/selfdrive/car/cruise.py @@ -15,6 +15,7 @@ V_CRUISE_MIN = 8 V_CRUISE_MAX = 145 V_CRUISE_UNSET = 255 V_CRUISE_INITIAL = 40 +LOW_SPEED_CRUISE_ON_SET = "LowSpeedCruiseOnSet" IMPERIAL_INCREMENT = round(CV.MPH_TO_KPH, 1) # round here to avoid rounding errors incrementing set speed ButtonEvent = car.CarState.ButtonEvent @@ -61,6 +62,7 @@ class VCruiseHelper: def __init__(self, CP): self.CP = CP self.intervals = CruiseIntervals() + self.low_speed_on_set = False self.v_cruise_kph = V_CRUISE_UNSET self.v_cruise_cluster_kph = V_CRUISE_UNSET self.v_cruise_kph_last = 0 @@ -311,7 +313,10 @@ class VCruiseHelper: self.apply_slc_target(slc_target_mps, is_metric) return True else: - self.v_cruise_kph = int(round(np.clip(max(CS.vEgo * CV.MS_TO_KPH, validated_initial_cruise_speed(initial_speed)), V_CRUISE_INITIAL, V_CRUISE_MAX))) + floor = validated_initial_cruise_speed(initial_speed) + if self.low_speed_on_set and math.isfinite(self.CP.minEnableSpeed): + floor = max(V_CRUISE_MIN, math.ceil(self.CP.minEnableSpeed * CV.MS_TO_KPH)) + self.v_cruise_kph = int(round(np.clip(CS.vEgo * CV.MS_TO_KPH, floor, V_CRUISE_MAX))) self.v_cruise_cluster_kph = self.v_cruise_kph return False diff --git a/openpilot/selfdrive/car/tests/test_cruise_speed.py b/openpilot/selfdrive/car/tests/test_cruise_speed.py index e97fef5937..f0a796dd91 100644 --- a/openpilot/selfdrive/car/tests/test_cruise_speed.py +++ b/openpilot/selfdrive/car/tests/test_cruise_speed.py @@ -204,6 +204,34 @@ class TestResumeInitialization(OpenpilotTestCase): class TestConfiguredInitialCruiseSpeed(OpenpilotTestCase): + def test_optional_low_speed_start_is_set_only(self): + software = VCruiseHelper(car.CarParams(pcmCruise=False, openpilotLongitudinalControl=True)) + stopped = car.CarState(vEgo=0) + assert not software.low_speed_on_set + software.initialize_v_cruise(stopped, False, resume=False) + assert software.v_cruise_kph == V_CRUISE_INITIAL + software.low_speed_on_set = True + software.initialize_v_cruise(stopped, False, resume=False, initial_speed=65) + assert software.v_cruise_kph == software.v_cruise_cluster_kph == V_CRUISE_MIN + software.CP.minEnableSpeed = 6.5 + software.initialize_v_cruise(stopped, False, resume=False) + assert software.v_cruise_kph == 24 + software.initialize_v_cruise(car.CarState(vEgo=25 * CV.KPH_TO_MS), False, resume=False) + assert software.v_cruise_kph == 25 + software.v_cruise_kph_last = 65 + software.initialize_v_cruise(stopped, False, resume=True) + assert software.v_cruise_kph == 65 + assert software.initialize_v_cruise(stopped, False, resume=False, slc_target_mps=50 * CV.KPH_TO_MS, is_metric=True) + assert software.v_cruise_kph == 50 + software.low_speed_on_set = False + software.initialize_v_cruise(stopped, False, resume=False, initial_speed=65) + assert software.v_cruise_kph == 65 + factory = VCruiseHelper(car.CarParams(pcmCruise=True)) + factory.low_speed_on_set = True + factory.v_cruise_kph = 48 + factory.initialize_v_cruise(stopped, False, resume=False) + assert factory.v_cruise_kph == 48 + def test_initial_speed_floor(self): for experimental_mode in (True, False): for initial_speed in (40, 65, 100, 145): diff --git a/openpilot/selfdrive/pandad/pandad b/openpilot/selfdrive/pandad/pandad index 45a62e8009..2d77573218 100755 Binary files a/openpilot/selfdrive/pandad/pandad and b/openpilot/selfdrive/pandad/pandad differ diff --git a/openpilot/starpilot/galaxy/tests/test_lead_approach_settings.py b/openpilot/starpilot/galaxy/tests/test_lead_approach_settings.py index dbf13c200d..114bc8028e 100644 --- a/openpilot/starpilot/galaxy/tests/test_lead_approach_settings.py +++ b/openpilot/starpilot/galaxy/tests/test_lead_approach_settings.py @@ -18,6 +18,7 @@ from openpilot.starpilot.ui.feature_settings_owner import FeatureSettingsOwner ("LeadApproachBuffer", "Approaching lead buffer", "Off"), ("FasterLeadTakeoff", "Faster Takeoffs", "Off"), ("ExperimentalSpeedNudge", "Experimental Speed Nudge", "On"), + ("LowSpeedCruiseOnSet", "Low-Speed Cruise Start", "Off"), ("DisengageOnAccelerator", "Disengage on Accelerator Pedal", "Off"), ]) def setup(tmp_path, request): diff --git a/openpilot/starpilot/ui/feature_settings_owner.py b/openpilot/starpilot/ui/feature_settings_owner.py index 6e28fba780..7137d7c072 100644 --- a/openpilot/starpilot/ui/feature_settings_owner.py +++ b/openpilot/starpilot/ui/feature_settings_owner.py @@ -27,6 +27,7 @@ from openpilot.starpilot.longitudinal.profile_runtime import TRAFFIC_CRUISE_BRAK from openpilot.starpilot.longitudinal.lead_approach_runtime import KEY as LEAD_APPROACH_KEY from openpilot.starpilot.longitudinal.lead_takeoff_preferences import KEY as LEAD_TAKEOFF_KEY from openpilot.starpilot.longitudinal.encouragement import KEY as NUDGE_KEY +from openpilot.selfdrive.car.cruise import LOW_SPEED_CRUISE_ON_SET from openpilot.starpilot.longitudinal.planner_selection import KEY as PLANNER_SELECTION_KEY, save_selection from openpilot.starpilot.longitudinal.profile_document import ( @@ -86,7 +87,8 @@ from openpilot.starpilot.controllers.toyota_cruise import capability as toyota_c AGGRESSIVE_COOLING_KEY = "AggressiveCoolingEnabled" AGGRESSIVE_COOLING_DESCRIPTION = ("Runs the fan sooner and harder to keep the comma 10-16 °C (18-29 °F) cooler on hot days, " + "at the cost of more fan noise. Applies next drive.") -GLOBAL_BOOL_PREFERENCES = frozenset((LEAD_APPROACH_KEY, LEAD_TAKEOFF_KEY, NUDGE_KEY, "DisengageOnAccelerator", AGGRESSIVE_COOLING_KEY)) +GLOBAL_BOOL_PREFERENCES = frozenset((LEAD_APPROACH_KEY, LEAD_TAKEOFF_KEY, NUDGE_KEY, LOW_SPEED_CRUISE_ON_SET, + "DisengageOnAccelerator", AGGRESSIVE_COOLING_KEY)) def cooling_available() -> bool: @@ -112,6 +114,7 @@ BOOL_DEFAULTS = { LEAD_APPROACH_KEY: False, LEAD_TAKEOFF_KEY: False, NUDGE_KEY: True, + LOW_SPEED_CRUISE_ON_SET: False, "DisengageOnAccelerator": False, AGGRESSIVE_COOLING_KEY: False, CURVE_MASTER_KEY: False, CURVE_NO_LEAD_KEY: False, @@ -1274,6 +1277,9 @@ class FeatureSettingsOwner: rows.append(self._bool_row(NUDGE_KEY, "Experimental Speed Nudge", self.authority("preferences"), reason="Gently recovers toward set speed when Experimental mode hesitates on a clear road. " + "Leads, stops, curve limits and driver overrides retain priority.")) + rows.append(self._bool_row(LOW_SPEED_CRUISE_ON_SET, "Low-Speed Cruise Start", self.authority("preferences"), + reason="Lets StarPilot SET at your current speed down to the vehicle’s minimum engagement speed. " + + "Factory cruise still uses the car’s minimum speed.")) if self._galaxy(): rows.append(self._bool_row("DisengageOnAccelerator", "Disengage on Accelerator Pedal", self.authority("preferences"))) document, raw, valid = self._document() diff --git a/openpilot/system/camerad/camerad b/openpilot/system/camerad/camerad index 1c06a7ba69..ed1759420c 100755 Binary files a/openpilot/system/camerad/camerad and b/openpilot/system/camerad/camerad differ diff --git a/openpilot/system/loggerd/bootlog b/openpilot/system/loggerd/bootlog index a2559a8bdc..7ff82ce75d 100755 Binary files a/openpilot/system/loggerd/bootlog and b/openpilot/system/loggerd/bootlog differ diff --git a/openpilot/system/loggerd/encoderd b/openpilot/system/loggerd/encoderd index c807480c95..84b7856af8 100755 Binary files a/openpilot/system/loggerd/encoderd and b/openpilot/system/loggerd/encoderd differ diff --git a/openpilot/system/loggerd/loggerd b/openpilot/system/loggerd/loggerd index e0363910cd..e520273757 100755 Binary files a/openpilot/system/loggerd/loggerd and b/openpilot/system/loggerd/loggerd differ diff --git a/openpilot/tools/replay/replay b/openpilot/tools/replay/replay index 6c58568548..3efa831efb 100755 Binary files a/openpilot/tools/replay/replay and b/openpilot/tools/replay/replay differ diff --git a/prebuilt.json b/prebuilt.json index b7f3606ca8..edb63ac5ec 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "8e850568bb76cb9927ab74e0a08bbd1c7553ae0d15430af6ad9ada022ef95448", "schema_version": 1} +{"protected_inventory_sha256": "ec6327581b4a4b4dd9f01c70ee4045e3923c5b81c63f53561a3bce1e7c24cf58", "schema_version": 1}