From f8091837c92ed096ef3b886d1b09fe758d6ae9f2 Mon Sep 17 00:00:00 2001
From: Lee Jong Mun <43285072+crwusiz@users.noreply.github.com>
Date: Tue, 18 Oct 2022 02:15:03 +0900
Subject: [PATCH 001/137] kor translation update (#26111)
---
selfdrive/ui/translations/main_ko.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts
index 86cd8f990a..f84797eb60 100644
--- a/selfdrive/ui/translations/main_ko.ts
+++ b/selfdrive/ui/translations/main_ko.ts
@@ -60,11 +60,11 @@
Cellular Metered
-
+ 데이터 요금제
Prevent large data uploads when on a metered connection
-
+ 데이터 요금제 연결 시 대용량 데이터 업로드 방지
From 93346c31d3728d27eaff56a3068690a47eac86ef Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 01:20:27 +0800
Subject: [PATCH 002/137] Cabana: add chart_height setting (#26066)
add chart_height setting
---
tools/cabana/canmessages.cc | 5 ++++-
tools/cabana/canmessages.h | 1 +
tools/cabana/chartswidget.cc | 11 ++++++++++-
tools/cabana/chartswidget.h | 1 +
tools/cabana/mainwin.cc | 7 +++++++
tools/cabana/mainwin.h | 1 +
6 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/tools/cabana/canmessages.cc b/tools/cabana/canmessages.cc
index b717424ece..3cf08eaaa0 100644
--- a/tools/cabana/canmessages.cc
+++ b/tools/cabana/canmessages.cc
@@ -141,11 +141,14 @@ void Settings::save() {
s.setValue("fps", fps);
s.setValue("log_size", can_msg_log_size);
s.setValue("cached_segment", cached_segment_limit);
+ s.setValue("chart_height", chart_height);
+ emit changed();
}
void Settings::load() {
QSettings s("settings", QSettings::IniFormat);
fps = s.value("fps", 10).toInt();
can_msg_log_size = s.value("log_size", 100).toInt();
- cached_segment_limit = s.value("cached_segment", 3.).toInt();
+ cached_segment_limit = s.value("cached_segment", 3).toInt();
+ chart_height = s.value("chart_height", 200).toInt();
}
diff --git a/tools/cabana/canmessages.h b/tools/cabana/canmessages.h
index 3d33f801a7..7f6955369b 100644
--- a/tools/cabana/canmessages.h
+++ b/tools/cabana/canmessages.h
@@ -19,6 +19,7 @@ public:
int fps = 10;
int can_msg_log_size = 100;
int cached_segment_limit = 3;
+ int chart_height = 200;
signals:
void changed();
diff --git a/tools/cabana/chartswidget.cc b/tools/cabana/chartswidget.cc
index d0f5356fac..e69729c03a 100644
--- a/tools/cabana/chartswidget.cc
+++ b/tools/cabana/chartswidget.cc
@@ -76,6 +76,11 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
docking = !docking;
updateTitleBar();
});
+ QObject::connect(&settings, &Settings::changed, [this]() {
+ for (auto chart : charts) {
+ chart->setHeight(settings.chart_height);
+ }
+ });
}
void ChartsWidget::updateTitleBar() {
@@ -152,7 +157,7 @@ ChartWidget::ChartWidget(const QString &id, const Signal *sig, QWidget *parent)
main_layout->addWidget(header);
chart_view = new ChartView(id, sig, this);
- chart_view->setFixedHeight(300);
+ chart_view->setFixedHeight(settings.chart_height);
main_layout->addWidget(chart_view);
main_layout->addStretch();
@@ -205,6 +210,10 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
updateSeries();
}
+void ChartWidget::setHeight(int height) {
+ chart_view->setFixedHeight(height);
+}
+
void ChartView::updateState() {
auto axis_x = dynamic_cast(chart()->axisX());
int x = chart()->plotArea().left() + chart()->plotArea().width() * (can->currentSec() - axis_x->min()) / (axis_x->max() - axis_x->min());
diff --git a/tools/cabana/chartswidget.h b/tools/cabana/chartswidget.h
index a3c470e960..3e43409dc4 100644
--- a/tools/cabana/chartswidget.h
+++ b/tools/cabana/chartswidget.h
@@ -46,6 +46,7 @@ Q_OBJECT
public:
ChartWidget(const QString &id, const Signal *sig, QWidget *parent);
void updateTitle();
+ void setHeight(int height);
signals:
void remove();
diff --git a/tools/cabana/mainwin.cc b/tools/cabana/mainwin.cc
index c9d9c85141..999a4816b0 100644
--- a/tools/cabana/mainwin.cc
+++ b/tools/cabana/mainwin.cc
@@ -96,6 +96,12 @@ SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) {
cached_segment->setValue(settings.cached_segment_limit);
form_layout->addRow(tr("Cached segments limit"), cached_segment);
+ chart_height = new QSpinBox(this);
+ chart_height->setRange(100, 500);
+ chart_height->setSingleStep(10);
+ chart_height->setValue(settings.chart_height);
+ form_layout->addRow(tr("Chart height"), chart_height);
+
main_layout->addLayout(form_layout);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@@ -110,6 +116,7 @@ void SettingsDlg::save() {
settings.fps = fps->value();
settings.can_msg_log_size = log_size->value();
settings.cached_segment_limit = cached_segment->value();
+ settings.chart_height = chart_height->value();
settings.save();
accept();
}
diff --git a/tools/cabana/mainwin.h b/tools/cabana/mainwin.h
index 14c4b1dfa9..594e608b59 100644
--- a/tools/cabana/mainwin.h
+++ b/tools/cabana/mainwin.h
@@ -33,4 +33,5 @@ public:
QSpinBox *fps;
QSpinBox *log_size ;
QSpinBox *cached_segment;
+ QSpinBox *chart_height;
};
From 3a8ddc191fd9a7537254399e3b9e49217de9bf16 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 01:32:31 +0800
Subject: [PATCH 003/137] Move Qt moc files to scons cache directory (#26109)
---
SConstruct | 1 +
1 file changed, 1 insertion(+)
diff --git a/SConstruct b/SConstruct
index 23ab37dc1e..74680c0598 100644
--- a/SConstruct
+++ b/SConstruct
@@ -327,6 +327,7 @@ qt_flags = [
qt_env['CXXFLAGS'] += qt_flags
qt_env['LIBPATH'] += ['#selfdrive/ui']
qt_env['LIBS'] = qt_libs
+qt_env['QT_MOCHPREFIX'] = cache_dir + '/moc_files/moc_'
if GetOption("clazy"):
checks = [
From 6d07268ee5b385010961eab206b0b42a0ae6b5f8 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 01:39:07 +0800
Subject: [PATCH 004/137] tools/replay: reduce test running time (#26110)
---
tools/replay/tests/test_replay.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/replay/tests/test_replay.cc b/tools/replay/tests/test_replay.cc
index 5b61b6b6f2..3fd410bb6e 100644
--- a/tools/replay/tests/test_replay.cc
+++ b/tools/replay/tests/test_replay.cc
@@ -207,8 +207,7 @@ void TestReplay::test_seek() {
}
TEST_CASE("Replay") {
- auto flag = GENERATE(REPLAY_FLAG_NO_FILE_CACHE, REPLAY_FLAG_NONE);
- TestReplay replay(DEMO_ROUTE, flag);
+ TestReplay replay(DEMO_ROUTE, (uint8_t)REPLAY_FLAG_NO_VIPC);
REQUIRE(replay.load());
replay.test_seek();
}
From 1dffbb629a6b629b3079bcea195f64f389fc5d1d Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 10:47:54 -0700
Subject: [PATCH 005/137] GM camera ACC: revert FCW logging (#26114)
Revert FCW logging
---
selfdrive/car/gm/carstate.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py
index 21eb440d7f..b67b97093a 100644
--- a/selfdrive/car/gm/carstate.py
+++ b/selfdrive/car/gm/carstate.py
@@ -96,9 +96,7 @@ class CarState(CarStateBase):
ret.cruiseState.standstill = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] == AccState.STANDSTILL
if self.CP.networkLocation == NetworkLocation.fwdCamera:
ret.cruiseState.speed = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCSpeedSetpoint"] * CV.KPH_TO_MS
-
ret.stockAeb = cam_cp.vl["AEBCmd"]["AEBCmdActive"] != 0
- ret.stockFcw = cam_cp.vl["ASCMActiveCruiseControlStatus"]["FCWAlert"] != 0
return ret
@@ -110,7 +108,6 @@ class CarState(CarStateBase):
signals += [
("AEBCmdActive", "AEBCmd"),
("RollingCounter", "ASCMLKASteeringCmd"),
- ("FCWAlert", "ASCMActiveCruiseControlStatus"),
("ACCSpeedSetpoint", "ASCMActiveCruiseControlStatus"),
]
checks += [
From 9e2a1121ea1103efaceaf52cca83370da73ba988 Mon Sep 17 00:00:00 2001
From: Cameron Clough
Date: Mon, 17 Oct 2022 12:55:40 -0700
Subject: [PATCH 006/137] athenad: small tests cleanup (#26037)
* test helpers
* create file helper
* clearer
* type
* fix default create path
* static methods
---
selfdrive/athena/tests/test_athenad.py | 68 ++++++++++++++------------
1 file changed, 36 insertions(+), 32 deletions(-)
diff --git a/selfdrive/athena/tests/test_athenad.py b/selfdrive/athena/tests/test_athenad.py
index 7f511eecf6..5e86a2e821 100755
--- a/selfdrive/athena/tests/test_athenad.py
+++ b/selfdrive/athena/tests/test_athenad.py
@@ -9,6 +9,7 @@ import threading
import queue
import unittest
from datetime import datetime, timedelta
+from typing import Optional
from multiprocessing import Process
from pathlib import Path
@@ -46,12 +47,26 @@ class TestAthenadMethods(unittest.TestCase):
else:
os.unlink(p)
- def wait_for_upload(self):
+
+ # *** test helpers ***
+
+ @staticmethod
+ def _wait_for_upload():
now = time.time()
while time.time() - now < 5:
if athenad.upload_queue.qsize() == 0:
break
+ @staticmethod
+ def _create_file(file: str, parent: Optional[str] = None) -> str:
+ fn = os.path.join(athenad.ROOT if parent is None else parent, file)
+ os.makedirs(os.path.dirname(fn), exist_ok=True)
+ Path(fn).touch()
+ return fn
+
+
+ # *** test cases ***
+
def test_echo(self):
assert dispatcher["echo"]("bob") == "bob"
@@ -85,9 +100,7 @@ class TestAthenadMethods(unittest.TestCase):
filenames = ['qlog', 'qcamera.ts', 'rlog', 'fcamera.hevc', 'ecamera.hevc', 'dcamera.hevc']
files = [f'{route}--{s}/{f}' for s in segments for f in filenames]
for file in files:
- fn = os.path.join(athenad.ROOT, file)
- os.makedirs(os.path.dirname(fn), exist_ok=True)
- Path(fn).touch()
+ self._create_file(file)
resp = dispatcher["listDataDirectory"]()
self.assertTrue(resp, 'list empty!')
@@ -121,16 +134,14 @@ class TestAthenadMethods(unittest.TestCase):
self.assertCountEqual(resp, expected)
def test_strip_bz2_extension(self):
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
if fn.endswith('.bz2'):
self.assertEqual(athenad.strip_bz2_extension(fn), fn[:-4])
@with_http_server
def test_do_upload(self, host):
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
item = athenad.UploadItem(path=fn, url="http://localhost:1238", headers={}, created_at=int(time.time()*1000), id='')
with self.assertRaises(requests.exceptions.ConnectionError):
@@ -142,8 +153,7 @@ class TestAthenadMethods(unittest.TestCase):
@with_http_server
def test_uploadFileToUrl(self, host):
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
resp = dispatcher["uploadFileToUrl"]("qlog.bz2", f"{host}/qlog.bz2", {})
self.assertEqual(resp['enqueued'], 1)
@@ -154,8 +164,7 @@ class TestAthenadMethods(unittest.TestCase):
@with_http_server
def test_uploadFileToUrl_duplicate(self, host):
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ self._create_file('qlog.bz2')
url1 = f"{host}/qlog.bz2?sig=sig1"
dispatcher["uploadFileToUrl"]("qlog.bz2", url1, {})
@@ -172,8 +181,7 @@ class TestAthenadMethods(unittest.TestCase):
@with_http_server
def test_upload_handler(self, host):
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
item = athenad.UploadItem(path=fn, url=f"{host}/qlog.bz2", headers={}, created_at=int(time.time()*1000), id='', allow_cellular=True)
end_event = threading.Event()
@@ -182,7 +190,7 @@ class TestAthenadMethods(unittest.TestCase):
athenad.upload_queue.put_nowait(item)
try:
- self.wait_for_upload()
+ self._wait_for_upload()
time.sleep(0.1)
# TODO: verify that upload actually succeeded
@@ -195,8 +203,7 @@ class TestAthenadMethods(unittest.TestCase):
def test_upload_handler_retry(self, host, mock_put):
for status, retry in ((500, True), (412, False)):
mock_put.return_value.status_code = status
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
item = athenad.UploadItem(path=fn, url=f"{host}/qlog.bz2", headers={}, created_at=int(time.time()*1000), id='', allow_cellular=True)
end_event = threading.Event()
@@ -205,7 +212,7 @@ class TestAthenadMethods(unittest.TestCase):
athenad.upload_queue.put_nowait(item)
try:
- self.wait_for_upload()
+ self._wait_for_upload()
time.sleep(0.1)
self.assertEqual(athenad.upload_queue.qsize(), 1 if retry else 0)
@@ -217,8 +224,7 @@ class TestAthenadMethods(unittest.TestCase):
def test_upload_handler_timeout(self):
"""When an upload times out or fails to connect it should be placed back in the queue"""
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
item = athenad.UploadItem(path=fn, url="http://localhost:44444/qlog.bz2", headers={}, created_at=int(time.time()*1000), id='', allow_cellular=True)
item_no_retry = item._replace(retry_count=MAX_RETRY_COUNT)
@@ -228,14 +234,14 @@ class TestAthenadMethods(unittest.TestCase):
try:
athenad.upload_queue.put_nowait(item_no_retry)
- self.wait_for_upload()
+ self._wait_for_upload()
time.sleep(0.1)
# Check that upload with retry count exceeded is not put back
self.assertEqual(athenad.upload_queue.qsize(), 0)
athenad.upload_queue.put_nowait(item)
- self.wait_for_upload()
+ self._wait_for_upload()
time.sleep(0.1)
# Check that upload item was put back in the queue with incremented retry count
@@ -256,7 +262,7 @@ class TestAthenadMethods(unittest.TestCase):
thread = threading.Thread(target=athenad.upload_handler, args=(end_event,))
thread.start()
try:
- self.wait_for_upload()
+ self._wait_for_upload()
time.sleep(0.1)
self.assertEqual(athenad.upload_queue.qsize(), 0)
@@ -269,8 +275,7 @@ class TestAthenadMethods(unittest.TestCase):
ts = int(t_future.strftime("%s")) * 1000
# Item that would time out if actually uploaded
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
item = athenad.UploadItem(path=fn, url="http://localhost:44444/qlog.bz2", headers={}, created_at=ts, id='', allow_cellular=True)
@@ -279,7 +284,7 @@ class TestAthenadMethods(unittest.TestCase):
thread.start()
try:
athenad.upload_queue.put_nowait(item)
- self.wait_for_upload()
+ self._wait_for_upload()
time.sleep(0.1)
self.assertEqual(athenad.upload_queue.qsize(), 0)
@@ -292,8 +297,7 @@ class TestAthenadMethods(unittest.TestCase):
@with_http_server
def test_listUploadQueueCurrent(self, host):
- fn = os.path.join(athenad.ROOT, 'qlog.bz2')
- Path(fn).touch()
+ fn = self._create_file('qlog.bz2')
item = athenad.UploadItem(path=fn, url=f"{host}/qlog.bz2", headers={}, created_at=int(time.time()*1000), id='', allow_cellular=True)
end_event = threading.Event()
@@ -302,7 +306,7 @@ class TestAthenadMethods(unittest.TestCase):
try:
athenad.upload_queue.put_nowait(item)
- self.wait_for_upload()
+ self._wait_for_upload()
items = dispatcher["listUploadQueue"]()
self.assertEqual(len(items), 1)
@@ -405,9 +409,9 @@ class TestAthenadMethods(unittest.TestCase):
def test_get_logs_to_send_sorted(self):
fl = list()
for i in range(10):
- fn = os.path.join(swaglog.SWAGLOG_DIR, f'swaglog.{i:010}')
- Path(fn).touch()
- fl.append(os.path.basename(fn))
+ file = f'swaglog.{i:010}'
+ self._create_file(file, athenad.SWAGLOG_DIR)
+ fl.append(file)
# ensure the list is all logs except most recent
sl = athenad.get_logs_to_send_sorted()
From 6c65e9bf9837cb00c5feeb3744232597c5b421bb Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 13:50:56 -0700
Subject: [PATCH 007/137] HKG FPv2: whitelist queried Ecus (#26115)
* whitelist all ecus
* remove engine and fwdCamera from queries they never return to
---
selfdrive/car/hyundai/values.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py
index 734e56c033..3585fcc313 100644
--- a/selfdrive/car/hyundai/values.py
+++ b/selfdrive/car/hyundai/values.py
@@ -293,10 +293,12 @@ FW_QUERY_CONFIG = FwQueryConfig(
Request(
[HYUNDAI_VERSION_REQUEST_LONG],
[HYUNDAI_VERSION_RESPONSE],
+ whitelist_ecus=[Ecu.transmission, Ecu.eps, Ecu.abs, Ecu.fwdRadar, Ecu.fwdCamera],
),
Request(
[HYUNDAI_VERSION_REQUEST_MULTI],
[HYUNDAI_VERSION_RESPONSE],
+ whitelist_ecus=[Ecu.engine, Ecu.transmission, Ecu.eps, Ecu.abs, Ecu.fwdRadar],
),
],
extra_ecus=[
From 581835df80dc2cf4d3c0e18fdf9f2772e643da5a Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 14:04:29 -0700
Subject: [PATCH 008/137] 2018 Kia Stinger: add missing FW versions (#26117)
add missing versions from 1ce52d9487767eae
---
selfdrive/car/hyundai/values.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py
index 3585fcc313..856bf1abd9 100644
--- a/selfdrive/car/hyundai/values.py
+++ b/selfdrive/car/hyundai/values.py
@@ -743,6 +743,7 @@ FW_VERSIONS = {
b'\xf1\x81640E0051\x00\x00\x00\x00\x00\x00\x00\x00',
b'\xf1\x82CKJN3TMSDE0B\x00\x00\x00\x00',
b'\xf1\x82CKKN3TMD_H0A\x00\x00\x00\x00',
+ b'\xe0\x19\xff\xe7\xe7g\x01\xa2\x00\x0f\x00\x9e\x00\x06\x00\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00\x0f\x0e\x0f\x0f\x0e\r\x00\x00\x7f\x02.\xff\x00\x00~p\x00\x00\x00\x00u\xff\xf9\xff\x00\x00\x00\x00V\t\xd5\x01\xc0\x00\x00\x00\x007\xfb\xfc\x0b\x8d\x00',
],
(Ecu.eps, 0x7d4, None): [
b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5200 4C2CL104',
@@ -765,6 +766,8 @@ FW_VERSIONS = {
b'\xf1\x87VDKLJ18675252DK6\x89vhgwwwwveVU\x88w\x87w\x99vgf\x97vXfgw_\xff\xc2\xfb\xf1\x89E25\x00\x00\x00\x00\x00\x00\x00\xf1\x82TCK0T33NB2',
b'\xf1\x87WAJTE17552812CH4vfFffvfVeT5DwvvVVdFeegeg\x88\x88o\xff\x1a]\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00TCK2T20NB1\x19\xd2\x00\x94',
b'\xf1\x87VDHLG17274082DK2wfFf\x89x\x98wUT5T\x88v\x97xgeGefTGTVvO\xff\x1c\x14\xf1\x81E19\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E19\x00\x00\x00\x00\x00\x00\x00SCK0T33UB2\xee[\x97S',
+ b'\xf1\x87VDHLG17000192DK2xdFffT\xa5VUD$DwT\x86wveVeeD&T\x99\xba\x8f\xff\xcc\x99\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\t\xb7\x17\xf5',
+ b'\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\t\xb7\x17\xf5',
],
},
CAR.PALISADE: {
From 60586e0d5835dbb3928321700c9d4d99cdeec216 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 05:39:18 +0800
Subject: [PATCH 009/137] Cabana: align the charts properly (#26116)
---
tools/cabana/chartswidget.cc | 20 +++++++++++++++++++-
tools/cabana/chartswidget.h | 1 +
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/tools/cabana/chartswidget.cc b/tools/cabana/chartswidget.cc
index e69729c03a..3652720e12 100644
--- a/tools/cabana/chartswidget.cc
+++ b/tools/cabana/chartswidget.cc
@@ -2,6 +2,7 @@
#include
#include
+#include
#include
#include
@@ -183,7 +184,6 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
font.setBold(true);
chart->setTitleFont(font);
chart->setMargins({0, 0, 0, 0});
- chart->layout()->setContentsMargins(0, 0, 0, 0);
track_line = new QGraphicsLineItem(chart);
track_line->setPen(QPen(Qt::gray, 1, Qt::DashLine));
@@ -202,14 +202,32 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
rubber->setPalette(pal);
}
+ QTimer *timer = new QTimer(this);
+ timer->setInterval(100);
+ timer->setSingleShot(true);
+ timer->callOnTimeout(this, &ChartView::adjustChartMargins);
+
QObject::connect(can, &CANMessages::updated, this, &ChartView::updateState);
QObject::connect(can, &CANMessages::rangeChanged, this, &ChartView::rangeChanged);
QObject::connect(can, &CANMessages::eventsMerged, this, &ChartView::updateSeries);
QObject::connect(dynamic_cast(chart->axisX()), &QValueAxis::rangeChanged, can, &CANMessages::setRange);
+ QObject::connect(chart, &QChart::plotAreaChanged, [=](const QRectF &plotArea) {
+ // use a singleshot timer to avoid recursion call.
+ timer->start();
+ });
updateSeries();
}
+void ChartView::adjustChartMargins() {
+ // TODO: Remove hardcoded aligned_pos
+ const int aligned_pos = 60;
+ if (chart()->plotArea().left() != aligned_pos) {
+ const float left_margin = chart()->margins().left() + aligned_pos - chart()->plotArea().left();
+ chart()->setMargins(QMargins(left_margin, 0, 0, 0));
+ }
+}
+
void ChartWidget::setHeight(int height) {
chart_view->setFixedHeight(height);
}
diff --git a/tools/cabana/chartswidget.h b/tools/cabana/chartswidget.h
index 3e43409dc4..fe2e14db9f 100644
--- a/tools/cabana/chartswidget.h
+++ b/tools/cabana/chartswidget.h
@@ -27,6 +27,7 @@ private:
void mouseMoveEvent(QMouseEvent *ev) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
+ void adjustChartMargins();
void rangeChanged(qreal min, qreal max);
void updateAxisY();
From c6b8a253e68fc62cd9eb3261e7f08d3cb3d3414d Mon Sep 17 00:00:00 2001
From: Cameron Clough
Date: Mon, 17 Oct 2022 15:36:29 -0700
Subject: [PATCH 010/137] networking: fix metered setting (#26113)
when metered set unknown, when unmetered set no
---
selfdrive/ui/qt/offroad/wifiManager.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc
index 62de3041b9..fde8645586 100644
--- a/selfdrive/ui/qt/offroad/wifiManager.cc
+++ b/selfdrive/ui/qt/offroad/wifiManager.cc
@@ -368,7 +368,7 @@ void WifiManager::updateGsmSettings(bool roaming, QString apn, bool metered) {
changes = true;
}
- int meteredInt = metered ? NM_METERED_NO : NM_METERED_UNKNOWN;
+ int meteredInt = metered ? NM_METERED_UNKNOWN : NM_METERED_NO;
if (settings.value("connection").value("metered").toInt() != meteredInt) {
qWarning() << "Changing connection.metered to" << meteredInt;
settings["connection"]["metered"] = meteredInt;
From e6cab24e08323ce1e8d846365a6ca1770a54f851 Mon Sep 17 00:00:00 2001
From: Cameron Clough
Date: Mon, 17 Oct 2022 15:38:31 -0700
Subject: [PATCH 011/137] updated: sync submodules (#26121)
---
selfdrive/updated.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/selfdrive/updated.py b/selfdrive/updated.py
index 9568b28ae3..57f957cfff 100755
--- a/selfdrive/updated.py
+++ b/selfdrive/updated.py
@@ -365,6 +365,7 @@ class Updater:
["git", "checkout", "--force", "--no-recurse-submodules", "-B", branch, "FETCH_HEAD"],
["git", "reset", "--hard"],
["git", "clean", "-xdff"],
+ ["git", "submodule", "sync"],
["git", "submodule", "init"],
["git", "submodule", "update"],
]
From 15b8c7d1dc3a75d78c0bbaa4f6b866374f6e8672 Mon Sep 17 00:00:00 2001
From: Adeeb Shihadeh
Date: Mon, 17 Oct 2022 17:14:38 -0700
Subject: [PATCH 012/137] ui: publish draw times + add test (#26119)
* ui: publish draw times + add test
* add some checks
* adjust
* fix linter
* update max
Co-authored-by: Comma Device
---
cereal | 2 +-
selfdrive/debug/check_timings.py | 2 +-
selfdrive/test/test_onroad.py | 23 +++++++++++++++++++++--
selfdrive/ui/qt/onroad.cc | 10 ++++++++++
selfdrive/ui/qt/onroad.h | 1 +
5 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/cereal b/cereal
index 5766e645f2..107048c83e 160000
--- a/cereal
+++ b/cereal
@@ -1 +1 @@
-Subproject commit 5766e645f2ee2a131b145fb1ea9e3b7c55a4a740
+Subproject commit 107048c83ec2f488286a1be314e7aece0a20a6b1
diff --git a/selfdrive/debug/check_timings.py b/selfdrive/debug/check_timings.py
index 083e084ca7..fb8467a3c4 100755
--- a/selfdrive/debug/check_timings.py
+++ b/selfdrive/debug/check_timings.py
@@ -19,7 +19,7 @@ if __name__ == "__main__":
for m in msgs:
ts[s].append(m.logMonoTime / 1e6)
- if len(ts[s]):
+ if len(ts[s]) > 2:
d = np.diff(ts[s])
print(f"{s:25} {np.mean(d):.2f} {np.std(d):.2f} {np.max(d):.2f} {np.min(d):.2f}")
time.sleep(1)
diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py
index b29ca5d35b..0d3d7b367a 100755
--- a/selfdrive/test/test_onroad.py
+++ b/selfdrive/test/test_onroad.py
@@ -120,8 +120,8 @@ class TestOnroad(unittest.TestCase):
if "DEBUG" in os.environ:
segs = filter(lambda x: os.path.exists(os.path.join(x, "rlog")), Path(ROOT).iterdir())
segs = sorted(segs, key=lambda x: x.stat().st_mtime)
- print(segs[-1])
- cls.lr = list(LogReader(os.path.join(segs[-1], "rlog")))
+ print(segs[-2])
+ cls.lr = list(LogReader(os.path.join(segs[-2], "rlog")))
return
# setup env
@@ -187,6 +187,25 @@ class TestOnroad(unittest.TestCase):
big_logs = [f for f, n in cnt.most_common(3) if n / sum(cnt.values()) > 30.]
self.assertEqual(len(big_logs), 0, f"Log spam: {big_logs}")
+ def test_ui_timings(self):
+ result = "\n"
+ result += "------------------------------------------------\n"
+ result += "-------------- UI Draw Timing ------------------\n"
+ result += "------------------------------------------------\n"
+
+ ts = [m.uiDebug.drawTimeMillis for m in self.lr if m.which() == 'uiDebug']
+ result += f"min {min(ts):.2f}ms\n"
+ result += f"max {max(ts):.2f}ms\n"
+ result += f"std {np.std(ts):.2f}ms\n"
+ result += f"mean {np.mean(ts):.2f}ms\n"
+ result += "------------------------------------------------\n"
+ print(result)
+
+ self.assertGreater(len(ts), 20*50, "insufficient samples")
+ self.assertLess(max(ts), 30.)
+ self.assertLess(np.mean(ts), 10.)
+ self.assertLess(np.std(ts), 5.)
+
def test_cpu_usage(self):
proclogs = [m for m in self.lr if m.which() == 'procLog']
self.assertGreater(len(proclogs), service_list['procLog'].frequency * 45, "insufficient samples")
diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc
index 0fbfb0cfc2..66bc38dbfc 100644
--- a/selfdrive/ui/qt/onroad.cc
+++ b/selfdrive/ui/qt/onroad.cc
@@ -176,6 +176,8 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
// NvgWindow
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) {
+ pm = std::make_unique>({"uiDebug"});
+
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size});
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size});
}
@@ -542,6 +544,8 @@ void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV
}
void NvgWindow::paintGL() {
+ const double start_draw_t = millis_since_boot();
+
UIState *s = uiState();
const cereal::ModelDataV2::Reader &model = (*s->sm)["modelV2"].getModelV2();
CameraViewWidget::setFrameId(model.getFrameId());
@@ -575,6 +579,12 @@ void NvgWindow::paintGL() {
LOGW("slow frame rate: %.2f fps", fps);
}
prev_draw_t = cur_draw_t;
+
+ // publish debug msg
+ MessageBuilder msg;
+ auto m = msg.initEvent().initUiDebug();
+ m.setDrawTimeMillis(cur_draw_t - start_draw_t);
+ pm->send("uiDebug", msg);
}
void NvgWindow::showEvent(QShowEvent *event) {
diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h
index 25920ccc6a..7ed2c9cc4a 100644
--- a/selfdrive/ui/qt/onroad.h
+++ b/selfdrive/ui/qt/onroad.h
@@ -68,6 +68,7 @@ private:
bool has_eu_speed_limit = false;
bool v_ego_cluster_seen = false;
int status = STATUS_DISENGAGED;
+ std::unique_ptr pm;
protected:
void paintGL() override;
From cd12ef4aa19a83f88532f5c1a8c3f290b87fcbf8 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 08:18:04 +0800
Subject: [PATCH 013/137] cabana: add a splitter between message lists and
detailview (#26118)
* add a splitter between message lists and detailview
* space
---
tools/cabana/mainwin.cc | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/cabana/mainwin.cc b/tools/cabana/mainwin.cc
index 999a4816b0..7aea8097cf 100644
--- a/tools/cabana/mainwin.cc
+++ b/tools/cabana/mainwin.cc
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include
MainWindow::MainWindow() : QWidget() {
@@ -13,12 +14,16 @@ MainWindow::MainWindow() : QWidget() {
QHBoxLayout *h_layout = new QHBoxLayout();
main_layout->addLayout(h_layout);
+ QSplitter *splitter = new QSplitter(Qt::Horizontal, this);
+
messages_widget = new MessagesWidget(this);
- h_layout->addWidget(messages_widget);
+ splitter->addWidget(messages_widget);
detail_widget = new DetailWidget(this);
- detail_widget->setFixedWidth(600);
- h_layout->addWidget(detail_widget);
+ splitter->addWidget(detail_widget);
+
+ splitter->setSizes({100, 500});
+ h_layout->addWidget(splitter);
// right widgets
QWidget *right_container = new QWidget(this);
From 409e8f5f89a38f9893a1f28f8fabd3bf526b46eb Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 08:18:24 +0800
Subject: [PATCH 014/137] cabana: faster history log with better stretch mode
(#26112)
---
tools/cabana/historylog.cc | 59 ++++++++++++++------------------------
tools/cabana/historylog.h | 13 +++++----
2 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/tools/cabana/historylog.cc b/tools/cabana/historylog.cc
index cbb3b6e882..c0efbca280 100644
--- a/tools/cabana/historylog.cc
+++ b/tools/cabana/historylog.cc
@@ -5,21 +5,16 @@
#include
QVariant HistoryLogModel::data(const QModelIndex &index, int role) const {
- auto msg = dbc()->msg(msg_id);
+ bool has_signal = dbc_msg && !dbc_msg->sigs.empty();
if (role == Qt::DisplayRole) {
- const auto &can_msgs = can->messages(msg_id);
- if (index.row() < can_msgs.size()) {
- const auto &can_data = can_msgs[index.row()];
- if (msg && index.column() < msg->sigs.size()) {
- return get_raw_value((uint8_t *)can_data.dat.begin(), can_data.dat.size(), msg->sigs[index.column()]);
- } else {
- return toHex(can_data.dat);
- }
- }
- } else if (role == Qt::FontRole) {
- if (index.column() == 0 && !(msg && msg->sigs.size() > 0)) {
- return QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ const auto &m = can->messages(msg_id)[index.row()];
+ if (index.column() == 0) {
+ return QString::number(m.ts, 'f', 2);
}
+ return has_signal ? QString::number(get_raw_value((uint8_t *)m.dat.begin(), m.dat.size(), dbc_msg->sigs[index.column() - 1]))
+ : toHex(m.dat);
+ } else if (role == Qt::FontRole && index.column() == 1 && !has_signal) {
+ return QFontDatabase::systemFont(QFontDatabase::FixedFont);
}
return {};
}
@@ -27,8 +22,8 @@ QVariant HistoryLogModel::data(const QModelIndex &index, int role) const {
void HistoryLogModel::setMessage(const QString &message_id) {
beginResetModel();
msg_id = message_id;
- const auto msg = dbc()->msg(message_id);
- column_count = msg && !msg->sigs.empty() ? msg->sigs.size() : 1;
+ dbc_msg = dbc()->msg(message_id);
+ column_count = (dbc_msg && !dbc_msg->sigs.empty() ? dbc_msg->sigs.size() : 1) + 1;
row_count = 0;
endResetModel();
@@ -37,18 +32,14 @@ void HistoryLogModel::setMessage(const QString &message_id) {
QVariant HistoryLogModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal) {
- auto msg = dbc()->msg(msg_id);
- if (msg && section < msg->sigs.size()) {
- if (role == Qt::BackgroundRole) {
- return QBrush(QColor(getColor(section)));
- } else if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
- return QString::fromStdString(msg->sigs[section].name);
+ bool has_signal = dbc_msg && !dbc_msg->sigs.empty();
+ if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
+ if (section == 0) {
+ return "Time";
}
- }
- } else if (role == Qt::DisplayRole) {
- const auto &can_msgs = can->messages(msg_id);
- if (section < can_msgs.size()) {
- return QString::number(can_msgs[section].ts, 'f', 2);
+ return has_signal ? dbc_msg->sigs[section - 1].name.c_str() : "Data";
+ } else if (role == Qt::BackgroundRole && section > 0 && has_signal) {
+ return QBrush(QColor(getColor(section - 1)));
}
}
return {};
@@ -69,7 +60,6 @@ void HistoryLogModel::updateState() {
}
if (row_count > 0) {
emit dataChanged(index(0, 0), index(row_count - 1, column_count - 1), {Qt::DisplayRole});
- emit headerDataChanged(Qt::Vertical, 0, row_count - 1);
}
}
@@ -79,17 +69,10 @@ HistoryLog::HistoryLog(QWidget *parent) : QWidget(parent) {
model = new HistoryLogModel(this);
table = new QTableView(this);
table->setModel(model);
- table->horizontalHeader()->setStretchLastSection(true);
- table->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
+ table->setColumnWidth(0, 60);
+ table->verticalHeader()->setVisible(false);
table->setStyleSheet("QTableView::item { border:0px; padding-left:5px; padding-right:5px; }");
- table->verticalHeader()->setStyleSheet("QHeaderView::section {padding-left: 5px; padding-right: 5px;min-width:40px;}");
main_layout->addWidget(table);
}
-
-void HistoryLog::setMessage(const QString &message_id) {
- model->setMessage(message_id);
-}
-
-void HistoryLog::updateState() {
- model->updateState();
-}
diff --git a/tools/cabana/historylog.h b/tools/cabana/historylog.h
index f3a9046bfa..bc6d1f9376 100644
--- a/tools/cabana/historylog.h
+++ b/tools/cabana/historylog.h
@@ -6,21 +6,22 @@
#include "tools/cabana/dbcmanager.h"
class HistoryLogModel : public QAbstractTableModel {
-Q_OBJECT
+ Q_OBJECT
public:
HistoryLogModel(QObject *parent) : QAbstractTableModel(parent) {}
void setMessage(const QString &message_id);
void updateState();
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override { return column_count; }
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override { return row_count; }
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override { return column_count; }
private:
QString msg_id;
int row_count = 0;
- int column_count = 0;
+ int column_count = 2;
+ const Msg *dbc_msg = nullptr;
};
class HistoryLog : public QWidget {
@@ -28,8 +29,8 @@ class HistoryLog : public QWidget {
public:
HistoryLog(QWidget *parent);
- void setMessage(const QString &message_id);
- void updateState();
+ void setMessage(const QString &message_id) { model->setMessage(message_id); }
+ void updateState() { model->updateState(); }
private:
QTableView *table;
From 99b16151fcc621832d573b9f7858eb5020f6503a Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 08:19:41 +0800
Subject: [PATCH 015/137] Cabana: show MSB/LSB of signals in the BinaryView
(#26103)
* dispaly msb and lsb in binary view
* draw at bottom
* move binaryview to seperate files
* increase the width of vertical header
* re-draw changed cells only
* correct lsb/msb position
* check bounds
* todo
---
tools/cabana/SConscript | 2 +-
tools/cabana/binaryview.cc | 184 +++++++++++++++++++++++++++++++++++
tools/cabana/binaryview.h | 72 ++++++++++++++
tools/cabana/canmessages.h | 1 +
tools/cabana/detailwidget.cc | 98 +------------------
tools/cabana/detailwidget.h | 26 +----
tools/cabana/signaledit.cc | 3 +
7 files changed, 265 insertions(+), 121 deletions(-)
create mode 100644 tools/cabana/binaryview.cc
create mode 100644 tools/cabana/binaryview.h
diff --git a/tools/cabana/SConscript b/tools/cabana/SConscript
index 8dbd4f1d1c..fd44ecd138 100644
--- a/tools/cabana/SConscript
+++ b/tools/cabana/SConscript
@@ -12,5 +12,5 @@ else:
qt_libs = ['qt_util', 'Qt5Charts'] + base_libs
cabana_libs = [widgets, cereal, messaging, visionipc, replay_lib, opendbc,'avutil', 'avcodec', 'avformat', 'bz2', 'curl', 'yuv'] + qt_libs
-qt_env.Program('_cabana', ['cabana.cc', 'mainwin.cc', 'chartswidget.cc', 'historylog.cc', 'videowidget.cc', 'signaledit.cc', 'dbcmanager.cc',
+qt_env.Program('_cabana', ['cabana.cc', 'mainwin.cc', 'binaryview.cc', 'chartswidget.cc', 'historylog.cc', 'videowidget.cc', 'signaledit.cc', 'dbcmanager.cc',
'canmessages.cc', 'messageswidget.cc', 'detailwidget.cc'], LIBS=cabana_libs, FRAMEWORKS=base_frameworks)
diff --git a/tools/cabana/binaryview.cc b/tools/cabana/binaryview.cc
new file mode 100644
index 0000000000..3b962b6de1
--- /dev/null
+++ b/tools/cabana/binaryview.cc
@@ -0,0 +1,184 @@
+#include "tools/cabana/binaryview.h"
+
+#include
+#include
+#include
+
+#include "tools/cabana/canmessages.h"
+
+// BinaryView
+
+const int CELL_HEIGHT = 35;
+
+BinaryView::BinaryView(QWidget *parent) : QTableView(parent) {
+ model = new BinaryViewModel(this);
+ setModel(model);
+ setItemDelegate(new BinaryItemDelegate(this));
+ horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ horizontalHeader()->hide();
+ verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ // replace selection model
+ auto old_model = selectionModel();
+ setSelectionModel(new BinarySelectionModel(model));
+ delete old_model;
+
+ QObject::connect(model, &QAbstractItemModel::modelReset, [this]() {
+ setFixedHeight((CELL_HEIGHT + 1) * std::min(model->rowCount(), 8) + 2);
+ });
+}
+
+void BinaryView::mouseReleaseEvent(QMouseEvent *event) {
+ QTableView::mouseReleaseEvent(event);
+
+ if (auto indexes = selectedIndexes(); !indexes.isEmpty()) {
+ int start_bit = indexes.first().row() * 8 + indexes.first().column();
+ int size = indexes.back().row() * 8 + indexes.back().column() - start_bit + 1;
+ emit cellsSelected(start_bit, size);
+ }
+}
+
+void BinaryView::setMessage(const QString &message_id) {
+ msg_id = message_id;
+ model->setMessage(message_id);
+ resizeRowsToContents();
+ clearSelection();
+ updateState();
+}
+
+void BinaryView::updateState() {
+ model->updateState();
+}
+
+// BinaryViewModel
+
+void BinaryViewModel::setMessage(const QString &message_id) {
+ msg_id = message_id;
+
+ beginResetModel();
+ items.clear();
+ row_count = 0;
+
+ dbc_msg = dbc()->msg(msg_id);
+ if (dbc_msg) {
+ row_count = dbc_msg->size;
+ items.resize(row_count * column_count);
+ for (int i = 0; i < dbc_msg->sigs.size(); ++i) {
+ const auto &sig = dbc_msg->sigs[i];
+ const int start = sig.is_little_endian ? sig.start_bit : bigEndianBitIndex(sig.start_bit);
+ const int end = start + sig.size - 1;
+ for (int j = start; j <= end; ++j) {
+ int idx = column_count * (j / 8) + j % 8;
+ if (idx >= items.size()) {
+ qWarning() << "signal " << sig.name.c_str() << "out of bounds.start_bit:" << sig.start_bit << "size:" << sig.size;
+ break;
+ }
+ if (j == start) {
+ sig.is_little_endian ? items[idx].is_lsb = true : items[idx].is_msb = true;
+ } else if (j == end) {
+ sig.is_little_endian ? items[idx].is_msb = true : items[idx].is_lsb = true;
+ }
+ items[idx].bg_color = QColor(getColor(i));
+ }
+ }
+ }
+
+ endResetModel();
+}
+
+QModelIndex BinaryViewModel::index(int row, int column, const QModelIndex &parent) const {
+ return createIndex(row, column, (void *)&items[row * column_count + column]);
+}
+
+Qt::ItemFlags BinaryViewModel::flags(const QModelIndex &index) const {
+ return (index.column() == column_count - 1) ? Qt::ItemIsEnabled : Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+void BinaryViewModel::updateState() {
+ auto prev_items = items;
+
+ const auto &binary = can->lastMessage(msg_id).dat;
+ // data size may changed.
+ if (!dbc_msg && binary.size() != row_count) {
+ beginResetModel();
+ row_count = binary.size();
+ items.clear();
+ items.resize(row_count * column_count);
+ endResetModel();
+ }
+
+ char hex[3] = {'\0'};
+ for (int i = 0; i < std::min(binary.size(), row_count); ++i) {
+ for (int j = 0; j < column_count - 1; ++j) {
+ items[i * column_count + j].val = QChar((binary[i] >> (7 - j)) & 1 ? '1' : '0');
+ }
+ hex[0] = toHex(binary[i] >> 4);
+ hex[1] = toHex(binary[i] & 0xf);
+ items[i * column_count + 8].val = hex;
+ }
+
+ for (int i = 0; i < items.size(); ++i) {
+ if (i >= prev_items.size() || prev_items[i].val != items[i].val) {
+ auto idx = index(i / column_count, i % column_count);
+ emit dataChanged(idx, idx);
+ }
+ }
+}
+
+QVariant BinaryViewModel::headerData(int section, Qt::Orientation orientation, int role) const {
+ if (orientation == Qt::Vertical) {
+ switch (role) {
+ case Qt::DisplayRole: return section + 1;
+ case Qt::SizeHintRole: return QSize(30, CELL_HEIGHT);
+ case Qt::TextAlignmentRole: return Qt::AlignCenter;
+ }
+ }
+ return {};
+}
+
+// BinarySelectionModel
+
+void BinarySelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) {
+ QItemSelection new_selection = selection;
+ if (auto indexes = selection.indexes(); !indexes.isEmpty()) {
+ auto [begin_idx, end_idx] = (QModelIndex[]){indexes.first(), indexes.back()};
+ for (int row = begin_idx.row(); row <= end_idx.row(); ++row) {
+ int left_col = (row == begin_idx.row()) ? begin_idx.column() : 0;
+ int right_col = (row == end_idx.row()) ? end_idx.column() : 7;
+ new_selection.merge({model()->index(row, left_col), model()->index(row, right_col)}, command);
+ }
+ }
+ QItemSelectionModel::select(new_selection, command);
+}
+
+// BinaryItemDelegate
+
+BinaryItemDelegate::BinaryItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {
+ // cache fonts and color
+ small_font.setPointSize(7);
+ bold_font.setBold(true);
+ highlight_color = QApplication::style()->standardPalette().color(QPalette::Active, QPalette::Highlight);
+}
+
+QSize BinaryItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
+ QSize sz = QStyledItemDelegate::sizeHint(option, index);
+ return {sz.width(), CELL_HEIGHT};
+}
+
+void BinaryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
+ auto item = (const BinaryViewModel::Item *)index.internalPointer();
+ painter->save();
+ // TODO: highlight signal cells on mouse over
+ painter->fillRect(option.rect, option.state & QStyle::State_Selected ? highlight_color : item->bg_color);
+ if (index.column() == 8) {
+ painter->setFont(bold_font);
+ }
+ painter->drawText(option.rect, Qt::AlignCenter, item->val);
+ if (item->is_msb || item->is_lsb) {
+ painter->setFont(small_font);
+ painter->drawText(option.rect, Qt::AlignHCenter | Qt::AlignBottom, item->is_msb ? "MSB" : "LSB");
+ }
+
+ painter->restore();
+}
diff --git a/tools/cabana/binaryview.h b/tools/cabana/binaryview.h
new file mode 100644
index 0000000000..631797ca48
--- /dev/null
+++ b/tools/cabana/binaryview.h
@@ -0,0 +1,72 @@
+#pragma once
+
+#include
+#include
+
+#include "tools/cabana/dbcmanager.h"
+
+class BinaryItemDelegate : public QStyledItemDelegate {
+ Q_OBJECT
+
+public:
+ BinaryItemDelegate(QObject *parent);
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+ QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+
+private:
+ QFont small_font, bold_font;
+ QColor highlight_color;
+};
+
+class BinaryViewModel : public QAbstractTableModel {
+ Q_OBJECT
+
+public:
+ BinaryViewModel(QObject *parent) : QAbstractTableModel(parent) {}
+ void setMessage(const QString &message_id);
+ void updateState();
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { return {}; }
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override { return row_count; }
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override { return column_count; }
+
+ struct Item {
+ QColor bg_color = QColor(Qt::white);
+ bool is_msb = false;
+ bool is_lsb = false;
+ QString val = "0";
+ };
+
+private:
+ QString msg_id;
+ const Msg *dbc_msg;
+ int row_count = 0;
+ const int column_count = 9;
+ std::vector- items;
+};
+
+// the default QItemSelectionModel does not support our selection mode.
+class BinarySelectionModel : public QItemSelectionModel {
+ public:
+ BinarySelectionModel(QAbstractItemModel *model = nullptr) : QItemSelectionModel(model) {}
+ void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override;
+};
+
+class BinaryView : public QTableView {
+ Q_OBJECT
+
+public:
+ BinaryView(QWidget *parent = nullptr);
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void setMessage(const QString &message_id);
+ void updateState();
+
+signals:
+ void cellsSelected(int start_bit, int size);
+
+private:
+ QString msg_id;
+ BinaryViewModel *model;
+};
diff --git a/tools/cabana/canmessages.h b/tools/cabana/canmessages.h
index 7f6955369b..fe71840d74 100644
--- a/tools/cabana/canmessages.h
+++ b/tools/cabana/canmessages.h
@@ -91,6 +91,7 @@ inline char toHex(uint value) {
}
inline const QString &getColor(int i) {
+ // TODO: add more colors
static const QString SIGNAL_COLORS[] = {"#9FE2BF", "#40E0D0", "#6495ED", "#CCCCFF", "#FF7F50", "#FFBF00"};
return SIGNAL_COLORS[i % std::size(SIGNAL_COLORS)];
}
diff --git a/tools/cabana/detailwidget.cc b/tools/cabana/detailwidget.cc
index a9899ec650..60d0632d4c 100644
--- a/tools/cabana/detailwidget.cc
+++ b/tools/cabana/detailwidget.cc
@@ -1,13 +1,13 @@
#include "tools/cabana/detailwidget.h"
#include
-#include
#include
-#include
#include
-#include
#include
+#include "tools/cabana/canmessages.h"
+#include "tools/cabana/dbcmanager.h"
+
// DetailWidget
DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent) {
@@ -141,98 +141,6 @@ void DetailWidget::removeSignal() {
}
}
-// BinaryView
-
-BinaryView::BinaryView(QWidget *parent) : QTableWidget(parent) {
- horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
- verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
- horizontalHeader()->hide();
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setColumnCount(9);
-
- // replace selection model
- auto old_model = selectionModel();
- setSelectionModel(new BinarySelectionModel(model()));
- delete old_model;
-}
-
-void BinaryView::mouseReleaseEvent(QMouseEvent *event) {
- QTableWidget::mouseReleaseEvent(event);
-
- if (auto items = selectedItems(); !items.isEmpty()) {
- int start_bit = items.first()->row() * 8 + items.first()->column();
- int size = items.back()->row() * 8 + items.back()->column() - start_bit + 1;
- emit cellsSelected(start_bit, size);
- }
-}
-
-void BinaryView::setMessage(const QString &message_id) {
- msg_id = message_id;
- if (msg_id.isEmpty()) return;
-
- const Msg *msg = dbc()->msg(msg_id);
- int row_count = msg ? msg->size : can->lastMessage(msg_id).dat.size();
- setRowCount(row_count);
- setColumnCount(9);
- for (int i = 0; i < rowCount(); ++i) {
- for (int j = 0; j < columnCount(); ++j) {
- auto item = new QTableWidgetItem();
- item->setFlags(item->flags() ^ Qt::ItemIsEditable);
- item->setTextAlignment(Qt::AlignCenter);
- if (j == 8) {
- QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
- font.setBold(true);
- item->setFont(font);
- item->setFlags(item->flags() ^ Qt::ItemIsSelectable);
- }
- setItem(i, j, item);
- }
- }
-
- // set background color
- if (msg) {
- for (int i = 0; i < msg->sigs.size(); ++i) {
- const auto &sig = msg->sigs[i];
- int start = sig.is_little_endian ? sig.start_bit : bigEndianBitIndex(sig.start_bit);
- for (int j = start; j <= std::min(start + sig.size - 1, rowCount() * columnCount() - 1); ++j) {
- item(j / 8, j % 8)->setBackground(QColor(getColor(i)));
- }
- }
- }
-
- setFixedHeight(rowHeight(0) * std::min(row_count, 8) + 2);
- clearSelection();
- updateState();
-}
-
-void BinaryView::updateState() {
- const auto &binary = can->lastMessage(msg_id).dat;
- setUpdatesEnabled(false);
- char hex[3] = {'\0'};
- for (int i = 0; i < binary.size(); ++i) {
- for (int j = 0; j < 8; ++j) {
- item(i, j)->setText(QChar((binary[i] >> (7 - j)) & 1 ? '1' : '0'));
- }
- hex[0] = toHex(binary[i] >> 4);
- hex[1] = toHex(binary[i] & 0xf);
- item(i, 8)->setText(hex);
- }
- setUpdatesEnabled(true);
-}
-
-void BinarySelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) {
- QItemSelection new_selection = selection;
- if (auto indexes = selection.indexes(); !indexes.isEmpty()) {
- auto [begin_idx, end_idx] = (QModelIndex[]){indexes.first(), indexes.back()};
- for (int row = begin_idx.row(); row <= end_idx.row(); ++row) {
- int left_col = (row == begin_idx.row()) ? begin_idx.column() : 0;
- int right_col = (row == end_idx.row()) ? end_idx.column() : 7;
- new_selection.merge({model()->index(row, left_col), model()->index(row, right_col)}, command);
- }
- }
- QItemSelectionModel::select(new_selection, command);
-}
-
// EditMessageDialog
EditMessageDialog::EditMessageDialog(const QString &msg_id, const QString &title, int size, QWidget *parent) : QDialog(parent) {
diff --git a/tools/cabana/detailwidget.h b/tools/cabana/detailwidget.h
index db174873f7..9d3b81dcb0 100644
--- a/tools/cabana/detailwidget.h
+++ b/tools/cabana/detailwidget.h
@@ -1,35 +1,11 @@
#pragma once
#include
-#include
-#include "opendbc/can/common.h"
-#include "opendbc/can/common_dbc.h"
-#include "tools/cabana/canmessages.h"
-#include "tools/cabana/dbcmanager.h"
+#include "tools/cabana/binaryview.h"
#include "tools/cabana/historylog.h"
#include "tools/cabana/signaledit.h"
-class BinarySelectionModel : public QItemSelectionModel {
-public:
- BinarySelectionModel(QAbstractItemModel *model = nullptr) : QItemSelectionModel(model) {}
- void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override;
-};
-
-class BinaryView : public QTableWidget {
- Q_OBJECT
-public:
- BinaryView(QWidget *parent = nullptr);
- void mouseReleaseEvent(QMouseEvent *event) override;
- void setMessage(const QString &message_id);
- void updateState();
-signals:
- void cellsSelected(int start_bit, int size);
-
-private:
- QString msg_id;
-};
-
class EditMessageDialog : public QDialog {
Q_OBJECT
diff --git a/tools/cabana/signaledit.cc b/tools/cabana/signaledit.cc
index 2da3e2eec2..b52f83dab6 100644
--- a/tools/cabana/signaledit.cc
+++ b/tools/cabana/signaledit.cc
@@ -23,6 +23,9 @@ SignalForm::SignalForm(const Signal &sig, QWidget *parent) : start_bit(sig.start
endianness->setCurrentIndex(sig.is_little_endian ? 0 : 1);
form_layout->addRow(tr("Endianness"), endianness);
+ form_layout->addRow(tr("lsb"), new QLabel(QString::number(sig.lsb)));
+ form_layout->addRow(tr("msb"), new QLabel(QString::number(sig.msb)));
+
sign = new QComboBox();
sign->addItems({"Signed", "Unsigned"});
sign->setCurrentIndex(sig.is_signed ? 0 : 1);
From c782e4d796e0981b3717222cb5551911fe40cb7a Mon Sep 17 00:00:00 2001
From: Jake Poznanski
Date: Mon, 17 Oct 2022 17:22:47 -0700
Subject: [PATCH 016/137] loggerd: fix length of ArrayPtr in handle_encoder_msg
(#26077)
---
selfdrive/loggerd/loggerd.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/selfdrive/loggerd/loggerd.cc b/selfdrive/loggerd/loggerd.cc
index e0892e68b4..9beb3c3bf1 100644
--- a/selfdrive/loggerd/loggerd.cc
+++ b/selfdrive/loggerd/loggerd.cc
@@ -55,7 +55,7 @@ int handle_encoder_msg(LoggerdState *s, Message *msg, std::string &name, struct
int bytes_count = 0;
// extract the message
- capnp::FlatArrayMessageReader cmsg(kj::ArrayPtr((capnp::word *)msg->getData(), msg->getSize()));
+ capnp::FlatArrayMessageReader cmsg(kj::ArrayPtr((capnp::word *)msg->getData(), msg->getSize() / sizeof(capnp::word)));
auto event = cmsg.getRoot();
auto edata = (name == "driverEncodeData") ? event.getDriverEncodeData() :
((name == "wideRoadEncodeData") ? event.getWideRoadEncodeData() :
From baca1cae1f71c70162374c887cf36d5cf828f2f3 Mon Sep 17 00:00:00 2001
From: HaraldSchafer
Date: Mon, 17 Oct 2022 18:18:01 -0700
Subject: [PATCH 017/137] UI Onroad widget renames (#26124)
Consistent widget naming
---
selfdrive/ui/qt/offroad/driverview.cc | 4 +--
selfdrive/ui/qt/offroad/driverview.h | 2 +-
selfdrive/ui/qt/onroad.cc | 45 ++++++++++++-----------
selfdrive/ui/qt/onroad.h | 6 ++--
selfdrive/ui/qt/widgets/cameraview.cc | 26 +++++++-------
selfdrive/ui/qt/widgets/cameraview.h | 6 ++--
selfdrive/ui/translations/main_ar.ts | 2 +-
selfdrive/ui/translations/main_ja.ts | 46 ++++++++++++------------
selfdrive/ui/translations/main_ko.ts | 46 ++++++++++++------------
selfdrive/ui/translations/main_nl.ts | 2 +-
selfdrive/ui/translations/main_pl.ts | 2 +-
selfdrive/ui/translations/main_pt-BR.ts | 46 ++++++++++++------------
selfdrive/ui/translations/main_th.ts | 2 +-
selfdrive/ui/translations/main_zh-CHS.ts | 46 ++++++++++++------------
selfdrive/ui/translations/main_zh-CHT.ts | 46 ++++++++++++------------
selfdrive/ui/watch3.cc | 8 ++---
tools/cabana/videowidget.cc | 6 ++--
tools/cabana/videowidget.h | 2 +-
18 files changed, 173 insertions(+), 170 deletions(-)
diff --git a/selfdrive/ui/qt/offroad/driverview.cc b/selfdrive/ui/qt/offroad/driverview.cc
index be8b84d45e..0ff786fb91 100644
--- a/selfdrive/ui/qt/offroad/driverview.cc
+++ b/selfdrive/ui/qt/offroad/driverview.cc
@@ -12,11 +12,11 @@ DriverViewWindow::DriverViewWindow(QWidget* parent) : QWidget(parent) {
layout = new QStackedLayout(this);
layout->setStackingMode(QStackedLayout::StackAll);
- cameraView = new CameraViewWidget("camerad", VISION_STREAM_DRIVER, true, this);
+ cameraView = new CameraWidget("camerad", VISION_STREAM_DRIVER, true, this);
layout->addWidget(cameraView);
scene = new DriverViewScene(this);
- connect(cameraView, &CameraViewWidget::vipcThreadFrameReceived, scene, &DriverViewScene::frameUpdated);
+ connect(cameraView, &CameraWidget::vipcThreadFrameReceived, scene, &DriverViewScene::frameUpdated);
layout->addWidget(scene);
layout->setCurrentWidget(scene);
}
diff --git a/selfdrive/ui/qt/offroad/driverview.h b/selfdrive/ui/qt/offroad/driverview.h
index 5d090ad772..255857970d 100644
--- a/selfdrive/ui/qt/offroad/driverview.h
+++ b/selfdrive/ui/qt/offroad/driverview.h
@@ -42,7 +42,7 @@ protected:
void mouseReleaseEvent(QMouseEvent* e) override;
private:
- CameraViewWidget *cameraView;
+ CameraWidget *cameraView;
DriverViewScene *scene;
QStackedLayout *layout;
};
diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc
index 66bc38dbfc..1f677fc92d 100644
--- a/selfdrive/ui/qt/onroad.cc
+++ b/selfdrive/ui/qt/onroad.cc
@@ -18,7 +18,7 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
stacked_layout->setStackingMode(QStackedLayout::StackAll);
main_layout->addLayout(stacked_layout);
- nvg = new NvgWindow(VISION_STREAM_ROAD, this);
+ nvg = new AnnotatedCameraWidget(VISION_STREAM_ROAD, this);
QWidget * split_wrapper = new QWidget;
split = new QHBoxLayout(split_wrapper);
@@ -27,7 +27,7 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
split->addWidget(nvg);
if (getenv("DUAL_CAMERA_VIEW")) {
- CameraViewWidget *arCam = new CameraViewWidget("camerad", VISION_STREAM_ROAD, true, this);
+ CameraWidget *arCam = new CameraWidget("camerad", VISION_STREAM_ROAD, true, this);
split->insertWidget(0, arCam);
}
@@ -173,16 +173,15 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
}
}
-// NvgWindow
-NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) {
+AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraWidget("camerad", type, true, parent) {
pm = std::make_unique>({"uiDebug"});
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size});
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size});
}
-void NvgWindow::updateState(const UIState &s) {
+void AnnotatedCameraWidget::updateState(const UIState &s) {
const int SET_SPEED_NA = 255;
const SubMaster &sm = *(s.sm);
@@ -234,13 +233,13 @@ void NvgWindow::updateState(const UIState &s) {
}
if (s.scene.calibration_valid) {
- CameraViewWidget::updateCalibration(s.scene.view_from_calib);
+ CameraWidget::updateCalibration(s.scene.view_from_calib);
} else {
- CameraViewWidget::updateCalibration(DEFAULT_CALIBRATION);
+ CameraWidget::updateCalibration(DEFAULT_CALIBRATION);
}
}
-void NvgWindow::drawHud(QPainter &p) {
+void AnnotatedCameraWidget::drawHud(QPainter &p) {
p.save();
// Header gradient
@@ -402,7 +401,11 @@ void NvgWindow::drawHud(QPainter &p) {
p.restore();
}
-void NvgWindow::drawText(QPainter &p, int x, int y, const QString &text, int alpha) {
+
+// Window that shows camera view and variety of
+// info drawn on top
+
+void AnnotatedCameraWidget::drawText(QPainter &p, int x, int y, const QString &text, int alpha) {
QRect real_rect = getTextRect(p, 0, text);
real_rect.moveCenter({x, y - real_rect.height() / 2});
@@ -410,7 +413,7 @@ void NvgWindow::drawText(QPainter &p, int x, int y, const QString &text, int alp
p.drawText(real_rect.x(), real_rect.bottom(), text);
}
-void NvgWindow::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) {
+void AnnotatedCameraWidget::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) {
p.setPen(Qt::NoPen);
p.setBrush(bg);
p.drawEllipse(x - radius / 2, y - radius / 2, radius, radius);
@@ -419,8 +422,8 @@ void NvgWindow::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, flo
}
-void NvgWindow::initializeGL() {
- CameraViewWidget::initializeGL();
+void AnnotatedCameraWidget::initializeGL() {
+ CameraWidget::initializeGL();
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION));
qInfo() << "OpenGL vendor:" << QString((const char*)glGetString(GL_VENDOR));
qInfo() << "OpenGL renderer:" << QString((const char*)glGetString(GL_RENDERER));
@@ -430,8 +433,8 @@ void NvgWindow::initializeGL() {
setBackgroundColor(bg_colors[STATUS_DISENGAGED]);
}
-void NvgWindow::updateFrameMat() {
- CameraViewWidget::updateFrameMat();
+void AnnotatedCameraWidget::updateFrameMat() {
+ CameraWidget::updateFrameMat();
UIState *s = uiState();
int w = width(), h = height();
@@ -448,7 +451,7 @@ void NvgWindow::updateFrameMat() {
.translate(-intrinsic_matrix.v[2], -intrinsic_matrix.v[5]);
}
-void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
+void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
painter.save();
const UIScene &scene = s->scene;
@@ -507,7 +510,7 @@ void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
painter.restore();
}
-void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) {
+void AnnotatedCameraWidget::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) {
painter.save();
const float speedBuff = 10.;
@@ -543,13 +546,13 @@ void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV
painter.restore();
}
-void NvgWindow::paintGL() {
+void AnnotatedCameraWidget::paintGL() {
const double start_draw_t = millis_since_boot();
UIState *s = uiState();
const cereal::ModelDataV2::Reader &model = (*s->sm)["modelV2"].getModelV2();
- CameraViewWidget::setFrameId(model.getFrameId());
- CameraViewWidget::paintGL();
+ CameraWidget::setFrameId(model.getFrameId());
+ CameraWidget::paintGL();
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
@@ -587,8 +590,8 @@ void NvgWindow::paintGL() {
pm->send("uiDebug", msg);
}
-void NvgWindow::showEvent(QShowEvent *event) {
- CameraViewWidget::showEvent(event);
+void AnnotatedCameraWidget::showEvent(QShowEvent *event) {
+ CameraWidget::showEvent(event);
ui_update_params(uiState());
prev_draw_t = millis_since_boot();
diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h
index 7ed2c9cc4a..2a663185f4 100644
--- a/selfdrive/ui/qt/onroad.h
+++ b/selfdrive/ui/qt/onroad.h
@@ -25,7 +25,7 @@ private:
};
// container window for the NVG UI
-class NvgWindow : public CameraViewWidget {
+class AnnotatedCameraWidget : public CameraWidget {
Q_OBJECT
Q_PROPERTY(float speed MEMBER speed);
Q_PROPERTY(QString speedUnit MEMBER speedUnit);
@@ -43,7 +43,7 @@ class NvgWindow : public CameraViewWidget {
Q_PROPERTY(int status MEMBER status);
public:
- explicit NvgWindow(VisionStreamType type, QWidget* parent = 0);
+ explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0);
void updateState(const UIState &s);
private:
@@ -98,7 +98,7 @@ private:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* e) override;
OnroadAlerts *alerts;
- NvgWindow *nvg;
+ AnnotatedCameraWidget *nvg;
QColor bg = bg_colors[STATUS_DISENGAGED];
QWidget *map = nullptr;
QHBoxLayout* split;
diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc
index 63d15660a0..200257235d 100644
--- a/selfdrive/ui/qt/widgets/cameraview.cc
+++ b/selfdrive/ui/qt/widgets/cameraview.cc
@@ -93,14 +93,14 @@ mat4 get_fit_view_transform(float widget_aspect_ratio, float frame_aspect_ratio)
} // namespace
-CameraViewWidget::CameraViewWidget(std::string stream_name, VisionStreamType type, bool zoom, QWidget* parent) :
+CameraWidget::CameraWidget(std::string stream_name, VisionStreamType type, bool zoom, QWidget* parent) :
stream_name(stream_name), stream_type(type), zoomed_view(zoom), QOpenGLWidget(parent) {
setAttribute(Qt::WA_OpaquePaintEvent);
- connect(this, &CameraViewWidget::vipcThreadConnected, this, &CameraViewWidget::vipcConnected, Qt::BlockingQueuedConnection);
- connect(this, &CameraViewWidget::vipcThreadFrameReceived, this, &CameraViewWidget::vipcFrameReceived);
+ connect(this, &CameraWidget::vipcThreadConnected, this, &CameraWidget::vipcConnected, Qt::BlockingQueuedConnection);
+ connect(this, &CameraWidget::vipcThreadFrameReceived, this, &CameraWidget::vipcFrameReceived);
}
-CameraViewWidget::~CameraViewWidget() {
+CameraWidget::~CameraWidget() {
makeCurrent();
if (isValid()) {
glDeleteVertexArrays(1, &frame_vao);
@@ -111,7 +111,7 @@ CameraViewWidget::~CameraViewWidget() {
doneCurrent();
}
-void CameraViewWidget::initializeGL() {
+void CameraWidget::initializeGL() {
initializeOpenGLFunctions();
program = std::make_unique(context());
@@ -161,7 +161,7 @@ void CameraViewWidget::initializeGL() {
#endif
}
-void CameraViewWidget::showEvent(QShowEvent *event) {
+void CameraWidget::showEvent(QShowEvent *event) {
frames.clear();
if (!vipc_thread) {
vipc_thread = new QThread();
@@ -171,7 +171,7 @@ void CameraViewWidget::showEvent(QShowEvent *event) {
}
}
-void CameraViewWidget::hideEvent(QHideEvent *event) {
+void CameraWidget::hideEvent(QHideEvent *event) {
if (vipc_thread) {
vipc_thread->requestInterruption();
vipc_thread->quit();
@@ -180,7 +180,7 @@ void CameraViewWidget::hideEvent(QHideEvent *event) {
}
}
-void CameraViewWidget::updateFrameMat() {
+void CameraWidget::updateFrameMat() {
int w = width(), h = height();
if (zoomed_view) {
@@ -224,12 +224,12 @@ void CameraViewWidget::updateFrameMat() {
}
}
-void CameraViewWidget::updateCalibration(const mat3 &calib) {
+void CameraWidget::updateCalibration(const mat3 &calib) {
calibration = calib;
updateFrameMat();
}
-void CameraViewWidget::paintGL() {
+void CameraWidget::paintGL() {
glClearColor(bg.redF(), bg.greenF(), bg.blueF(), bg.alphaF());
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
@@ -286,7 +286,7 @@ void CameraViewWidget::paintGL() {
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
-void CameraViewWidget::vipcConnected(VisionIpcClient *vipc_client) {
+void CameraWidget::vipcConnected(VisionIpcClient *vipc_client) {
makeCurrent();
frames.clear();
stream_width = vipc_client->buffers[0].width;
@@ -339,7 +339,7 @@ void CameraViewWidget::vipcConnected(VisionIpcClient *vipc_client) {
updateFrameMat();
}
-void CameraViewWidget::vipcFrameReceived(VisionBuf *buf, uint32_t frame_id) {
+void CameraWidget::vipcFrameReceived(VisionBuf *buf, uint32_t frame_id) {
frames.push_back(std::make_pair(frame_id, buf));
while (frames.size() > FRAME_BUFFER_SIZE) {
frames.pop_front();
@@ -347,7 +347,7 @@ void CameraViewWidget::vipcFrameReceived(VisionBuf *buf, uint32_t frame_id) {
update();
}
-void CameraViewWidget::vipcThread() {
+void CameraWidget::vipcThread() {
VisionStreamType cur_stream_type = stream_type;
std::unique_ptr vipc_client;
VisionIpcBufExtra meta_main = {0};
diff --git a/selfdrive/ui/qt/widgets/cameraview.h b/selfdrive/ui/qt/widgets/cameraview.h
index 081483b649..9bcad935c0 100644
--- a/selfdrive/ui/qt/widgets/cameraview.h
+++ b/selfdrive/ui/qt/widgets/cameraview.h
@@ -23,13 +23,13 @@
const int FRAME_BUFFER_SIZE = 5;
static_assert(FRAME_BUFFER_SIZE <= YUV_BUFFER_COUNT);
-class CameraViewWidget : public QOpenGLWidget, protected QOpenGLFunctions {
+class CameraWidget : public QOpenGLWidget, protected QOpenGLFunctions {
Q_OBJECT
public:
using QOpenGLWidget::QOpenGLWidget;
- explicit CameraViewWidget(std::string stream_name, VisionStreamType stream_type, bool zoom, QWidget* parent = nullptr);
- ~CameraViewWidget();
+ explicit CameraWidget(std::string stream_name, VisionStreamType stream_type, bool zoom, QWidget* parent = nullptr);
+ ~CameraWidget();
void setStreamType(VisionStreamType type) { stream_type = type; }
void setBackgroundColor(const QColor &color) { bg = color; }
void setFrameId(int frame_id) { draw_frame_id = frame_id; }
diff --git a/selfdrive/ui/translations/main_ar.ts b/selfdrive/ui/translations/main_ar.ts
index 284208720b..a94d2fbc05 100644
--- a/selfdrive/ui/translations/main_ar.ts
+++ b/selfdrive/ui/translations/main_ar.ts
@@ -493,7 +493,7 @@ location set
- NvgWindow
+ AnnotatedCameraWidget
km/h
diff --git a/selfdrive/ui/translations/main_ja.ts b/selfdrive/ui/translations/main_ja.ts
index b39c83c098..314a6b8338 100644
--- a/selfdrive/ui/translations/main_ja.ts
+++ b/selfdrive/ui/translations/main_ja.ts
@@ -67,6 +67,29 @@
+
+ AnnotatedCameraWidget
+
+ km/h
+ km/h
+
+
+ mph
+ mph
+
+
+ MAX
+ 最高速度
+
+
+ SPEED
+ 速度
+
+
+ LIMIT
+ 制限速度
+
+
ConfirmationDialog
@@ -406,29 +429,6 @@ location set
パスワードが間違っています
-
- NvgWindow
-
- km/h
- km/h
-
-
- mph
- mph
-
-
- MAX
- 最高速度
-
-
- SPEED
- 速度
-
-
- LIMIT
- 制限速度
-
-
OffroadHome
diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts
index f84797eb60..021243595e 100644
--- a/selfdrive/ui/translations/main_ko.ts
+++ b/selfdrive/ui/translations/main_ko.ts
@@ -67,6 +67,29 @@
데이터 요금제 연결 시 대용량 데이터 업로드 방지
+
+ AnnotatedCameraWidget
+
+ km/h
+ km/h
+
+
+ mph
+ mph
+
+
+ MAX
+ MAX
+
+
+ SPEED
+ SPEED
+
+
+ LIMIT
+ LIMIT
+
+
ConfirmationDialog
@@ -406,29 +429,6 @@ location set
비밀번호가 틀렸습니다
-
- NvgWindow
-
- km/h
- km/h
-
-
- mph
- mph
-
-
- MAX
- MAX
-
-
- SPEED
- SPEED
-
-
- LIMIT
- LIMIT
-
-
OffroadHome
diff --git a/selfdrive/ui/translations/main_nl.ts b/selfdrive/ui/translations/main_nl.ts
index 99646ed749..21bb66d356 100644
--- a/selfdrive/ui/translations/main_nl.ts
+++ b/selfdrive/ui/translations/main_nl.ts
@@ -489,7 +489,7 @@ ingesteld
- NvgWindow
+ AnnotatedCameraWidget
km/h
diff --git a/selfdrive/ui/translations/main_pl.ts b/selfdrive/ui/translations/main_pl.ts
index 8593d68261..92902d04a9 100644
--- a/selfdrive/ui/translations/main_pl.ts
+++ b/selfdrive/ui/translations/main_pl.ts
@@ -490,7 +490,7 @@ nie zostało ustawione
- NvgWindow
+ AnnotatedCameraWidget
km/h
diff --git a/selfdrive/ui/translations/main_pt-BR.ts b/selfdrive/ui/translations/main_pt-BR.ts
index 8f59bf4715..2afdaf3388 100644
--- a/selfdrive/ui/translations/main_pt-BR.ts
+++ b/selfdrive/ui/translations/main_pt-BR.ts
@@ -67,6 +67,29 @@
Evite grandes uploads de dados quando estiver em uma conexão limitada
+
+ AnnotatedCameraWidget
+
+ km/h
+ km/h
+
+
+ mph
+ mph
+
+
+ MAX
+ LIMITE
+
+
+ SPEED
+ MAX
+
+
+ LIMIT
+ VELO
+
+
ConfirmationDialog
@@ -407,29 +430,6 @@ trabalho definido
Senha incorreta
-
- NvgWindow
-
- km/h
- km/h
-
-
- mph
- mph
-
-
- MAX
- LIMITE
-
-
- SPEED
- MAX
-
-
- LIMIT
- VELO
-
-
OffroadHome
diff --git a/selfdrive/ui/translations/main_th.ts b/selfdrive/ui/translations/main_th.ts
index 7e7fcf2788..d502c3fce1 100644
--- a/selfdrive/ui/translations/main_th.ts
+++ b/selfdrive/ui/translations/main_th.ts
@@ -488,7 +488,7 @@ location set
- NvgWindow
+ AnnotatedCameraWidget
km/h
diff --git a/selfdrive/ui/translations/main_zh-CHS.ts b/selfdrive/ui/translations/main_zh-CHS.ts
index 1d942387e0..9e7c354444 100644
--- a/selfdrive/ui/translations/main_zh-CHS.ts
+++ b/selfdrive/ui/translations/main_zh-CHS.ts
@@ -67,6 +67,29 @@
+
+ AnnotatedCameraWidget
+
+ km/h
+ km/h
+
+
+ mph
+ mph
+
+
+ MAX
+ 最高定速
+
+
+ SPEED
+ SPEED
+
+
+ LIMIT
+ LIMIT
+
+
ConfirmationDialog
@@ -404,29 +427,6 @@ location set
密码错误
-
- NvgWindow
-
- km/h
- km/h
-
-
- mph
- mph
-
-
- MAX
- 最高定速
-
-
- SPEED
- SPEED
-
-
- LIMIT
- LIMIT
-
-
OffroadHome
diff --git a/selfdrive/ui/translations/main_zh-CHT.ts b/selfdrive/ui/translations/main_zh-CHT.ts
index 816d4fd3cc..513135c7f4 100644
--- a/selfdrive/ui/translations/main_zh-CHT.ts
+++ b/selfdrive/ui/translations/main_zh-CHT.ts
@@ -67,6 +67,29 @@
+
+ AnnotatedCameraWidget
+
+ km/h
+ km/h
+
+
+ mph
+ mph
+
+
+ MAX
+ 最高
+
+
+ SPEED
+ 速度
+
+
+ LIMIT
+ 速限
+
+
ConfirmationDialog
@@ -406,29 +429,6 @@ location set
密碼錯誤
-
- NvgWindow
-
- km/h
- km/h
-
-
- mph
- mph
-
-
- MAX
- 最高
-
-
- SPEED
- 速度
-
-
- LIMIT
- 速限
-
-
OffroadHome
diff --git a/selfdrive/ui/watch3.cc b/selfdrive/ui/watch3.cc
index d6b5cc67a7..ec35c29b6b 100644
--- a/selfdrive/ui/watch3.cc
+++ b/selfdrive/ui/watch3.cc
@@ -19,15 +19,15 @@ int main(int argc, char *argv[]) {
{
QHBoxLayout *hlayout = new QHBoxLayout();
layout->addLayout(hlayout);
- hlayout->addWidget(new CameraViewWidget("navd", VISION_STREAM_MAP, false));
- hlayout->addWidget(new CameraViewWidget("camerad", VISION_STREAM_ROAD, false));
+ hlayout->addWidget(new CameraWidget("navd", VISION_STREAM_MAP, false));
+ hlayout->addWidget(new CameraWidget("camerad", VISION_STREAM_ROAD, false));
}
{
QHBoxLayout *hlayout = new QHBoxLayout();
layout->addLayout(hlayout);
- hlayout->addWidget(new CameraViewWidget("camerad", VISION_STREAM_DRIVER, false));
- hlayout->addWidget(new CameraViewWidget("camerad", VISION_STREAM_WIDE_ROAD, false));
+ hlayout->addWidget(new CameraWidget("camerad", VISION_STREAM_DRIVER, false));
+ hlayout->addWidget(new CameraWidget("camerad", VISION_STREAM_WIDE_ROAD, false));
}
return a.exec();
diff --git a/tools/cabana/videowidget.cc b/tools/cabana/videowidget.cc
index b6fe8de3e2..bb90d56570 100644
--- a/tools/cabana/videowidget.cc
+++ b/tools/cabana/videowidget.cc
@@ -16,8 +16,8 @@ inline QString formatTime(int seconds) {
VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent) {
QVBoxLayout *main_layout = new QVBoxLayout(this);
- // TODO: figure out why the CameraViewWidget crashed occasionally.
- cam_widget = new CameraViewWidget("camerad", VISION_STREAM_ROAD, false, this);
+ // TODO: figure out why the CameraWidget crashed occasionally.
+ cam_widget = new CameraWidget("camerad", VISION_STREAM_ROAD, false, this);
cam_widget->setFixedSize(parent->width(), parent->width() / 1.596);
main_layout->addWidget(cam_widget);
@@ -60,7 +60,7 @@ VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent) {
QObject::connect(can, &CANMessages::updated, this, &VideoWidget::updateState);
QObject::connect(slider, &QSlider::sliderReleased, [this]() { can->seekTo(slider->value() / 1000.0); });
QObject::connect(slider, &QSlider::valueChanged, [=](int value) { time_label->setText(formatTime(value / 1000)); });
- QObject::connect(cam_widget, &CameraViewWidget::clicked, [this]() { pause(!can->isPaused()); });
+ QObject::connect(cam_widget, &CameraWidget::clicked, [this]() { pause(!can->isPaused()); });
QObject::connect(play_btn, &QPushButton::clicked, [=]() { pause(!can->isPaused()); });
}
diff --git a/tools/cabana/videowidget.h b/tools/cabana/videowidget.h
index fd896f1e11..d6d036c461 100644
--- a/tools/cabana/videowidget.h
+++ b/tools/cabana/videowidget.h
@@ -32,7 +32,7 @@ protected:
void updateState();
void pause(bool pause);
- CameraViewWidget *cam_widget;
+ CameraWidget *cam_widget;
QLabel *end_time_label;
QPushButton *play_btn;
Slider *slider;
From 755a6c0a46f07cdadb06821ced904af458fbf4e3 Mon Sep 17 00:00:00 2001
From: Adeeb Shihadeh
Date: Mon, 17 Oct 2022 19:15:21 -0700
Subject: [PATCH 018/137] Revert "tools/replay: reduce test running time
(#26110)"
This reverts commit 6d07268ee5b385010961eab206b0b42a0ae6b5f8.
---
tools/replay/tests/test_replay.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/replay/tests/test_replay.cc b/tools/replay/tests/test_replay.cc
index 3fd410bb6e..5b61b6b6f2 100644
--- a/tools/replay/tests/test_replay.cc
+++ b/tools/replay/tests/test_replay.cc
@@ -207,7 +207,8 @@ void TestReplay::test_seek() {
}
TEST_CASE("Replay") {
- TestReplay replay(DEMO_ROUTE, (uint8_t)REPLAY_FLAG_NO_VIPC);
+ auto flag = GENERATE(REPLAY_FLAG_NO_FILE_CACHE, REPLAY_FLAG_NONE);
+ TestReplay replay(DEMO_ROUTE, flag);
REQUIRE(replay.load());
replay.test_seek();
}
From d522492ba0b80928adc475c1f37b995834c31a90 Mon Sep 17 00:00:00 2001
From: ZwX1616
Date: Mon, 17 Oct 2022 19:40:06 -0700
Subject: [PATCH 019/137] DM: add use of e2e preds (#26078)
* try ml
* de56
* j914ef75a
* jd1124586
* jd1124586
* d112
* oops
* set
* update ref
* use offset
* bump DM power usage
* new ref
---
.../modeld/models/dmonitoring_model.current | 4 ++--
.../modeld/models/dmonitoring_model.onnx | 4 ++--
.../modeld/models/dmonitoring_model_q.dlc | 4 ++--
selfdrive/monitoring/driver_monitor.py | 21 +++++++++----------
.../process_replay/model_replay_ref_commit | 2 +-
selfdrive/test/process_replay/ref_commit | 2 +-
system/hardware/tici/test_power_draw.py | 2 +-
7 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/selfdrive/modeld/models/dmonitoring_model.current b/selfdrive/modeld/models/dmonitoring_model.current
index d1e7d1136f..065bc7d489 100644
--- a/selfdrive/modeld/models/dmonitoring_model.current
+++ b/selfdrive/modeld/models/dmonitoring_model.current
@@ -1,2 +1,2 @@
-ee8f830b-d6a1-42ef-9b1b-50fd0b2faae4
-cac8f7b69d420506707ff7a19d573d5011ef2533
\ No newline at end of file
+d1124586-761e-4e18-a771-6b5ef35124fe
+6fec774f513a19e44d4316e46ad38277197d45ea
\ No newline at end of file
diff --git a/selfdrive/modeld/models/dmonitoring_model.onnx b/selfdrive/modeld/models/dmonitoring_model.onnx
index 4cbd6bb7dd..f8bf94c061 100644
--- a/selfdrive/modeld/models/dmonitoring_model.onnx
+++ b/selfdrive/modeld/models/dmonitoring_model.onnx
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:932e589e5cce66e5d9f48492426a33c74cd7f352a870d3ddafcede3e9156f30d
-size 9157561
+oid sha256:517262fa9f1ad3cc8049ad3722903f40356d87ea423ee5cf011226fb6cfc3d5b
+size 16072278
diff --git a/selfdrive/modeld/models/dmonitoring_model_q.dlc b/selfdrive/modeld/models/dmonitoring_model_q.dlc
index 94632030ed..e4e6fb3347 100644
--- a/selfdrive/modeld/models/dmonitoring_model_q.dlc
+++ b/selfdrive/modeld/models/dmonitoring_model_q.dlc
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:3587976a8b7e3be274fa86c2e2233e3e464cad713f5077c4394cd1ddd3c7c6c5
-size 2636965
+oid sha256:64b94659226a1e3c6594a13c2e5d029465d5803a5c3005121ec7217acdbbef20
+size 4443461
diff --git a/selfdrive/monitoring/driver_monitor.py b/selfdrive/monitoring/driver_monitor.py
index 9ff3125c15..30781f4d1b 100644
--- a/selfdrive/monitoring/driver_monitor.py
+++ b/selfdrive/monitoring/driver_monitor.py
@@ -29,10 +29,10 @@ class DRIVER_MONITOR_SETTINGS():
self._FACE_THRESHOLD = 0.7
self._EYE_THRESHOLD = 0.65
self._SG_THRESHOLD = 0.9
- self._BLINK_THRESHOLD = 0.87
+ self._BLINK_THRESHOLD = 0.895
- self._EE_THRESH11 = 0.75
- self._EE_THRESH12 = 3.25
+ self._EE_THRESH11 = 0.275
+ self._EE_THRESH12 = 3.0
self._EE_THRESH21 = 0.01
self._EE_THRESH22 = 0.35
@@ -207,11 +207,11 @@ class DriverStatus():
ee1_dist = self.eev1 > self.ee1_offseter.filtered_stat.M * self.settings._EE_THRESH12
else:
ee1_dist = self.eev1 > self.settings._EE_THRESH11
- if self.ee2_calibrated:
- ee2_dist = self.eev2 < self.ee2_offseter.filtered_stat.M * self.settings._EE_THRESH22
- else:
- ee2_dist = self.eev2 < self.settings._EE_THRESH21
- if ee1_dist or ee2_dist:
+ # if self.ee2_calibrated:
+ # ee2_dist = self.eev2 < self.ee2_offseter.filtered_stat.M * self.settings._EE_THRESH22
+ # else:
+ # ee2_dist = self.eev2 < self.settings._EE_THRESH21
+ if ee1_dist:
distracted_types.append(DistractedType.DISTRACTED_E2E)
return distracted_types
@@ -257,12 +257,11 @@ class DriverStatus():
self.pose.low_std = model_std_max < self.settings._POSESTD_THRESHOLD
self.blink.left_blink = driver_data.leftBlinkProb * (driver_data.leftEyeProb > self.settings._EYE_THRESHOLD) * (driver_data.sunglassesProb < self.settings._SG_THRESHOLD)
self.blink.right_blink = driver_data.rightBlinkProb * (driver_data.rightEyeProb > self.settings._EYE_THRESHOLD) * (driver_data.sunglassesProb < self.settings._SG_THRESHOLD)
- self.eev1 = driver_data.notReadyProb[1]
+ self.eev1 = driver_data.notReadyProb[0]
self.eev2 = driver_data.readyProb[0]
self.distracted_types = self._get_distracted_types()
- self.driver_distracted = (DistractedType.DISTRACTED_POSE in self.distracted_types or
- DistractedType.DISTRACTED_BLINK in self.distracted_types) and \
+ self.driver_distracted = (DistractedType.DISTRACTED_E2E in self.distracted_types or DistractedType.DISTRACTED_POSE in self.distracted_types or DistractedType.DISTRACTED_BLINK in self.distracted_types) and \
driver_data.faceProb > self.settings._FACE_THRESHOLD and self.pose.low_std
self.driver_distraction_filter.update(self.driver_distracted)
diff --git a/selfdrive/test/process_replay/model_replay_ref_commit b/selfdrive/test/process_replay/model_replay_ref_commit
index b3e9c8c488..5bb045ec29 100644
--- a/selfdrive/test/process_replay/model_replay_ref_commit
+++ b/selfdrive/test/process_replay/model_replay_ref_commit
@@ -1 +1 @@
-bfb0a2a52212d2aa1619d999aaae97fa7f7ff788
+865885fc49b2766326568e5cc7ec06be8a3f6fad
diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit
index 864b7019a0..998bf4e756 100644
--- a/selfdrive/test/process_replay/ref_commit
+++ b/selfdrive/test/process_replay/ref_commit
@@ -1 +1 @@
-e5a86c14e2318f2dd218b3985cdbea6f875f7d83
+6bb7d8baae51d88dd61f0baf561e386664ddd266
\ No newline at end of file
diff --git a/system/hardware/tici/test_power_draw.py b/system/hardware/tici/test_power_draw.py
index 4830975917..2460152998 100755
--- a/system/hardware/tici/test_power_draw.py
+++ b/system/hardware/tici/test_power_draw.py
@@ -21,7 +21,7 @@ class Proc:
PROCS = [
Proc('camerad', 2.15),
Proc('modeld', 1.15, atol=0.2),
- Proc('dmonitoringmodeld', 0.35),
+ Proc('dmonitoringmodeld', 0.4),
Proc('encoderd', 0.23),
]
From 988fede1858486ec0679f208540a88533e9296e3 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 12:00:07 +0800
Subject: [PATCH 020/137] cabana: reduce the padding in DetailsView (#26126)
---
tools/cabana/binaryview.cc | 4 ++--
tools/cabana/signaledit.cc | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/cabana/binaryview.cc b/tools/cabana/binaryview.cc
index 3b962b6de1..71175e783e 100644
--- a/tools/cabana/binaryview.cc
+++ b/tools/cabana/binaryview.cc
@@ -8,7 +8,7 @@
// BinaryView
-const int CELL_HEIGHT = 35;
+const int CELL_HEIGHT = 30;
BinaryView::BinaryView(QWidget *parent) : QTableView(parent) {
model = new BinaryViewModel(this);
@@ -156,7 +156,7 @@ void BinarySelectionModel::select(const QItemSelection &selection, QItemSelectio
BinaryItemDelegate::BinaryItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {
// cache fonts and color
- small_font.setPointSize(7);
+ small_font.setPointSize(6);
bold_font.setBold(true);
highlight_color = QApplication::style()->standardPalette().color(QPalette::Active, QPalette::Highlight);
}
diff --git a/tools/cabana/signaledit.cc b/tools/cabana/signaledit.cc
index b52f83dab6..7cace48402 100644
--- a/tools/cabana/signaledit.cc
+++ b/tools/cabana/signaledit.cc
@@ -85,18 +85,17 @@ SignalEdit::SignalEdit(int index, const QString &msg_id, const Signal &sig, QWid
// title bar
QHBoxLayout *title_layout = new QHBoxLayout();
icon = new QLabel(">");
- icon->setFixedSize(15, 30);
icon->setStyleSheet("font-weight:bold");
title_layout->addWidget(icon);
title = new ElidedLabel(this);
title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
title->setText(QString("%1. %2").arg(index + 1).arg(sig_name));
title->setStyleSheet(QString("font-weight:bold; color:%1").arg(getColor(index)));
- title_layout->addWidget(title);
+ title_layout->addWidget(title, 1);
QPushButton *plot_btn = new QPushButton("📈");
plot_btn->setToolTip(tr("Show Plot"));
- plot_btn->setFixedSize(30, 30);
+ plot_btn->setFixedSize(20, 20);
QObject::connect(plot_btn, &QPushButton::clicked, this, &SignalEdit::showChart);
title_layout->addWidget(plot_btn);
main_layout->addLayout(title_layout);
From b89b881bdccb0fb844c597e9d26b64d36ba4af99 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 12:00:20 +0800
Subject: [PATCH 021/137] cabana: sort DBC list alphabetically (#26127)
---
tools/cabana/messageswidget.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/cabana/messageswidget.cc b/tools/cabana/messageswidget.cc
index 3c9af67ea6..878a852e13 100644
--- a/tools/cabana/messageswidget.cc
+++ b/tools/cabana/messageswidget.cc
@@ -21,6 +21,7 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
for (const auto &name : dbc_names) {
combo->addItem(QString::fromStdString(name));
}
+ combo->model()->sort(0);
combo->setEditable(true);
combo->setCurrentText(QString());
combo->setInsertPolicy(QComboBox::NoInsert);
From 544526edeb343d4b6f9c7c6f2521659c34d37012 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 12:00:36 +0800
Subject: [PATCH 022/137] cabana: fix chart margins (#26125)
---
tools/cabana/chartswidget.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/cabana/chartswidget.cc b/tools/cabana/chartswidget.cc
index 3652720e12..811eae68cb 100644
--- a/tools/cabana/chartswidget.cc
+++ b/tools/cabana/chartswidget.cc
@@ -184,6 +184,7 @@ ChartView::ChartView(const QString &id, const Signal *sig, QWidget *parent)
font.setBold(true);
chart->setTitleFont(font);
chart->setMargins({0, 0, 0, 0});
+ chart->layout()->setContentsMargins(0, 0, 0, 0);
track_line = new QGraphicsLineItem(chart);
track_line->setPen(QPen(Qt::gray, 1, Qt::DashLine));
From 60fc7274eb631559f772ea0969e0ec28026e1426 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 21:15:57 -0700
Subject: [PATCH 023/137] =?UTF-8?q?Hyundai=20CAN-FD:=20remove=2090=C2=B0?=
=?UTF-8?q?=20steering=20lockout=20(#26045)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* bump panda
* bump panda
* for CAN-FD too
* clean up
* bump
* adjust safety
* fix lat active
* bump panda to master
* same limits
* rm line
* bump panda to master
---
panda | 2 +-
selfdrive/car/hyundai/carcontroller.py | 29 +++++++++++++-------------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/panda b/panda
index 62868c36a8..9ed3f75f67 160000
--- a/panda
+++ b/panda
@@ -1 +1 @@
-Subproject commit 62868c36a80d1f44064da7b47423f0ef331f64e9
+Subproject commit 9ed3f75f67c3e5f00f910c8d7497ebed63851b5a
diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py
index a5d995df25..6b38297eb9 100644
--- a/selfdrive/car/hyundai/carcontroller.py
+++ b/selfdrive/car/hyundai/carcontroller.py
@@ -90,13 +90,27 @@ class CarController:
addr, bus = 0x730, 5
can_sends.append([addr, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", bus])
+ # >90 degree steering fault prevention
+ # Count up to MAX_ANGLE_FRAMES, at which point we need to cut torque to avoid a steering fault
+ if CC.latActive and abs(CS.out.steeringAngleDeg) >= MAX_ANGLE:
+ self.angle_limit_counter += 1
+ else:
+ self.angle_limit_counter = 0
+
+ # Cut steer actuation bit for two frames and hold torque with induced temporary fault
+ torque_fault = CC.latActive and self.angle_limit_counter > MAX_ANGLE_FRAMES
+ lat_active = CC.latActive and not torque_fault
+
+ if self.angle_limit_counter >= MAX_ANGLE_FRAMES + MAX_ANGLE_CONSECUTIVE_FRAMES:
+ self.angle_limit_counter = 0
+
# CAN-FD platforms
if self.CP.carFingerprint in CANFD_CAR:
hda2 = self.CP.flags & HyundaiFlags.CANFD_HDA2
hda2_long = hda2 and self.CP.openpilotLongitudinalControl
# steering control
- can_sends.extend(hyundaicanfd.create_steering_messages(self.packer, self.CP, CC.enabled, CC.latActive, apply_steer))
+ can_sends.extend(hyundaicanfd.create_steering_messages(self.packer, self.CP, CC.enabled, lat_active, apply_steer))
# disable LFA on HDA2
if self.frame % 5 == 0 and hda2:
@@ -131,19 +145,6 @@ class CarController:
can_sends.append(hyundaicanfd.create_buttons(self.packer, CS.buttons_counter+1, Buttons.RES_ACCEL))
self.last_button_frame = self.frame
else:
- # Count up to MAX_ANGLE_FRAMES, at which point we need to cut torque to avoid a steering fault
- if CC.latActive and abs(CS.out.steeringAngleDeg) >= MAX_ANGLE:
- self.angle_limit_counter += 1
- else:
- self.angle_limit_counter = 0
-
- # Cut steer actuation bit for two frames and hold torque with induced temporary fault
- torque_fault = CC.latActive and self.angle_limit_counter > MAX_ANGLE_FRAMES
- lat_active = CC.latActive and not torque_fault
-
- if self.angle_limit_counter >= MAX_ANGLE_FRAMES + MAX_ANGLE_CONSECUTIVE_FRAMES:
- self.angle_limit_counter = 0
-
can_sends.append(hyundaican.create_lkas11(self.packer, self.frame, self.car_fingerprint, apply_steer, lat_active,
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
hud_control.leftLaneVisible, hud_control.rightLaneVisible,
From 12058c21c73c7777e260334827b30f4d24c8313d Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Tue, 18 Oct 2022 12:44:56 +0800
Subject: [PATCH 024/137] cabana: load dbc from paste (#26098)
---
opendbc | 2 +-
tools/cabana/dbcmanager.cc | 12 ++++++++
tools/cabana/dbcmanager.h | 1 +
tools/cabana/messageswidget.cc | 51 ++++++++++++++++++++++++++--------
tools/cabana/messageswidget.h | 13 +++++++++
5 files changed, 66 insertions(+), 13 deletions(-)
diff --git a/opendbc b/opendbc
index dde0ff6f44..e37ef84f1a 160000
--- a/opendbc
+++ b/opendbc
@@ -1 +1 @@
-Subproject commit dde0ff6f4456c167df204bf5ac1e3f2979c844c9
+Subproject commit e37ef84f1ab848e2bf37f2c755f9e56213ce14e2
diff --git a/tools/cabana/dbcmanager.cc b/tools/cabana/dbcmanager.cc
index 5b1bddcabe..fc40fc58e4 100644
--- a/tools/cabana/dbcmanager.cc
+++ b/tools/cabana/dbcmanager.cc
@@ -1,5 +1,6 @@
#include "tools/cabana/dbcmanager.h"
+#include
#include
DBCManager::DBCManager(QObject *parent) : QObject(parent) {}
@@ -16,6 +17,17 @@ void DBCManager::open(const QString &dbc_file_name) {
emit DBCFileChanged();
}
+void DBCManager::open(const QString &name, const QString &content) {
+ this->dbc_name = name;
+ std::istringstream stream(content.toStdString());
+ dbc = const_cast(dbc_parse_from_stream(name.toStdString(), stream));
+ msg_map.clear();
+ for (auto &msg : dbc->msgs) {
+ msg_map[msg.address] = &msg;
+ }
+ emit DBCFileChanged();
+}
+
void save(const QString &dbc_file_name) {
// TODO: save DBC to file
}
diff --git a/tools/cabana/dbcmanager.h b/tools/cabana/dbcmanager.h
index 1f890a39db..74d935119a 100644
--- a/tools/cabana/dbcmanager.h
+++ b/tools/cabana/dbcmanager.h
@@ -12,6 +12,7 @@ public:
~DBCManager();
void open(const QString &dbc_file_name);
+ void open(const QString &name, const QString &content);
void save(const QString &dbc_file_name);
void addSignal(const QString &id, const Signal &sig);
diff --git a/tools/cabana/messageswidget.cc b/tools/cabana/messageswidget.cc
index 878a852e13..28f79adad3 100644
--- a/tools/cabana/messageswidget.cc
+++ b/tools/cabana/messageswidget.cc
@@ -1,12 +1,13 @@
#include "tools/cabana/messageswidget.h"
-#include
#include
+#include
#include
#include
#include
#include
#include
+#include
#include
#include "tools/cabana/dbcmanager.h"
@@ -16,20 +17,23 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
// DBC file selector
QHBoxLayout *dbc_file_layout = new QHBoxLayout();
- QComboBox *combo = new QComboBox(this);
+ dbc_combo = new QComboBox(this);
auto dbc_names = dbc()->allDBCNames();
for (const auto &name : dbc_names) {
- combo->addItem(QString::fromStdString(name));
+ dbc_combo->addItem(QString::fromStdString(name));
}
- combo->model()->sort(0);
- combo->setEditable(true);
- combo->setCurrentText(QString());
- combo->setInsertPolicy(QComboBox::NoInsert);
- combo->completer()->setCompletionMode(QCompleter::PopupCompletion);
+ dbc_combo->model()->sort(0);
+ dbc_combo->setEditable(true);
+ dbc_combo->setCurrentText(QString());
+ dbc_combo->setInsertPolicy(QComboBox::NoInsert);
+ dbc_combo->completer()->setCompletionMode(QCompleter::PopupCompletion);
QFont font;
font.setBold(true);
- combo->lineEdit()->setFont(font);
- dbc_file_layout->addWidget(combo);
+ dbc_combo->lineEdit()->setFont(font);
+ dbc_file_layout->addWidget(dbc_combo);
+
+ QPushButton *load_from_paste = new QPushButton(tr("Load from paste"), this);
+ dbc_file_layout->addWidget(load_from_paste);
dbc_file_layout->addStretch();
QPushButton *save_btn = new QPushButton(tr("Save DBC"), this);
@@ -64,7 +68,8 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
// signals/slots
QObject::connect(filter, &QLineEdit::textChanged, proxy_model, &QSortFilterProxyModel::setFilterFixedString);
QObject::connect(can, &CANMessages::updated, model, &MessageListModel::updateState);
- QObject::connect(combo, SIGNAL(activated(const QString &)), SLOT(dbcSelectionChanged(const QString &)));
+ QObject::connect(dbc_combo, SIGNAL(activated(const QString &)), SLOT(dbcSelectionChanged(const QString &)));
+ QObject::connect(load_from_paste, &QPushButton::clicked, this, &MessagesWidget::loadFromPaste);
QObject::connect(save_btn, &QPushButton::clicked, [=]() {
// TODO: save DBC to file
});
@@ -75,7 +80,7 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
});
// For test purpose
- combo->setCurrentText("toyota_nodsu_pt_generated");
+ dbc_combo->setCurrentText("toyota_nodsu_pt_generated");
}
void MessagesWidget::dbcSelectionChanged(const QString &dbc_file) {
@@ -84,6 +89,14 @@ void MessagesWidget::dbcSelectionChanged(const QString &dbc_file) {
table_widget->sortByColumn(0, Qt::AscendingOrder);
}
+void MessagesWidget::loadFromPaste() {
+ LoadDBCDialog dlg(this);
+ if (dlg.exec()) {
+ dbc()->open("from paste", dlg.dbc_edit->toPlainText());
+ dbc_combo->setCurrentText("loaded from paste");
+ }
+}
+
// MessageListModel
QVariant MessageListModel::headerData(int section, Qt::Orientation orientation, int role) const {
@@ -133,3 +146,17 @@ void MessageListModel::updateState() {
emit dataChanged(index(0, 0), index(row_count - 1, 3), {Qt::DisplayRole});
}
}
+
+LoadDBCDialog::LoadDBCDialog(QWidget *parent) : QDialog(parent) {
+ QVBoxLayout *main_layout = new QVBoxLayout(this);
+ dbc_edit = new QTextEdit(this);
+ dbc_edit->setAcceptRichText(false);
+ dbc_edit->setPlaceholderText(tr("paste DBC file here"));
+ main_layout->addWidget(dbc_edit);
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ main_layout->addWidget(buttonBox);
+
+ setFixedWidth(640);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+}
diff --git a/tools/cabana/messageswidget.h b/tools/cabana/messageswidget.h
index f6487ba2bd..1184772f3b 100644
--- a/tools/cabana/messageswidget.h
+++ b/tools/cabana/messageswidget.h
@@ -1,10 +1,21 @@
#pragma once
#include
+#include
+#include
#include
+#include
#include "tools/cabana/canmessages.h"
+class LoadDBCDialog : public QDialog {
+ Q_OBJECT
+
+public:
+ LoadDBCDialog(QWidget *parent);
+ QTextEdit *dbc_edit;
+};
+
class MessageListModel : public QAbstractTableModel {
Q_OBJECT
@@ -28,11 +39,13 @@ public:
public slots:
void dbcSelectionChanged(const QString &dbc_file);
+ void loadFromPaste();
signals:
void msgSelectionChanged(const QString &message_id);
protected:
QTableView *table_widget;
+ QComboBox *dbc_combo;
MessageListModel *model;
};
From dcd804e2bfe2c29287749eb5777ced5a641c5e62 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 22:47:54 -0700
Subject: [PATCH 025/137] bump opendbc
---
opendbc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/opendbc b/opendbc
index e37ef84f1a..8f245e6ef5 160000
--- a/opendbc
+++ b/opendbc
@@ -1 +1 @@
-Subproject commit e37ef84f1ab848e2bf37f2c755f9e56213ce14e2
+Subproject commit 8f245e6ef5e25814d8e6e1f096221f6dfeefe86b
From 7bf70bf7d8aaccd23ad0b0a9af8235eb939a617e Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 23:04:06 -0700
Subject: [PATCH 026/137] CAN-FD HKG: query FW versions from camera (#26063)
* add adas essential ecus
* add adas ecu and query
* add queries
* add name
* after
* presence of adas ecu
* Revert "presence of adas ecu" (POC)
This reverts commit ab88a7e7df32e1c02a175b81848bd4112b2e5c69.
* no whitelist for debugging
* Apply suggestions from code review
* add adas response
* remove adas version
* temp
* read pandaStates
* works in debug script
* only fwdCamera on tucson
* fix pandaStates reading
* fix test_startup
* fix
* simpler
* use existing socket
* pass in number of pandas
* need to create sm using outcome of fingerprinting, which uses sm
fix
* move default argument
* use sock
* always ignore
always ignore
* add canfd fingerprint test
* Update selfdrive/car/hyundai/tests/test_hyundai.py
* set
---
selfdrive/car/car_helpers.py | 8 ++--
selfdrive/car/fw_versions.py | 14 +++++--
selfdrive/car/hyundai/tests/test_hyundai.py | 29 ++++++++++++++
selfdrive/car/hyundai/values.py | 42 +++++++--------------
selfdrive/controls/controlsd.py | 30 +++++++--------
selfdrive/controls/tests/test_startup.py | 3 ++
6 files changed, 74 insertions(+), 52 deletions(-)
create mode 100755 selfdrive/car/hyundai/tests/test_hyundai.py
diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py
index 4a8fd5fbd9..61e7a3d55d 100644
--- a/selfdrive/car/car_helpers.py
+++ b/selfdrive/car/car_helpers.py
@@ -76,7 +76,7 @@ interfaces = load_interfaces(interface_names)
# **** for use live only ****
-def fingerprint(logcan, sendcan):
+def fingerprint(logcan, sendcan, num_pandas):
fixed_fingerprint = os.environ.get('FINGERPRINT', "")
skip_fw_query = os.environ.get('SKIP_FW_QUERY', False)
ecu_rx_addrs = set()
@@ -100,7 +100,7 @@ def fingerprint(logcan, sendcan):
cloudlog.warning("Getting VIN & FW versions")
vin_rx_addr, vin = get_vin(logcan, sendcan, bus)
ecu_rx_addrs = get_present_ecus(logcan, sendcan)
- car_fw = get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs)
+ car_fw = get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs, num_pandas=num_pandas)
cached = False
exact_fw_match, fw_candidates = match_fw_to_car(car_fw)
@@ -173,8 +173,8 @@ def fingerprint(logcan, sendcan):
return car_fingerprint, finger, vin, car_fw, source, exact_match
-def get_car(logcan, sendcan):
- candidate, fingerprints, vin, car_fw, source, exact_match = fingerprint(logcan, sendcan)
+def get_car(logcan, sendcan, num_pandas=1):
+ candidate, fingerprints, vin, car_fw, source, exact_match = fingerprint(logcan, sendcan, num_pandas)
if candidate is None:
cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints)
diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py
index d3e8eae0de..f4d92ab960 100755
--- a/selfdrive/car/fw_versions.py
+++ b/selfdrive/car/fw_versions.py
@@ -194,14 +194,14 @@ def get_brand_ecu_matches(ecu_rx_addrs):
return brand_matches
-def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs, timeout=0.1, debug=False, progress=False):
+def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs, timeout=0.1, num_pandas=1, debug=False, progress=False):
"""Queries for FW versions ordering brands by likelihood, breaks when exact match is found"""
all_car_fw = []
brand_matches = get_brand_ecu_matches(ecu_rx_addrs)
for brand in sorted(brand_matches, key=lambda b: len(brand_matches[b]), reverse=True):
- car_fw = get_fw_versions(logcan, sendcan, query_brand=brand, timeout=timeout, debug=debug, progress=progress)
+ car_fw = get_fw_versions(logcan, sendcan, query_brand=brand, timeout=timeout, num_pandas=num_pandas, debug=debug, progress=progress)
all_car_fw.extend(car_fw)
# Try to match using FW returned from this brand only
matches = match_fw_to_car_exact(build_fw_dict(car_fw))
@@ -211,7 +211,7 @@ def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs, timeout=0.1, debug=Fa
return all_car_fw
-def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1, debug=False, progress=False):
+def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1, num_pandas=1, debug=False, progress=False):
versions = VERSIONS.copy()
# Each brand can define extra ECUs to query for data collection
@@ -252,6 +252,10 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1,
for addr in tqdm(addrs, disable=not progress):
for addr_chunk in chunks(addr):
for brand, r in requests:
+ # Skip query if no panda available
+ if r.bus > num_pandas * 4 - 1:
+ continue
+
try:
addrs = [(a, s) for (b, a, s) in addr_chunk if b in (brand, 'any') and
(len(r.whitelist_ecus) == 0 or ecu_types[(b, a, s)] in r.whitelist_ecus)]
@@ -292,6 +296,7 @@ if __name__ == "__main__":
args = parser.parse_args()
logcan = messaging.sub_sock('can')
+ pandaStates_sock = messaging.sub_sock('pandaStates')
sendcan = messaging.pub_sock('sendcan')
extra: Any = None
@@ -305,6 +310,7 @@ if __name__ == "__main__":
extra = {"any": {"debug": extra}}
time.sleep(1.)
+ num_pandas = len(messaging.recv_one_retry(pandaStates_sock).pandaStates)
t = time.time()
print("Getting vin...")
@@ -314,7 +320,7 @@ if __name__ == "__main__":
print()
t = time.time()
- fw_vers = get_fw_versions(logcan, sendcan, query_brand=args.brand, extra=extra, debug=args.debug, progress=True)
+ fw_vers = get_fw_versions(logcan, sendcan, query_brand=args.brand, extra=extra, num_pandas=num_pandas, debug=args.debug, progress=True)
_, candidates = match_fw_to_car(fw_vers)
print()
diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py
new file mode 100755
index 0000000000..a52027f448
--- /dev/null
+++ b/selfdrive/car/hyundai/tests/test_hyundai.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+import unittest
+
+from cereal import car
+from selfdrive.car.car_helpers import get_interface_attr
+from selfdrive.car.fw_versions import FW_QUERY_CONFIGS
+from selfdrive.car.hyundai.values import CANFD_CAR
+
+Ecu = car.CarParams.Ecu
+
+ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()}
+VERSIONS = get_interface_attr("FW_VERSIONS", ignore_none=True)
+
+
+class TestHyundaiFingerprint(unittest.TestCase):
+ def test_auxiliary_request_ecu_whitelist(self):
+ # Asserts only auxiliary Ecus can exist in database for CAN-FD cars
+ config = FW_QUERY_CONFIGS['hyundai']
+ whitelisted_ecus = {ecu for r in config.requests for ecu in r.whitelist_ecus if r.bus > 3}
+
+ for car_model in CANFD_CAR:
+ ecus = {fw[0] for fw in VERSIONS['hyundai'][car_model].keys()}
+ ecus_not_in_whitelist = ecus - whitelisted_ecus
+ ecu_strings = ", ".join([f'Ecu.{ECU_NAME[ecu]}' for ecu in ecus_not_in_whitelist])
+ self.assertEqual(len(ecus_not_in_whitelist), 0, f'{car_model}: Car model has ECUs not in auxiliary request whitelists: {ecu_strings}')
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py
index 856bf1abd9..1599005d1c 100644
--- a/selfdrive/car/hyundai/values.py
+++ b/selfdrive/car/hyundai/values.py
@@ -300,6 +300,19 @@ FW_QUERY_CONFIG = FwQueryConfig(
[HYUNDAI_VERSION_RESPONSE],
whitelist_ecus=[Ecu.engine, Ecu.transmission, Ecu.eps, Ecu.abs, Ecu.fwdRadar],
),
+ # CAN-FD queries
+ Request(
+ [HYUNDAI_VERSION_REQUEST_LONG],
+ [HYUNDAI_VERSION_RESPONSE],
+ whitelist_ecus=[Ecu.fwdRadar],
+ bus=4,
+ ),
+ Request(
+ [HYUNDAI_VERSION_REQUEST_LONG],
+ [HYUNDAI_VERSION_RESPONSE],
+ whitelist_ecus=[Ecu.fwdCamera, Ecu.adas],
+ bus=5,
+ ),
],
extra_ecus=[
(Ecu.adas, 0x730, None), # ADAS Driving ECU on HDA2 platforms
@@ -1326,15 +1339,6 @@ FW_VERSIONS = {
],
},
CAR.KIA_EV6: {
- (Ecu.abs, 0x7d1, None): [
- b'\xf1\x00CV IEB \x02 101!\x10\x18 58520-CV100',
- b'\xf1\x00CV IEB \x03 101!\x10\x18 58520-CV100',
- b'\xf1\x8758520CV100\xf1\x00CV IEB \x02 101!\x10\x18 58520-CV100',
- ],
- (Ecu.eps, 0x7d4, None): [
- b'\xf1\x00CV1 MDPS R 1.00 1.04 57700-CV000 1B30',
- b'\xf1\x00CV1 MDPS R 1.00 1.05 57700-CV000 2425',
- ],
(Ecu.fwdRadar, 0x7d0, None): [
b'\xf1\x00CV1_ RDR ----- 1.00 1.01 99110-CV000 ',
b'\xf1\x8799110CV000\xf1\x00CV1_ RDR ----- 1.00 1.01 99110-CV000 ',
@@ -1346,16 +1350,6 @@ FW_VERSIONS = {
],
},
CAR.IONIQ_5: {
- (Ecu.abs, 0x7d1, None): [
- b'\xf1\x00NE1 IEB \x07 106!\x11) 58520-GI010',
- b'\xf1\x8758520GI010\xf1\x00NE1 IEB \x07 106!\x11) 58520-GI010',
- b'\xf1\x00NE1 IEB \x08 104!\x04\x05 58520-GI000',
- b'\xf1\x8758520GI000\xf1\x00NE1 IEB \x08 104!\x04\x05 58520-GI000',
- ],
- (Ecu.eps, 0x7d4, None): [
- b'\xf1\x00NE MDPS R 1.00 1.06 57700GI000 4NEDR106',
- b'\xf1\x8757700GI000 \xf1\x00NE MDPS R 1.00 1.06 57700GI000 4NEDR106',
- ],
(Ecu.fwdRadar, 0x7d0, None): [
b'\xf1\x00NE1_ RDR ----- 1.00 1.00 99110-GI000 ',
b'\xf1\x8799110GI000\xf1\x00NE1_ RDR ----- 1.00 1.00 99110-GI000 ',
@@ -1369,16 +1363,6 @@ FW_VERSIONS = {
(Ecu.fwdCamera, 0x7c4, None): [
b'\xf1\x00NX4 FR_CMR AT USA LHD 1.00 1.00 99211-N9240 14Q',
],
- (Ecu.eps, 0x7d4, None): [
- b'\xf1\x00NX4 MDPS C 1.00 1.01 56300-P0100 2228',
- ],
- (Ecu.engine, 0x7e0, None): [
- b'\xf1\x87391312MND0',
- ],
- (Ecu.transmission, 0x7e1, None): [
- b'\xf1\x00PSBG2441 G19_Rev\x00\x00\x00SNX4T16XXHS01NS2lS\xdfa',
- b'\xf1\x8795441-3D220\x00\xf1\x81G19_Rev\x00\x00\x00\xf1\x00PSBG2441 G19_Rev\x00\x00\x00SNX4T16XXHS01NS2lS\xdfa',
- ],
},
}
diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py
index 8abb1a02a6..cbc54eadb8 100755
--- a/selfdrive/controls/controlsd.py
+++ b/selfdrive/controls/controlsd.py
@@ -82,30 +82,30 @@ class Controls:
self.log_sock = messaging.sub_sock('androidLog')
- if CI is None:
- # wait for one pandaState and one CAN packet
- print("Waiting for CAN messages...")
- get_one_can(self.can_sock)
-
- self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan'])
- else:
- self.CI, self.CP = CI, CI.CP
-
params = Params()
- self.joystick_mode = params.get_bool("JoystickDebugMode") or (self.CP.notCar and sm is None)
- joystick_packet = ['testJoystick'] if self.joystick_mode else []
-
self.sm = sm
if self.sm is None:
- ignore = []
+ ignore = ['testJoystick']
if SIMULATION:
ignore += ['driverCameraState', 'managerState']
if params.get_bool('WideCameraOnly'):
ignore += ['roadCameraState']
self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration',
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman',
- 'managerState', 'liveParameters', 'radarState', 'liveTorqueParameters'] + self.camera_packets + joystick_packet,
- ignore_alive=ignore, ignore_avg_freq=['radarState', 'longitudinalPlan'])
+ 'managerState', 'liveParameters', 'radarState', 'liveTorqueParameters', 'testJoystick'] + self.camera_packets,
+ ignore_alive=ignore, ignore_avg_freq=['radarState', 'longitudinalPlan', 'testJoystick'])
+
+ if CI is None:
+ # wait for one pandaState and one CAN packet
+ print("Waiting for CAN messages...")
+ get_one_can(self.can_sock)
+
+ num_pandas = len(messaging.recv_one_retry(self.sm.sock['pandaStates']).pandaStates)
+ self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan'], num_pandas)
+ else:
+ self.CI, self.CP = CI, CI.CP
+
+ self.joystick_mode = params.get_bool("JoystickDebugMode") or (self.CP.notCar and sm is None)
# set alternative experiences from parameters
self.disengage_on_accelerator = params.get_bool("DisengageOnAccelerator")
diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py
index 63af4c7d95..ba2d2f5c02 100755
--- a/selfdrive/controls/tests/test_startup.py
+++ b/selfdrive/controls/tests/test_startup.py
@@ -94,6 +94,9 @@ class TestStartup(unittest.TestCase):
time.sleep(2) # wait for controlsd to be ready
+ pm.send('can', can_list_to_can_capnp([[0, 0, b"", 0]]))
+ time.sleep(0.1)
+
msg = messaging.new_message('pandaStates', 1)
msg.pandaStates[0].pandaType = log.PandaState.PandaType.uno
pm.send('pandaStates', msg)
From 5b85c2df4e2d855dc8fcb572bda33d2d456841d9 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Mon, 17 Oct 2022 23:24:34 -0700
Subject: [PATCH 027/137] Tucson Hybrid 4th gen: add missing fwdRadar (#26128)
add missing fwdRadar
---
selfdrive/car/hyundai/values.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py
index 1599005d1c..f69273ba55 100644
--- a/selfdrive/car/hyundai/values.py
+++ b/selfdrive/car/hyundai/values.py
@@ -1363,6 +1363,9 @@ FW_VERSIONS = {
(Ecu.fwdCamera, 0x7c4, None): [
b'\xf1\x00NX4 FR_CMR AT USA LHD 1.00 1.00 99211-N9240 14Q',
],
+ (Ecu.fwdRadar, 0x7d0, None): [
+ b'\xf1\x00NX4__ 1.00 1.00 99110-N9100 ',
+ ],
},
}
From a121212386c94ea5cc93de68b49971ff4e9d5674 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 02:01:21 +0800
Subject: [PATCH 028/137] cabana: fix background refresh issue (#26134)
---
tools/cabana/mainwin.cc | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/cabana/mainwin.cc b/tools/cabana/mainwin.cc
index 7aea8097cf..f3c3bf74ae 100644
--- a/tools/cabana/mainwin.cc
+++ b/tools/cabana/mainwin.cc
@@ -48,7 +48,6 @@ MainWindow::MainWindow() : QWidget() {
}
void MainWindow::dockCharts(bool dock) {
- charts_widget->setUpdatesEnabled(false);
if (dock && floating_window) {
floating_window->removeEventFilter(charts_widget);
r_layout->addWidget(charts_widget);
@@ -62,7 +61,6 @@ void MainWindow::dockCharts(bool dock) {
floating_window->setMinimumSize(QGuiApplication::primaryScreen()->size() / 2);
floating_window->showMaximized();
}
- charts_widget->setUpdatesEnabled(true);
}
void MainWindow::closeEvent(QCloseEvent *event) {
From 855099eb86938d683bb58868697c038b7b7ac650 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 02:01:38 +0800
Subject: [PATCH 029/137] cabana: display fingerprint and route on the top
right (#26133)
---
tools/cabana/canmessages.cc | 3 ++-
tools/cabana/canmessages.h | 3 +++
tools/cabana/mainwin.cc | 11 ++++++++++-
tools/cabana/videowidget.cc | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/tools/cabana/canmessages.cc b/tools/cabana/canmessages.cc
index 3cf08eaaa0..252a8c680c 100644
--- a/tools/cabana/canmessages.cc
+++ b/tools/cabana/canmessages.cc
@@ -26,7 +26,8 @@ static bool event_filter(const Event *e, void *opaque) {
}
bool CANMessages::loadRoute(const QString &route, const QString &data_dir, bool use_qcam) {
- replay = new Replay(route, {"can", "roadEncodeIdx"}, {}, nullptr, use_qcam ? REPLAY_FLAG_QCAMERA : 0, data_dir, this);
+ routeName = route;
+ replay = new Replay(route, {"can", "roadEncodeIdx", "carParams"}, {}, nullptr, use_qcam ? REPLAY_FLAG_QCAMERA : 0, data_dir, this);
replay->setSegmentCacheLimit(settings.cached_segment_limit);
replay->installEventFilter(event_filter, this);
QObject::connect(replay, &Replay::segmentsMerged, this, &CANMessages::segmentsMerged);
diff --git a/tools/cabana/canmessages.h b/tools/cabana/canmessages.h
index fe71840d74..58f5ad70b7 100644
--- a/tools/cabana/canmessages.h
+++ b/tools/cabana/canmessages.h
@@ -44,6 +44,8 @@ public:
bool eventFilter(const Event *event);
inline std::pair range() const { return {begin_sec, end_sec}; }
+ inline QString route() const { return routeName; }
+ inline QString carFingerprint() const { return replay->carFingerprint().c_str(); }
inline double totalSeconds() const { return replay->totalSeconds(); }
inline double routeStartTime() const { return replay->routeStartTime() / (double)1e9; }
inline double currentSec() const { return current_sec; }
@@ -80,6 +82,7 @@ protected:
double event_begin_sec = 0;
double event_end_sec = 0;
bool is_zoomed = false;
+ QString routeName;
Replay *replay = nullptr;
};
diff --git a/tools/cabana/mainwin.cc b/tools/cabana/mainwin.cc
index f3c3bf74ae..50fcbc455c 100644
--- a/tools/cabana/mainwin.cc
+++ b/tools/cabana/mainwin.cc
@@ -30,8 +30,16 @@ MainWindow::MainWindow() : QWidget() {
right_container->setFixedWidth(640);
r_layout = new QVBoxLayout(right_container);
+ QHBoxLayout *right_hlayout = new QHBoxLayout();
+ QLabel *fingerprint_label = new QLabel(this);
+ right_hlayout->addWidget(fingerprint_label);
+
+ // TODO: click to select another route.
+ right_hlayout->addWidget(new QLabel(can->route()));
QPushButton *settings_btn = new QPushButton("Settings");
- r_layout->addWidget(settings_btn, 0, Qt::AlignRight);
+ right_hlayout->addWidget(settings_btn, 0, Qt::AlignRight);
+
+ r_layout->addLayout(right_hlayout);
video_widget = new VideoWidget(this);
r_layout->addWidget(video_widget, 0, Qt::AlignTop);
@@ -45,6 +53,7 @@ MainWindow::MainWindow() : QWidget() {
QObject::connect(detail_widget, &DetailWidget::showChart, charts_widget, &ChartsWidget::addChart);
QObject::connect(charts_widget, &ChartsWidget::dock, this, &MainWindow::dockCharts);
QObject::connect(settings_btn, &QPushButton::clicked, this, &MainWindow::setOption);
+ QObject::connect(can, &CANMessages::eventsMerged, [=]() { fingerprint_label->setText(can->carFingerprint() ); });
}
void MainWindow::dockCharts(bool dock) {
diff --git a/tools/cabana/videowidget.cc b/tools/cabana/videowidget.cc
index bb90d56570..78965e3e8c 100644
--- a/tools/cabana/videowidget.cc
+++ b/tools/cabana/videowidget.cc
@@ -15,6 +15,7 @@ inline QString formatTime(int seconds) {
VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent) {
QVBoxLayout *main_layout = new QVBoxLayout(this);
+ main_layout->setContentsMargins(0, 0, 0, 0);
// TODO: figure out why the CameraWidget crashed occasionally.
cam_widget = new CameraWidget("camerad", VISION_STREAM_ROAD, false, this);
From 826d8a8ae34bfd909535f5edff2229b8b2daf1a6 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Tue, 18 Oct 2022 11:24:13 -0700
Subject: [PATCH 030/137] GM: match panda & ECM standstill checks (#26095)
* gm: match panda standstill check
* fix
* needs to be <= 10 to avoid a fault, fix for safety tests
* fix
* fix
* bump panda to master
---
panda | 2 +-
selfdrive/car/gm/carstate.py | 4 +++-
selfdrive/car/tests/test_models.py | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/panda b/panda
index 9ed3f75f67..b95a65df58 160000
--- a/panda
+++ b/panda
@@ -1 +1 @@
-Subproject commit 9ed3f75f67c3e5f00f910c8d7497ebed63851b5a
+Subproject commit b95a65df58fea89b42b7c6b4fc85289b93a0bdb2
diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py
index b67b97093a..f531914877 100644
--- a/selfdrive/car/gm/carstate.py
+++ b/selfdrive/car/gm/carstate.py
@@ -8,6 +8,7 @@ from selfdrive.car.gm.values import DBC, AccState, CanBus, STEER_THRESHOLD
TransmissionType = car.CarParams.TransmissionType
NetworkLocation = car.CarParams.NetworkLocation
+STANDSTILL_THRESHOLD = 10 * 0.0311 * CV.KPH_TO_MS
class CarState(CarStateBase):
@@ -39,7 +40,8 @@ class CarState(CarStateBase):
)
ret.vEgoRaw = mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr])
ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw)
- ret.standstill = ret.vEgoRaw < 0.01
+ # sample rear wheel speeds, standstill=True if ECM allows engagement with brake
+ ret.standstill = ret.wheelSpeeds.rl <= STANDSTILL_THRESHOLD and ret.wheelSpeeds.rr <= STANDSTILL_THRESHOLD
if pt_cp.vl["ECMPRDNL2"]["ManualMode"] == 1:
ret.gearShifter = self.parse_gear_shifter("T")
diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py
index bab9f859e6..e4e141153f 100755
--- a/selfdrive/car/tests/test_models.py
+++ b/selfdrive/car/tests/test_models.py
@@ -234,7 +234,7 @@ class TestCarModelBase(unittest.TestCase):
checks['gasPressed'] += CS.gasPressed != self.safety.get_gas_pressed_prev()
checks['cruiseState'] += CS.cruiseState.enabled and not CS.cruiseState.available
- if self.CP.carName not in ("hyundai", "volkswagen", "gm", "body"):
+ if self.CP.carName not in ("hyundai", "volkswagen", "body"):
# TODO: fix standstill mismatches for other makes
checks['standstill'] += CS.standstill == self.safety.get_vehicle_moving()
From 03d259a51742066e1fbbbad1d6ee1b94bd302bc6 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Tue, 18 Oct 2022 13:52:05 -0700
Subject: [PATCH 031/137] Honda docs: remove global min steer speed (#26138)
* remove global min_steer_speed so we can define in carparams
* remove 0 defaults
---
selfdrive/car/honda/values.py | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py
index e48edc42ba..46a8d6a31e 100644
--- a/selfdrive/car/honda/values.py
+++ b/selfdrive/car/honda/values.py
@@ -105,7 +105,6 @@ class Footnote(Enum):
@dataclass
class HondaCarInfo(CarInfo):
package: str = "Honda Sensing"
- min_steer_speed: float = 12. * CV.MPH_TO_MS
CAR_INFO: Dict[str, Optional[Union[HondaCarInfo, List[HondaCarInfo]]]] = {
@@ -114,31 +113,31 @@ CAR_INFO: Dict[str, Optional[Union[HondaCarInfo, List[HondaCarInfo]]]] = {
HondaCarInfo("Honda Inspire 2018", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch_a),
],
CAR.ACCORDH: HondaCarInfo("Honda Accord Hybrid 2018-22", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch_a),
- CAR.CIVIC: HondaCarInfo("Honda Civic 2016-18", harness=Harness.nidec, video_link="https://youtu.be/-IkImTe1NYE"),
+ CAR.CIVIC: HondaCarInfo("Honda Civic 2016-18", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec, video_link="https://youtu.be/-IkImTe1NYE"),
CAR.CIVIC_BOSCH: [
HondaCarInfo("Honda Civic 2019-21", "All", "https://www.youtube.com/watch?v=4Iz1Mz5LGF8", [Footnote.CIVIC_DIESEL], min_steer_speed=2. * CV.MPH_TO_MS, harness=Harness.bosch_a),
- HondaCarInfo("Honda Civic Hatchback 2017-21", harness=Harness.bosch_a),
+ HondaCarInfo("Honda Civic Hatchback 2017-21", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.bosch_a),
],
CAR.CIVIC_BOSCH_DIESEL: None, # same platform
CAR.CIVIC_2022: [
- HondaCarInfo("Honda Civic 2022", "All", min_steer_speed=0., harness=Harness.bosch_b),
- HondaCarInfo("Honda Civic Hatchback 2022", "All", min_steer_speed=0., harness=Harness.bosch_b),
+ HondaCarInfo("Honda Civic 2022", "All", harness=Harness.bosch_b),
+ HondaCarInfo("Honda Civic Hatchback 2022", "All", harness=Harness.bosch_b),
],
CAR.ACURA_ILX: HondaCarInfo("Acura ILX 2016-19", "AcuraWatch Plus", min_steer_speed=25. * CV.MPH_TO_MS, harness=Harness.nidec),
- CAR.CRV: HondaCarInfo("Honda CR-V 2015-16", "Touring Trim", harness=Harness.nidec),
- CAR.CRV_5G: HondaCarInfo("Honda CR-V 2017-22", harness=Harness.bosch_a),
+ CAR.CRV: HondaCarInfo("Honda CR-V 2015-16", "Touring Trim", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
+ CAR.CRV_5G: HondaCarInfo("Honda CR-V 2017-22", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.bosch_a),
CAR.CRV_EU: None, # HondaCarInfo("Honda CR-V EU", "Touring"), # Euro version of CRV Touring
- CAR.CRV_HYBRID: HondaCarInfo("Honda CR-V Hybrid 2017-19", harness=Harness.bosch_a),
- CAR.FIT: HondaCarInfo("Honda Fit 2018-20", harness=Harness.nidec),
- CAR.FREED: HondaCarInfo("Honda Freed 2020", harness=Harness.nidec),
- CAR.HRV: HondaCarInfo("Honda HR-V 2019-22", harness=Harness.nidec),
- CAR.ODYSSEY: HondaCarInfo("Honda Odyssey 2018-20", min_steer_speed=0., harness=Harness.nidec),
+ CAR.CRV_HYBRID: HondaCarInfo("Honda CR-V Hybrid 2017-19", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.bosch_a),
+ CAR.FIT: HondaCarInfo("Honda Fit 2018-20", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
+ CAR.FREED: HondaCarInfo("Honda Freed 2020", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
+ CAR.HRV: HondaCarInfo("Honda HR-V 2019-22", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
+ CAR.ODYSSEY: HondaCarInfo("Honda Odyssey 2018-20", harness=Harness.nidec),
CAR.ODYSSEY_CHN: None, # Chinese version of Odyssey
- CAR.ACURA_RDX: HondaCarInfo("Acura RDX 2016-18", "AcuraWatch Plus", harness=Harness.nidec),
+ CAR.ACURA_RDX: HondaCarInfo("Acura RDX 2016-18", "AcuraWatch Plus", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
CAR.ACURA_RDX_3G: HondaCarInfo("Acura RDX 2019-22", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch_a),
- CAR.PILOT: HondaCarInfo("Honda Pilot 2016-22", harness=Harness.nidec),
- CAR.PASSPORT: HondaCarInfo("Honda Passport 2019-21", "All", harness=Harness.nidec),
- CAR.RIDGELINE: HondaCarInfo("Honda Ridgeline 2017-22", harness=Harness.nidec),
+ CAR.PILOT: HondaCarInfo("Honda Pilot 2016-22", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
+ CAR.PASSPORT: HondaCarInfo("Honda Passport 2019-21", "All", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
+ CAR.RIDGELINE: HondaCarInfo("Honda Ridgeline 2017-22", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec),
CAR.INSIGHT: HondaCarInfo("Honda Insight 2019-22", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch_a),
CAR.HONDA_E: HondaCarInfo("Honda e 2020", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch_a),
}
From 972951f5f4aadf9b4fd2384efa85ca5378fd09f0 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Tue, 18 Oct 2022 14:07:54 -0700
Subject: [PATCH 032/137] Fix pass by keyword
---
selfdrive/car/honda/values.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py
index 46a8d6a31e..638008934a 100644
--- a/selfdrive/car/honda/values.py
+++ b/selfdrive/car/honda/values.py
@@ -115,7 +115,7 @@ CAR_INFO: Dict[str, Optional[Union[HondaCarInfo, List[HondaCarInfo]]]] = {
CAR.ACCORDH: HondaCarInfo("Honda Accord Hybrid 2018-22", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch_a),
CAR.CIVIC: HondaCarInfo("Honda Civic 2016-18", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.nidec, video_link="https://youtu.be/-IkImTe1NYE"),
CAR.CIVIC_BOSCH: [
- HondaCarInfo("Honda Civic 2019-21", "All", "https://www.youtube.com/watch?v=4Iz1Mz5LGF8", [Footnote.CIVIC_DIESEL], min_steer_speed=2. * CV.MPH_TO_MS, harness=Harness.bosch_a),
+ HondaCarInfo("Honda Civic 2019-21", "All", "https://www.youtube.com/watch?v=4Iz1Mz5LGF8", [Footnote.CIVIC_DIESEL], 2. * CV.MPH_TO_MS, harness=Harness.bosch_a),
HondaCarInfo("Honda Civic Hatchback 2017-21", min_steer_speed=12. * CV.MPH_TO_MS, harness=Harness.bosch_a),
],
CAR.CIVIC_BOSCH_DIESEL: None, # same platform
From 98cac3578b2d0d2e4db283a728f647bc71825bfb Mon Sep 17 00:00:00 2001
From: Adeeb Shihadeh
Date: Tue, 18 Oct 2022 18:40:47 -0700
Subject: [PATCH 033/137] cabana: fix binary view for can-fd
---
tools/cabana/binaryview.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/cabana/binaryview.cc b/tools/cabana/binaryview.cc
index 71175e783e..32811c4b6f 100644
--- a/tools/cabana/binaryview.cc
+++ b/tools/cabana/binaryview.cc
@@ -25,7 +25,7 @@ BinaryView::BinaryView(QWidget *parent) : QTableView(parent) {
delete old_model;
QObject::connect(model, &QAbstractItemModel::modelReset, [this]() {
- setFixedHeight((CELL_HEIGHT + 1) * std::min(model->rowCount(), 8) + 2);
+ setFixedHeight((CELL_HEIGHT + 1) * std::min(model->rowCount(), 64) + 2);
});
}
From 9a8bd8c0975673a2831ca8af7629d22063b5f8fa Mon Sep 17 00:00:00 2001
From: Cameron Clough
Date: Tue, 18 Oct 2022 20:46:08 -0700
Subject: [PATCH 034/137] Revert "cabana: fix binary view for can-fd"
This reverts commit 98cac3578b2d0d2e4db283a728f647bc71825bfb.
---
tools/cabana/binaryview.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/cabana/binaryview.cc b/tools/cabana/binaryview.cc
index 32811c4b6f..71175e783e 100644
--- a/tools/cabana/binaryview.cc
+++ b/tools/cabana/binaryview.cc
@@ -25,7 +25,7 @@ BinaryView::BinaryView(QWidget *parent) : QTableView(parent) {
delete old_model;
QObject::connect(model, &QAbstractItemModel::modelReset, [this]() {
- setFixedHeight((CELL_HEIGHT + 1) * std::min(model->rowCount(), 64) + 2);
+ setFixedHeight((CELL_HEIGHT + 1) * std::min(model->rowCount(), 8) + 2);
});
}
From 1548db8962c2555b53843ec361453ece7abdbc16 Mon Sep 17 00:00:00 2001
From: HaraldSchafer
Date: Tue, 18 Oct 2022 21:25:06 -0700
Subject: [PATCH 035/137] Partial revert, lax torque control (#26146)
* Closer to original
* Update ref
---
selfdrive/controls/lib/latcontrol_torque.py | 2 +-
selfdrive/controls/lib/lateral_planner.py | 3 +--
selfdrive/test/process_replay/ref_commit | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py
index 7d656b55a9..51676086ba 100644
--- a/selfdrive/controls/lib/latcontrol_torque.py
+++ b/selfdrive/controls/lib/latcontrol_torque.py
@@ -17,7 +17,7 @@ from selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY
# friction in the steering wheel that needs to be overcome to
# move it at all, this is compensated for too.
-LOW_SPEED_FACTOR = 100
+LOW_SPEED_FACTOR = 200
class LatControlTorque(LatControl):
diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py
index 9fbfd4a11f..29137defd3 100644
--- a/selfdrive/controls/lib/lateral_planner.py
+++ b/selfdrive/controls/lib/lateral_planner.py
@@ -22,8 +22,7 @@ LATERAL_JERK_COST = 0.05
# TODO this cost should be lowered when low
# speed lateral control is stable on all cars
STEERING_RATE_COST = 800.0
-
-MIN_SPEED = .3
+MIN_SPEED = 1.5
class LateralPlanner:
diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit
index 998bf4e756..0b4081595b 100644
--- a/selfdrive/test/process_replay/ref_commit
+++ b/selfdrive/test/process_replay/ref_commit
@@ -1 +1 @@
-6bb7d8baae51d88dd61f0baf561e386664ddd266
\ No newline at end of file
+1c1287691cbdd866d9e435d5d27f59f6a027d270
From 1bd9632156a78ae947eeaaebe96a08bd5b0cfeeb Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Wed, 19 Oct 2022 01:02:51 -0700
Subject: [PATCH 036/137] FPv2 tests: consider extra ECUs in brand ECUs
(#26149)
* Hyundai: add corner radar FW query
* add extra ecus to brand ecus
* add comment
* rev
* bumpo
* cmt
Co-authored-by: Adeeb Shihadeh
---
selfdrive/car/tests/test_fw_fingerprint.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py
index ed323b0563..b9926301f1 100755
--- a/selfdrive/car/tests/test_fw_fingerprint.py
+++ b/selfdrive/car/tests/test_fw_fingerprint.py
@@ -45,6 +45,7 @@ class TestFwFingerprint(unittest.TestCase):
self.assertFalse(len(duplicates), f"{car_model}: Duplicate FW versions: Ecu.{ECU_NAME[ecu[0]]}, {duplicates}")
def test_data_collection_ecus(self):
+ # Asserts no extra ECUs are in the fingerprinting database
for brand, config in FW_QUERY_CONFIGS.items():
for car_model, ecus in VERSIONS[brand].items():
bad_ecus = set(ecus).intersection(config.extra_ecus)
@@ -80,10 +81,11 @@ class TestFwFingerprint(unittest.TestCase):
def test_fw_request_ecu_whitelist(self):
for brand, config in FW_QUERY_CONFIGS.items():
with self.subTest(brand=brand):
- whitelisted_ecus = set([ecu for r in config.requests for ecu in r.whitelist_ecus])
- brand_ecus = set([fw[0] for car_fw in VERSIONS[brand].values() for fw in car_fw])
+ whitelisted_ecus = {ecu for r in config.requests for ecu in r.whitelist_ecus}
+ brand_ecus = {fw[0] for car_fw in VERSIONS[brand].values() for fw in car_fw}
+ brand_ecus |= {ecu[0] for ecu in config.extra_ecus}
- # each ecu in brand's fw versions needs to be whitelisted at least once
+ # each ecu in brand's fw versions + extra ecus needs to be whitelisted at least once
ecus_not_whitelisted = brand_ecus - whitelisted_ecus
ecu_strings = ", ".join([f'Ecu.{ECU_NAME[ecu]}' for ecu in ecus_not_whitelisted])
From e46d162b1e5d4414d54d27c54190e7b3116596ba Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Wed, 19 Oct 2022 01:28:46 -0700
Subject: [PATCH 037/137] GM camera ACC: show under enable speed alert (#26148)
* fix the fault more generically
* fix
* need this
* some clean up
* comment and use standstill
* comment
* add comment
* better fix
* rm
* better (for now)
* update docs
---
docs/CARS.md | 6 +++---
selfdrive/car/gm/interface.py | 20 +++++++-------------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/docs/CARS.md b/docs/CARS.md
index 40eef06102..4c65f0007b 100644
--- a/docs/CARS.md
+++ b/docs/CARS.md
@@ -18,8 +18,8 @@ A supported vehicle is one that just works when you install a comma three. All s
|Audi|RS3 2018|Adaptive Cruise Control (ACC) & Lane Assist|Stock|0 mph|0 mph|[](##)|[](##)|VW|
|Audi|S3 2015-17|Adaptive Cruise Control (ACC) & Lane Assist|Stock|0 mph|0 mph|[](##)|[](##)|VW|
|Cadillac|Escalade ESV 2016[1](#footnotes)|Adaptive Cruise Control (ACC) & LKAS|openpilot|0 mph|6 mph|[](##)|[](##)|OBD-II|
-|Chevrolet|Bolt EUV 2022-23|Premier or Premier Redline Trim without Super Cruise Package|Stock|0 mph|6 mph|[](##)|[](##)|GM|
-|Chevrolet|Silverado 1500 2020-21|Safety Package II|Stock|0 mph|6 mph|[](##)|[](##)|GM|
+|Chevrolet|Bolt EUV 2022-23|Premier or Premier Redline Trim without Super Cruise Package|Stock|3 mph|6 mph|[](##)|[](##)|GM|
+|Chevrolet|Silverado 1500 2020-21|Safety Package II|Stock|3 mph|6 mph|[](##)|[](##)|GM|
|Chevrolet|Volt 2017-18[1](#footnotes)|Adaptive Cruise Control (ACC)|openpilot|0 mph|6 mph|[](##)|[](##)|OBD-II|
|Chrysler|Pacifica 2017-18|Adaptive Cruise Control (ACC)|Stock|0 mph|9 mph|[](##)|[](##)|FCA|
|Chrysler|Pacifica 2019-20|Adaptive Cruise Control (ACC)|Stock|0 mph|39 mph|[](##)|[](##)|FCA|
@@ -32,7 +32,7 @@ A supported vehicle is one that just works when you install a comma three. All s
|Genesis|G80 2017-19|All|Stock|0 mph|0 mph|[](##)|[](##)|Hyundai H|
|Genesis|G90 2017-18|All|openpilot|0 mph|0 mph|[](##)|[](##)|Hyundai C|
|GMC|Acadia 2018[1](#footnotes)|Adaptive Cruise Control (ACC)|openpilot|0 mph|6 mph|[](##)|[](##)|OBD-II|
-|GMC|Sierra 1500 2020-21|Driver Alert Package II|Stock|0 mph|6 mph|[](##)|[](##)|GM|
+|GMC|Sierra 1500 2020-21|Driver Alert Package II|Stock|3 mph|6 mph|[](##)|[](##)|GM|
|Honda|Accord 2018-22|All|openpilot|0 mph|3 mph|[](##)|[](##)|Honda Bosch A|
|Honda|Accord Hybrid 2018-22|All|openpilot|0 mph|3 mph|[](##)|[](##)|Honda Bosch A|
|Honda|Civic 2016-18|Honda Sensing|openpilot|0 mph|12 mph|[](##)|[](##)|Honda Nidec|
diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py
index 248828e757..e25f203772 100755
--- a/selfdrive/car/gm/interface.py
+++ b/selfdrive/car/gm/interface.py
@@ -62,11 +62,14 @@ class CarInterface(CarInterfaceBase):
ret.radarOffCan = True # no radar
ret.pcmCruise = True
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_CAM
+ ret.minEnableSpeed = 5 * CV.KPH_TO_MS
else: # ASCM, OBD-II harness
ret.openpilotLongitudinalControl = True
ret.networkLocation = NetworkLocation.gateway
ret.radarOffCan = False
ret.pcmCruise = False # stock non-adaptive cruise control is kept off
+ # supports stop and go, but initial engage must (conservatively) be above 18mph
+ ret.minEnableSpeed = 18 * CV.MPH_TO_MS
# These cars have been put into dashcam only due to both a lack of users and test coverage.
# These cars likely still work fine. Once a user confirms each car works and a test route is
@@ -90,9 +93,6 @@ class CarInterface(CarInterfaceBase):
ret.steerLimitTimer = 0.4
ret.radarTimeStep = 0.0667 # GM radar runs at 15Hz instead of standard 20Hz
- # supports stop and go, but initial engage must (conservatively) be above 18mph
- ret.minEnableSpeed = 18 * CV.MPH_TO_MS
-
if candidate == CAR.VOLT:
ret.mass = 1607. + STD_CARGO_KG
ret.wheelbase = 2.69
@@ -153,7 +153,6 @@ class CarInterface(CarInterfaceBase):
tire_stiffness_factor = 1.0
elif candidate in (CAR.BOLT_EV, CAR.BOLT_EUV):
- ret.minEnableSpeed = -1
ret.mass = 1669. + STD_CARGO_KG
ret.wheelbase = 2.63779
ret.steerRatio = 16.8
@@ -163,7 +162,6 @@ class CarInterface(CarInterfaceBase):
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
elif candidate == CAR.SILVERADO:
- ret.minEnableSpeed = -1
ret.mass = 2200. + STD_CARGO_KG
ret.wheelbase = 3.75
ret.steerRatio = 16.3
@@ -172,7 +170,6 @@ class CarInterface(CarInterfaceBase):
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
elif candidate == CAR.EQUINOX:
- ret.minEnableSpeed = -1
ret.mass = 3500. * CV.LB_TO_KG + STD_CARGO_KG
ret.wheelbase = 2.72
ret.steerRatio = 14.4
@@ -207,19 +204,16 @@ class CarInterface(CarInterfaceBase):
GearShifter.eco, GearShifter.manumatic],
pcm_enable=self.CP.pcmCruise)
- if ret.vEgo < self.CP.minEnableSpeed:
+ # Enabling at a standstill with brake is allowed
+ # TODO: verify 17 Volt can enable for the first time at a stop and allow for all GMs
+ if ret.vEgo < self.CP.minEnableSpeed and not (ret.standstill and ret.brake >= 20 and
+ self.CP.networkLocation == NetworkLocation.fwdCamera):
events.add(EventName.belowEngageSpeed)
if ret.cruiseState.standstill:
events.add(EventName.resumeRequired)
if ret.vEgo < self.CP.minSteerSpeed:
events.add(EventName.belowSteerSpeed)
- if self.CP.networkLocation == NetworkLocation.fwdCamera and self.CP.pcmCruise:
- # The ECM has a higher brake pressed threshold than the camera, causing an
- # ACC fault when you engage at a stop with your foot partially on the brake
- if ret.vEgoRaw < 0.1 and ret.brake < 20:
- events.add(EventName.gmAccFaultedTemp)
-
ret.events = events.to_msg()
return ret
From b1efdab788da77380dfd3f5765bb6cc03ccc3a77 Mon Sep 17 00:00:00 2001
From: Shane Smiskol
Date: Wed, 19 Oct 2022 01:31:12 -0700
Subject: [PATCH 038/137] Rename gmAccFaultedTemp -> accFaultedTemp
---
cereal | 2 +-
selfdrive/controls/lib/events.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cereal b/cereal
index 107048c83e..1e3dd70a39 160000
--- a/cereal
+++ b/cereal
@@ -1 +1 @@
-Subproject commit 107048c83ec2f488286a1be314e7aece0a20a6b1
+Subproject commit 1e3dd70a391bc1bbe437d3eea8be30947f929a75
diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py
index 5bfe89b31c..44426620e9 100644
--- a/selfdrive/controls/lib/events.py
+++ b/selfdrive/controls/lib/events.py
@@ -811,7 +811,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
ET.NO_ENTRY: NoEntryAlert("Cruise Faulted"),
},
- EventName.gmAccFaultedTemp: {
+ EventName.accFaultedTemp: {
ET.NO_ENTRY: NoEntryAlert("Cruise Temporarily Faulted"),
},
From a24e6616c2f701896328c7cba5e6e8e76b42de1e Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 23:01:42 +0800
Subject: [PATCH 039/137] Cabana: fix time column was being cutoff (#26156)
fix time column
---
tools/cabana/historylog.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/cabana/historylog.cc b/tools/cabana/historylog.cc
index c0efbca280..a20845f15f 100644
--- a/tools/cabana/historylog.cc
+++ b/tools/cabana/historylog.cc
@@ -70,7 +70,7 @@ HistoryLog::HistoryLog(QWidget *parent) : QWidget(parent) {
table = new QTableView(this);
table->setModel(model);
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
- table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
+ table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
table->setColumnWidth(0, 60);
table->verticalHeader()->setVisible(false);
table->setStyleSheet("QTableView::item { border:0px; padding-left:5px; padding-right:5px; }");
From a927d7b0ea25d1fde6a121888f8abd34e2fef867 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 23:02:47 +0800
Subject: [PATCH 040/137] Cabana: warn when DBC message length is wrong
(#26154)
display warning if message size is incorrect
---
tools/cabana/detailwidget.cc | 16 ++++++++++++++++
tools/cabana/detailwidget.h | 3 ++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/cabana/detailwidget.cc b/tools/cabana/detailwidget.cc
index 60d0632d4c..a92969d4d3 100644
--- a/tools/cabana/detailwidget.cc
+++ b/tools/cabana/detailwidget.cc
@@ -29,6 +29,17 @@ DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent) {
title_layout->addWidget(edit_btn);
main_layout->addLayout(title_layout);
+ // warning
+ warning_widget = new QWidget(this);
+ QHBoxLayout *warning_hlayout = new QHBoxLayout(warning_widget);
+ QLabel *warning_icon = new QLabel(this);
+ warning_icon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap({16, 16}));
+ warning_hlayout->addWidget(warning_icon);
+ warning_label = new QLabel(this);
+ warning_hlayout->addWidget(warning_label,1, Qt::AlignLeft);
+ warning_widget->hide();
+ main_layout->addWidget(warning_widget);
+
// binary view
binary_view = new BinaryView(this);
main_layout->addWidget(binary_view, 0, Qt::AlignTop);
@@ -64,6 +75,7 @@ void DetailWidget::setMessage(const QString &message_id) {
void DetailWidget::dbcMsgChanged() {
if (msg_id.isEmpty()) return;
+ warning_widget->hide();
qDeleteAll(signals_container->findChildren());
QString msg_name = tr("untitled");
if (auto msg = dbc()->msg(msg_id)) {
@@ -76,6 +88,10 @@ void DetailWidget::dbcMsgChanged() {
QObject::connect(form, &SignalEdit::save, this, &DetailWidget::saveSignal);
}
msg_name = msg->name.c_str();
+ if (msg->size != can->lastMessage(msg_id).dat.size()) {
+ warning_label->setText(tr("Message size (%1) is incorrect!").arg(msg->size));
+ warning_widget->show();
+ }
}
edit_btn->setVisible(true);
name_label->setText(msg_name);
diff --git a/tools/cabana/detailwidget.h b/tools/cabana/detailwidget.h
index 9d3b81dcb0..07c78caa4a 100644
--- a/tools/cabana/detailwidget.h
+++ b/tools/cabana/detailwidget.h
@@ -46,7 +46,8 @@ private:
void updateState();
QString msg_id;
- QLabel *name_label, *time_label;
+ QLabel *name_label, *time_label, *warning_label;
+ QWidget *warning_widget;
QPushButton *edit_btn;
QWidget *signals_container;
HistoryLog *history_log;
From 3fae3b366087c20621624de8b4f3e00da4de987b Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 23:03:14 +0800
Subject: [PATCH 041/137] cabana: use monospaced font for hex in BinaryView
(#26153)
use fixedfont
---
tools/cabana/binaryview.cc | 6 ++++--
tools/cabana/binaryview.h | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/cabana/binaryview.cc b/tools/cabana/binaryview.cc
index 71175e783e..4fc55077da 100644
--- a/tools/cabana/binaryview.cc
+++ b/tools/cabana/binaryview.cc
@@ -1,6 +1,7 @@
#include "tools/cabana/binaryview.h"
#include
+#include
#include
#include
@@ -157,7 +158,8 @@ void BinarySelectionModel::select(const QItemSelection &selection, QItemSelectio
BinaryItemDelegate::BinaryItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {
// cache fonts and color
small_font.setPointSize(6);
- bold_font.setBold(true);
+ hex_font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ hex_font.setBold(true);
highlight_color = QApplication::style()->standardPalette().color(QPalette::Active, QPalette::Highlight);
}
@@ -172,7 +174,7 @@ void BinaryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
// TODO: highlight signal cells on mouse over
painter->fillRect(option.rect, option.state & QStyle::State_Selected ? highlight_color : item->bg_color);
if (index.column() == 8) {
- painter->setFont(bold_font);
+ painter->setFont(hex_font);
}
painter->drawText(option.rect, Qt::AlignCenter, item->val);
if (item->is_msb || item->is_lsb) {
diff --git a/tools/cabana/binaryview.h b/tools/cabana/binaryview.h
index 631797ca48..38f0ddf216 100644
--- a/tools/cabana/binaryview.h
+++ b/tools/cabana/binaryview.h
@@ -14,7 +14,7 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
- QFont small_font, bold_font;
+ QFont small_font, hex_font;
QColor highlight_color;
};
From 1211ffbcf22800049682244727984a596395c217 Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 23:03:34 +0800
Subject: [PATCH 042/137] cabana: display a clear button in filter string edit
box (#26152)
display clear button
---
tools/cabana/messageswidget.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/cabana/messageswidget.cc b/tools/cabana/messageswidget.cc
index 28f79adad3..f39ce97684 100644
--- a/tools/cabana/messageswidget.cc
+++ b/tools/cabana/messageswidget.cc
@@ -42,6 +42,7 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
// message filter
QLineEdit *filter = new QLineEdit(this);
+ filter->setClearButtonEnabled(true);
filter->setPlaceholderText(tr("filter messages"));
main_layout->addWidget(filter);
From d1495a90903ea3a29f2987af6de996dfbd9ab9ff Mon Sep 17 00:00:00 2001
From: Dean Lee
Date: Wed, 19 Oct 2022 23:07:01 +0800
Subject: [PATCH 043/137] Cabana: add dialog to find and locate signal values
(#26131)
* add dialog to find signals
* dont close dlg after goto
* limit number
* cleanup
* merge master
---
tools/cabana/canmessages.cc | 29 ++++++++++++++
tools/cabana/canmessages.h | 4 ++
tools/cabana/signaledit.cc | 79 ++++++++++++++++++++++++++++++++++++-
tools/cabana/signaledit.h | 7 ++++
4 files changed, 118 insertions(+), 1 deletion(-)
diff --git a/tools/cabana/canmessages.cc b/tools/cabana/canmessages.cc
index 252a8c680c..897381b3f2 100644
--- a/tools/cabana/canmessages.cc
+++ b/tools/cabana/canmessages.cc
@@ -3,6 +3,8 @@
#include
#include
+#include "tools/cabana/dbcmanager.h"
+
Q_DECLARE_METATYPE(std::vector);
Settings settings;
@@ -38,6 +40,33 @@ bool CANMessages::loadRoute(const QString &route, const QString &data_dir, bool
return false;
}
+QList CANMessages::findSignalValues(const QString &id, const Signal *signal, double value, FindFlags flag, int max_count) {
+ auto evts = events();
+ if (!evts) return {};
+
+ auto l = id.split(':');
+ int bus = l[0].toInt();
+ uint32_t address = l[1].toUInt(nullptr, 16);
+
+ QList ret;
+ ret.reserve(max_count);
+ for (auto &evt : *evts) {
+ if (evt->which != cereal::Event::Which::CAN) continue;
+
+ for (auto c : evt->event.getCan()) {
+ if (bus == c.getSrc() && address == c.getAddress()) {
+ double val = get_raw_value((uint8_t *)c.getDat().begin(), c.getDat().size(), *signal);
+ if ((flag == EQ && val == value) || (flag == LT && val < value) || (flag == GT && val > value)) {
+ ret.push_back({(evt->mono_time / (double)1e9) - can->routeStartTime(), val});
+ }
+ if (ret.size() >= max_count)
+ return ret;
+ }
+ }
+ }
+ return ret;
+}
+
void CANMessages::process(QHash> *messages) {
for (auto it = messages->begin(); it != messages->end(); ++it) {
++counters[it.key()];
diff --git a/tools/cabana/canmessages.h b/tools/cabana/canmessages.h
index 58f5ad70b7..44131ad5c9 100644
--- a/tools/cabana/canmessages.h
+++ b/tools/cabana/canmessages.h
@@ -5,7 +5,9 @@
#include