Merge branch 'master-new' into alc-new

This commit is contained in:
Kumar
2025-03-22 21:49:02 -07:00
committed by GitHub
5 changed files with 31 additions and 14 deletions
@@ -67,14 +67,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) {
}
});
connect(buttons["resetParams"], &PushButtonSP::clicked, [=]() {
if (ConfirmationDialog::confirm(tr("Are you sure you want to reset all sunnypilot settings to default ? This cannot be undone."), tr("Reset"), this)) {
int rm = std::system("sudo rm -rf /data/params/d/*");
if (rm == 0) {
Hardware::reboot();
}
}
});
connect(buttons["resetParams"], &PushButtonSP::clicked, this, &DevicePanelSP::resetSettings);
addItem(device_grid_layout);
@@ -141,6 +134,19 @@ void DevicePanelSP::setOffroadMode() {
updateState();
}
void DevicePanelSP::resetSettings() {
if (ConfirmationDialog::confirm(tr("Are you sure you want to reset all sunnypilot settings to default? Once the settings are reset, there is no going back."), tr("Reset"), this)) {
if (ConfirmationDialog::confirm(tr("The reset cannot be undone. You have been warned."), tr("Confirm"), this)) {
const std::vector<std::string> keys = params.allKeys();
for (const auto& key : keys) {
params.remove(key);
}
Hardware::reboot();
}
}
}
void DevicePanelSP::showEvent(QShowEvent *event) {
updateState();
}
@@ -18,6 +18,7 @@ public:
void showEvent(QShowEvent *event) override;
void setOffroadMode();
void updateState();
void resetSettings();
private:
std::map<QString, PushButtonSP*> buttons;
@@ -5,12 +5,14 @@ This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
import os
import tomllib
from difflib import SequenceMatcher
from opendbc.car import structs
from openpilot.common.basedir import BASEDIR
TORQUE_NN_MODEL_PATH = os.path.join(BASEDIR, "sunnypilot", "neural_network_data", "neural_network_lateral_control")
TORQUE_NN_MODEL_SUBSTITUTE_PATH = os.path.join(BASEDIR, "opendbc", "car", "torque_data/substitute.toml")
MOCK_MODEL_PATH = os.path.join(TORQUE_NN_MODEL_PATH, "MOCK.json")
@@ -42,16 +44,24 @@ def get_nn_model_path(CP: structs.CarParams) -> tuple[str, str, bool]:
model_path, max_similarity = check_nn_path(nn_candidate)
exact_match = max_similarity >= 0.99
if car_fingerprint not in model_path or 0.0 <= max_similarity < 0.8:
nn_candidate = car_fingerprint
model_path, max_similarity = check_nn_path(nn_candidate)
if 0.0 <= max_similarity < 0.8:
model_path = MOCK_MODEL_PATH
with open(TORQUE_NN_MODEL_SUBSTITUTE_PATH, 'rb') as f:
sub = tomllib.load(f)
sub_candidate = sub.get(car_fingerprint, car_fingerprint)
for candidate in [car_fingerprint, sub_candidate]:
model_path, max_similarity = check_nn_path(candidate)
exact_match = False
if CP.steerControlType == structs.CarParams.SteerControlType.angle:
model_path = MOCK_MODEL_PATH
model_name = os.path.splitext(os.path.basename(model_path))[0]
exact_match = max_similarity >= 0.99
return model_path, model_name, exact_match
@@ -1,4 +1,3 @@
from numpy.ma.testutils import assert_equal
from parameterized import parameterized
from opendbc.car.car_helpers import interfaces
@@ -13,8 +12,8 @@ from openpilot.sunnypilot.selfdrive.car import interfaces as sunnypilot_interfac
class TestNNTorqueModel:
@parameterized.expand([(HONDA.HONDA_CIVIC, True), (TOYOTA.TOYOTA_RAV4, True), (HYUNDAI.HYUNDAI_SANTA_CRUZ_1ST_GEN, False)])
def test_load_model(self, car_name, should_load_model):
@parameterized.expand([HONDA.HONDA_CIVIC, TOYOTA.TOYOTA_RAV4, HYUNDAI.HYUNDAI_SANTA_CRUZ_1ST_GEN])
def test_load_model(self, car_name):
params = Params()
params.put_bool("NeuralNetworkLateralControl", True)
@@ -29,4 +28,4 @@ class TestNNTorqueModel:
controller = LatControlTorque(CP.as_reader(), CP_SP.as_reader(), CI)
assert_equal(should_load_model, controller.extension.has_nn_model)
assert controller.extension.has_nn_model
+1
View File
@@ -91,6 +91,7 @@ def register(show_spinner=False) -> str | None:
if time.monotonic() - start_time > 60 and show_spinner:
spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})")
return UNREGISTERED_DONGLE_ID # hotfix to prevent an infinite wait for registration
if show_spinner:
spinner.close()