mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 03:03:41 +08:00
Tune End to End Boost by Personality
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -253,7 +253,11 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"DriverLockoutCount", {CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON, INT, "0"}},
|
||||
{"AlphaLongitudinalEnabled", {PERSISTENT, BOOL}},
|
||||
{"ExperimentalMode", {PERSISTENT, BOOL}},
|
||||
{"ExperimentalSpeedNudge", {PERSISTENT, BOOL, "1"}},
|
||||
{"ExperimentalSpeedNudge", {PERSISTENT, BOOL, "0"}},
|
||||
{"AggressivePersonalityBoost", {PERSISTENT, FLOAT, "100"}},
|
||||
{"StandardPersonalityBoost", {PERSISTENT, FLOAT, "100"}},
|
||||
{"RelaxedPersonalityBoost", {PERSISTENT, FLOAT, "100"}},
|
||||
{"TrafficPersonalityBoost", {PERSISTENT, FLOAT, "200"}},
|
||||
{"FirmwareQueryDone", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION | CLEAR_ON_OFFROAD_TRANSITION, BOOL}},
|
||||
{"ForcePowerDown", {PERSISTENT, BOOL}},
|
||||
{"GitBranch", {PERSISTENT, STRING}},
|
||||
|
||||
@@ -151,6 +151,7 @@ class LongitudinalPlanner:
|
||||
self.allow_throttle = True
|
||||
self.accel_boost = AccelBoost()
|
||||
self.personality_accel_boost = PersonalityAccelBoost(dt)
|
||||
self.personality_boost_scale = 1.0
|
||||
self.encouragement = Encouragement()
|
||||
self.plan_drive_id = 0
|
||||
self.throttle_gate = ModelThrottleGate()
|
||||
@@ -563,21 +564,25 @@ class LongitudinalPlanner:
|
||||
boost_blocked = (
|
||||
not e2e_active or not profile_eligible or reset_state or self.fcw or not self.allow_throttle or self.force_stop_plan.forcing or
|
||||
output_should_stop_mpc or output_should_stop_e2e or cruise_should_stop or self.mpc.solution_status != 0 or
|
||||
curve.effective_mps is not None or traffic_mode is not False or sm['controlsState'].forceDecel or
|
||||
curve.effective_mps is not None or traffic_mode is None or sm['controlsState'].forceDecel or
|
||||
not cs.canValid or cs.canTimeout or cs.gasPressed or cs.brakePressed or
|
||||
not all(getattr(sm, health, {}).get(service, False)
|
||||
for health in ('alive', 'valid', 'freq_ok') for service in ('modelV2', 'carState', 'radarState'))
|
||||
)
|
||||
use_nudge = traffic_mode is True or relaxed and experimental_speed_nudge is True
|
||||
encouraged_model = self.encouragement.update(
|
||||
sm, self.CP, now_ns=sample_now_ns, drive_id=drive_id, dt=self.dt, target_speed=v_cruise,
|
||||
model_accel=output_a_target_e2e, mpc_accel=output_a_target_mpc, cruise_accel=self.a_cruise,
|
||||
lateral_accel=(v_ego ** 2 * steer_angle_without_offset * CV.DEG_TO_RAD / (self.CP.steerRatio * self.CP.wheelbase)
|
||||
if self.CP.steerRatio > 0 and self.CP.wheelbase > 0 else math.inf),
|
||||
blocked=bool(boost_blocked or not relaxed or experimental_speed_nudge is not True))
|
||||
if boost_blocked or relaxed:
|
||||
blocked=bool(boost_blocked or not use_nudge or self.personality_boost_scale == 0.0),
|
||||
scale=self.personality_boost_scale)
|
||||
if boost_blocked or relaxed or traffic_mode is True or self.personality_boost_scale == 0.0:
|
||||
self.personality_accel_boost.reset()
|
||||
else:
|
||||
encouraged_model = self.personality_accel_boost.update(sm, output_a_target_e2e, 0.0)
|
||||
boosted_model = self.personality_accel_boost.update(sm, output_a_target_e2e, 0.0)
|
||||
scale = self.personality_boost_scale if output_a_target_e2e > 0.0 else min(self.personality_boost_scale, 1.0)
|
||||
encouraged_model = output_a_target_e2e + scale * (boosted_model - output_a_target_e2e)
|
||||
manual_model = self.accel_boost.update(sm, output_a_target_e2e, output_a_target_mpc, self.a_cruise)
|
||||
output_a_target_e2e = max(manual_model, encouraged_model)
|
||||
|
||||
|
||||
@@ -557,6 +557,9 @@ def starpilot_main():
|
||||
return force_stop_owner.sample(sm, CP, now_ns=clock_pair[0], now_boot_ns=clock_pair[1],
|
||||
drive_id=current_start_ns, follow_seconds=follow_seconds,
|
||||
traffic_mode=traffic_mode, takeoff_enabled=faster_lead_takeoff)
|
||||
speed_nudge = nudge_preferences.sample(now_ns)
|
||||
personality = "traffic" if traffic_mode is True else str(sm["selfdriveState"].personality)
|
||||
longitudinal_planner.personality_boost_scale = nudge_preferences.boost_scales.get(personality, 1.0)
|
||||
curve_result = update_curve_frame(longitudinal_planner, sm, CP, now_ns, host=curve_host,
|
||||
cruise_ceiling=cruise_ceiling,
|
||||
profile_tuning=profile_tuning,
|
||||
@@ -566,7 +569,7 @@ def starpilot_main():
|
||||
lead_approach_key=lead_approach_key, force_stop_provider=force_stop_provider,
|
||||
drive_id=current_start_ns, event=curve_event,
|
||||
faster_lead_takeoff=faster_lead_takeoff, wheel_coast=(wheel_coast, params),
|
||||
experimental_speed_nudge=nudge_preferences.sample(now_ns))
|
||||
experimental_speed_nudge=speed_nudge)
|
||||
if curve_preferences is not None and curve_host is not None and curve_result is not None:
|
||||
curve_preferences.persist(curve_host, curve_result, now_ns)
|
||||
assert curve_status is not None
|
||||
|
||||
@@ -71,6 +71,10 @@ DESCRIPTIONS = {
|
||||
'RedneckCruise': 'Adjusts conventional factory cruise with Resume and Set after the next startup.',
|
||||
'LowSpeedCruiseOnSet': ('Uses the vehicle’s minimum engagement speed as the floor when pressing SET with StarPilot cruise. ' +
|
||||
'SET uses your current speed when you are above that floor.'),
|
||||
'StandardPersonalityBoost': 'Scales the Standard End to End acceleration boost. 100% is stock and 0% is off.',
|
||||
'AggressivePersonalityBoost': 'Scales the Aggressive End to End acceleration boost. 100% is stock and 0% is off.',
|
||||
'RelaxedPersonalityBoost': 'Scales clear-road assistance when Speed Nudge in Relaxed is on. 100% is the regular nudge.',
|
||||
'TrafficPersonalityBoost': 'Scales clear-road End to End assistance in Traffic Mode. 200% is the default and 0% is off.',
|
||||
'ExperimentalSpeedNudge': ('Helps End to End return to set speed on clear roads in the Relaxed personality. ' +
|
||||
'Leads, stops, curve limits and driver overrides retain priority.'),
|
||||
'FasterLeadTakeoff': ('Improves launches from a stop and responds sooner when a lead starts moving. ' +
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
"DriverCamera",
|
||||
"EVTuning",
|
||||
"EngageVolume",
|
||||
"AggressivePersonalityBoost",
|
||||
"StandardPersonalityBoost",
|
||||
"RelaxedPersonalityBoost",
|
||||
"TrafficPersonalityBoost",
|
||||
"ExperimentalSpeedNudge",
|
||||
"FasterLeadTakeoff",
|
||||
"ForceAutoTuneOff",
|
||||
|
||||
@@ -17,7 +17,7 @@ from openpilot.starpilot.ui.feature_settings_owner import FeatureSettingsOwner
|
||||
@pytest.fixture(params=[
|
||||
("LeadApproachBuffer", "Approaching lead buffer", "Off"),
|
||||
("FasterLeadTakeoff", "Faster Takeoffs", "Off"),
|
||||
("ExperimentalSpeedNudge", "Speed Nudge in Relaxed", "On"),
|
||||
("ExperimentalSpeedNudge", "Speed Nudge in Relaxed", "Off"),
|
||||
("LowSpeedCruiseOnSet", "Low-Speed Cruise Start", "Off"),
|
||||
("DisengageOnAccelerator", "Disengage on Accelerator Pedal", "Off"),
|
||||
])
|
||||
@@ -31,8 +31,9 @@ def setup(tmp_path, request):
|
||||
return params, current, SettingsGateway(params, Mock(wraps=context), clock=lambda: 10.0)
|
||||
|
||||
|
||||
def page_row(gateway, label):
|
||||
page = gateway.page("profiles", "session", b"generation")
|
||||
def page_row(gateway, label, section=None):
|
||||
section = section or ("relaxed" if label == "Speed Nudge in Relaxed" else "profiles")
|
||||
page = gateway.page(section, "session", b"generation")
|
||||
index = next(index for index, row in enumerate(page["rows"]) if row["label"] == label)
|
||||
return page, index, page["rows"][index]
|
||||
|
||||
@@ -142,3 +143,29 @@ def test_accelerator_row_is_only_added_to_galaxy(tmp_path, galaxy):
|
||||
owner = FeatureSettingsOwner(params, lambda _: True, vehicle_fingerprint=lambda: None, galaxy=lambda: galaxy)
|
||||
rows = owner.snapshot("profiles", parked=True, system_long=False, lateral_context=False, metric=False).rows
|
||||
assert any(row.key == "DisengageOnAccelerator" for row in rows) == galaxy
|
||||
|
||||
|
||||
def test_galaxy_boost_slider_round_trip_and_planner_preference(tmp_path):
|
||||
from openpilot.starpilot.longitudinal.encouragement import BOOST_KEYS, NudgePreferences
|
||||
|
||||
params = Params(str(tmp_path))
|
||||
cp = CarInterface.get_non_essential_params(CAR.HONDA_CIVIC)
|
||||
context = SimpleNamespace(sample=lambda: AuthorityContext(True, cp, b"current-honda-cp"))
|
||||
gateway = SettingsGateway(params, Mock(wraps=context), clock=lambda: 10.0)
|
||||
viewer = NudgePreferences(params)
|
||||
assert not viewer.sample(1_000_000_000)
|
||||
assert viewer.boost_scales == {"relaxed": 1., "standard": 1., "aggressive": 1., "traffic": 2.}
|
||||
for name, chosen in (("relaxed", 65), ("standard", 150), ("aggressive", 200), ("traffic", 100)):
|
||||
page, index, row = page_row(gateway, "End to End Boost Strength", name)
|
||||
default = 200 if name == "traffic" else 100
|
||||
assert (float(row["value"]), float(row["defaultValue"]), row["minimum"], row["maximum"], row["step"], row["unit"]) == (default, default, 0, 200, 5, "%")
|
||||
assert row["available"] and row["level"] == "advanced"
|
||||
intent = gateway.preview(page["view"], index, 0, "session", b"generation", value=str(chosen))
|
||||
assert gateway.confirm(intent["intent"], "session", b"generation")
|
||||
assert params.get(BOOST_KEYS[name]) == chosen
|
||||
_, _, nudge = page_row(gateway, "Speed Nudge in Relaxed")
|
||||
assert nudge["level"] == "advanced" and nudge["value"] == nudge["defaultValue"] == "Off"
|
||||
assert not viewer.sample(2_000_000_000)
|
||||
assert viewer.boost_scales == {"relaxed": .65, "standard": 1.5, "aggressive": 2., "traffic": 1.}
|
||||
Path(params.get_param_path(BOOST_KEYS["relaxed"])).write_bytes(b"201")
|
||||
assert not viewer.sample(3_000_000_000) and viewer.boost_scales["relaxed"] == 0.
|
||||
|
||||
@@ -5,6 +5,8 @@ import math
|
||||
from openpilot.starpilot.saved_source import read_saved
|
||||
|
||||
KEY = "ExperimentalSpeedNudge"
|
||||
BOOST_KEYS = {name: name.title() + "PersonalityBoost" for name in ("relaxed", "standard", "aggressive", "traffic")}
|
||||
MAX_BOOST_PERCENT = 200.0
|
||||
|
||||
SOURCES = ('carState', 'carControl', 'controlsState', 'selfdriveState', 'radarState', 'modelV2')
|
||||
MAX_SOURCE_AGE_NS = 250_000_000
|
||||
@@ -26,7 +28,7 @@ class Encouragement:
|
||||
self.hesitation_accel: float | None = None
|
||||
|
||||
def update(self, sm, cp, *, now_ns, drive_id, dt, target_speed, model_accel, mpc_accel, cruise_accel,
|
||||
lateral_accel, blocked):
|
||||
lateral_accel, blocked, scale=1.0):
|
||||
eligible = False
|
||||
model_ns = 0
|
||||
try:
|
||||
@@ -72,13 +74,15 @@ class Encouragement:
|
||||
if self.clear_seconds > SETTLE_SECONDS and car.aEgo < RECOVERY_ACCEL:
|
||||
self.boost = min(MAX_BOOST, self.boost + BOOST_RATE * dt)
|
||||
gap_scale = min(1., max(0., (target_speed - car.vEgo - .2) / 1.8))
|
||||
return min(max(model_accel, self.boost * gap_scale), mpc_accel, cruise_accel)
|
||||
bonus = max(0.0, self.boost * gap_scale - model_accel)
|
||||
return min(model_accel + scale * bonus, mpc_accel, cruise_accel)
|
||||
|
||||
|
||||
class NudgePreferences:
|
||||
def __init__(self, params):
|
||||
self.params = params
|
||||
self.enabled = False
|
||||
self.boost_scales = dict.fromkeys(BOOST_KEYS, 1.0)
|
||||
self.next_ns = 0
|
||||
self.last_ns = 0
|
||||
|
||||
@@ -90,7 +94,14 @@ class NudgePreferences:
|
||||
self.next_ns = now_ns + 1_000_000_000
|
||||
try:
|
||||
raw, readable = read_saved(self.params, KEY, 16)
|
||||
self.enabled = readable and raw in (None, b'1')
|
||||
self.enabled = readable and raw == b'1'
|
||||
except (OSError, RuntimeError, TypeError, ValueError):
|
||||
self.enabled = False
|
||||
for name, key in BOOST_KEYS.items():
|
||||
try:
|
||||
raw, readable = read_saved(self.params, key, 16)
|
||||
percent = float(self.params.get_default_value(key) if raw is None else raw)
|
||||
self.boost_scales[name] = percent / 100.0 if readable and 0.0 <= percent <= MAX_BOOST_PERCENT else 0.0
|
||||
except (OSError, RuntimeError, TypeError, ValueError):
|
||||
self.boost_scales[name] = 0.0
|
||||
return self.enabled
|
||||
|
||||
@@ -21,7 +21,7 @@ from openpilot.starpilot.longitudinal.tests.test_cruise_ceiling import ACTIVE
|
||||
class PlannerOptions(TypedDict, total=False):
|
||||
curve_ceiling: CurveCeiling
|
||||
cruise_ceiling: CruiseCeiling
|
||||
traffic_mode: bool
|
||||
traffic_mode: bool | None
|
||||
|
||||
|
||||
def frame(tick):
|
||||
@@ -107,6 +107,15 @@ def test_native_planner_helps_weak_clear_road_recovery_toward_set_speed(factory,
|
||||
assert planner.encouragement.boost == pytest.approx(MAX_BOOST)
|
||||
|
||||
|
||||
def test_relaxed_scale_respects_planner_ceilings():
|
||||
owner = Encouragement()
|
||||
for tick in range(120):
|
||||
step(owner, tick)
|
||||
assert step(owner, 120, scale=2.0, mpc_accel=.8, cruise_accel=1.) == pytest.approx(.8)
|
||||
assert step(owner, 121, scale=2.0, mpc_accel=2., cruise_accel=1.5) == pytest.approx(2 * MAX_BOOST)
|
||||
assert step(owner, 122, scale=0.0, model_accel=.2) == pytest.approx(.2)
|
||||
|
||||
|
||||
def test_started_recovery_keeps_building_assistance_past_weak_acceleration():
|
||||
owner = Encouragement()
|
||||
for tick in range(60):
|
||||
@@ -286,7 +295,7 @@ def test_native_planner_limits_and_immediate_withdrawal(case):
|
||||
if case == 'stale':
|
||||
sm.logMonoTime['modelV2'] = now - 250_000_001
|
||||
if case == 'traffic':
|
||||
options['traffic_mode'] = True
|
||||
options['traffic_mode'] = None
|
||||
with patch.object(original.encouragement, 'update', side_effect=lambda *a, **kw: kw['model_accel']):
|
||||
original.update(sm, now_ns=now, **options)
|
||||
current.update(sm, now_ns=now, **options)
|
||||
@@ -329,6 +338,22 @@ def test_native_planner_override_release_uses_higher_request_without_stacking(fa
|
||||
assert planner.accel_boost.total_boost == planner.encouragement.boost == 0.
|
||||
|
||||
|
||||
def test_traffic_boost_uses_clear_road_gates_with_relaxed_nudge_off():
|
||||
planner = LongitudinalPlanner(cp(), init_v=20.)
|
||||
planner.personality_boost_scale = 2.
|
||||
for tick in range(200):
|
||||
sm, now = frame(tick)
|
||||
planner.update(sm, now_ns=now, traffic_mode=True, experimental_speed_nudge=False)
|
||||
assert planner.output_a_target <= planner.a_cruise + 1e-6
|
||||
assert planner.mpc.solution_status == 0
|
||||
assert .6 < planner.output_a_target <= 2 * MAX_BOOST + 1e-6
|
||||
sm, now = frame(200)
|
||||
lead = sm['radarState'].leadOne
|
||||
lead.present, lead.dRel, lead.vLead, lead.vLeadK, lead.vRel = True, 35., 15., 15., -5.
|
||||
planner.update(sm, now_ns=now, traffic_mode=True, experimental_speed_nudge=False)
|
||||
assert planner.encouragement.boost == 0.
|
||||
|
||||
|
||||
def test_native_planner_preserves_manual_override_input_and_boost():
|
||||
planner = LongitudinalPlanner(cp(), init_v=20.)
|
||||
for tick in range(120):
|
||||
@@ -393,20 +418,20 @@ def test_native_planner_recovers_despite_recorded_acceleration_noise(factory, ca
|
||||
assert maximum_extra > .05
|
||||
|
||||
|
||||
@pytest.mark.parametrize('raw,readable,enabled', [(None, True, True), (b'1', True, True), (b'0', True, False),
|
||||
@pytest.mark.parametrize('raw,readable,enabled', [(None, True, False), (b'1', True, True), (b'0', True, False),
|
||||
(b'true', True, False), (None, False, False)])
|
||||
def test_speed_nudge_preference_defaults_on_and_rejects_invalid_sources(raw, readable, enabled):
|
||||
def test_speed_nudge_preference_defaults_off_and_rejects_invalid_sources(raw, readable, enabled):
|
||||
with patch('openpilot.starpilot.longitudinal.encouragement.read_saved', return_value=(raw, readable)) as read:
|
||||
preferences = NudgePreferences(object())
|
||||
preferences = NudgePreferences(Mock(get_default_value=lambda _: 100.))
|
||||
assert preferences.sample(1_000_000_000) is enabled
|
||||
assert preferences.sample(1_500_000_000) is enabled
|
||||
assert read.call_count == 1
|
||||
assert read.call_count == 5
|
||||
read.return_value = (b'0', True)
|
||||
assert not preferences.sample(2_000_000_000)
|
||||
assert read.call_count == 2
|
||||
assert read.call_count == 10
|
||||
read.return_value = (b'1', True)
|
||||
assert preferences.sample(500_000_000)
|
||||
assert read.call_count == 3
|
||||
assert read.call_count == 15
|
||||
|
||||
|
||||
@pytest.mark.parametrize('factory,car', [(HondaInterface, HONDA.HONDA_CIVIC),
|
||||
|
||||
@@ -162,6 +162,30 @@ class TestModelLeadTrajectory(unittest.TestCase):
|
||||
self.assertFalse(boost.called)
|
||||
self.assertEqual(planner.personality_accel_boost.bias_filter.x, 0.0)
|
||||
|
||||
def test_actual_planner_scales_only_the_automatic_extra_acceleration(self):
|
||||
for personality in ('standard', 'aggressive'):
|
||||
outputs = []
|
||||
for scale in (0., .5, 1., 2.):
|
||||
planner = self.planner()
|
||||
planner.personality_boost_scale = scale
|
||||
planner.a_cruise = .8
|
||||
planner.output_a_target = .8
|
||||
planner.mpc.a_prev[:] = .8
|
||||
sm, _ = inputs()
|
||||
sm['radarState'].leadOne.present = sm['radarState'].leadTwo.present = False
|
||||
sm['selfdriveState'].experimentalMode = True
|
||||
sm['selfdriveState'].personality = personality
|
||||
sm['modelV2'].action.desiredAcceleration = .10
|
||||
sm['modelV2'].position.x = [0., 250.]
|
||||
sm['modelV2'].position.t = [0., 10.]
|
||||
for _ in range(50):
|
||||
planner.update(sm, now_ns=NOW, experimental_speed_nudge=False)
|
||||
outputs.append(planner.output_a_target)
|
||||
self.assertAlmostEqual(outputs[0], .10)
|
||||
self.assertGreater(outputs[2], outputs[0])
|
||||
self.assertAlmostEqual(outputs[1], (outputs[0] + outputs[2]) / 2)
|
||||
self.assertAlmostEqual(outputs[3], outputs[0] + 2 * (outputs[2] - outputs[0]))
|
||||
|
||||
def test_planner_fault_stale_future_and_missing_health_fall_back_exactly(self):
|
||||
variants = [lambda s: s.logMonoTime.update(modelV2=NOW-150_000_001),
|
||||
lambda s: s.logMonoTime.update(radarState=NOW+1),
|
||||
|
||||
@@ -4,7 +4,7 @@ from openpilot.selfdrive.car.cruise import LOW_SPEED_CRUISE_ON_SET
|
||||
from openpilot.starpilot.curve_speed.preferences import MASTER_KEY as CURVE_MASTER_KEY, NO_LEAD_KEY as CURVE_NO_LEAD_KEY
|
||||
from openpilot.starpilot.lateral.lane_centering import STRENGTH_MAX
|
||||
from openpilot.starpilot.longitudinal.downhill_coast import KEY as DOWNHILL_KEY, SURPLUS_KEY, MAX_SURPLUS_MPH
|
||||
from openpilot.starpilot.longitudinal.encouragement import KEY as NUDGE_KEY
|
||||
from openpilot.starpilot.longitudinal.encouragement import BOOST_KEYS, MAX_BOOST_PERCENT, KEY as NUDGE_KEY
|
||||
from openpilot.starpilot.longitudinal.lead_approach_runtime import KEY as LEAD_APPROACH_KEY
|
||||
from openpilot.starpilot.longitudinal.lead_takeoff_preferences import KEY as LEAD_TAKEOFF_KEY
|
||||
from openpilot.starpilot.longitudinal.planner_selection import KEY as PLANNER_SELECTION_KEY
|
||||
@@ -34,7 +34,7 @@ BOOL_DEFAULTS = {
|
||||
LEAD_APPROACH_KEY: False,
|
||||
LEAD_TAKEOFF_KEY: False,
|
||||
DOWNHILL_KEY: False,
|
||||
NUDGE_KEY: True,
|
||||
NUDGE_KEY: False,
|
||||
LOW_SPEED_CRUISE_ON_SET: False,
|
||||
"DisengageOnAccelerator": False,
|
||||
AGGRESSIVE_COOLING_KEY: False,
|
||||
@@ -43,6 +43,7 @@ BOOL_DEFAULTS = {
|
||||
"ForceAutoTuneOff": False, "AlwaysOnLateral": True, "NostalgiaMode": False,
|
||||
}
|
||||
FLOAT_SPECS = {
|
||||
**dict.fromkeys(BOOST_KEYS.values(), (0.0, MAX_BOOST_PERCENT, 5.0, "%")),
|
||||
SURPLUS_KEY: (0, MAX_SURPLUS_MPH, 1, "mph"),
|
||||
"ForceStopDistanceOffset": (-20, 20, 1, "ft"),
|
||||
"LaneCenterOffset": (-0.3, 0.3, 0.01, "m"),
|
||||
|
||||
@@ -26,7 +26,7 @@ from openpilot.starpilot.longitudinal.accel_profile import A_CRUISE_MAX_VALS_TRA
|
||||
from openpilot.starpilot.longitudinal.profile_runtime import TRAFFIC_CRUISE_BRAKE_MAGNITUDE
|
||||
from openpilot.starpilot.longitudinal.lead_approach_runtime import KEY as LEAD_APPROACH_KEY
|
||||
from openpilot.starpilot.longitudinal.lead_takeoff_preferences import KEY as LEAD_TAKEOFF_KEY
|
||||
from openpilot.starpilot.longitudinal.encouragement import KEY as NUDGE_KEY
|
||||
from openpilot.starpilot.longitudinal.encouragement import BOOST_KEYS, KEY as NUDGE_KEY
|
||||
from openpilot.starpilot.longitudinal.downhill_coast import KEY as DOWNHILL_KEY, SURPLUS_KEY
|
||||
from openpilot.selfdrive.car.cruise import LOW_SPEED_CRUISE_ON_SET
|
||||
from openpilot.starpilot.longitudinal.planner_selection import KEY as PLANNER_SELECTION_KEY, save_selection
|
||||
@@ -1231,9 +1231,6 @@ class FeatureSettingsOwner:
|
||||
rows.append(self._bool_row(LEAD_TAKEOFF_KEY, "Faster Takeoffs", self.authority("preferences"),
|
||||
reason="Improves launches from a stop and responds sooner when a lead starts moving. " +
|
||||
"Selected acceleration profiles, stop detection and vehicle limits still apply."))
|
||||
rows.append(self._bool_row(NUDGE_KEY, "Speed Nudge in Relaxed", self.authority("preferences"),
|
||||
reason="Helps End to End return to set speed on clear roads in the Relaxed personality. " +
|
||||
"Leads, stops, curve limits and driver overrides retain priority."))
|
||||
downhill_allowed = allowed and self.authority("long") and self._value(PLANNER_SELECTION_KEY)[0] == "1"
|
||||
downhill = self._bool_row(DOWNHILL_KEY, "Coast Downhills", downhill_allowed,
|
||||
"Lets gravity carry the car above set speed without targeting a higher speed. Changes apply while driving.")
|
||||
@@ -1292,6 +1289,9 @@ class FeatureSettingsOwner:
|
||||
elif page == FeaturePage.TRAFFIC:
|
||||
level = SettingLevel.ADVANCED
|
||||
title = "Traffic Profile"
|
||||
rows.append(self._number_row(BOOST_KEYS["traffic"], "End to End Boost Strength",
|
||||
configurable and system_long and self._value(PLANNER_SELECTION_KEY)[0] == "1",
|
||||
level=SettingLevel.ADVANCED))
|
||||
rows.extend(self.traffic_profiles.rows(configurable, system_long, repair_allowed=parked))
|
||||
for category in PRESETS:
|
||||
rows.append(FeatureRow("", category.title(), ""))
|
||||
@@ -1301,6 +1301,13 @@ class FeatureSettingsOwner:
|
||||
level = SettingLevel.ADVANCED
|
||||
allowed = configurable and system_long
|
||||
name = page.title()
|
||||
if page == "relaxed":
|
||||
rows.append(self._bool_row(NUDGE_KEY, "Speed Nudge in Relaxed", self.authority("preferences"),
|
||||
reason="Helps End to End return to set speed on clear roads in the Relaxed personality.",
|
||||
level=SettingLevel.ADVANCED))
|
||||
rows.append(self._number_row(BOOST_KEYS[page], "End to End Boost Strength",
|
||||
allowed and self._value(PLANNER_SELECTION_KEY)[0] == "1",
|
||||
level=SettingLevel.ADVANCED))
|
||||
health = read_profile_health(self.params)
|
||||
for suffix, label in (
|
||||
("Follow", "Low-speed follow"), ("FollowHigh", "High-speed follow"),
|
||||
@@ -1609,6 +1616,8 @@ class FeatureSettingsOwner:
|
||||
return False
|
||||
if key == "ForceStopDistanceOffset" and self._value("ForceStops")[0] != "1" and not (reset_default and float(request.value) == float(self._default(key))):
|
||||
return False
|
||||
if key in BOOST_KEYS.values() and self._value(PLANNER_SELECTION_KEY)[0] != "1":
|
||||
return False
|
||||
if key in (DOWNHILL_KEY, SURPLUS_KEY) and (self._value(PLANNER_SELECTION_KEY)[0] != "1" or
|
||||
key == SURPLUS_KEY and self._value(DOWNHILL_KEY)[0] != "1"):
|
||||
return False
|
||||
|
||||
@@ -7,17 +7,17 @@ from openpilot.starpilot.ui.feature_settings_state import FeatureSettingsRequest
|
||||
from openpilot.starpilot.galaxy.settings import PAGES
|
||||
|
||||
|
||||
def test_nudge_is_default_on_persistent_and_editable_without_a_vehicle():
|
||||
def test_nudge_is_default_off_persistent_and_editable_without_a_vehicle():
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
params = Params(directory)
|
||||
assert params.get_type('ExperimentalSpeedNudge') == ParamKeyType.BOOL
|
||||
assert params.get_default_value('ExperimentalSpeedNudge') is True
|
||||
assert params.get_default_value('ExperimentalSpeedNudge') is False
|
||||
owner = FeatureSettingsOwner(params, lambda group: group == 'preferences', vehicle_fingerprint=lambda: None)
|
||||
state = owner.snapshot('profiles', parked=False, system_long=False, lateral_context=False, metric=False)
|
||||
state = owner.snapshot('relaxed', parked=False, system_long=False, lateral_context=False, metric=False)
|
||||
row = next(row for row in state.rows if row.key == 'ExperimentalSpeedNudge')
|
||||
assert row.label == 'Speed Nudge in Relaxed'
|
||||
assert row.value == row.default_value == 'On'
|
||||
assert row.available and row.vehicle_fingerprint is None
|
||||
assert row.value == row.default_value == 'Off'
|
||||
assert row.available and row.vehicle_fingerprint is None and row.level == 'advanced'
|
||||
assert owner.apply(FeatureSettingsRequest(row.key, row.source, 'Off'))
|
||||
assert Params(directory).get('ExperimentalSpeedNudge') is False
|
||||
assert Path(params.get_param_path(row.key)).read_bytes() == b'0'
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "7fcc75b246b1aa02bbf3d0ce7ce3ffe0707a6d44edf39174e31659f2b15b4cc1", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "340895f2a58fca3ddac4c6dc616b865ffb6b99b20863299982f9266dc8b95bfd", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user