mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-10 15:54:49 +08:00
Compare commits
32 Commits
dockerize-
...
elantra-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57ddde15ed | ||
|
|
ef5fa07b69 | ||
|
|
f99a0be7b6 | ||
|
|
761dc11c8f | ||
|
|
32f25e2119 | ||
|
|
922462ad7e | ||
|
|
eae708bb68 | ||
|
|
dced18e294 | ||
|
|
a11100fd38 | ||
|
|
40c4fe4076 | ||
|
|
4896e8334b | ||
|
|
9bda90ebdb | ||
|
|
50aededd6f | ||
|
|
2f4e771ac5 | ||
|
|
69733087d8 | ||
|
|
f93404294b | ||
|
|
b2843947bc | ||
|
|
10848c91cb | ||
|
|
06b7718bcc | ||
|
|
3fcd3e192c | ||
|
|
6e99de6acb | ||
|
|
6a797cdd0e | ||
|
|
1073f54245 | ||
|
|
c706fc3f55 | ||
|
|
e4e3a7404c | ||
|
|
5bed14233c | ||
|
|
2d25bdca0e | ||
|
|
2e15bfbe92 | ||
|
|
999feae5f3 | ||
|
|
8998ed067e | ||
|
|
f418fbddb9 | ||
|
|
7544a47505 |
@@ -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},
|
||||
|
||||
Submodule opendbc_repo updated: 4fa4acd981...d63406b0ef
2
panda
2
panda
Submodule panda updated: 4ca963345a...10d700c270
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
sunnypilot/selfdrive/car/car_list.json
Symbolic link
1
sunnypilot/selfdrive/car/car_list.json
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../opendbc_repo/opendbc/sunnypilot/car/car_list.json
|
||||
Reference in New Issue
Block a user