From 0953fb6bf221d245661ce56fc31a51db508ca7b7 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Fri, 24 May 2024 06:22:20 +0000 Subject: [PATCH 1/2] Hyundai CAN Longitudinal: Lenient parsing for auto-enabled radar configs --- selfdrive/car/hyundai/interface.py | 7 ++++--- selfdrive/car/hyundai/radar_interface.py | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index f1c2d05e38..79eaf88384 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -78,7 +78,6 @@ class CarInterface(CarInterfaceBase): if 0x2AB in fingerprint[0]: ret.spFlags |= HyundaiFlagsSP.SP_ENHANCED_SCC.value - ret.radarUnavailable = False if 0x53E in fingerprint[2]: ret.spFlags |= HyundaiFlagsSP.SP_LKAS12.value @@ -94,14 +93,12 @@ class CarInterface(CarInterfaceBase): ret.experimentalLongitudinalAvailable = candidate not in (CANFD_UNSUPPORTED_LONGITUDINAL_CAR | CANFD_RADAR_SCC_CAR | NON_SCC_CAR) if ret.flags & HyundaiFlags.CANFD_CAMERA_SCC and not hda2: ret.spFlags |= HyundaiFlagsSP.SP_CAMERA_SCC_LEAD.value - ret.radarUnavailable = False else: ret.longitudinalTuning.kpV = [0.5] ret.longitudinalTuning.kiV = [0.0] ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | NON_SCC_CAR) if candidate in CAMERA_SCC_CAR: ret.spFlags |= HyundaiFlagsSP.SP_CAMERA_SCC_LEAD.value - ret.radarUnavailable = False ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable ret.pcmCruise = not ret.openpilotLongitudinalControl @@ -112,6 +109,10 @@ class CarInterface(CarInterfaceBase): ret.longitudinalActuatorDelayLowerBound = 0.5 ret.longitudinalActuatorDelayUpperBound = 0.5 + if DBC[ret.carFingerprint]["radar"] is None: + if ret.spFlags & (HyundaiFlagsSP.SP_ENHANCED_SCC | HyundaiFlagsSP.SP_CAMERA_SCC_LEAD): + ret.radarUnavailable = False + # *** feature detection *** if candidate in CANFD_CAR: ret.enableBsm = 0x1e5 in fingerprint[CAN.ECAN] diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index e470011737..2d822befd4 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -48,6 +48,8 @@ class RadarInterface(RadarInterfaceBase): self.radar_off_can = CP.radarUnavailable self.rcp = get_radar_can_parser(CP) + self.sp_radar_tracks = CP.spFlags & HyundaiFlagsSP.SP_RADAR_TRACKS + def update(self, can_strings): if self.radar_off_can or (self.rcp is None): return super().update(None) @@ -61,6 +63,12 @@ class RadarInterface(RadarInterfaceBase): rr = self._update(self.updated_messages) self.updated_messages.clear() + radar_error = [] + if rr is not None: + radar_error = rr.errors + if list(radar_error) and self.sp_radar_tracks: + return super().update(None) + return rr def _update(self, updated_messages): From 30b1180a3b42f9e62b9b210a5153bc035a75cbe9 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Fri, 24 May 2024 06:26:28 +0000 Subject: [PATCH 2/2] SP-72: sunnylink: Add sunnylink status to Sidebar UI --- CHANGELOGS.md | 1 + selfdrive/ui/qt/sidebar.cc | 23 ++++++++++++++++++++--- selfdrive/ui/qt/sidebar.h | 5 ++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 7e152d94d0..850013c029 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -56,6 +56,7 @@ sunnypilot - 0.9.7.0 (2024-05-xx) * Display Metrics Below Chevron * NEW❗: Metrics is now being displayed below the chevron instead of above * NEW❗: Display both Distance and Speed simultaneously + * NEW❗: View sunnylink connectivity status on the left sidebar! sunnypilot - 0.9.6.1 (2024-02-27) ======================== diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index d44e818b24..df9ebc45c0 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -5,6 +5,7 @@ #include #include "selfdrive/ui/qt/util.h" +#include "common/params.h" void Sidebar::drawMetric(QPainter &p, const QPair &label, QColor c, int y) { const QRect rect = {30, y, 240, 126}; @@ -152,6 +153,21 @@ void Sidebar::updateState(const UIState &s) { pandaStatus = {{tr("GPS"), tr("SEARCH")}, warning_color}; } setProperty("pandaStatus", QVariant::fromValue(pandaStatus)); + + ItemStatus sunnylinkStatus; + auto last_sunnylink_ping = std::strtol(params.get("LastSunnylinkPingTime").c_str(), nullptr, 10); + auto sunnylink_enabled = params.getBool("SunnylinkEnabled"); + if (!sunnylink_enabled) { + sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("DISABLED")}, disabled_color}; + } else if (last_ping == 0) { + sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("OFFLINE")}, warning_color}; + } else { + if (nanos_since_boot() - last_sunnylink_ping < 80e9) + sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("ONLINE")}, good_color}; + else + sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("ERROR")}, danger_color}; + } + setProperty("sunnylinkStatus", QVariant::fromValue(sunnylinkStatus)); } void Sidebar::paintEvent(QPaintEvent *event) { @@ -183,7 +199,8 @@ void Sidebar::paintEvent(QPaintEvent *event) { p.drawText(r, Qt::AlignCenter, net_type); // metrics - drawMetric(p, temp_status.first, temp_status.second, 338); - drawMetric(p, panda_status.first, panda_status.second, 496); - drawMetric(p, connect_status.first, connect_status.second, 654); + drawMetric(p, temp_status.first, temp_status.second, 310); + drawMetric(p, panda_status.first, panda_status.second, 440); + drawMetric(p, connect_status.first, connect_status.second, 570); + drawMetric(p, sunnylink_status.first, sunnylink_status.second, 700); } diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 4297602908..be2c34cae0 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -13,6 +13,7 @@ Q_DECLARE_METATYPE(ItemStatus); class Sidebar : public QFrame { Q_OBJECT Q_PROPERTY(ItemStatus connectStatus MEMBER connect_status NOTIFY valueChanged); + Q_PROPERTY(ItemStatus sunnylinkStatus MEMBER sunnylink_status NOTIFY valueChanged); Q_PROPERTY(ItemStatus pandaStatus MEMBER panda_status NOTIFY valueChanged); Q_PROPERTY(ItemStatus tempStatus MEMBER temp_status NOTIFY valueChanged); Q_PROPERTY(QString netType MEMBER net_type NOTIFY valueChanged); @@ -53,12 +54,14 @@ protected: const QColor good_color = QColor(255, 255, 255); const QColor warning_color = QColor(218, 202, 37); const QColor danger_color = QColor(201, 34, 49); + const QColor disabled_color = QColor(128, 128, 128); - ItemStatus connect_status, panda_status, temp_status; + ItemStatus connect_status, panda_status, temp_status, sunnylink_status; QString net_type; int net_strength = 0; private: + Params params; std::unique_ptr pm; QString sidebar_temp = "0";