mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 11:23:49 +08:00
The Final Countdown
This commit is contained in:
@@ -22,7 +22,7 @@ DEVELOPER_METRIC_DISPLAY_KEYS = (
|
||||
)
|
||||
DEVICE_SHUTDOWN_KEY = "DeviceShutdown"
|
||||
CAMERA_VIEW_KEY = "CameraView"
|
||||
REVERSE_CRUISE_KEY = "ReverseCruise"
|
||||
GALAXY_NEW_DEFAULT_KEY = "GalaxyMobileDefault"
|
||||
|
||||
DEFAULT_STEER_KP = 0.6
|
||||
LEGACY_STEER_KP = 0.7
|
||||
@@ -39,7 +39,8 @@ LANE_CHANGE_SMOOTHING_MIGRATION_MARKER = ".starpilot_lane_change_smoothing_defau
|
||||
SPEED_LIMIT_VISIBILITY_MIGRATION_MARKER = ".starpilot_speed_limit_visibility_v1"
|
||||
DEVICE_SHUTDOWN_HOURS_MIGRATION_MARKER = ".starpilot_device_shutdown_hours_v1"
|
||||
CAMERA_VIEW_DEFAULT_MIGRATION_MARKER = ".starpilot_camera_view_default_v1"
|
||||
REVERSE_CRUISE_REMOVAL_MIGRATION_MARKER = ".starpilot_remove_reverse_cruise_v1"
|
||||
REVERSE_CRUISE_RESTORE_MIGRATION_MARKER = ".starpilot_restore_reverse_cruise_v1"
|
||||
GALAXY_NEW_DEFAULT_MIGRATION_MARKER = ".starpilot_galaxy_new_default_v1"
|
||||
MARKER_DIRNAME = ".starpilot_param_migrations"
|
||||
|
||||
LATERAL_METHOD_PARAM_SUFFIXES = (
|
||||
@@ -147,8 +148,12 @@ def _camera_view_default_marker_path(params: ParamsLike) -> Path:
|
||||
return _marker_dir_path(params) / CAMERA_VIEW_DEFAULT_MIGRATION_MARKER
|
||||
|
||||
|
||||
def _reverse_cruise_removal_marker_path(params: ParamsLike) -> Path:
|
||||
return _marker_dir_path(params) / REVERSE_CRUISE_REMOVAL_MIGRATION_MARKER
|
||||
def _reverse_cruise_restore_marker_path(params: ParamsLike) -> Path:
|
||||
return _marker_dir_path(params) / REVERSE_CRUISE_RESTORE_MIGRATION_MARKER
|
||||
|
||||
|
||||
def _galaxy_new_default_marker_path(params: ParamsLike) -> Path:
|
||||
return _marker_dir_path(params) / GALAXY_NEW_DEFAULT_MIGRATION_MARKER
|
||||
|
||||
|
||||
def _marker_dir_path(params: ParamsLike) -> Path:
|
||||
@@ -332,12 +337,24 @@ def _apply_camera_view_default_migration(params: ParamsLike, marker: Path) -> No
|
||||
marker.touch()
|
||||
|
||||
|
||||
def _remove_reverse_cruise_param(params: ParamsLike, marker: Path) -> None:
|
||||
def _restore_reverse_cruise_param(params: ParamsLike, marker: Path) -> None:
|
||||
if marker.exists():
|
||||
return
|
||||
|
||||
marker.parent.mkdir(parents=True, exist_ok=True)
|
||||
Path(params.get_param_path(REVERSE_CRUISE_KEY)).unlink(missing_ok=True)
|
||||
if (not _param_file_exists(params, "ReverseCruise") and
|
||||
_approx_equal(params.get_float("CustomCruise"), 5.0) and
|
||||
_approx_equal(params.get_float("CustomCruiseLong"), 1.0)):
|
||||
params.put_bool("ReverseCruise", True)
|
||||
marker.touch()
|
||||
|
||||
|
||||
def _enable_galaxy_new_default(params: ParamsLike, marker: Path) -> None:
|
||||
if marker.exists():
|
||||
return
|
||||
|
||||
marker.parent.mkdir(parents=True, exist_ok=True)
|
||||
params.put_bool(GALAXY_NEW_DEFAULT_KEY, True)
|
||||
marker.touch()
|
||||
|
||||
|
||||
@@ -352,7 +369,8 @@ def apply_launch_param_migrations(params: ParamsLike, marker_path: Path | None =
|
||||
speed_limit_visibility_marker_path: Path | None = None,
|
||||
device_shutdown_hours_marker_path: Path | None = None,
|
||||
camera_view_default_marker_path: Path | None = None,
|
||||
reverse_cruise_removal_marker_path: Path | None = None) -> None:
|
||||
reverse_cruise_restore_marker_path: Path | None = None,
|
||||
galaxy_new_default_marker_path: Path | None = None) -> None:
|
||||
_apply_legacy_launch_param_migrations(params, marker_path or _default_marker_path(params))
|
||||
# Keep branch-default rollout on its own marker so older installs that already
|
||||
# have the legacy marker still receive this one-time param reset.
|
||||
@@ -384,8 +402,11 @@ def apply_launch_param_migrations(params: ParamsLike, marker_path: Path | None =
|
||||
_apply_camera_view_default_migration(
|
||||
params, camera_view_default_marker_path or _camera_view_default_marker_path(params)
|
||||
)
|
||||
_remove_reverse_cruise_param(
|
||||
params, reverse_cruise_removal_marker_path or _reverse_cruise_removal_marker_path(params)
|
||||
_restore_reverse_cruise_param(
|
||||
params, reverse_cruise_restore_marker_path or _reverse_cruise_restore_marker_path(params)
|
||||
)
|
||||
_enable_galaxy_new_default(
|
||||
params, galaxy_new_default_marker_path or _galaxy_new_default_marker_path(params)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ STARPILOT_DEFAULT_MODEL_MIGRATION_FLAG = Path("/data") / "starpilot_default_mode
|
||||
STARPILOT_CE_MODEL_STOP_TIME_MIGRATION_FLAG = Path("/data") / "starpilot_ce_model_stop_time_v2"
|
||||
STARPILOT_LEGACY_CACHE_MARKER_KEYS = ("RemapCancelToDistance",)
|
||||
STARPILOT_REMOVED_PARAM_KEYS = (
|
||||
"CoastUpToLeads", "HumanAcceleration", "HumanFollowing", "PrioritizeSmoothFollowing", "ReverseCruise",
|
||||
"CoastUpToLeads", "HumanAcceleration", "HumanFollowing", "PrioritizeSmoothFollowing",
|
||||
)
|
||||
LEGACY_CARMODEL_MIGRATIONS = {
|
||||
"CHEVROLET_BOLT_CC_2019_2021": "CHEVROLET_BOLT_CC_2018_2021",
|
||||
|
||||
@@ -7,6 +7,7 @@ from openpilot.system.manager.launch_param_migrations import (
|
||||
DEFAULT_CAMERA_VIEW,
|
||||
DEVELOPER_METRIC_DISPLAY_KEYS,
|
||||
DEVELOPER_METRIC_DISPLAY_MIGRATION_MARKER,
|
||||
GALAXY_NEW_DEFAULT_MIGRATION_MARKER,
|
||||
DEFAULT_LANE_CHANGE_SMOOTHING,
|
||||
DEFAULT_STEER_KP,
|
||||
DEVICE_SHUTDOWN_HOURS_MIGRATION_MARKER,
|
||||
@@ -14,7 +15,7 @@ from openpilot.system.manager.launch_param_migrations import (
|
||||
LAUNCH_PARAM_MIGRATION_MARKER,
|
||||
LATERAL_METHOD_REBRAND_MIGRATION_MARKER,
|
||||
MARKER_DIRNAME,
|
||||
REVERSE_CRUISE_REMOVAL_MIGRATION_MARKER,
|
||||
REVERSE_CRUISE_RESTORE_MIGRATION_MARKER,
|
||||
STANDARD_ACCELERATION_PROFILE,
|
||||
SPEED_LIMIT_VISIBILITY_MIGRATION_MARKER,
|
||||
LEGACY_UI_SELECTION_MIGRATION_MARKER,
|
||||
@@ -178,14 +179,42 @@ def test_apply_launch_param_migrations_preserves_custom_camera_view(tmp_path):
|
||||
assert params.get_int("CameraView") == 0
|
||||
|
||||
|
||||
def test_apply_launch_param_migrations_removes_reverse_cruise_param(tmp_path):
|
||||
def test_apply_launch_param_migrations_restores_reverse_cruise_from_swapped_intervals(tmp_path):
|
||||
params = FileBackedFakeParams(tmp_path / "params")
|
||||
params.put_bool("ReverseCruise", True)
|
||||
params.put_float("CustomCruise", 5.0)
|
||||
params.put_float("CustomCruiseLong", 1.0)
|
||||
|
||||
apply_launch_param_migrations(params)
|
||||
|
||||
assert not Path(params.get_param_path("ReverseCruise")).exists()
|
||||
assert marker_path(tmp_path, REVERSE_CRUISE_REMOVAL_MIGRATION_MARKER).is_file()
|
||||
assert params.get_bool("ReverseCruise")
|
||||
assert marker_path(tmp_path, REVERSE_CRUISE_RESTORE_MIGRATION_MARKER).is_file()
|
||||
|
||||
|
||||
def test_apply_launch_param_migrations_preserves_explicit_reverse_cruise_choice(tmp_path):
|
||||
params = FileBackedFakeParams(tmp_path / "params")
|
||||
params.put_float("CustomCruise", 5.0)
|
||||
params.put_float("CustomCruiseLong", 1.0)
|
||||
params.put_bool("ReverseCruise", False)
|
||||
|
||||
apply_launch_param_migrations(params)
|
||||
|
||||
assert not params.get_bool("ReverseCruise")
|
||||
|
||||
|
||||
def test_apply_launch_param_migrations_enables_galaxy_new_default_once(tmp_path):
|
||||
params = FileBackedFakeParams(tmp_path / "params")
|
||||
params.put_bool("GalaxyMobileDefault", False)
|
||||
|
||||
apply_launch_param_migrations(params)
|
||||
|
||||
assert params.get_bool("GalaxyMobileDefault")
|
||||
marker = marker_path(tmp_path, GALAXY_NEW_DEFAULT_MIGRATION_MARKER)
|
||||
assert marker.is_file()
|
||||
|
||||
params.put_bool("GalaxyMobileDefault", False)
|
||||
apply_launch_param_migrations(params)
|
||||
|
||||
assert not params.get_bool("GalaxyMobileDefault")
|
||||
|
||||
|
||||
def test_apply_launch_param_migrations_applies_branch_defaults_for_existing_installs(tmp_path):
|
||||
|
||||
@@ -397,7 +397,6 @@ class TestManager:
|
||||
params_cache = FileBackedFakeParams(tmp_path / "cache", {
|
||||
"HumanFollowing": False,
|
||||
"PrioritizeSmoothFollowing": True,
|
||||
"ReverseCruise": True,
|
||||
})
|
||||
|
||||
manager.cleanup_removed_starpilot_params(params, params_cache)
|
||||
@@ -405,10 +404,9 @@ class TestManager:
|
||||
assert not Path(params.get_param_path("CoastUpToLeads")).exists()
|
||||
assert not Path(params.get_param_path("HumanAcceleration")).exists()
|
||||
assert not Path(params.get_param_path("HumanFollowing")).exists()
|
||||
assert not Path(params.get_param_path("ReverseCruise")).exists()
|
||||
assert params.get_bool("ReverseCruise")
|
||||
assert not Path(params_cache.get_param_path("HumanFollowing")).exists()
|
||||
assert not Path(params_cache.get_param_path("PrioritizeSmoothFollowing")).exists()
|
||||
assert not Path(params_cache.get_param_path("ReverseCruise")).exists()
|
||||
|
||||
def test_migrate_legacy_starpilot_params_cache_copies_marker_sources(self, tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(manager, "STARPILOT_PARAMS_CACHE_MIGRATION_FLAG", tmp_path / "starpilot_params_cache_v1")
|
||||
|
||||
Reference in New Issue
Block a user