diff --git a/common/libcommon.a b/common/libcommon.a index 108532ae..4c6dc857 100644 Binary files a/common/libcommon.a and b/common/libcommon.a differ diff --git a/common/params_keys.h b/common/params_keys.h index 7b0d81af..977856bc 100644 --- a/common/params_keys.h +++ b/common/params_keys.h @@ -200,6 +200,7 @@ inline static std::unordered_map keys = { {"CurveSpeedController", {PERSISTENT, BOOL, "1", "0", 1}}, {"CustomAlerts", {PERSISTENT, BOOL, "0", "0", 0}}, {"CustomAccelProfile", {PERSISTENT, BOOL, "0", "0", 3}}, + {"CustomAccelProfileInitialized", {PERSISTENT, BOOL, "0", "0", 3}}, {"CustomAccelProfile0MPH", {PERSISTENT, FLOAT, "3.0", "3.0", 3}}, {"CustomAccelProfile11MPH", {PERSISTENT, FLOAT, "2.5", "2.5", 3}}, {"CustomAccelProfile22MPH", {PERSISTENT, FLOAT, "2.0", "2.0", 3}}, diff --git a/common/params_pyx.so b/common/params_pyx.so index 9d2d2ea1..c0a97149 100755 Binary files a/common/params_pyx.so and b/common/params_pyx.so differ diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index 860de4df..3b65dd0a 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -184,7 +184,7 @@ class CarController(CarControllerBase): else: small_cmd_scale = np.interp(abs(accel), [0.0, 0.35, 0.8, 1.5, 2.5], [0.44, 0.54, 0.70, 0.89, 1.0]) accel_cmd = accel * small_cmd_scale - if (not press_regen_paddle) and accel < -2.0: + if accel < -2.0: accel_cmd *= np.interp(abs(accel), [2.0, 2.5, 3.0], [1.0, 1.03, 1.06]) raw_pedal_gas = float(np.clip(pedaloffset + accel_cmd * accel_gain * accel_term_scale, 0.0, 1.0)) diff --git a/panda/board/obj/body_h7.bin.signed b/panda/board/obj/body_h7.bin.signed index cf00ebb6..7b9132c8 100644 Binary files a/panda/board/obj/body_h7.bin.signed and b/panda/board/obj/body_h7.bin.signed differ diff --git a/panda/board/obj/body_h7/bootstub.elf b/panda/board/obj/body_h7/bootstub.elf index a2f3a042..0b35d589 100755 Binary files a/panda/board/obj/body_h7/bootstub.elf and b/panda/board/obj/body_h7/bootstub.elf differ diff --git a/panda/board/obj/body_h7/main.bin b/panda/board/obj/body_h7/main.bin index bdbd436d..f9cffe5d 100755 Binary files a/panda/board/obj/body_h7/main.bin and b/panda/board/obj/body_h7/main.bin differ diff --git a/panda/board/obj/body_h7/main.elf b/panda/board/obj/body_h7/main.elf index 63d5fac1..f2478657 100755 Binary files a/panda/board/obj/body_h7/main.elf and b/panda/board/obj/body_h7/main.elf differ diff --git a/panda/board/obj/bootstub.body_h7.bin b/panda/board/obj/bootstub.body_h7.bin index 66181e44..405986fd 100755 Binary files a/panda/board/obj/bootstub.body_h7.bin and b/panda/board/obj/bootstub.body_h7.bin differ diff --git a/panda/board/obj/bootstub.panda.bin b/panda/board/obj/bootstub.panda.bin index de522e7a..fef45ebd 100755 Binary files a/panda/board/obj/bootstub.panda.bin and b/panda/board/obj/bootstub.panda.bin differ diff --git a/panda/board/obj/bootstub.panda_h7.bin b/panda/board/obj/bootstub.panda_h7.bin index d9d7bc03..41eb4011 100755 Binary files a/panda/board/obj/bootstub.panda_h7.bin and b/panda/board/obj/bootstub.panda_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_h7_remote.bin b/panda/board/obj/bootstub.panda_h7_remote.bin index d9d7bc03..41eb4011 100755 Binary files a/panda/board/obj/bootstub.panda_h7_remote.bin and b/panda/board/obj/bootstub.panda_h7_remote.bin differ diff --git a/panda/board/obj/bootstub.panda_jungle_h7.bin b/panda/board/obj/bootstub.panda_jungle_h7.bin index 8bec4707..3cec0e3a 100755 Binary files a/panda/board/obj/bootstub.panda_jungle_h7.bin and b/panda/board/obj/bootstub.panda_jungle_h7.bin differ diff --git a/panda/board/obj/bootstub.panda_remote.bin b/panda/board/obj/bootstub.panda_remote.bin index de522e7a..fef45ebd 100755 Binary files a/panda/board/obj/bootstub.panda_remote.bin and b/panda/board/obj/bootstub.panda_remote.bin differ diff --git a/panda/board/obj/gitversion.h b/panda/board/obj/gitversion.h index f13d9034..b126a021 100644 --- a/panda/board/obj/gitversion.h +++ b/panda/board/obj/gitversion.h @@ -1,2 +1,2 @@ extern const uint8_t gitversion[19]; -const uint8_t gitversion[19] = "DEV-5f1e0eeb-DEBUG"; +const uint8_t gitversion[19] = "DEV-46d6d0ac-DEBUG"; diff --git a/panda/board/obj/panda.bin.signed b/panda/board/obj/panda.bin.signed index 9cf6784f..a866f028 100644 Binary files a/panda/board/obj/panda.bin.signed and b/panda/board/obj/panda.bin.signed differ diff --git a/panda/board/obj/panda/bootstub.elf b/panda/board/obj/panda/bootstub.elf index 03753408..92ad5446 100755 Binary files a/panda/board/obj/panda/bootstub.elf and b/panda/board/obj/panda/bootstub.elf differ diff --git a/panda/board/obj/panda/main.bin b/panda/board/obj/panda/main.bin index b2a5c33c..e9abc59a 100755 Binary files a/panda/board/obj/panda/main.bin and b/panda/board/obj/panda/main.bin differ diff --git a/panda/board/obj/panda/main.elf b/panda/board/obj/panda/main.elf index 600c17fd..53663207 100755 Binary files a/panda/board/obj/panda/main.elf and b/panda/board/obj/panda/main.elf differ diff --git a/panda/board/obj/panda_h7.bin.signed b/panda/board/obj/panda_h7.bin.signed index 94b96287..80fb8ab2 100644 Binary files a/panda/board/obj/panda_h7.bin.signed and b/panda/board/obj/panda_h7.bin.signed differ diff --git a/panda/board/obj/panda_h7/bootstub.elf b/panda/board/obj/panda_h7/bootstub.elf index 78859407..618eb930 100755 Binary files a/panda/board/obj/panda_h7/bootstub.elf and b/panda/board/obj/panda_h7/bootstub.elf differ diff --git a/panda/board/obj/panda_h7/main.bin b/panda/board/obj/panda_h7/main.bin index b44cfdd3..ebefdc73 100755 Binary files a/panda/board/obj/panda_h7/main.bin and b/panda/board/obj/panda_h7/main.bin differ diff --git a/panda/board/obj/panda_h7/main.elf b/panda/board/obj/panda_h7/main.elf index 8a3b3083..65052ceb 100755 Binary files a/panda/board/obj/panda_h7/main.elf and b/panda/board/obj/panda_h7/main.elf differ diff --git a/panda/board/obj/panda_h7_remote.bin.signed b/panda/board/obj/panda_h7_remote.bin.signed index f4274a82..52298b00 100644 Binary files a/panda/board/obj/panda_h7_remote.bin.signed and b/panda/board/obj/panda_h7_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote/bootstub.elf b/panda/board/obj/panda_h7_remote/bootstub.elf index dfceeb8b..650ecee1 100755 Binary files a/panda/board/obj/panda_h7_remote/bootstub.elf and b/panda/board/obj/panda_h7_remote/bootstub.elf differ diff --git a/panda/board/obj/panda_h7_remote/main.bin b/panda/board/obj/panda_h7_remote/main.bin index e7631368..fb8099f0 100755 Binary files a/panda/board/obj/panda_h7_remote/main.bin and b/panda/board/obj/panda_h7_remote/main.bin differ diff --git a/panda/board/obj/panda_h7_remote/main.elf b/panda/board/obj/panda_h7_remote/main.elf index f7fdd7be..62332aca 100755 Binary files a/panda/board/obj/panda_h7_remote/main.elf and b/panda/board/obj/panda_h7_remote/main.elf differ diff --git a/panda/board/obj/panda_jungle_h7.bin.signed b/panda/board/obj/panda_jungle_h7.bin.signed index 590145b2..e857029c 100644 Binary files a/panda/board/obj/panda_jungle_h7.bin.signed and b/panda/board/obj/panda_jungle_h7.bin.signed differ diff --git a/panda/board/obj/panda_jungle_h7/bootstub.elf b/panda/board/obj/panda_jungle_h7/bootstub.elf index 136c1d0e..fa5a7021 100755 Binary files a/panda/board/obj/panda_jungle_h7/bootstub.elf and b/panda/board/obj/panda_jungle_h7/bootstub.elf differ diff --git a/panda/board/obj/panda_jungle_h7/main.bin b/panda/board/obj/panda_jungle_h7/main.bin index f6ac3e84..47a1e877 100755 Binary files a/panda/board/obj/panda_jungle_h7/main.bin and b/panda/board/obj/panda_jungle_h7/main.bin differ diff --git a/panda/board/obj/panda_jungle_h7/main.elf b/panda/board/obj/panda_jungle_h7/main.elf index 66ad33e6..5a42bdee 100755 Binary files a/panda/board/obj/panda_jungle_h7/main.elf and b/panda/board/obj/panda_jungle_h7/main.elf differ diff --git a/panda/board/obj/panda_remote.bin.signed b/panda/board/obj/panda_remote.bin.signed index b332f4c3..810ddba6 100644 Binary files a/panda/board/obj/panda_remote.bin.signed and b/panda/board/obj/panda_remote.bin.signed differ diff --git a/panda/board/obj/panda_remote/bootstub.elf b/panda/board/obj/panda_remote/bootstub.elf index 98f22165..e5cf0a7d 100755 Binary files a/panda/board/obj/panda_remote/bootstub.elf and b/panda/board/obj/panda_remote/bootstub.elf differ diff --git a/panda/board/obj/panda_remote/main.bin b/panda/board/obj/panda_remote/main.bin index 5e0e2e42..ee6170a9 100755 Binary files a/panda/board/obj/panda_remote/main.bin and b/panda/board/obj/panda_remote/main.bin differ diff --git a/panda/board/obj/panda_remote/main.elf b/panda/board/obj/panda_remote/main.elf index 9d8a7db8..7bed694d 100755 Binary files a/panda/board/obj/panda_remote/main.elf and b/panda/board/obj/panda_remote/main.elf differ diff --git a/panda/board/obj/version b/panda/board/obj/version index e5a2ab49..8aa14db3 100644 --- a/panda/board/obj/version +++ b/panda/board/obj/version @@ -1 +1 @@ -DEV-5f1e0eeb-DEBUG \ No newline at end of file +DEV-46d6d0ac-DEBUG \ No newline at end of file diff --git a/selfdrive/pandad/pandad b/selfdrive/pandad/pandad index 8d99b8d3..85cc292e 100755 Binary files a/selfdrive/pandad/pandad and b/selfdrive/pandad/pandad differ diff --git a/selfdrive/ui/ui b/selfdrive/ui/ui index 4a6cbfb1..7f87991b 100755 Binary files a/selfdrive/ui/ui and b/selfdrive/ui/ui differ diff --git a/starpilot/common/accel_profile.py b/starpilot/common/accel_profile.py index f4569a15..ce26bd31 100644 --- a/starpilot/common/accel_profile.py +++ b/starpilot/common/accel_profile.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 from __future__ import annotations +import math + from openpilot.selfdrive.controls.lib.longitudinal_planner import get_max_accel ACCELERATION_PROFILES = { @@ -29,6 +31,7 @@ CUSTOM_ACCEL_PROFILE_PARAM_SPECS = [ ("CustomAccelProfile89MPH", 89), ] CUSTOM_ACCEL_PROFILE_PARAM_KEYS = [key for key, _ in CUSTOM_ACCEL_PROFILE_PARAM_SPECS] +CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY = "CustomAccelProfileInitialized" CUSTOM_ACCEL_PROFILE_VALUE_MIN = 0.0 CUSTOM_ACCEL_PROFILE_VALUE_MAX = 6.0 @@ -116,6 +119,35 @@ def build_custom_accel_profile_defaults(acceleration_profile, ev_tuning=True, tr } +CUSTOM_ACCEL_PROFILE_STATIC_DEFAULTS = { + key: float(A_CRUISE_MAX_VALS_SPORT_GAS[idx]) + for idx, key in enumerate(CUSTOM_ACCEL_PROFILE_PARAM_KEYS) +} + + +def custom_accel_profile_is_initialized(initialized_flag, raw_values_by_key): + if _coerce_bool(initialized_flag): + return True + + if not isinstance(raw_values_by_key, dict): + return False + + for key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS: + raw_value = raw_values_by_key.get(key) + if raw_value is None: + return False + + try: + value = float(raw_value.decode("utf-8", errors="replace") if isinstance(raw_value, bytes) else raw_value) + except (TypeError, ValueError): + return False + + if not math.isclose(value, CUSTOM_ACCEL_PROFILE_STATIC_DEFAULTS[key], abs_tol=1e-6): + return True + + return False + + def coerce_custom_accel_profile_values(raw_values, acceleration_profile, ev_tuning=True, truck_tuning=False): defaults = get_accel_profile_curve_values(acceleration_profile, ev_tuning, truck_tuning) values = [] @@ -141,3 +173,13 @@ def _normalize_profile(value, profile_map, fallback): return int(float(value)) except (TypeError, ValueError): return fallback + + +def _coerce_bool(value): + if isinstance(value, bytes): + value = value.decode("utf-8", errors="replace") + + if isinstance(value, str): + return value.strip() in ("1", "true", "True") + + return bool(value) diff --git a/starpilot/common/safe_mode.py b/starpilot/common/safe_mode.py index 1cd18d20..0d6c1745 100644 --- a/starpilot/common/safe_mode.py +++ b/starpilot/common/safe_mode.py @@ -49,6 +49,7 @@ SAFE_MODE_MANAGED_KEYS = ( "EVTuning", "TruckTuning", "CustomAccelProfile", + "CustomAccelProfileInitialized", "CustomAccelProfile0MPH", "CustomAccelProfile11MPH", "CustomAccelProfile22MPH", diff --git a/starpilot/common/starpilot_variables.py b/starpilot/common/starpilot_variables.py index 82e4846a..cdca3d06 100644 --- a/starpilot/common/starpilot_variables.py +++ b/starpilot/common/starpilot_variables.py @@ -29,10 +29,12 @@ from openpilot.selfdrive.modeld.constants import ModelConstants from openpilot.starpilot.common.accel_profile import ( ACCELERATION_PROFILES, CUSTOM_ACCEL_PROFILE_PARAM_KEYS, + CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY, CUSTOM_ACCEL_PROFILE_VALUE_MAX, CUSTOM_ACCEL_PROFILE_VALUE_MIN, DECELERATION_PROFILES, build_custom_accel_profile_defaults, + custom_accel_profile_is_initialized, normalize_acceleration_profile, normalize_deceleration_profile, ) @@ -806,11 +808,19 @@ class StarPilotVariables: ) toggle.custom_accel_profile = self.get_value("CustomAccelProfile", condition=longitudinal_tuning) custom_accel_defaults = build_custom_accel_profile_defaults(toggle.acceleration_profile, toggle.ev_tuning, toggle.truck_tuning) - toggle.custom_accel_profile_values = [ - self.get_value(key, cast=float, condition=longitudinal_tuning, default=custom_accel_defaults[key], - min=CUSTOM_ACCEL_PROFILE_VALUE_MIN, max=CUSTOM_ACCEL_PROFILE_VALUE_MAX) - for key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS - ] + custom_accel_raw_values = {key: self.params_raw.get(key) for key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS} + custom_accel_initialized = custom_accel_profile_is_initialized( + self.params_raw.get(CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY), + custom_accel_raw_values, + ) + if custom_accel_initialized: + toggle.custom_accel_profile_values = [ + self.get_value(key, cast=float, condition=longitudinal_tuning, default=custom_accel_defaults[key], + min=CUSTOM_ACCEL_PROFILE_VALUE_MIN, max=CUSTOM_ACCEL_PROFILE_VALUE_MAX) + for key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS + ] + else: + 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.human_lane_changes = has_radar and self.get_value("HumanLaneChanges", condition=longitudinal_tuning) diff --git a/starpilot/system/the_pond/the_pond.py b/starpilot/system/the_pond/the_pond.py index 67247d38..c01085f9 100644 --- a/starpilot/system/the_pond/the_pond.py +++ b/starpilot/system/the_pond/the_pond.py @@ -42,8 +42,10 @@ from panda import Panda from openpilot.starpilot.assets.theme_manager import HOLIDAY_THEME_PATH, THEME_COMPONENT_PARAMS from openpilot.starpilot.common.accel_profile import ( + CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY, CUSTOM_ACCEL_PROFILE_PARAM_KEYS, build_custom_accel_profile_defaults, + custom_accel_profile_is_initialized, normalize_acceleration_profile, ) from openpilot.starpilot.common.maps_catalog import ( @@ -1858,6 +1860,14 @@ def _get_runtime_default_param_overrides(): return overrides def _get_current_param_value(key, value_type, defaults_lookup=None): + if key == CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY: + return _get_custom_accel_profile_initialized() + + if key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS and not _get_custom_accel_profile_initialized(): + if defaults_lookup is None: + defaults_lookup = _get_default_param_values() + return _coerce_param_value(defaults_lookup.get(key), value_type) + raw_value = _safe_params_get_live_raw(key) if _is_blank_param_raw(raw_value): if defaults_lookup is None: @@ -1865,6 +1875,17 @@ def _get_current_param_value(key, value_type, defaults_lookup=None): raw_value = defaults_lookup.get(key) return _coerce_param_value(raw_value, value_type) + +def _get_custom_accel_profile_initialized(): + raw_values = { + key: _safe_params_get_live_raw(key) + for key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS + } + return custom_accel_profile_is_initialized( + _safe_params_get_live_raw(CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY), + raw_values, + ) + def _serialize_param_write_value(raw_value): if isinstance(raw_value, bool): return "1" if raw_value else "0" @@ -3156,6 +3177,25 @@ def setup(app): "updated": updated, }), 200 + if key == "CustomAccelProfile": + enabled = str_val.strip() in ("1", "true", "True") + params.put_bool(key, enabled) + + updated = {key: enabled} + if enabled and not _get_custom_accel_profile_initialized(): + defaults_lookup = _get_default_param_values() + for custom_key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS: + custom_value = defaults_lookup[custom_key] + params.put(custom_key, _serialize_param_write_value(custom_value)) + updated[custom_key] = float(custom_value) + params.put_bool(CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY, True) + + update_starpilot_toggles() + return jsonify({ + "message": f"Parameter '{key}' updated successfully.", + "updated": updated, + }), 200 + if key == "CarMake": catalog = _get_fingerprint_catalog() normalized_make = _normalize_fingerprint_make_key(str_val) @@ -3232,6 +3272,9 @@ def setup(app): elif key in ("ModelVersion", "DrivingModelVersion"): params.put("ModelVersion", str_val) params.put("DrivingModelVersion", str_val) + elif key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS: + params.put(key, str_val) + params.put_bool(CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY, True) else: params.put(key, str_val) @@ -3267,7 +3310,13 @@ def setup(app): return jsonify(response), 200 - return params.get(request.args.get("key")) or "", 200 + request_key = request.args.get("key") + if request_key in CUSTOM_ACCEL_PROFILE_PARAM_KEYS and not _get_custom_accel_profile_initialized(): + defaults_lookup = _get_default_param_values() + return _serialize_param_write_value(defaults_lookup.get(request_key)), 200 + if request_key == CUSTOM_ACCEL_PROFILE_INITIALIZED_KEY: + return _serialize_param_write_value(_get_custom_accel_profile_initialized()), 200 + return params.get(request_key) or "", 200 @app.route("/api/params/all", methods=["GET"]) def get_all_params(): diff --git a/system/camerad/camerad b/system/camerad/camerad index e0ee9b26..ac7bd595 100755 Binary files a/system/camerad/camerad and b/system/camerad/camerad differ diff --git a/system/loggerd/bootlog b/system/loggerd/bootlog index 802b9299..8f855f98 100755 Binary files a/system/loggerd/bootlog and b/system/loggerd/bootlog differ diff --git a/system/loggerd/encoderd b/system/loggerd/encoderd index 9da8f561..b81fd416 100755 Binary files a/system/loggerd/encoderd and b/system/loggerd/encoderd differ diff --git a/system/loggerd/loggerd b/system/loggerd/loggerd index 02d04f06..80896893 100755 Binary files a/system/loggerd/loggerd and b/system/loggerd/loggerd differ