mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-28 18:33:45 +08:00
cabana: remove dependence on opendbc (#30329)
* remove dependence on opendbc * move into function old-commit-hash: bf932c6277c25294857d68cf1a333ce9d151140c
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import os
|
||||
Import('env', 'qt_env', 'arch', 'common', 'messaging', 'visionipc', 'replay_lib',
|
||||
'cereal', 'transformations', 'widgets')
|
||||
Import('qt_env', 'arch', 'common', 'messaging', 'visionipc', 'replay_lib', 'cereal', 'widgets')
|
||||
|
||||
base_frameworks = qt_env['FRAMEWORKS']
|
||||
base_libs = [common, messaging, cereal, visionipc, transformations, 'zmq',
|
||||
'capnp', 'kj', 'm', 'ssl', 'crypto', 'pthread'] + qt_env["LIBS"]
|
||||
base_libs = [common, messaging, cereal, visionipc, 'qt_util', 'zmq', 'capnp', 'kj', 'm', 'ssl', 'crypto', 'pthread'] + qt_env["LIBS"]
|
||||
|
||||
if arch == "Darwin":
|
||||
base_frameworks.append('OpenCL')
|
||||
@@ -18,8 +15,7 @@ else:
|
||||
qt_libs = ['qt_util'] + base_libs
|
||||
|
||||
cabana_env = qt_env.Clone()
|
||||
cabana_env["LIBPATH"] += ['../../opendbc/can']
|
||||
cabana_libs = [widgets, cereal, messaging, visionipc, replay_lib, 'panda', 'libdbc_static', 'avutil', 'avcodec', 'avformat', 'bz2', 'curl', 'yuv', 'usb-1.0'] + qt_libs
|
||||
cabana_libs = [widgets, cereal, messaging, visionipc, replay_lib, 'panda', 'avutil', 'avcodec', 'avformat', 'bz2', 'curl', 'yuv', 'usb-1.0'] + qt_libs
|
||||
opendbc_path = '-DOPENDBC_FILE_PATH=\'"%s"\'' % (cabana_env.Dir("../../opendbc").abspath)
|
||||
cabana_env['CXXFLAGS'] += [opendbc_path]
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
#include "opendbc/can/common_dbc.h"
|
||||
|
||||
const QString UNTITLED = "untitled";
|
||||
const QString DEFAULT_NODE_NAME = "XXX";
|
||||
@@ -120,5 +119,4 @@ public:
|
||||
double get_raw_value(const uint8_t *data, size_t data_size, const cabana::Signal &sig);
|
||||
void updateMsbLsb(cabana::Signal &s);
|
||||
inline int flipBitPos(int start_bit) { return 8 * (start_bit / 8) + 7 - start_bit % 8; }
|
||||
inline std::vector<std::string> allDBCNames() { return get_dbc_names(); }
|
||||
inline QString doubleToString(double value) { return QString::number(value, 'g', std::numeric_limits<double>::digits10); }
|
||||
|
||||
+14
-11
@@ -9,6 +9,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonObject>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QResizeEvent>
|
||||
@@ -24,6 +25,7 @@
|
||||
#include "tools/replay/replay.h"
|
||||
|
||||
MainWindow::MainWindow() : QMainWindow() {
|
||||
loadFingerprints();
|
||||
createDockWindows();
|
||||
setCentralWidget(center_widget = new CenterWidget(this));
|
||||
createActions();
|
||||
@@ -56,12 +58,6 @@ MainWindow::MainWindow() : QMainWindow() {
|
||||
qInfo() << QString::fromStdString(msg);
|
||||
});
|
||||
|
||||
// load fingerprints
|
||||
QFile json_file(QApplication::applicationDirPath() + "/dbc/car_fingerprint_to_dbc.json");
|
||||
if (json_file.open(QIODevice::ReadOnly)) {
|
||||
fingerprint_to_dbc = QJsonDocument::fromJson(json_file.readAll());
|
||||
}
|
||||
|
||||
setStyleSheet(QString(R"(QMainWindow::separator {
|
||||
width: %1px; /* when vertical */
|
||||
height: %1px; /* when horizontal */
|
||||
@@ -77,6 +73,16 @@ MainWindow::MainWindow() : QMainWindow() {
|
||||
QObject::connect(StreamNotifier::instance(), &StreamNotifier::streamStarted, this, &MainWindow::streamStarted);
|
||||
}
|
||||
|
||||
void MainWindow::loadFingerprints() {
|
||||
QFile json_file(QApplication::applicationDirPath() + "/dbc/car_fingerprint_to_dbc.json");
|
||||
if (json_file.open(QIODevice::ReadOnly)) {
|
||||
fingerprint_to_dbc = QJsonDocument::fromJson(json_file.readAll());
|
||||
auto dbc_names = fingerprint_to_dbc.object().toVariantMap().values();
|
||||
std::transform(dbc_names.begin(), dbc_names.end(), std::inserter(opendbc_names, opendbc_names.begin()),
|
||||
[](const auto &name) { return name.toString(); });
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::createActions() {
|
||||
// File menu
|
||||
QMenu *file_menu = menuBar()->addMenu(tr("&File"));
|
||||
@@ -102,11 +108,8 @@ void MainWindow::createActions() {
|
||||
file_menu->addSeparator();
|
||||
QMenu *load_opendbc_menu = file_menu->addMenu(tr("Load DBC from commaai/opendbc"));
|
||||
// load_opendbc_menu->setStyleSheet("QMenu { menu-scrollable: true; }");
|
||||
auto dbc_names = allDBCNames();
|
||||
std::sort(dbc_names.begin(), dbc_names.end());
|
||||
for (const auto &name : dbc_names) {
|
||||
QString dbc_name = QString::fromStdString(name);
|
||||
load_opendbc_menu->addAction(dbc_name, [=]() { loadDBCFromOpendbc(dbc_name); });
|
||||
for (const auto &dbc_name : opendbc_names) {
|
||||
load_opendbc_menu->addAction(dbc_name, [this, name = dbc_name]() { loadDBCFromOpendbc(name); });
|
||||
}
|
||||
|
||||
file_menu->addAction(tr("Load DBC From Clipboard"), [=]() { loadFromClipboard(); });
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QProgressBar>
|
||||
#include <QSplitter>
|
||||
#include <QStatusBar>
|
||||
#include <set>
|
||||
|
||||
#include "tools/cabana/chart/chartswidget.h"
|
||||
#include "tools/cabana/dbc/dbcmanager.h"
|
||||
@@ -50,6 +51,7 @@ protected:
|
||||
void saveFile(DBCFile *dbc_file);
|
||||
void saveFileAs(DBCFile *dbc_file);
|
||||
void saveFileToClipboard(DBCFile *dbc_file);
|
||||
void loadFingerprints();
|
||||
void loadFromClipboard(SourceSet s = SOURCE_ALL, bool close_all = true);
|
||||
void autoSave();
|
||||
void cleanupAutoSaveFile();
|
||||
@@ -84,6 +86,7 @@ protected:
|
||||
QProgressBar *progress_bar;
|
||||
QLabel *status_label;
|
||||
QJsonDocument fingerprint_to_dbc;
|
||||
std::set<QString> opendbc_names;
|
||||
QSplitter *video_splitter = nullptr;
|
||||
enum { MAX_RECENT_FILES = 15 };
|
||||
QAction *recent_files_acts[MAX_RECENT_FILES] = {};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#include "opendbc/can/common.h"
|
||||
#undef INFO
|
||||
#include "catch2/catch.hpp"
|
||||
#include "tools/replay/logreader.h"
|
||||
@@ -29,46 +28,6 @@ TEST_CASE("DBCFile::generateDBC") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Parse can messages") {
|
||||
DBCManager dbc(nullptr);
|
||||
dbc.open({0}, "toyota_new_mc_pt_generated");
|
||||
CANParser can_parser(0, "toyota_new_mc_pt_generated", {}, {});
|
||||
|
||||
LogReader log;
|
||||
REQUIRE(log.load(TEST_RLOG_URL, nullptr, {}, true));
|
||||
REQUIRE(log.events.size() > 0);
|
||||
for (auto e : log.events) {
|
||||
if (e->which == cereal::Event::Which::CAN) {
|
||||
std::map<std::pair<uint32_t, QString>, std::vector<double>> values_1;
|
||||
for (const auto &c : e->event.getCan()) {
|
||||
const auto msg = dbc.msg({.source = c.getSrc(), .address = c.getAddress()});
|
||||
if (c.getSrc() == 0 && msg) {
|
||||
for (auto sig : msg->getSignals()) {
|
||||
double val = get_raw_value((uint8_t *)c.getDat().begin(), c.getDat().size(), *sig);
|
||||
values_1[{c.getAddress(), sig->name}].push_back(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
can_parser.UpdateCans(e->mono_time, e->event.getCan());
|
||||
std::vector<SignalValue> values_2;
|
||||
can_parser.query_latest(values_2);
|
||||
for (auto &[key, v1] : values_1) {
|
||||
bool found = false;
|
||||
for (auto &v2 : values_2) {
|
||||
if (v2.address == key.first && key.second == v2.name.c_str()) {
|
||||
REQUIRE(v2.all_values.size() == v1.size());
|
||||
REQUIRE(v2.all_values == v1);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
REQUIRE(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("parse_dbc") {
|
||||
QString content = R"(
|
||||
BO_ 160 message_1: 8 EON
|
||||
|
||||
Reference in New Issue
Block a user