mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-10 02:03:42 +08:00
Merge branch 'master-new' of https://github.com/sunnypilot/sunnypilot into master-new
This commit is contained in:
@@ -170,6 +170,7 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"BackupManager_RestoreVersion", PERSISTENT},
|
||||
|
||||
// sunnypilot car specific params
|
||||
{"HyundaiLongitudinalTuning", PERSISTENT},
|
||||
{"HyundaiRadarTracks", PERSISTENT},
|
||||
{"HyundaiRadarTracksConfirmed", PERSISTENT},
|
||||
{"HyundaiRadarTracksPersistent", PERSISTENT},
|
||||
|
||||
@@ -17,7 +17,7 @@ static const QStringList supportedBrands = {
|
||||
"mazda",
|
||||
"nissan",
|
||||
"rivian",
|
||||
"subaru"
|
||||
"subaru",
|
||||
"tesla",
|
||||
"toyota",
|
||||
"volkswagen",
|
||||
|
||||
@@ -6,3 +6,16 @@
|
||||
*/
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/brand_settings_interface.h"
|
||||
|
||||
BrandSettingsInterface::BrandSettingsInterface(QWidget *parent) : QWidget(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
list = new ListWidget(this, false);
|
||||
main_layout->addWidget(list);
|
||||
}
|
||||
|
||||
void BrandSettingsInterface::updatePanel(bool _offroad) {
|
||||
offroad = _offroad;
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
@@ -7,15 +7,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
|
||||
class BrandSettingsInterface : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BrandSettingsInterface(QWidget *parent = nullptr) : QWidget(parent) {}
|
||||
explicit BrandSettingsInterface(QWidget *parent = nullptr);
|
||||
virtual ~BrandSettingsInterface() = default;
|
||||
|
||||
virtual void updatePanel(bool offroad) = 0;
|
||||
void updatePanel(bool _offroad);
|
||||
virtual void updateSettings() = 0;
|
||||
|
||||
protected:
|
||||
ListWidget *list = nullptr;
|
||||
Params params;
|
||||
bool offroad = false;
|
||||
};
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/chrysler_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
ChryslerSettings::ChryslerSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void ChryslerSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void ChryslerSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class ChryslerSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit ChryslerSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/ford_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
FordSettings::FordSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void FordSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void FordSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class FordSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit FordSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/gm_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
GMSettings::GMSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void GMSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void GMSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class GMSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit GMSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/honda_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
HondaSettings::HondaSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void HondaSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void HondaSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class HondaSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit HondaSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,51 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/hyundai_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
HyundaiSettings::HyundaiSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void HyundaiSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
std::vector<QString> tuning_texts{ tr("Off"), tr("Dynamic"), tr("Predictive") };
|
||||
longitudinalTuningToggle = new ButtonParamControl(
|
||||
"HyundaiLongitudinalTuning",
|
||||
tr("Custom Longitudinal Tuning"),
|
||||
"",
|
||||
"",
|
||||
tuning_texts,
|
||||
500
|
||||
);
|
||||
QObject::connect(longitudinalTuningToggle, &ButtonParamControlSP::buttonToggled, this, &HyundaiSettings::updateSettings);
|
||||
list->addItem(longitudinalTuningToggle);
|
||||
longitudinalTuningToggle->showDescription();
|
||||
}
|
||||
|
||||
void HyundaiSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
auto longitudinal_tuning_param = std::atoi(params.get("HyundaiLongitudinalTuning").c_str());
|
||||
|
||||
auto cp_bytes = params.get("CarParamsPersistent");
|
||||
if (!cp_bytes.empty()) {
|
||||
AlignedBuffer aligned_buf;
|
||||
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size()));
|
||||
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
|
||||
|
||||
has_longitudinal_control = hasLongitudinalControl(CP);
|
||||
} else {
|
||||
has_longitudinal_control = false;
|
||||
}
|
||||
|
||||
LongitudinalTuningOption longitudinal_tuning_option;
|
||||
if (longitudinal_tuning_param == int(LongitudinalTuningOption::PREDICTIVE)) {
|
||||
longitudinal_tuning_option = LongitudinalTuningOption::PREDICTIVE;
|
||||
} else if (longitudinal_tuning_param == int(LongitudinalTuningOption::DYNAMIC)) {
|
||||
longitudinal_tuning_option = LongitudinalTuningOption::DYNAMIC;
|
||||
} else {
|
||||
longitudinal_tuning_option = LongitudinalTuningOption::OFF;
|
||||
}
|
||||
|
||||
bool longitudinal_tuning_disabled = !offroad || !has_longitudinal_control;
|
||||
QString longitudinal_tuning_description = longitudinalTuningDescription(longitudinal_tuning_option);
|
||||
if (longitudinal_tuning_disabled) {
|
||||
longitudinal_tuning_description = toggleDisableMsg(offroad, has_longitudinal_control);
|
||||
}
|
||||
|
||||
longitudinalTuningToggle->setEnabled(!longitudinal_tuning_disabled);
|
||||
longitudinalTuningToggle->setDescription(longitudinal_tuning_description);
|
||||
longitudinalTuningToggle->showDescription();
|
||||
}
|
||||
|
||||
@@ -14,14 +14,52 @@
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
|
||||
enum class LongitudinalTuningOption {
|
||||
OFF,
|
||||
DYNAMIC,
|
||||
PREDICTIVE,
|
||||
};
|
||||
|
||||
class HyundaiSettings : public BrandSettingsInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HyundaiSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
bool has_longitudinal_control = false;
|
||||
ButtonParamControl *longitudinalTuningToggle = nullptr;
|
||||
|
||||
static QString toggleDisableMsg(bool _offroad, bool _has_longitudinal_control) {
|
||||
if (!_has_longitudinal_control) {
|
||||
return tr("This feature can only be used with openpilot longitudinal control enabled.");
|
||||
}
|
||||
|
||||
if (!_offroad) {
|
||||
return tr("Enable \"Always Offroad\" in Device panel, or turn vehicle off to select an option.");
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
static QString longitudinalTuningDescription(LongitudinalTuningOption option = LongitudinalTuningOption::OFF) {
|
||||
QString off_str = tr("Off: Uses default tuning");
|
||||
QString dynamic_str = tr("Dynamic: Adjusts acceleration limits based on current speed");
|
||||
QString predictive_str = tr("Predictive: Uses future trajectory data to anticipate needed adjustments");
|
||||
|
||||
if (option == LongitudinalTuningOption::PREDICTIVE) {
|
||||
predictive_str = "<font color='white'><b>" + predictive_str + "</b></font>";
|
||||
} else if (option == LongitudinalTuningOption::DYNAMIC) {
|
||||
dynamic_str = "<font color='white'><b>" + dynamic_str + "</b></font>";
|
||||
} else {
|
||||
off_str = "<font color='white'><b>" + off_str + "</b></font>";
|
||||
}
|
||||
|
||||
return QString("%1<br><br>%2<br>%3<br>%4<br>")
|
||||
.arg(tr("Fine-tune your driving experience by adjusting acceleration smoothness with openpilot longitudinal control."))
|
||||
.arg(off_str)
|
||||
.arg(dynamic_str)
|
||||
.arg(predictive_str);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/mazda_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
MazdaSettings::MazdaSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void MazdaSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void MazdaSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class MazdaSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit MazdaSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/nissan_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
NissanSettings::NissanSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void NissanSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void NissanSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class NissanSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit NissanSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -72,7 +72,6 @@ void PlatformSelector::refresh(bool _offroad) {
|
||||
|
||||
for (auto it = platforms.constBegin(); it != platforms.constEnd(); ++it) {
|
||||
if (it.value()["platform"].toString() == platform) {
|
||||
platform = it.key();
|
||||
brand = it.value()["brand"].toString();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/rivian_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
RivianSettings::RivianSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void RivianSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void RivianSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class RivianSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit RivianSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/subaru_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
SubaruSettings::SubaruSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void SubaruSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void SubaruSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class SubaruSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit SubaruSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/tesla_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
TeslaSettings::TeslaSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void TeslaSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void TeslaSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class TeslaSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit TeslaSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/toyota_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
ToyotaSettings::ToyotaSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void ToyotaSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void ToyotaSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class ToyotaSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit ToyotaSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -7,25 +7,8 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/volkswagen_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
VolkswagenSettings::VolkswagenSettings(QWidget *parent) : BrandSettingsInterface(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
void VolkswagenSettings::updatePanel(bool _offroad) {
|
||||
updateSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void VolkswagenSettings::updateSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class VolkswagenSettings : public BrandSettingsInterface {
|
||||
|
||||
public:
|
||||
explicit VolkswagenSettings(QWidget *parent = nullptr);
|
||||
void updatePanel(bool _offroad);
|
||||
void updateSettings();
|
||||
void updateSettings() override;
|
||||
|
||||
private:
|
||||
bool offroad = false;
|
||||
|
||||
@@ -12,26 +12,27 @@
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
VehiclePanel::VehiclePanel(QWidget *parent) : QFrame(parent) {
|
||||
main_layout = new QStackedLayout(this);
|
||||
ListWidget *list = new ListWidget(this);
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(50, 20, 50, 20);
|
||||
|
||||
vehicleScreen = new QWidget(this);
|
||||
QVBoxLayout *vlayout = new QVBoxLayout(vehicleScreen);
|
||||
vlayout->setContentsMargins(50, 20, 50, 20);
|
||||
ListWidget *list = new ListWidget(this);
|
||||
|
||||
platformSelector = new PlatformSelector();
|
||||
QObject::connect(platformSelector, &PlatformSelector::refreshPanel, this, &VehiclePanel::updateBrandSettings);
|
||||
list->addItem(platformSelector);
|
||||
|
||||
brandSettingsContainer = new QWidget(this);
|
||||
brandSettingsContainerLayout = new QVBoxLayout(brandSettingsContainer);
|
||||
brandSettingsContainerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
brandSettingsContainerLayout->setSpacing(0);
|
||||
list->addItem(brandSettingsContainer);
|
||||
|
||||
ScrollViewSP *scroller = new ScrollViewSP(list, this);
|
||||
vlayout->addWidget(scroller);
|
||||
main_layout->addWidget(scroller);
|
||||
|
||||
currentBrandSettings = nullptr;
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &VehiclePanel::updatePanel);
|
||||
|
||||
main_layout->addWidget(vehicleScreen);
|
||||
main_layout->setCurrentWidget(vehicleScreen);
|
||||
}
|
||||
|
||||
void VehiclePanel::showEvent(QShowEvent *event) {
|
||||
@@ -39,9 +40,9 @@ void VehiclePanel::showEvent(QShowEvent *event) {
|
||||
}
|
||||
|
||||
void VehiclePanel::updatePanel(bool _offroad) {
|
||||
offroad = _offroad;
|
||||
platformSelector->refresh(_offroad);
|
||||
updateBrandSettings();
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void VehiclePanel::updateBrandSettings() {
|
||||
@@ -50,7 +51,7 @@ void VehiclePanel::updateBrandSettings() {
|
||||
}
|
||||
|
||||
if (currentBrandSettings) {
|
||||
vehicleScreen->layout()->removeWidget(currentBrandSettings);
|
||||
brandSettingsContainerLayout->removeWidget(currentBrandSettings);
|
||||
delete currentBrandSettings;
|
||||
currentBrandSettings = nullptr;
|
||||
}
|
||||
@@ -58,7 +59,8 @@ void VehiclePanel::updateBrandSettings() {
|
||||
if (BrandSettingsFactory::isBrandSupported(platformSelector->brand)) {
|
||||
currentBrandSettings = BrandSettingsFactory::createBrandSettings(platformSelector->brand, this);
|
||||
if (currentBrandSettings) {
|
||||
vehicleScreen->layout()->addWidget(currentBrandSettings);
|
||||
currentBrandSettings->setContentsMargins(0, 0, 0, 0);
|
||||
brandSettingsContainerLayout->addWidget(currentBrandSettings);
|
||||
currentBrandSettings->updatePanel(offroad);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public slots:
|
||||
void updatePanel(bool _offroad);
|
||||
|
||||
private:
|
||||
QStackedLayout* main_layout = nullptr;
|
||||
QWidget* vehicleScreen = nullptr;
|
||||
PlatformSelector* platformSelector = nullptr;
|
||||
BrandSettingsInterface* currentBrandSettings = nullptr;
|
||||
QWidget* brandSettingsContainer = nullptr;
|
||||
QVBoxLayout* brandSettingsContainerLayout = nullptr;
|
||||
bool offroad = false;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -148,7 +148,7 @@ AbstractControlSP_SELECTOR::AbstractControlSP_SELECTOR(const QString &title, con
|
||||
|
||||
// description
|
||||
description = new QLabel(desc);
|
||||
description->setContentsMargins(0, 20, 40, 20);
|
||||
description->setContentsMargins(40, 20, 40, 20);
|
||||
description->setStyleSheet("font-size: 40px; color: grey");
|
||||
description->setWordWrap(true);
|
||||
description->setVisible(false);
|
||||
|
||||
@@ -72,7 +72,7 @@ class ModularAssistiveDrivingSystem:
|
||||
if self.events.has(EventName.seatbeltNotLatched):
|
||||
replace_event(EventName.seatbeltNotLatched, EventNameSP.silentSeatbeltNotLatched)
|
||||
transition_paused_state()
|
||||
if self.events.has(EventName.wrongGear) and (CS.standstill or CS.gearShifter == GearShifter.reverse):
|
||||
if self.events.has(EventName.wrongGear) and (CS.vEgo < 2.5 or CS.gearShifter == GearShifter.reverse):
|
||||
replace_event(EventName.wrongGear, EventNameSP.silentWrongGear)
|
||||
transition_paused_state()
|
||||
if self.events.has(EventName.reverseGear):
|
||||
|
||||
@@ -11,6 +11,7 @@ from opendbc.car.car_helpers import can_fingerprint
|
||||
from opendbc.car.interfaces import CarInterfaceBase
|
||||
from opendbc.car.hyundai.radar_interface import RADAR_START_ADDR
|
||||
from opendbc.car.hyundai.values import HyundaiFlags, DBC as HYUNDAI_DBC
|
||||
from opendbc.sunnypilot.car.hyundai.longitudinal.helpers import LongitudinalTuningType
|
||||
from opendbc.sunnypilot.car.hyundai.values import HyundaiFlagsSP
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
@@ -25,6 +26,21 @@ def log_fingerprint(CP: structs.CarParams) -> None:
|
||||
else:
|
||||
sentry.capture_fingerprint(CP.carFingerprint, CP.brand)
|
||||
|
||||
def _initialize_custom_longitudinal_tuning(CI: CarInterfaceBase, CP: structs.CarParams, CP_SP: structs.CarParamsSP,
|
||||
params: Params = None) -> None:
|
||||
if params is None:
|
||||
params = Params()
|
||||
|
||||
# Hyundai Custom Longitudinal Tuning
|
||||
if CP.brand == 'hyundai':
|
||||
hyundai_longitudinal_tuning = int(params.get("HyundaiLongitudinalTuning", encoding="utf8") or 0)
|
||||
if hyundai_longitudinal_tuning == LongitudinalTuningType.DYNAMIC:
|
||||
CP_SP.flags |= HyundaiFlagsSP.LONG_TUNING_DYNAMIC.value
|
||||
if hyundai_longitudinal_tuning == LongitudinalTuningType.PREDICTIVE:
|
||||
CP_SP.flags |= HyundaiFlagsSP.LONG_TUNING_PREDICTIVE.value
|
||||
|
||||
CP_SP = CI.get_longitudinal_tuning_sp(CP, CP_SP)
|
||||
|
||||
|
||||
def _initialize_neural_network_lateral_control(CI: CarInterfaceBase, CP: structs.CarParams, CP_SP: structs.CarParamsSP,
|
||||
params: Params = None, enabled: bool = False) -> None:
|
||||
@@ -61,10 +77,11 @@ def _initialize_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP,
|
||||
CP.radarUnavailable = False
|
||||
|
||||
|
||||
def setup_interfaces(CI: CarInterfaceBase, params: Params = None):
|
||||
def setup_interfaces(CI: CarInterfaceBase, params: Params = None) -> None:
|
||||
CP = CI.CP
|
||||
CP_SP = CI.CP_SP
|
||||
|
||||
_initialize_custom_longitudinal_tuning(CI, CP, CP_SP, params)
|
||||
_initialize_neural_network_lateral_control(CI, CP, CP_SP, params)
|
||||
_initialize_radar_tracks(CP, CP_SP, params)
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ def manager_init() -> None:
|
||||
("AutoLaneChangeTimer", "0"),
|
||||
("AutoLaneChangeBsmDelay", "0"),
|
||||
("DynamicExperimentalControl", "0"),
|
||||
("HyundaiLongitudinalTuning", "0"),
|
||||
("Mads", "1"),
|
||||
("MadsMainCruiseAllowed", "1"),
|
||||
("MadsPauseLateralOnBrake", "0"),
|
||||
|
||||
Reference in New Issue
Block a user