mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-29 00:03:57 +08:00
Default Highway Smoothing to 70 percent once
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -202,7 +202,8 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"PauseLateralOnSignal", {PERSISTENT, BOOL, "0"}},
|
||||
{"LateralResumeDelay", {PERSISTENT, FLOAT, "0.0"}},
|
||||
{"TurnAssist", {PERSISTENT, BOOL, "1"}},
|
||||
{"HighwaySmoothingLevel", {PERSISTENT, FLOAT, "10.0"}},
|
||||
{"HighwaySmoothingDefaultApplied", {PERSISTENT, BOOL}},
|
||||
{"HighwaySmoothingLevel", {PERSISTENT, FLOAT, "3.7"}},
|
||||
{"GMPedalLongitudinal", {PERSISTENT, BOOL, "0"}},
|
||||
{"ApiCache_Device", {PERSISTENT, STRING}},
|
||||
{"ApiCache_FirehoseStats", {PERSISTENT, JSON}},
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -223,9 +223,9 @@ def slider(fixture):
|
||||
return page, index, page['rows'][index]
|
||||
|
||||
|
||||
def test_default_off_at_left(gateway):
|
||||
def test_default_is_seventy_percent_with_off_still_at_left(gateway):
|
||||
_, _, row = slider(gateway)
|
||||
assert (row['value'], row['defaultValue'], row['minimum'], row['maximum'], row['unit']) == ('0', '0', 0, 100, '%')
|
||||
assert (row['value'], row['defaultValue'], row['minimum'], row['maximum'], row['unit']) == ('70', '70', 0, 100, '%')
|
||||
assert row['step'] == 1 and row['resetAvailable']
|
||||
assert '0% is off' in row['reason'] and 'higher values add more smoothing' in row['reason']
|
||||
assert read_gain(gateway.params) == 1
|
||||
@@ -242,7 +242,7 @@ def test_saved_effect_is_preserved_without_migration(gateway, saved, shown):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('strength', 'gain'), [(0, 1.), (50, .55), (100, .1)])
|
||||
def test_higher_strength_saves_more_smoothing_and_default_disables(gateway, strength, gain):
|
||||
def test_higher_strength_saves_more_smoothing_and_default_restores_seventy(gateway, strength, gain):
|
||||
page, index, _ = slider(gateway)
|
||||
intent = gateway.gateway.preview(page['view'], index, 0, gateway.session, gateway.generation, value=strength)
|
||||
assert gateway.gateway.confirm(intent['intent'], gateway.session, gateway.generation)
|
||||
@@ -251,8 +251,8 @@ def test_higher_strength_saves_more_smoothing_and_default_disables(gateway, stre
|
||||
page, index, _ = slider(gateway)
|
||||
intent = gateway.gateway.preview(page['view'], index, 0, gateway.session, gateway.generation, reset_default=True)
|
||||
assert gateway.gateway.confirm(intent['intent'], gateway.session, gateway.generation)
|
||||
assert read_gain(gateway.params) == 1
|
||||
assert slider(gateway)[2]['value'] == '0'
|
||||
assert read_gain(gateway.params) == pytest.approx(.37)
|
||||
assert slider(gateway)[2]['value'] == '70'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('value', [-1, 101, float('nan'), float('inf')])
|
||||
@@ -272,3 +272,18 @@ def test_stale_source_cannot_overwrite_a_newer_setting(gateway):
|
||||
except SettingsChanged:
|
||||
pass
|
||||
assert read_gain(gateway.params) == .3
|
||||
|
||||
|
||||
def test_enrollment_then_galaxy_opt_out_persists_across_startups(gateway):
|
||||
from openpilot.starpilot.settings_retirement import retire_settings
|
||||
assert gateway.params.get_default_value(KEY) == pytest.approx(3.7)
|
||||
retire_settings(gateway.params)
|
||||
assert slider(gateway)[2]['value'] == '70'
|
||||
assert read_gain(gateway.params) == pytest.approx(.37)
|
||||
page, index, _ = slider(gateway)
|
||||
intent = gateway.gateway.preview(page['view'], index, 0, gateway.session, gateway.generation, value=0)
|
||||
assert gateway.gateway.confirm(intent['intent'], gateway.session, gateway.generation)
|
||||
for _ in range(3):
|
||||
retire_settings(gateway.params)
|
||||
assert slider(gateway)[2]['value'] == '0'
|
||||
assert read_gain(gateway.params) == 1.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Retire redundant switches once, preserving their effective saved behavior."""
|
||||
"""Reconcile one-time settings changes before default creation and consumers."""
|
||||
|
||||
import base64
|
||||
import json
|
||||
@@ -22,10 +22,17 @@ def retire_settings(params):
|
||||
"""Run parked after state admission and before default creation/consumers.
|
||||
|
||||
Write child reconciliation before retiring each parent. Corrupt switches are
|
||||
archived in an optional document and treated as Off; this never enables a
|
||||
dormant feature. Returns concrete reconciliation issues for manager logging.
|
||||
archived in an optional document and treated as Off. Smoothing enrollment
|
||||
is independent of retired switches and preserves later strength changes.
|
||||
Returns concrete reconciliation issues for manager logging.
|
||||
"""
|
||||
issues = []
|
||||
smoothing_migrated, readable = read_saved(params, "HighwaySmoothingDefaultApplied", 8)
|
||||
if readable and smoothing_migrated is None:
|
||||
params.put("HighwaySmoothingLevel", 3.7, block=True)
|
||||
params.put_bool("HighwaySmoothingDefaultApplied", True, block=True)
|
||||
elif not readable or smoothing_migrated != b"1":
|
||||
issues.append("Invalid highway smoothing enrollment state retained; saved strength unchanged")
|
||||
evidence = {}
|
||||
evidence_writable = True
|
||||
raw, readable = read_saved(params, EVIDENCE_KEY, 65536)
|
||||
|
||||
@@ -170,3 +170,51 @@ class TestSettingsRetirement(unittest.TestCase):
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
class TestHighwaySmoothingEnrollment(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.directory.cleanup)
|
||||
self.params = SavedParams(self.directory.name)
|
||||
|
||||
def test_new_and_existing_off_or_custom_strength_migrate_once(self):
|
||||
for saved in (None, 10., 1., 5.5, 3.7):
|
||||
with self.subTest(saved=saved), tempfile.TemporaryDirectory() as root:
|
||||
params = SavedParams(root)
|
||||
params.put("SteerFriction", .123)
|
||||
if saved is not None:
|
||||
params.put("HighwaySmoothingLevel", saved)
|
||||
retire_settings(params)
|
||||
self.assertEqual(params.get("HighwaySmoothingLevel"), b"3.7")
|
||||
self.assertEqual(params.get("HighwaySmoothingDefaultApplied"), b"1")
|
||||
self.assertEqual(params.get("SteerFriction"), b"0.123")
|
||||
retire_settings(SavedParams(root))
|
||||
self.assertEqual(params.get("HighwaySmoothingLevel"), b"3.7")
|
||||
for chosen in (10., 6., 1.):
|
||||
params.put("HighwaySmoothingLevel", chosen)
|
||||
retire_settings(SavedParams(root))
|
||||
self.assertEqual(params.get("HighwaySmoothingLevel"), str(chosen).encode())
|
||||
|
||||
def test_invalid_enrollment_marker_does_not_reenable_smoothing(self):
|
||||
for marker in (b"0", b"invalid"):
|
||||
self.params.put("HighwaySmoothingLevel", 10.)
|
||||
Path(self.params.get_param_path("HighwaySmoothingDefaultApplied")).write_bytes(marker)
|
||||
issues = retire_settings(self.params)
|
||||
self.assertTrue(any("smoothing enrollment" in issue for issue in issues))
|
||||
self.assertEqual(self.params.get("HighwaySmoothingLevel"), b"10.0")
|
||||
self.assertEqual(self.params.get("HighwaySmoothingDefaultApplied"), marker)
|
||||
|
||||
def test_failed_strength_write_is_not_marked_complete(self):
|
||||
from unittest.mock import patch
|
||||
original_put = self.params.put
|
||||
def put(key, value, block=True):
|
||||
if key == "HighwaySmoothingLevel":
|
||||
raise OSError("disk full")
|
||||
original_put(key, value, block=block)
|
||||
with patch.object(self.params, "put", side_effect=put), self.assertRaises(OSError):
|
||||
retire_settings(self.params)
|
||||
self.assertIsNone(self.params.get("HighwaySmoothingDefaultApplied"))
|
||||
retire_settings(self.params)
|
||||
self.assertEqual(self.params.get("HighwaySmoothingLevel"), b"3.7")
|
||||
self.assertEqual(self.params.get("HighwaySmoothingDefaultApplied"), b"1")
|
||||
|
||||
@@ -833,7 +833,7 @@ class FeatureSettingsOwner:
|
||||
return FeatureRow(KEY, "Highway Smoothing", f"{strength:.0f}" if valid else "Invalid saved value", raw,
|
||||
step=1.0 if valid else 0., minimum=0., maximum=100., unit="%",
|
||||
available=allowed and (valid or self.authority("parked_preferences") and self._readable(KEY)),
|
||||
repair_value="0" if not valid else "", default_value="0",
|
||||
repair_value="0" if not valid else "", default_value="70",
|
||||
vehicle_fingerprint=self.vehicle_fingerprint(), capability=capability,
|
||||
reason="Reduces small steering corrections on highways above about 40 mph. 0% is off; higher values add more smoothing.")
|
||||
|
||||
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern const uint8_t gitversion[29];
|
||||
const uint8_t gitversion[29] = "DEV-7fe19d9c-Pf38f504f-DEBUG";
|
||||
const uint8_t gitversion[29] = "DEV-5a62d763-Pf38f504f-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.
@@ -1 +1 @@
|
||||
DEV-7fe19d9c-Pf38f504f-DEBUG
|
||||
DEV-5a62d763-Pf38f504f-DEBUG
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "641d96b3d3c570d2188521eff62ce0b43ab7d3c5ee88096f61defd42fa70e3e5", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "48bdf642b57bb456c64886c0eb9be4c451fc1b7003975315bbf35cc14533aee2", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user