From c1794e6f83c6019f960291aea3398161985c8d5b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 10 Jun 2025 01:48:46 -0700 Subject: [PATCH] ui: expose lateral control learning state (#35519) * add lagd * add live torque params * clean up * too many openpilot is's * add back * fix weird pattern causing segfault * cu * 10 more lines for "all complete" * Revert "10 more lines for "all complete"" This reverts commit de1ad0b7386f4c5d9967ea733edbe5bf1df5039c. * one line --- selfdrive/ui/qt/offroad/settings.cc | 45 ++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 4ce33ecc10..28df3afe3f 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -298,9 +298,7 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { } void DevicePanel::updateCalibDescription() { - QString desc = - tr("openpilot requires the device to be mounted within 4° left or right and " - "within 5° up or 9° down. openpilot is continuously calibrating, resetting is rarely required."); + QString desc = tr("\nopenpilot requires the device to be mounted within 4° left or right and within 5° up or 9° down."); std::string calib_bytes = params.get("CalibrationParams"); if (!calib_bytes.empty()) { try { @@ -318,7 +316,46 @@ void DevicePanel::updateCalibDescription() { qInfo() << "invalid CalibrationParams"; } } - desc += tr(" Resetting calibration will restart openpilot if the car is powered on."); + + int lag_perc = 0; + std::string lag_bytes = params.get("LiveDelay"); + if (!lag_bytes.empty()) { + try { + AlignedBuffer aligned_buf; + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(lag_bytes.data(), lag_bytes.size())); + lag_perc = cmsg.getRoot().getLiveDelay().getCalPerc(); + } catch (kj::Exception) { + qInfo() << "invalid LiveDelay"; + } + } + if (lag_perc < 100) { + desc += tr("\n\nSteering lag calibration is %1% complete.").arg(lag_perc); + } else { + desc += tr("\n\nSteering lag calibration is complete."); + } + + std::string torque_bytes = params.get("LiveTorqueParameters"); + if (!torque_bytes.empty()) { + try { + AlignedBuffer aligned_buf; + capnp::FlatArrayMessageReader cmsg(aligned_buf.align(torque_bytes.data(), torque_bytes.size())); + auto torque = cmsg.getRoot().getLiveTorqueParameters(); + // don't add for non-torque cars + if (torque.getUseParams()) { + int torque_perc = torque.getCalPerc(); + if (torque_perc < 100) { + desc += tr(" Steering torque response calibration is %1% complete.").arg(torque_perc); + } else { + desc += tr(" Steering torque response calibration is complete."); + } + } + } catch (kj::Exception) { + qInfo() << "invalid LiveTorqueParameters"; + } + } + + desc += tr("\n\nopenpilot is continuously calibrating, resetting is rarely required. " + "Resetting calibration will restart openpilot if the car is powered on."); resetCalibBtn->setDescription(desc); }