mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 06:13:40 +08:00
Add an optional vehicle-minimum cruise start
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -258,6 +258,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> 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}},
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Binary file not shown.
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "8e850568bb76cb9927ab74e0a08bbd1c7553ae0d15430af6ad9ada022ef95448", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "ec6327581b4a4b4dd9f01c70ee4045e3923c5b81c63f53561a3bce1e7c24cf58", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user