Coast Toggle

This commit is contained in:
firestar5683
2026-04-20 12:09:36 -05:00
parent 688e0c3fc0
commit bbc1737fbd
50 changed files with 68 additions and 4 deletions
Binary file not shown.
+1
View File
@@ -297,6 +297,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"HolidayThemes", {PERSISTENT, BOOL, "1", "0", 0}},
{"HumanAcceleration", {PERSISTENT, BOOL, "0", "0", 2}},
{"HumanFollowing", {PERSISTENT, BOOL, "0", "0", 2}},
{"CoastUpToLeads", {PERSISTENT, BOOL, "1", "1", 2}},
{"HumanLaneChanges", {PERSISTENT, BOOL, "0", "0", 2}},
{"IconPack", {PERSISTENT, STRING, "frog-animated", "stock", 0}},
{"IconToDownload", {CLEAR_ON_MANAGER_START, STRING, "", ""}},
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,2 +1,2 @@
extern const uint8_t gitversion[19];
const uint8_t gitversion[19] = "DEV-392d38c5-DEBUG";
const uint8_t gitversion[19] = "DEV-688e0c3f-DEBUG";
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
DEV-392d38c5-DEBUG
DEV-688e0c3f-DEBUG
Binary file not shown.
@@ -596,6 +596,15 @@ class StarPilotLongitudinalTuneLayout(StarPilotPanel):
"color": "#597497",
"visible": self._longitudinal_enabled,
},
{
"title": tr_noop("Coast Up To Leads"),
"desc": tr_noop("Allow openpilot to briefly coast toward far leads before applying normal throttle again."),
"type": "toggle",
"get_state": lambda: self._params.get_bool("CoastUpToLeads"),
"set_state": lambda s: self._params.put_bool("CoastUpToLeads", s),
"color": "#597497",
"visible": self._longitudinal_enabled,
},
{
"title": tr_noop("Human-Like Lane Changes"),
"desc": tr_noop("Use radar-informed behavior during lane changes when radar support is available."),
BIN
View File
Binary file not shown.
+1
View File
@@ -68,6 +68,7 @@ SAFE_MODE_MANAGED_KEYS = (
"DecelerationProfile",
"HumanAcceleration",
"HumanFollowing",
"CoastUpToLeads",
"HumanLaneChanges",
"LeadDetectionThreshold",
"RecoveryPower",
+3
View File
@@ -851,6 +851,9 @@ class StarPilotVariables:
toggle.custom_accel_profile_values = [custom_accel_defaults[key] for key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS]
toggle.human_acceleration = self.get_value("HumanAcceleration", condition=longitudinal_tuning)
toggle.human_following = self.get_value("HumanFollowing", condition=longitudinal_tuning)
toggle.coast_up_to_leads = self.get_value("CoastUpToLeads", condition=longitudinal_tuning)
if longitudinal_tuning and self.params.get("CoastUpToLeads") is None:
toggle.coast_up_to_leads = True
toggle.human_lane_changes = has_radar and self.get_value("HumanLaneChanges", condition=longitudinal_tuning)
# Keep lead detection sensitivity normalized even when longitudinal tuning is disabled.
# Some branches can return raw integer defaults (e.g. 35) when condition=False.
@@ -85,7 +85,7 @@ class StarPilotFollowing:
self.t_follow = min(self.t_follow + self.starpilot_planner.starpilot_weather.increase_following_distance, MAX_T_FOLLOW)
self.disable_throttle = False
if self.starpilot_planner.tracking_lead and self.starpilot_planner.lead_one.status:
if getattr(starpilot_toggles, "coast_up_to_leads", True) and self.starpilot_planner.tracking_lead and self.starpilot_planner.lead_one.status:
lead_distance = self.starpilot_planner.lead_one.dRel
v_lead = self.starpilot_planner.lead_one.vLead
closing_speed = max(0.0, v_ego - v_lead)
@@ -967,6 +967,14 @@
"ui_type": "toggle",
"parent_key": "LongitudinalTune"
},
{
"key": "CoastUpToLeads",
"label": "Coast Up To Leads",
"description": "Allow openpilot to briefly coast toward far leads before resuming normal throttle. Disable this if your vehicle shows gas/brake alternation while approaching distant traffic.",
"data_type": "bool",
"ui_type": "toggle",
"parent_key": "LongitudinalTune"
},
{
"key": "HumanLaneChanges",
"label": "Human-Like Lane Changes",
@@ -148,6 +148,7 @@ StarPilotLongitudinalPanel::StarPilotLongitudinalPanel(StarPilotSettingsWindow *
{"DecelerationProfile", tr("Deceleration Profile"), tr("<b>How firmly openpilot slows down.</b> \"Eco\" favors coasting, \"Sport\" applies stronger braking."), ""},
{"HumanAcceleration", tr("Human-Like Acceleration"), tr("<b>Acceleration that mimics human behavior</b> by easing the throttle at low speeds and adding extra power when taking off from a stop."), ""},
{"HumanFollowing", tr("Human-Like Following"), tr("<b>Following behavior that mimics human drivers</b> by closing gaps behind faster vehicles for quicker takeoffs and dynamically adjusting the desired following distance for gentler, more efficient braking."), ""},
{"CoastUpToLeads", tr("Coast Up To Leads"), tr("<b>Allow openpilot to coast toward far leads before resuming normal throttle.</b> Disable this if your vehicle shows noticeable gas/brake alternation while approaching distant traffic."), ""},
{"HumanLaneChanges", tr("Human-Like Lane Changes"), tr("<b>Lane-change behavior that mimics human drivers</b> by anticipating and tracking adjacent vehicles during lane changes."), ""},
{"LeadDetectionThreshold", tr("Lead Detection Sensitivity"), tr("<b>How sensitive openpilot is to detecting vehicles.</b> Higher sensitivity allows quicker detection at longer distances but may react to non-vehicle objects; lower sensitivity is more conservative and reduces false detections."), ""},
{"TacoTune", tr("\"Taco Bell Run\" Turn Speed Hack"), tr("<b>The turn-speed hack from comma's 2022 \"Taco Bell Run\".</b> Designed to slow down for left and right turns."), ""},
@@ -33,7 +33,7 @@ private:
QSet<QString> conditionalExperimentalKeys = {"PersistExperimentalState", "CESpeed", "CESpeedLead", "CECurves", "CELead", "CEModelStopTime", "CESignalSpeed", "CEStopLights", "ShowCEMStatus"};
QSet<QString> curveSpeedKeys = {"CalibratedLateralAcceleration", "CalibrationProgress", "ResetCurveData", "ShowCSCStatus"};
QSet<QString> customDrivingPersonalityKeys = {"AggressivePersonalityProfile", "RelaxedPersonalityProfile", "StandardPersonalityProfile", "TrafficPersonalityProfile"};
QSet<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "HumanAcceleration", "HumanFollowing", "HumanLaneChanges", "LeadDetectionThreshold", "TacoTune"};
QSet<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "HumanAcceleration", "HumanFollowing", "CoastUpToLeads", "HumanLaneChanges", "LeadDetectionThreshold", "TacoTune"};
QSet<QString> qolKeys = {"CustomCruise", "CustomCruiseLong", "ForceStops", "ForceStandstill", "IncreasedStoppedDistance", "MapGears", "ReverseCruise", "SetSpeedOffset", "WeatherPresets"};
QSet<QString> relaxedPersonalityKeys = {"RelaxedFollow", "RelaxedFollowHigh", "RelaxedJerkAcceleration", "RelaxedJerkDeceleration", "RelaxedJerkDanger", "RelaxedJerkSpeed", "RelaxedJerkSpeedDecrease", "ResetRelaxedPersonality"};
QSet<QString> speedLimitControllerKeys = {"SLCOffsets", "SLCFallback", "SLCOverride", "SLCPriority", "SLCQOL", "SLCVisuals"};
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+18
View File
@@ -36,6 +36,7 @@ LEGACY_BOLT_FP_MIGRATION_FLAG = Path("/data") / "legacy_bolt_fp_migration_v1"
STARPILOT_DEFAULTS_PARITY_MIGRATION_FLAG = Path("/data") / "starpilot_defaults_parity_v1"
STARPILOT_HUMANLIKE_DISABLE_MIGRATION_FLAG = Path("/data") / "starpilot_humanlike_disable_v1"
STARPILOT_CLUSTER_OFFSET_MIGRATION_FLAG = Path("/data") / "starpilot_cluster_offset_v1"
STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG = Path("/data") / "starpilot_coast_up_to_leads_v1"
STARPILOT_PARAM_RENAME_MIGRATION_FLAG = Path("/data") / "starpilot_param_rename_v1"
STARPILOT_PARAM_CANONICALIZATION_MIGRATION_FLAG = Path("/data") / "starpilot_param_canonicalization_v1"
STARPILOT_PC_ROOT_MIGRATION_FLAG = Path("/data") / "starpilot_pc_root_v1"
@@ -433,6 +434,22 @@ def migrate_cluster_offset_default(params: Params, params_cache: Params) -> None
cloudlog.exception(f"Failed to write migration flag: {STARPILOT_CLUSTER_OFFSET_MIGRATION_FLAG}")
def migrate_coast_up_to_leads_default(params: Params, params_cache: Params) -> None:
if STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG.exists():
return
if not _has_persisted_param_file(params, "CoastUpToLeads") and not _has_persisted_param_file(params_cache, "CoastUpToLeads"):
params.put_bool("CoastUpToLeads", True)
params_cache.put_bool("CoastUpToLeads", True)
cloudlog.warning("Seeded CoastUpToLeads to default enabled")
try:
STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG.parent.mkdir(parents=True, exist_ok=True)
STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG.write_text(f"{datetime.datetime.now(datetime.UTC).isoformat()}\n")
except Exception:
cloudlog.exception(f"Failed to write migration flag: {STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG}")
def _read_raw_param_bytes(params: Params, key: str | bytes):
try:
path = params.get_param_path(key)
@@ -601,6 +618,7 @@ def manager_init() -> None:
migrate_starpilot_default_parity(params, params_cache)
migrate_disable_humanlike_defaults(params, params_cache)
migrate_cluster_offset_default(params, params_cache)
migrate_coast_up_to_leads_default(params, params_cache)
# set unset params to their default value
for k in params.all_keys():
+23
View File
@@ -217,6 +217,29 @@ class TestManager:
assert params.get("ClusterOffset") == "1.02"
assert params_cache.get("ClusterOffset") is None
def test_migrate_coast_up_to_leads_default_seeds_enabled(self, tmp_path, monkeypatch):
monkeypatch.setattr(manager, "STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG", tmp_path / "starpilot_coast_up_to_leads_v1")
params = FileBackedFakeParams(tmp_path / "params", {})
params_cache = FileBackedFakeParams(tmp_path / "cache", {})
manager.migrate_coast_up_to_leads_default(params, params_cache)
assert params.get_bool("CoastUpToLeads")
assert params_cache.get_bool("CoastUpToLeads")
def test_migrate_coast_up_to_leads_default_preserves_existing_values(self, tmp_path, monkeypatch):
monkeypatch.setattr(manager, "STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG", tmp_path / "starpilot_coast_up_to_leads_v1")
params = FileBackedFakeParams(tmp_path / "params", {
"CoastUpToLeads": False,
})
params_cache = FileBackedFakeParams(tmp_path / "cache", {})
manager.migrate_coast_up_to_leads_default(params, params_cache)
assert not params.get_bool("CoastUpToLeads")
@pytest.mark.skip("this test is flaky the way it's currently written, should be moved to test_onroad")
def test_clean_exit(self, subtests):
"""