diff --git a/common/params_keys.h b/common/params_keys.h index be7f941..8d79e97 100644 --- a/common/params_keys.h +++ b/common/params_keys.h @@ -119,11 +119,11 @@ inline static std::unordered_map keys = { {"UpdaterTargetBranch", CLEAR_ON_MANAGER_START}, {"UpdaterLastFetchTime", PERSISTENT}, {"Version", PERSISTENT}, - + // carrot {"LongitudinalPersonalityMax", PERSISTENT}, {"NetworkAddress", CLEAR_ON_MANAGER_START}, - + {"ApiCache_NavDestinations", PERSISTENT}, {"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, {"NavDestinationWaypoints", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, @@ -261,9 +261,10 @@ inline static std::unordered_map keys = { {"CustomSR", PERSISTENT}, {"SteerRatioRate", PERSISTENT}, {"SoftRestartTriggered", CLEAR_ON_MANAGER_START}, - + {"NNFF", PERSISTENT}, {"NNFFLite", PERSISTENT}, {"NNFFModelName", CLEAR_ON_OFFROAD_TRANSITION}, - + + {"DevicePosition", CLEAR_ON_MANAGER_START}, }; diff --git a/selfdrive/assets/img_c3x.png b/selfdrive/assets/img_c3x.png new file mode 100644 index 0000000..73631d7 Binary files /dev/null and b/selfdrive/assets/img_c3x.png differ diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index cde0998..2f3d1fd 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -282,7 +282,26 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { auto statusCalibBtn = new ButtonControl(tr("Calibration Status"), tr("SHOW"), ""); connect(statusCalibBtn, &ButtonControl::showDescriptionEvent, this, &DevicePanel::updateCalibDescription); addItem(statusCalibBtn); - + + std::string calib_bytes = params.get("CalibrationParams"); + if (!calib_bytes.empty()) { + try { + AlignedBuffer aligned_buf; + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(calib_bytes.data(), calib_bytes.size())); + auto calib = cmsg.getRoot().getLiveCalibration(); + if (calib.getCalStatus() != cereal::LiveCalibrationData::Status::UNCALIBRATED) { + double pitch = calib.getRpyCalib()[1] * (180 / M_PI); + double yaw = calib.getRpyCalib()[2] * (180 / M_PI); + QString position = QString("%2 %1° %4 %3°") + .arg(QString::number(std::abs(pitch), 'g', 1), pitch > 0 ? "↓" : "↑", + QString::number(std::abs(yaw), 'g', 1), yaw > 0 ? "←" : "→"); + params.put("DevicePosition", position.toStdString()); + } + } catch (kj::Exception) { + qInfo() << "invalid CalibrationParams"; + } + } + if (Hardware::TICI()) { auto regulatoryBtn = new ButtonControl(tr("Regulatory"), tr("VIEW"), ""); connect(regulatoryBtn, &ButtonControl::clicked, [=]() { @@ -399,7 +418,7 @@ void SettingsWindow::setCurrentPanel(int index, const QString ¶m) { if (param.endsWith("Panel")) { QString panelName = param; panelName.chop(5); // Remove "Panel" suffix - + // Find the panel by name for (int i = 0; i < nav_btns->buttons().size(); i++) { if (nav_btns->buttons()[i]->text() == tr(panelName.toStdString().c_str())) { @@ -411,7 +430,7 @@ void SettingsWindow::setCurrentPanel(int index, const QString ¶m) { emit expandToggleDescription(param); } } - + panel_widget->setCurrentIndex(index); nav_btns->buttons()[index]->setChecked(true); } diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 966396e..0f865be 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -28,6 +28,7 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed( home_img = loadPixmap("../assets/images/button_home.png", home_btn.size()); flag_img = loadPixmap("../assets/images/button_flag.png", home_btn.size()); settings_img = loadPixmap("../assets/images/button_settings.png", settings_btn.size(), Qt::IgnoreAspectRatio); + c3x_img = loadPixmap("../assets/img_c3x.png", home_btn.size()); connect(this, &Sidebar::valueChanged, [=] { update(); }); @@ -115,11 +116,20 @@ void Sidebar::paintEvent(QPaintEvent *event) { p.fillRect(rect(), QColor(57, 57, 57)); + QString c3x_position = QString("%1").arg(QString::fromStdString(params.get("DevicePosition"))); + // buttons p.setOpacity(settings_pressed ? 0.65 : 1.0); p.drawPixmap(settings_btn.x(), settings_btn.y(), settings_img); p.setOpacity(onroad && flag_pressed ? 0.65 : 1.0); - p.drawPixmap(home_btn.x(), home_btn.y(), onroad ? flag_img : home_img); + //p.drawPixmap(home_btn.x(), home_btn.y(), onroad ? flag_img : home_img); + p.drawPixmap(home_btn.x(), home_btn.y(), c3x_img); + + const QRect r3 = QRect(0, 967, event->rect().width(), 50); + p.setFont(InterFont(30)); + p.setPen(QColor(0xff, 0xff, 0xff)); + p.drawText(r3, Qt::AlignCenter, c3x_position); + p.setOpacity(1.0); // network diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 2091418..4ba44fd 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -36,7 +36,7 @@ protected: void mouseReleaseEvent(QMouseEvent *event) override; void drawMetric(QPainter &p, const QPair &label, QColor c, int y); - QPixmap home_img, flag_img, settings_img; + QPixmap home_img, flag_img, settings_img, c3x_img; bool onroad, flag_pressed, settings_pressed; const QMap network_type = { {cereal::DeviceState::NetworkType::NONE, tr("--")}, @@ -61,4 +61,5 @@ protected: private: std::unique_ptr pm; Networking *networking = nullptr; + Params params; };