mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-04 00:59:31 +08:00
Revert "Hyundai: custom longitudinal tuning" (#892)
* Revert "Hyundai: custom longitudinal tuning (#658)"
This reverts commit 72f09ec9f5.
* bump
* Revert "bump"
This reverts commit a437f3538db4720d797e3af7df8363898d410a7e.
* bump
This commit is contained in:
@@ -164,7 +164,6 @@ 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},
|
||||
|
||||
@@ -50,7 +50,6 @@ network_src = [
|
||||
]
|
||||
|
||||
vehicle_panel_qt_src = [
|
||||
"sunnypilot/qt/offroad/settings/vehicle/hyundai_settings.cc",
|
||||
"sunnypilot/qt/offroad/settings/vehicle/platform_selector.cc",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* 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/hyundai_settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
HyundaiSettings::HyundaiSettings(QWidget *parent) : QWidget(parent) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ListWidget *list = new ListWidget(this, false);
|
||||
|
||||
std::vector<QString> tuning_texts{ tr("Off"), tr("Dynamic"), tr("Predictive") };
|
||||
longitudinalTuningToggle = new ButtonParamControlSP(
|
||||
"HyundaiLongitudinalTuning",
|
||||
tr("Custom Longitudinal Tuning"),
|
||||
tr("Select a tuning mode.\n"
|
||||
"Off: no custom tuning applied.\n"
|
||||
"Dynamic: on-the-spot adjustments using dynamic calculations.\n"
|
||||
"Predictive: adjusts based on anticipated ACC variation."),
|
||||
"",
|
||||
tuning_texts,
|
||||
500
|
||||
);
|
||||
longitudinalTuningToggle->showDescription();
|
||||
longitudinalTuningToggle->setProperty("originalDesc", longitudinalTuningToggle->getDescription());
|
||||
list->addItem(longitudinalTuningToggle);
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &HyundaiSettings::updateSettings);
|
||||
|
||||
main_layout->addWidget(new ScrollViewSP(list, this));
|
||||
}
|
||||
|
||||
QString HyundaiSettings::toggleDisableMsg() const {
|
||||
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();
|
||||
}
|
||||
|
||||
void HyundaiSettings::showEvent(QShowEvent *event) {
|
||||
updateSettings(offroad);
|
||||
}
|
||||
|
||||
void HyundaiSettings::updateSettings(bool _offroad) {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
QString longitudinal_tuning_disabled_msg = toggleDisableMsg();
|
||||
if (!longitudinal_tuning_disabled_msg.isEmpty()) {
|
||||
longitudinalTuningToggle->setEnabled(false);
|
||||
longitudinalTuningToggle->setDescription(longitudinal_tuning_disabled_msg);
|
||||
} else {
|
||||
longitudinalTuningToggle->setEnabled(true);
|
||||
longitudinalTuningToggle->setDescription(longitudinalTuningToggle->property("originalDesc").toString());
|
||||
}
|
||||
|
||||
longitudinalTuningToggle->showDescription();
|
||||
} else {
|
||||
has_longitudinal_control = false;
|
||||
longitudinalTuningToggle->setEnabled(false);
|
||||
}
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* 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/qt/util.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
|
||||
class HyundaiSettings : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HyundaiSettings(QWidget *parent = nullptr);
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void updateSettings(bool _offroad);
|
||||
|
||||
private:
|
||||
Params params;
|
||||
bool offroad = false;
|
||||
bool has_longitudinal_control = false;
|
||||
|
||||
ButtonParamControlSP *longitudinalTuningToggle = nullptr;
|
||||
QString toggleDisableMsg() const;
|
||||
};
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle_panel.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/hyundai_settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
VehiclePanel::VehiclePanel(QWidget *parent) : QFrame(parent) {
|
||||
@@ -19,16 +18,11 @@ VehiclePanel::VehiclePanel(QWidget *parent) : QFrame(parent) {
|
||||
vlayout->setContentsMargins(50, 20, 50, 20);
|
||||
|
||||
platformSelector = new PlatformSelector();
|
||||
QObject::connect(platformSelector, &PlatformSelector::refreshPanel, this, &VehiclePanel::updateBrandSettings);
|
||||
list->addItem(platformSelector);
|
||||
|
||||
ScrollViewSP *scroller = new ScrollViewSP(list, this);
|
||||
vlayout->addWidget(scroller);
|
||||
|
||||
hyundaiSettings = new HyundaiSettings(this);
|
||||
vlayout->addWidget(hyundaiSettings);
|
||||
hyundaiSettings->setVisible(false);
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &VehiclePanel::updatePanel);
|
||||
|
||||
main_layout->addWidget(vehicleScreen);
|
||||
@@ -42,24 +36,5 @@ void VehiclePanel::showEvent(QShowEvent *event) {
|
||||
void VehiclePanel::updatePanel(bool _offroad) {
|
||||
platformSelector->refresh(_offroad);
|
||||
|
||||
updateBrandSettings();
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void VehiclePanel::updateBrandSettings() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
resetBrandSettings();
|
||||
|
||||
QString brand = platformSelector->getPlatformBundle("brand").toString();
|
||||
if (brand == "hyundai") {
|
||||
hyundaiSettings->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void VehiclePanel::resetBrandSettings() {
|
||||
hyundaiSettings->setVisible(false);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/hyundai_settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/vehicle/platform_selector.h"
|
||||
|
||||
class VehiclePanel : public QFrame {
|
||||
@@ -23,17 +22,8 @@ public slots:
|
||||
void updatePanel(bool _offroad);
|
||||
|
||||
private:
|
||||
void resetBrandSettings();
|
||||
|
||||
QStackedLayout* main_layout = nullptr;
|
||||
QWidget* vehicleScreen = nullptr;
|
||||
PlatformSelector* platformSelector = nullptr;
|
||||
|
||||
// brand panels
|
||||
HyundaiSettings* hyundaiSettings = nullptr;
|
||||
|
||||
bool offroad = false;
|
||||
|
||||
private slots:
|
||||
void updateBrandSettings();
|
||||
PlatformSelector *platformSelector = nullptr;
|
||||
bool offroad;
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@ 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
|
||||
@@ -26,21 +25,6 @@ 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:
|
||||
@@ -77,11 +61,10 @@ def _initialize_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP,
|
||||
CP.radarUnavailable = False
|
||||
|
||||
|
||||
def setup_interfaces(CI: CarInterfaceBase, params: Params = None) -> None:
|
||||
def setup_interfaces(CI: CarInterfaceBase, params: Params = 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,7 +45,6 @@ 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