Compare commits

...

32 Commits

Author SHA1 Message Date
Jason Wen
57ddde15ed try this out 2025-01-29 09:38:01 -05:00
Jason Wen
ef5fa07b69 should be 10 hz 2025-01-28 15:29:07 -05:00
Jason Wen
f99a0be7b6 always okay 2025-01-28 15:19:52 -05:00
Jason Wen
761dc11c8f camera scc duh 2025-01-28 12:37:58 -05:00
Jason Wen
32f25e2119 all off 2025-01-28 12:35:02 -05:00
Jason Wen
922462ad7e Fix none 2025-01-28 11:52:35 -05:00
Jason Wen
eae708bb68 fix events 2025-01-28 03:39:50 -05:00
Jason Wen
dced18e294 do it on OP long too 2025-01-28 01:53:18 -05:00
Jason Wen
a11100fd38 support elantra 2024-25 as hacks 2025-01-28 01:37:21 -05:00
Jason Wen
40c4fe4076 conditionally filter lkas12 2025-01-28 01:36:43 -05:00
Jason Wen
4896e8334b Need to be str 2025-01-26 08:08:04 -05:00
Jason Wen
9bda90ebdb Merge branch 'fcr' into elantra-2024-sp
# Conflicts:
#	opendbc_repo
2025-01-26 05:54:10 -05:00
Jason Wen
50aededd6f no hardcode 2025-01-26 05:53:52 -05:00
Jason Wen
2f4e771ac5 OP long (with 0x485 8 bytes) 2025-01-26 00:37:24 -05:00
Jason Wen
69733087d8 elantra 2024 (hard coded) 2025-01-26 00:32:06 -05:00
Jason Wen
f93404294b use toList 2025-01-26 00:15:50 -05:00
Jason Wen
b2843947bc need that param too 2025-01-26 00:13:23 -05:00
Jason Wen
10848c91cb old qt 2025-01-26 00:13:02 -05:00
Jason Wen
06b7718bcc show demo car 2025-01-26 00:03:37 -05:00
Jason Wen
3fcd3e192c tldr 2025-01-26 00:01:07 -05:00
Jason Wen
6e99de6acb set while initializing 2025-01-25 23:56:26 -05:00
Jason Wen
6a797cdd0e confirm/cancel 2025-01-25 23:46:04 -05:00
Jason Wen
1073f54245 Merge branch 'master-new' into fcr
# Conflicts:
#	opendbc_repo
2025-01-25 23:43:23 -05:00
Jason Wen
c706fc3f55 different prompt in onroad/offroad 2025-01-25 23:42:30 -05:00
Jason Wen
e4e3a7404c more precision search 2025-01-25 22:47:48 -05:00
Jason Wen
5bed14233c set actual fingerprint 2025-01-25 22:36:12 -05:00
Jason Wen
2d25bdca0e bump opendbc 2025-01-25 22:31:25 -05:00
Jason Wen
2e15bfbe92 single list is fine 2025-01-25 22:22:51 -05:00
Jason Wen
999feae5f3 search with user input 2025-01-25 21:25:06 -05:00
Jason Wen
8998ed067e symlink dat 2025-01-25 14:04:30 -05:00
Jason Wen
f418fbddb9 symlink for OP 2025-01-25 02:02:38 -05:00
Jason Wen
7544a47505 QFrame 2025-01-24 22:45:30 -05:00
25 changed files with 891 additions and 26 deletions

View File

@@ -206,6 +206,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"CarParamsSP", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION},
{"CarParamsSPCache", CLEAR_ON_MANAGER_START},
{"CarParamsSPPersistent", PERSISTENT},
{"CarPlatform", PERSISTENT},
{"CarPlatformName", PERSISTENT},
{"EnableGithubRunner", PERSISTENT | BACKUP},
{"ModelRunnerTypeCache", CLEAR_ON_ONROAD_TRANSITION},
{"OffroadMode", CLEAR_ON_MANAGER_START},

2
panda

Submodule panda updated: 4ca963345a...10d700c270

View File

@@ -104,7 +104,9 @@ class Car:
with car.CarParams.from_bytes(cached_params_raw) as _cached_params:
cached_params = _cached_params
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params)
fixed_fingerprint = self.params.get("CarPlatform", encoding='utf-8')
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params, fixed_fingerprint)
interfaces.setup_car_interface_sp(self.CI.CP, self.CI.CP_SP, self.params)
self.RI = get_radar_interface(self.CI.CP, self.CI.CP_SP)
self.CP = self.CI.CP

View File

@@ -35,8 +35,12 @@ sunnypilot_panel_qt_src = [
"sunnypilot/qt/offroad/settings/sunnypilot/mads_settings.cc",
]
vehicle_panel_qt_src = [
"sunnypilot/qt/offroad/settings/vehicle/platform_selector.cc",
]
sp_widgets_src = widgets_src
sp_qt_src = qt_src + sunnypilot_panel_qt_src
sp_qt_src = qt_src + sunnypilot_panel_qt_src + vehicle_panel_qt_src
sp_qt_util = qt_util
Export('sp_widgets_src', 'sp_qt_src', "sp_qt_util")

View File

@@ -0,0 +1,202 @@
/**
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
*
* 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.
*/
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/platform_selector.h"
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QMap>
PlatformSelector::PlatformSelector() : ButtonControl(tr("Vehicle"), "", "") {
QObject::connect(this, &ButtonControl::clicked, [=]() {
if (text() == tr("SEARCH")) {
QString query = InputDialog::getText(tr("Search your vehicle"), this, tr("Enter model year (e.g., 2021) and model name (Toyota Corolla):"), false);
if (query.length() > 0) {
setText(tr("SEARCHING"));
setEnabled(false);
searchPlatforms(query);
refresh(offroad);
}
} else {
params.remove("CarPlatform");
params.remove("CarPlatformName");
refresh(offroad);
}
});
refresh(offroad);
}
void PlatformSelector::refresh(bool _offroad) {
QString platform_param = QString::fromStdString(params.get("CarPlatform"));
if (platform_param.length()) {
setValue(QString::fromStdString(params.get("CarPlatformName")));
setText("REMOVE");
} else {
setValue("");
setText("SEARCH");
}
setEnabled(true);
offroad = _offroad;
}
QMap<QString, QVariantMap> PlatformSelector::loadPlatformList() {
QMap<QString, QVariantMap> platforms;
std::string json_data = util::read_file("../../sunnypilot/selfdrive/car/car_list.json").c_str();
if (json_data.empty()) {
return platforms;
}
QJsonParseError json_error;
QJsonDocument doc = QJsonDocument::fromJson(QString::fromStdString(json_data).toUtf8(), &json_error);
if (doc.isNull()) {
return platforms;
}
if (doc.isObject()) {
QJsonObject obj = doc.object();
for (const QString &key : obj.keys()) {
QJsonObject attributes = obj.value(key).toObject();
QVariantMap platform_data;
QJsonArray yearArray = attributes.value("year").toArray();
QVariantList yearList;
for (const QJsonValue &year : yearArray) {
yearList.append(year.toString());
}
platform_data["year"] = yearList;
platform_data["make"] = attributes.value("make").toString();
platform_data["model"] = attributes.value("model").toString();
platform_data["platform"] = attributes.value("platform").toString();
platform_data["package"] = attributes.value("package").toString();
platforms[key] = platform_data;
}
}
return platforms;
}
void PlatformSelector::searchPlatforms(const QString &query) {
if (query.isEmpty()) {
return;
}
QMap<QString, QVariantMap> platforms = loadPlatformList();
QSet<QString> matched_cars;
QString normalized_query = query.simplified().toLower();
QStringList tokens = normalized_query.split(" ", QString::SkipEmptyParts);
int search_year = -1;
QStringList search_terms;
for (const QString &token : tokens) {
bool ok;
int year = token.toInt(&ok);
if (ok && year >= 1900 && year <= 2100) {
search_year = year;
} else {
search_terms << token;
}
}
for (auto it = platforms.constBegin(); it != platforms.constEnd(); ++it) {
QString platform_name = it.key();
QVariantMap platform_data = it.value();
if (search_year != -1) {
QVariantList year_list = platform_data["year"].toList();
bool year_match = false;
for (const QVariant &year_var : year_list) {
int year = year_var.toString().toInt();
if (year == search_year) {
year_match = true;
break;
}
}
if (!year_match) continue;
}
QString normalized_make = platform_data["make"].toString().normalized(QString::NormalizationForm_KD).toLower();
QString normalized_model = platform_data["model"].toString().normalized(QString::NormalizationForm_KD).toLower();
normalized_make.remove(QRegExp("[^a-zA-Z0-9\\s]"));
normalized_model.remove(QRegExp("[^a-zA-Z0-9\\s]"));
bool all_terms_match = true;
for (const QString &term : search_terms) {
QString normalized_term = term.normalized(QString::NormalizationForm_KD).toLower();
normalized_term.remove(QRegExp("[^a-zA-Z0-9\\s]"));
bool term_matched = false;
if (normalized_make.contains(normalized_term, Qt::CaseInsensitive)) {
term_matched = true;
}
if (!term_matched) {
if (term.contains(QRegExp("[a-z]\\d|\\d[a-z]", Qt::CaseInsensitive))) {
QString clean_model = normalized_model;
QString clean_term = normalized_term;
clean_model.remove(" ");
clean_term.remove(" ");
if (clean_model.contains(clean_term, Qt::CaseInsensitive)) {
term_matched = true;
}
} else {
if (normalized_model.contains(normalized_term, Qt::CaseInsensitive)) {
term_matched = true;
}
}
}
if (!term_matched) {
all_terms_match = false;
break;
}
}
if (all_terms_match) {
matched_cars.insert(platform_name);
}
}
QStringList results = matched_cars.toList();
results.sort();
if (results.isEmpty()) {
ConfirmationDialog::alert(tr("No vehicles found for query: %1").arg(query), this);
return;
}
QString selected_platform = MultiOptionDialog::getSelection(tr("Select a vehicle"), results, "", this);
if (!selected_platform.isEmpty()) {
QVariantMap platform_data = platforms[selected_platform];
const QString offroad_msg = offroad ? tr("This setting will take effect immediately.") :
tr("This setting will take effect once the device enters offroad state.");
const QString msg = QString("<b>%1</b><br><br>%2")
.arg(selected_platform)
.arg(offroad_msg);
QString content("<body><h2 style=\"text-align: center;\">" + tr("Vehicle Selector") + "</h2><br>"
"<p style=\"text-align: center; margin: 0 128px; font-size: 50px;\">" + msg + "</p></body>");
if (ConfirmationDialog(content, tr("Confirm"), tr("Cancel"), true, this).exec()) {
params.put("CarPlatform", platform_data["platform"].toString().toStdString());
params.put("CarPlatformName", selected_platform.toStdString());
}
}
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
*
* 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.
*/
#pragma once
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
class PlatformSelector : public ButtonControl {
Q_OBJECT
public:
PlatformSelector();
public slots:
void refresh(bool _offroad);
private:
void searchPlatforms(const QString &query);
QMap<QString, QVariantMap> loadPlatformList();
Params params;
bool offroad;
};

View File

@@ -7,5 +7,24 @@
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle_panel.h"
VehiclePanel::VehiclePanel(QWidget *parent) : QWidget(parent) {
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
VehiclePanel::VehiclePanel(QWidget *parent) : QFrame(parent) {
main_layout = new QStackedLayout(this);
ListWidget *list = new ListWidget(this);
vehicleScreen = new QWidget(this);
QVBoxLayout *vlayout = new QVBoxLayout(vehicleScreen);
vlayout->setContentsMargins(50, 20, 50, 20);
platformSelector = new PlatformSelector();
list->addItem(platformSelector);
ScrollViewSP *scroller = new ScrollViewSP(list, this);
vlayout->addWidget(scroller);
QObject::connect(uiState(), &UIState::offroadTransition, platformSelector, &PlatformSelector::refresh);
main_layout->addWidget(vehicleScreen);
main_layout->setCurrentWidget(vehicleScreen);
}

View File

@@ -9,9 +9,16 @@
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
class VehiclePanel : public QWidget {
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/platform_selector.h"
class VehiclePanel : public QFrame {
Q_OBJECT
public:
explicit VehiclePanel(QWidget *parent = nullptr);
private:
QStackedLayout* main_layout = nullptr;
QWidget* vehicleScreen = nullptr;
PlatformSelector *platformSelector = nullptr;
};

View File

@@ -220,6 +220,9 @@ def setup_settings_trips(click, pm: PubMaster, scroll=None):
time.sleep(UI_DELAY)
def setup_settings_vehicle(click, pm: PubMaster, scroll=None):
Params().put("CarPlatform", "HONDA_CIVIC_2022")
Params().put("CarPlatformName", "Honda Civic 2022-24")
setup_settings_device(click, pm)
scroll(-400, 278, 862)
click(278, 862)

View File

@@ -674,6 +674,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation type="unfinished">إلغاء</translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">موافق</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished">تأكيد</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">إلغاء</translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -669,6 +669,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation>Aktivieren</translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">Ok</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished">Bestätigen</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Abbrechen</translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -670,6 +670,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation>Cancelar</translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">OK</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished">Confirmar</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Cancelar</translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -670,6 +670,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation>Annuler</translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">Ok</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished">Confirmer</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Annuler</translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -669,6 +669,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation></translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">OK</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -669,6 +669,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation></translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -670,6 +670,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation>Ativar</translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">OK</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished">Confirmar</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Cancelar</translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -669,6 +669,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation></translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -668,6 +668,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete">Tamam</translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished">Onayla</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -669,6 +669,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation></translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -669,6 +669,61 @@ Pause Steering: ALC will be paused after the brake pedal is manually pressed.</s
<translation></translation>
</message>
</context>
<context>
<name>PlatformSelector</name>
<message>
<source>Vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search your vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SEARCHING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No vehicles found for query: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a vehicle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter model year (e.g., 2021) and model name (Toyota Corolla):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vehicle Selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect once the device enters offroad state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This setting will take effect immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ok</source>
<translation type="obsolete"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrimeAdWidget</name>
<message>

View File

@@ -111,7 +111,7 @@ class ModularAssistiveDrivingSystem:
transition_paused_state()
if not (self.pause_lateral_on_brake_toggle and CS.brakePressed) and \
not self.events.contains_in_list(GEARS_ALLOW_PAUSED_SILENT):
not self.events_sp.contains_in_list(GEARS_ALLOW_PAUSED_SILENT):
if self.state_machine.state == State.paused:
self.events_sp.add(EventNameSP.silentLkasEnable)
@@ -160,7 +160,7 @@ class ModularAssistiveDrivingSystem:
self.update_events(CS)
if not self.selfdrive.CP.passive and self.selfdrive.initialized:
self.enabled, self.active = self.state_machine.update(self.events, self.events_sp)
self.enabled, self.active = self.state_machine.update()
# Copy of previous SelfdriveD states for MADS events handling
self.selfdrive.enabled_prev = self.selfdrive.enabled

View File

@@ -25,12 +25,10 @@ Last updated: July 29, 2024
"""
from cereal import log, custom
from openpilot.selfdrive.selfdrived.events import ET, Events
from openpilot.selfdrive.selfdrived.events import ET
from openpilot.selfdrive.selfdrived.state import SOFT_DISABLE_TIME
from openpilot.common.realtime import DT_CTRL
from openpilot.sunnypilot.selfdrive.selfdrived.events import EventsSP
State = custom.ModularAssistiveDrivingSystem.ModularAssistiveDrivingSystemState
EventName = log.OnroadEvent.EventName
EventNameSP = custom.OnroadEventSP.EventName
@@ -41,20 +39,18 @@ ENABLED_STATES = (State.paused, *ACTIVE_STATES)
GEARS_ALLOW_PAUSED_SILENT = [EventNameSP.silentWrongGear, EventNameSP.silentReverseGear, EventNameSP.silentBrakeHold,
EventNameSP.silentDoorOpen, EventNameSP.silentSeatbeltNotLatched, EventNameSP.silentParkBrake]
GEARS_ALLOW_PAUSED = [EventName.wrongGear, EventName.reverseGear, EventName.brakeHold,
EventName.doorOpen, EventName.seatbeltNotLatched, EventName.parkBrake,
*GEARS_ALLOW_PAUSED_SILENT]
EventName.doorOpen, EventName.seatbeltNotLatched, EventName.parkBrake]
class StateMachine:
def __init__(self, mads):
self.selfdrive = mads.selfdrive
self.ss_state_machine = mads.selfdrive.state_machine
self._events = self.selfdrive.events
self._events_sp = self.selfdrive.events_sp
self.state = State.disabled
self._events = Events()
self._events_sp = EventsSP()
def add_current_alert_types(self, alert_type):
if not self.selfdrive.enabled:
self.ss_state_machine.current_alert_types.append(alert_type)
@@ -62,22 +58,19 @@ class StateMachine:
def check_contains(self, event_type: str) -> bool:
return bool(self._events.contains(event_type) or self._events_sp.contains(event_type))
def check_contains_in_list(self, events_list: list[int]) -> bool:
return bool(self._events.contains_in_list(events_list) or self._events_sp.contains_in_list(events_list))
def check_gear_allow_paused_contains_in_list(self) -> bool:
return bool(self._events.contains_in_list(GEARS_ALLOW_PAUSED) or self._events_sp.contains_in_list(GEARS_ALLOW_PAUSED_SILENT))
def update(self, events: Events, events_sp: EventsSP):
def update(self):
# soft disable timer and current alert types are from the state machine of openpilot
# decrement the soft disable timer at every step, as it's reset on
# entrance in SOFT_DISABLING state
self._events = events
self._events_sp = events_sp
# ENABLED, SOFT DISABLING, PAUSED, OVERRIDING
if self.state != State.disabled:
# user and immediate disable always have priority in a non-disabled state
if self.check_contains(ET.USER_DISABLE):
if events_sp.has(EventNameSP.silentLkasDisable) or events_sp.has(EventNameSP.silentBrakeHold):
if self._events_sp.has(EventNameSP.silentLkasDisable) or self._events_sp.has(EventNameSP.silentBrakeHold):
self.state = State.paused
else:
self.state = State.disabled
@@ -141,7 +134,7 @@ class StateMachine:
elif self.state == State.disabled:
if self.check_contains(ET.ENABLE):
if self.check_contains(ET.NO_ENTRY):
if self.check_contains_in_list(GEARS_ALLOW_PAUSED):
if self.check_gear_allow_paused_contains_in_list():
self.state = State.paused
self.add_current_alert_types(ET.NO_ENTRY)

View File

@@ -29,7 +29,7 @@ from pytest_mock import MockerFixture
from cereal import custom
from openpilot.common.realtime import DT_CTRL
from openpilot.sunnypilot.mads.state import StateMachine, SOFT_DISABLE_TIME, GEARS_ALLOW_PAUSED
from openpilot.sunnypilot.mads.state import StateMachine, SOFT_DISABLE_TIME
from openpilot.selfdrive.selfdrived.events import ET, NormalPermanentAlert
from openpilot.sunnypilot.selfdrive.selfdrived.events import EVENTS_SP
@@ -129,7 +129,7 @@ class TestMADSStateMachine:
def test_no_entry(self):
for et in ENABLE_EVENT_TYPES:
self.events_sp.add(make_event([ET.NO_ENTRY, et]))
if not self.state_machine.check_contains_in_list(GEARS_ALLOW_PAUSED):
if not self.state_machine.check_gear_allow_paused_contains_in_list():
self.state_machine.update(self.events, self.events_sp)
assert self.state_machine.state == State.disabled
self.reset()

View File

@@ -0,0 +1 @@
../../../opendbc_repo/opendbc/sunnypilot/car/car_list.json