mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-30 00:33:41 +08:00
Calm RAV4 TSS2 low-speed center corrections
This commit is contained in:
@@ -4,6 +4,7 @@ import math
|
||||
import numpy as np
|
||||
|
||||
from opendbc.car import structs
|
||||
from openpilot.common.constants import CV
|
||||
from opendbc.car.toyota.values import CAR
|
||||
from openpilot.starpilot.lateral.torque_shaping import get_standard_friction_threshold, sigmoid
|
||||
|
||||
@@ -30,7 +31,10 @@ def friction_threshold(speed, setpoint, jerk):
|
||||
|
||||
|
||||
def center_output_scale(setpoint, speed):
|
||||
return 1.0 - .12 * center_envelope(setpoint, speed)
|
||||
speed_weight = float(np.interp(max(speed, 0.0), [15 * CV.MPH_TO_MS, 20 * CV.MPH_TO_MS,
|
||||
40 * CV.MPH_TO_MS, 50 * CV.MPH_TO_MS], [0., 1., 1., 0.]))
|
||||
center_weight = float(np.interp(abs(setpoint), [.30, .65], [1., 0.]))
|
||||
return 1.0 - (.12 + .08 * speed_weight * center_weight) * center_envelope(setpoint, speed)
|
||||
|
||||
|
||||
class Rav4TSS2TorquePolicy:
|
||||
|
||||
@@ -85,7 +85,7 @@ def test_latest_cleanup_knots_taper_and_left_right_symmetry(speed, increment):
|
||||
for accel, jerk in ((.85, 0), (0, .75)):
|
||||
env = (1 / (1 + math.exp((speed - 13) / 3))) * (1 / (1 + math.exp((abs(accel) - .30) / .08)))
|
||||
assert friction_threshold(speed, accel, jerk) == pytest.approx(.30 * (1 + .14 * env))
|
||||
assert .88 <= center_output_scale(0, speed) <= 1
|
||||
assert .80 <= center_output_scale(0, speed) <= 1
|
||||
|
||||
|
||||
def test_exact_scope_excludes_related_racks_and_bad_tunes():
|
||||
@@ -249,3 +249,27 @@ def test_actual_ui_controller_switch_preserves_learning_and_explicit_toggle(init
|
||||
assert learning_allowed(saved, cp)
|
||||
unrelated = read_preference(saved, unrelated_cp)
|
||||
assert unrelated.valid and not unrelated.enabled and unrelated.source == "scope"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mph", [0., 10., 15., 50., 60., 80.])
|
||||
@pytest.mark.parametrize("accel", [0., .15, -.15, .7, -.7])
|
||||
def test_low_speed_taper_preserves_other_speed_ranges(mph, accel):
|
||||
from openpilot.common.constants import CV
|
||||
from openpilot.starpilot.lateral.rav4_tss2_policy import center_envelope
|
||||
speed = mph * CV.MPH_TO_MS
|
||||
assert center_output_scale(accel, speed) == 1.0 - .12 * center_envelope(accel, speed)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mph", [20., 27., 35., 40.])
|
||||
def test_low_speed_center_taper_is_small_symmetric_and_fades_for_curves(mph):
|
||||
from openpilot.common.constants import CV
|
||||
from openpilot.starpilot.lateral.rav4_tss2_policy import center_envelope
|
||||
speed = mph * CV.MPH_TO_MS
|
||||
for accel in (0., .15, .30):
|
||||
previous = 1.0 - .12 * center_envelope(accel, speed)
|
||||
adjusted = center_output_scale(accel, speed)
|
||||
assert 0 < previous - adjusted <= .08
|
||||
assert .8 <= adjusted <= 1.
|
||||
assert adjusted == center_output_scale(-accel, speed)
|
||||
for accel in (.65, -.65, 1., -1.):
|
||||
assert center_output_scale(accel, speed) == 1.0 - .12 * center_envelope(accel, speed)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "78d3dd7d3c367905a043ae893bffccaf5c4a667a57eef39e0304216a914b73d6", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "fef1c4ace34f8bfeb0f4ee4ef7c0f4ef928c9a8da6a17e559bbf76ea1a7a6f65", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user