mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-07-26 20:32:04 +08:00
honda
This commit is contained in:
@@ -142,7 +142,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
|
||||
// StarPilot variables
|
||||
{"AccelerationPath", {PERSISTENT, BOOL, "1", "0", 2}},
|
||||
{"AccelerationProfile", {PERSISTENT, INT, "2", "0", 0}},
|
||||
{"AccelerationProfile", {PERSISTENT, INT, "0", "0", 0}},
|
||||
{"AdjacentLeadsUI", {PERSISTENT, BOOL, "1", "0", 3}},
|
||||
{"AdjacentPath", {PERSISTENT, BOOL, "0", "0", 3}},
|
||||
{"AdjacentPathMetrics", {PERSISTENT, BOOL, "0", "0", 3}},
|
||||
|
||||
@@ -15,13 +15,13 @@ def civic_bosch_modified_lateral_testing_ground_active() -> bool:
|
||||
def get_civic_bosch_modified_pid_output_scale(desired_angle_deg: float, desired_angle_delta_deg: float, v_ego: float) -> float:
|
||||
abs_angle = abs(desired_angle_deg)
|
||||
speed_weight = min(max((v_ego - 4.0) / 10.0, 0.0), 1.0)
|
||||
center_speed_weight = 0.65 + (0.35 * speed_weight)
|
||||
center_weight = min(max((16.0 - abs_angle) / 16.0, 0.0), 1.0)
|
||||
angle_weight = min(max((abs_angle - 16.0) / 12.0, 0.0), 1.0)
|
||||
center_speed_weight = 0.70 + (0.30 * speed_weight)
|
||||
center_weight = min(max((18.0 - abs_angle) / 18.0, 0.0), 1.0)
|
||||
angle_weight = min(max((abs_angle - 18.0) / 10.0, 0.0), 1.0)
|
||||
phase = desired_angle_deg * desired_angle_delta_deg
|
||||
|
||||
is_left = desired_angle_deg > 0.0
|
||||
center_taper = 0.30
|
||||
center_taper = 0.32
|
||||
base_scale = 0.10 if is_left else 0.12
|
||||
turn_in_scale = 0.10 if is_left else 0.14
|
||||
unwind_scale = 0.14 if is_left else 0.20
|
||||
@@ -33,7 +33,7 @@ def get_civic_bosch_modified_pid_output_scale(desired_angle_deg: float, desired_
|
||||
elif phase < -0.2:
|
||||
scale -= speed_weight * angle_weight * unwind_scale
|
||||
|
||||
return max(scale, 0.74)
|
||||
return max(scale, 0.70)
|
||||
|
||||
|
||||
class LatControlPID(LatControl):
|
||||
|
||||
@@ -385,8 +385,9 @@ class TestLatControl:
|
||||
assert get_civic_bosch_modified_pid_output_scale(10.0, 0.0, 12.0) < 1.0
|
||||
assert get_civic_bosch_modified_pid_output_scale(12.0, 0.0, 12.0) < 1.0
|
||||
assert get_civic_bosch_modified_pid_output_scale(14.0, 0.0, 12.0) < 1.0
|
||||
assert get_civic_bosch_modified_pid_output_scale(16.0, 0.0, 12.0) < 1.0
|
||||
assert get_civic_bosch_modified_pid_output_scale(0.0, 0.0, 6.0) < 0.9
|
||||
assert get_civic_bosch_modified_pid_output_scale(16.0, 0.0, 12.0) > get_civic_bosch_modified_pid_output_scale(8.0, 0.0, 12.0)
|
||||
assert get_civic_bosch_modified_pid_output_scale(18.0, 0.0, 12.0) > get_civic_bosch_modified_pid_output_scale(8.0, 0.0, 12.0)
|
||||
assert get_civic_bosch_modified_pid_output_scale(20.0, 0.5, 12.0) > get_civic_bosch_modified_pid_output_scale(20.0, 0.0, 12.0)
|
||||
assert get_civic_bosch_modified_pid_output_scale(-20.0, -0.5, 12.0) > get_civic_bosch_modified_pid_output_scale(-20.0, 0.0, 12.0)
|
||||
assert get_civic_bosch_modified_pid_output_scale(20.0, -0.5, 12.0) < get_civic_bosch_modified_pid_output_scale(20.0, 0.0, 12.0)
|
||||
|
||||
@@ -925,7 +925,7 @@ class StarPilotVariables:
|
||||
custom_accel_profile_tuning = advanced_longitudinal_tuning and self.get_value("CustomAccelProfile")
|
||||
acceleration_profile_tuning = longitudinal_tuning or custom_accel_profile_tuning
|
||||
toggle.acceleration_profile = normalize_acceleration_profile(
|
||||
self.get_value("AccelerationProfile", cast=None, condition=acceleration_profile_tuning, default=ACCELERATION_PROFILES["SPORT"])
|
||||
self.get_value("AccelerationProfile", cast=None, condition=acceleration_profile_tuning, default=ACCELERATION_PROFILES["STANDARD"])
|
||||
)
|
||||
toggle.deceleration_profile = normalize_deceleration_profile(
|
||||
self.get_value("DecelerationProfile", cast=None, condition=longitudinal_tuning, default=DECELERATION_PROFILES["ECO"])
|
||||
|
||||
@@ -16,6 +16,8 @@ QT_STEER_KP_PLACEHOLDER = 1.0
|
||||
|
||||
LAUNCH_PARAM_MIGRATION_MARKER = ".starpilot_launch_param_migrations_v2"
|
||||
BRANCH_DEFAULTS_MIGRATION_MARKER = ".starpilot_branch_defaults_migrations_v1"
|
||||
ACCELERATION_PROFILE_MIGRATION_MARKER = ".starpilot_acceleration_profile_default_v1"
|
||||
STANDARD_ACCELERATION_PROFILE = 0
|
||||
|
||||
BRANCH_BOOL_DEFAULTS = {
|
||||
"ConditionalExperimental": True,
|
||||
@@ -53,8 +55,10 @@ BRANCH_FLOAT_DEFAULTS = {
|
||||
class ParamsLike(Protocol):
|
||||
def get_param_path(self, key: str = "") -> str: ...
|
||||
def get_bool(self, key: str) -> bool: ...
|
||||
def get_int(self, key: str) -> int: ...
|
||||
def get_float(self, key: str) -> float: ...
|
||||
def put_bool(self, key: str, value: bool) -> None: ...
|
||||
def put_int(self, key: str, value: int) -> None: ...
|
||||
def put_float(self, key: str, value: float) -> None: ...
|
||||
|
||||
|
||||
@@ -70,6 +74,10 @@ def _branch_defaults_marker_path(params: ParamsLike) -> Path:
|
||||
return Path(params.get_param_path()) / BRANCH_DEFAULTS_MIGRATION_MARKER
|
||||
|
||||
|
||||
def _acceleration_profile_marker_path(params: ParamsLike) -> Path:
|
||||
return Path(params.get_param_path()) / ACCELERATION_PROFILE_MIGRATION_MARKER
|
||||
|
||||
|
||||
def _apply_legacy_launch_param_migrations(params: ParamsLike, marker: Path) -> None:
|
||||
if marker.exists():
|
||||
return
|
||||
@@ -112,12 +120,25 @@ def _apply_branch_default_migration(params: ParamsLike, marker: Path) -> None:
|
||||
marker.touch()
|
||||
|
||||
|
||||
def _apply_acceleration_profile_default_migration(params: ParamsLike, marker: Path) -> None:
|
||||
if marker.exists():
|
||||
return
|
||||
|
||||
marker.parent.mkdir(parents=True, exist_ok=True)
|
||||
params.put_int("AccelerationProfile", STANDARD_ACCELERATION_PROFILE)
|
||||
marker.touch()
|
||||
|
||||
|
||||
def apply_launch_param_migrations(params: ParamsLike, marker_path: Path | None = None,
|
||||
branch_defaults_marker_path: Path | None = None) -> None:
|
||||
branch_defaults_marker_path: Path | None = None,
|
||||
acceleration_profile_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.
|
||||
_apply_branch_default_migration(params, branch_defaults_marker_path or _branch_defaults_marker_path(params))
|
||||
_apply_acceleration_profile_default_migration(
|
||||
params, acceleration_profile_marker_path or _acceleration_profile_marker_path(params)
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
from openpilot.system.manager.launch_param_migrations import (
|
||||
ACCELERATION_PROFILE_MIGRATION_MARKER,
|
||||
BRANCH_DEFAULTS_MIGRATION_MARKER,
|
||||
DEFAULT_STEER_KP,
|
||||
LAUNCH_PARAM_MIGRATION_MARKER,
|
||||
STANDARD_ACCELERATION_PROFILE,
|
||||
apply_launch_param_migrations,
|
||||
)
|
||||
|
||||
@@ -32,9 +34,16 @@ class FileBackedFakeParams:
|
||||
value = self.get(key)
|
||||
return float(value) if value is not None else 0.0
|
||||
|
||||
def get_int(self, key):
|
||||
value = self.get(key)
|
||||
return int(float(value)) if value is not None else 0
|
||||
|
||||
def put_bool(self, key, value):
|
||||
Path(self.get_param_path(key)).write_text("1" if value else "0", encoding="utf-8")
|
||||
|
||||
def put_int(self, key, value):
|
||||
Path(self.get_param_path(key)).write_text(str(int(value)), encoding="utf-8")
|
||||
|
||||
def put_float(self, key, value):
|
||||
Path(self.get_param_path(key)).write_text(str(float(value)), encoding="utf-8")
|
||||
|
||||
@@ -141,3 +150,28 @@ def test_apply_launch_param_migrations_does_not_reapply_branch_defaults_after_ma
|
||||
assert params.get_float("AggressiveFollowHigh") == 2.0
|
||||
assert params.get_float("StandardJerkAcceleration") == 25.0
|
||||
assert params.get_float("RelaxedFollow") == 2.0
|
||||
|
||||
|
||||
def test_apply_launch_param_migrations_updates_acceleration_profile_for_existing_installs(tmp_path):
|
||||
params = FileBackedFakeParams(tmp_path / "params")
|
||||
|
||||
params.put_int("AccelerationProfile", 2)
|
||||
(tmp_path / "params" / LAUNCH_PARAM_MIGRATION_MARKER).touch()
|
||||
(tmp_path / "params" / BRANCH_DEFAULTS_MIGRATION_MARKER).touch()
|
||||
|
||||
apply_launch_param_migrations(params)
|
||||
|
||||
assert params.get_int("AccelerationProfile") == STANDARD_ACCELERATION_PROFILE
|
||||
assert (tmp_path / "params" / ACCELERATION_PROFILE_MIGRATION_MARKER).is_file()
|
||||
|
||||
|
||||
def test_apply_launch_param_migrations_does_not_reapply_acceleration_profile_after_marker(tmp_path):
|
||||
params = FileBackedFakeParams(tmp_path / "params")
|
||||
acceleration_profile_marker = tmp_path / "params" / ACCELERATION_PROFILE_MIGRATION_MARKER
|
||||
|
||||
params.put_int("AccelerationProfile", 3)
|
||||
acceleration_profile_marker.touch()
|
||||
|
||||
apply_launch_param_migrations(params)
|
||||
|
||||
assert params.get_int("AccelerationProfile") == 3
|
||||
|
||||
Reference in New Issue
Block a user