mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-16 14:52:15 +08:00
ui/settings: allow driving personality without CarParams (#28753)
* allow driving personality without CarParams * rename to hasLongitudinalControl * Update selfdrive/ui/qt/util.cc --------- Co-authored-by: Shane Smiskol <shane@smiskol.com> old-commit-hash: 5493cb4289aea0d69e30408075a43044b895c8ec
This commit is contained in:
@@ -139,7 +139,6 @@ void TogglesPanel::updateToggles() {
|
||||
.arg(tr("New Driving Visualization"))
|
||||
.arg(tr("The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner."));
|
||||
|
||||
long_personality_setting->setEnabled(false);
|
||||
const bool is_release = params.getBool("IsReleaseBranch");
|
||||
auto cp_bytes = params.get("CarParamsPersistent");
|
||||
if (!cp_bytes.empty()) {
|
||||
@@ -151,10 +150,7 @@ void TogglesPanel::updateToggles() {
|
||||
params.remove("ExperimentalLongitudinalEnabled");
|
||||
}
|
||||
op_long_toggle->setVisible(CP.getExperimentalLongitudinalAvailable() && !is_release);
|
||||
|
||||
const bool op_long = CP.getOpenpilotLongitudinalControl() && !CP.getExperimentalLongitudinalAvailable();
|
||||
const bool exp_long_enabled = CP.getExperimentalLongitudinalAvailable() && params.getBool("ExperimentalLongitudinalEnabled");
|
||||
if (op_long || exp_long_enabled) {
|
||||
if (hasLongitudinalControl(CP)) {
|
||||
// normal description and toggle
|
||||
e2e_toggle->setEnabled(true);
|
||||
e2e_toggle->setDescription(e2e_description);
|
||||
@@ -162,6 +158,7 @@ void TogglesPanel::updateToggles() {
|
||||
} else {
|
||||
// no long for now
|
||||
e2e_toggle->setEnabled(false);
|
||||
long_personality_setting->setEnabled(false);
|
||||
params.remove("ExperimentalMode");
|
||||
|
||||
const QString unavailable = tr("Experimental mode is currently unavailable on this car since the car's stock ACC is used for longitudinal control.");
|
||||
|
||||
@@ -191,8 +191,7 @@ ExperimentalButton::ExperimentalButton(QWidget *parent) : experimental_mode(fals
|
||||
|
||||
void ExperimentalButton::changeMode() {
|
||||
const auto cp = (*uiState()->sm)["carParams"].getCarParams();
|
||||
const bool experimental_mode_available = cp.getExperimentalLongitudinalAvailable() ? params.getBool("ExperimentalLongitudinalEnabled") : cp.getOpenpilotLongitudinalControl();
|
||||
bool can_change = experimental_mode_available && params.getBool("ExperimentalModeConfirmed");
|
||||
bool can_change = hasLongitudinalControl(cp) && params.getBool("ExperimentalModeConfirmed");
|
||||
if (can_change) {
|
||||
params.putBool("ExperimentalMode", !experimental_mode);
|
||||
}
|
||||
|
||||
@@ -250,3 +250,11 @@ QPixmap bootstrapPixmap(const QString &id) {
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
bool hasLongitudinalControl(const cereal::CarParams::Reader &car_params) {
|
||||
// Using the experimental longitudinal toggle, returns whether longitudinal control
|
||||
// will be active without needing a restart of openpilot
|
||||
return car_params.getExperimentalLongitudinalAvailable()
|
||||
? Params().getBool("ExperimentalLongitudinalEnabled")
|
||||
: car_params.getOpenpilotLongitudinalControl();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <QSurfaceFormat>
|
||||
#include <QWidget>
|
||||
|
||||
#include "cereal/gen/cpp/car.capnp.h"
|
||||
|
||||
QString getVersion();
|
||||
QString getBrand();
|
||||
QString getUserAgent();
|
||||
@@ -27,3 +29,4 @@ QPixmap bootstrapPixmap(const QString &id);
|
||||
|
||||
void drawRoundedRect(QPainter &painter, const QRectF &rect, qreal xRadiusTop, qreal yRadiusTop, qreal xRadiusBottom, qreal yRadiusBottom);
|
||||
QColor interpColor(float xv, std::vector<float> xp, std::vector<QColor> fp);
|
||||
bool hasLongitudinalControl(const cereal::CarParams::Reader &car_params);
|
||||
|
||||
Reference in New Issue
Block a user