This commit is contained in:
firestar5683
2026-06-20 12:33:29 -05:00
parent e4809535dc
commit fbb6eb651c
4 changed files with 31 additions and 14 deletions
+8 -8
View File
@@ -169,18 +169,18 @@ def get_testing_ground_1_brake_switch_bias(v_ego: float) -> int:
def shape_truck_positive_accel(accel: float, v_ego: float, enabled: bool) -> float:
if not enabled or accel <= 0.0 or v_ego < 8.0:
if not enabled or accel <= 0.0 or v_ego < 12.0:
return accel
low_scale = float(np.interp(v_ego, [8.0, 15.0, 25.0, 35.0], [0.60, 0.45, 0.32, 0.25]))
mid_scale = float(np.interp(v_ego, [8.0, 15.0, 25.0, 35.0], [0.82, 0.72, 0.60, 0.52]))
low_scale = float(np.interp(v_ego, [12.0, 18.0, 25.0, 35.0], [0.95, 0.88, 0.82, 0.76]))
mid_scale = float(np.interp(v_ego, [12.0, 18.0, 25.0, 35.0], [0.98, 0.94, 0.89, 0.84]))
if accel <= 0.18:
if accel <= 0.12:
return accel * low_scale
if accel <= 0.45:
return float(np.interp(accel, [0.18, 0.45], [0.18 * low_scale, 0.45 * mid_scale]))
if accel <= 0.8:
return float(np.interp(accel, [0.45, 0.8], [0.45 * mid_scale, 0.8]))
if accel <= 0.35:
return float(np.interp(accel, [0.12, 0.35], [0.12 * low_scale, 0.35 * mid_scale]))
if accel <= 0.65:
return float(np.interp(accel, [0.35, 0.65], [0.35 * mid_scale, 0.65]))
return accel
@@ -569,13 +569,13 @@ def test_calc_pedal_command_keeps_strong_positive_requests_responsive():
def test_shape_truck_positive_accel_softens_small_highway_requests():
shaped = shape_truck_positive_accel(0.12, 26.0, True)
assert shaped < 0.05
assert 0.09 < shaped < 0.10
def test_shape_truck_positive_accel_keeps_mid_follow_requests_available():
shaped = shape_truck_positive_accel(0.45, 13.5, True)
assert 0.30 < shaped < 0.35
assert 0.43 < shaped < 0.45
def test_shape_truck_positive_accel_leaves_large_requests_alone():
@@ -8,6 +8,7 @@ from openpilot.starpilot.common.accel_profile import ACCELERATION_PROFILES, DECE
from openpilot.starpilot.controls.lib.starpilot_acceleration import (
A_CRUISE_MIN_ECO,
StarPilotAcceleration,
get_max_accel_standard,
get_slc_shaped_min_accel,
)
@@ -149,3 +150,19 @@ def test_slc_coast_window_disabled_when_target_drop_is_not_slc():
accel.update(57.0 * CV.MPH_TO_MS, sm, make_toggles(deceleration_profile=DECELERATION_PROFILES["ECO"]))
assert accel.min_accel == pytest.approx(A_CRUISE_MIN_ECO)
def test_truck_tuning_standard_profile_limits_launch_spike():
assert get_max_accel_standard(0.0, ev_tuning=False, truck_tuning=True) < 3.0
def test_truck_tuning_standard_profile_keeps_mid_speed_headroom():
truck = get_max_accel_standard(15.0, ev_tuning=False, truck_tuning=True)
gas = get_max_accel_standard(15.0, ev_tuning=False, truck_tuning=False)
assert truck >= gas - 0.05
assert truck > 1.25
def test_truck_tuning_standard_profile_does_not_fall_off_at_highway_speed():
assert get_max_accel_standard(25.0, ev_tuning=False, truck_tuning=True) >= 0.85
+4 -4
View File
@@ -45,10 +45,10 @@ A_CRUISE_MAX_VALS_STANDARD_GAS = [2.00, 1.80, 1.55, 1.30, 1.05, 0.85, 0.55]
A_CRUISE_MAX_VALS_SPORT_GAS = [2.50, 2.25, 1.95, 1.60, 1.30, 1.05, 0.75]
A_CRUISE_MAX_VALS_SPORT_PLUS_GAS = [3.50, 3.20, 2.80, 2.35, 1.90, 1.55, 1.15]
A_CRUISE_MAX_VALS_ECO_TRUCK = [3.00, 1.05, 0.60, 0.50, 0.50, 0.45, 0.35]
A_CRUISE_MAX_VALS_STANDARD_TRUCK = [6.00, 1.10, 0.70, 0.60, 0.55, 0.45, 0.35]
A_CRUISE_MAX_VALS_SPORT_TRUCK = [6.00, 1.15, 0.75, 0.70, 0.60, 0.50, 0.40]
A_CRUISE_MAX_VALS_SPORT_PLUS_TRUCK = [6.00, 1.30, 0.90, 0.80, 0.70, 0.60, 0.45]
A_CRUISE_MAX_VALS_ECO_TRUCK = [2.00, 1.50, 1.20, 1.00, 0.82, 0.62, 0.40]
A_CRUISE_MAX_VALS_STANDARD_TRUCK = [2.75, 2.00, 1.65, 1.35, 1.10, 0.88, 0.58]
A_CRUISE_MAX_VALS_SPORT_TRUCK = [3.25, 2.40, 2.00, 1.65, 1.35, 1.10, 0.78]
A_CRUISE_MAX_VALS_SPORT_PLUS_TRUCK = [4.00, 2.80, 2.35, 1.95, 1.60, 1.30, 0.98]
def akima_interp(x, xp, fp):