patches
This commit is contained in:
Binary file not shown.
@@ -200,6 +200,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> 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}},
|
||||
|
||||
Binary file not shown.
@@ -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))
|
||||
|
||||
|
||||
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,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";
|
||||
|
||||
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 @@
|
||||
DEV-5f1e0eeb-DEBUG
|
||||
DEV-46d6d0ac-DEBUG
|
||||
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
|
||||
@@ -49,6 +49,7 @@ SAFE_MODE_MANAGED_KEYS = (
|
||||
"EVTuning",
|
||||
"TruckTuning",
|
||||
"CustomAccelProfile",
|
||||
"CustomAccelProfileInitialized",
|
||||
"CustomAccelProfile0MPH",
|
||||
"CustomAccelProfile11MPH",
|
||||
"CustomAccelProfile22MPH",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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():
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user