diff --git a/selfdrive/ui/replay/main.cc b/selfdrive/ui/replay/main.cc index 3450056827..84167fe4fb 100644 --- a/selfdrive/ui/replay/main.cc +++ b/selfdrive/ui/replay/main.cc @@ -72,6 +72,8 @@ int main(int argc, char *argv[]){ parser.addOption({{"b", "block"}, "blacklist of services to send", "block"}); parser.addOption({{"s", "start"}, "start from ", "seconds"}); parser.addOption({"demo", "use a demo route instead of providing your own"}); + parser.addOption({"dcam", "load driver camera"}); + parser.addOption({"ecam", "load wide road camera"}); parser.process(a); const QStringList args = parser.positionalArguments(); @@ -82,7 +84,7 @@ int main(int argc, char *argv[]){ const QString route = args.empty() ? DEMO_ROUTE : args.first(); QStringList allow = parser.value("allow").isEmpty() ? QStringList{} : parser.value("allow").split(","); QStringList block = parser.value("block").isEmpty() ? QStringList{} : parser.value("block").split(","); - Replay *replay = new Replay(route, allow, block); + Replay *replay = new Replay(route, allow, block, nullptr, parser.isSet("dcam"), parser.isSet("ecam")); replay->start(parser.value("start").toInt()); // start keyboard control thread diff --git a/selfdrive/ui/replay/replay.cc b/selfdrive/ui/replay/replay.cc index 50dcecf114..ece5c47dc8 100644 --- a/selfdrive/ui/replay/replay.cc +++ b/selfdrive/ui/replay/replay.cc @@ -7,7 +7,8 @@ #include "selfdrive/common/timing.h" #include "selfdrive/hardware/hw.h" -Replay::Replay(QString route, QStringList allow, QStringList block, SubMaster *sm_, QObject *parent) : sm(sm_), QObject(parent) { +Replay::Replay(QString route, QStringList allow, QStringList block, SubMaster *sm_, bool dcam, bool ecam, QObject *parent) + : sm(sm_), load_dcam(dcam), load_ecam(ecam), QObject(parent) { std::vector s; for (const auto &it : services) { if ((allow.size() == 0 || allow.contains(it.name)) && @@ -90,7 +91,7 @@ void Replay::queueSegment() { int end_idx = cur_seg; for (int i = cur_seg, fwd = 0; i < segments.size() && fwd <= FORWARD_SEGS; ++i) { if (!segments[i]) { - segments[i] = std::make_unique(i, route_->at(i)); + segments[i] = std::make_unique(i, route_->at(i), load_dcam, load_ecam); QObject::connect(segments[i].get(), &Segment::loadFinished, this, &Replay::queueSegment); } end_idx = i; diff --git a/selfdrive/ui/replay/replay.h b/selfdrive/ui/replay/replay.h index f9aa549f49..7d7deab6fb 100644 --- a/selfdrive/ui/replay/replay.h +++ b/selfdrive/ui/replay/replay.h @@ -14,7 +14,7 @@ class Replay : public QObject { Q_OBJECT public: - Replay(QString route, QStringList allow, QStringList block, SubMaster *sm = nullptr, QObject *parent = 0); + Replay(QString route, QStringList allow, QStringList block, SubMaster *sm = nullptr, bool dcam = false, bool ecam = false, QObject *parent = 0); ~Replay(); void start(int seconds = 0); @@ -34,6 +34,8 @@ protected: void setCurrentSegment(int n); void mergeSegments(int begin_idx, int end_idx); + bool load_dcam = false, load_ecam = false; + float last_print = 0; uint64_t route_start_ts = 0; std::atomic seek_ts = 0; diff --git a/selfdrive/ui/replay/route.cc b/selfdrive/ui/replay/route.cc index be8af108db..7a99cfbb97 100644 --- a/selfdrive/ui/replay/route.cc +++ b/selfdrive/ui/replay/route.cc @@ -70,7 +70,7 @@ bool Route::loadFromJson(const QString &json) { // class Segment -Segment::Segment(int n, const SegmentFile &segment_files) : seg_num_(n), files_(segment_files) { +Segment::Segment(int n, const SegmentFile &segment_files, bool load_dcam, bool load_ecam) : seg_num_(n), files_(segment_files) { static std::once_flag once_flag; std::call_once(once_flag, [=]() { if (!QDir(CACHE_DIR).exists()) QDir().mkdir(CACHE_DIR); @@ -81,6 +81,13 @@ Segment::Segment(int n, const SegmentFile &segment_files) : seg_num_(n), files_( valid_ = !files_.rlog.isEmpty() && !road_cam_path_.isEmpty(); if (!valid_) return; + if (!load_dcam) { + files_.driver_cam = ""; + } + if (!load_ecam) { + files_.wide_road_cam = ""; + } + if (!QUrl(files_.rlog).isLocalFile()) { for (auto &url : {files_.rlog, road_cam_path_, files_.driver_cam, files_.wide_road_cam}) { if (!url.isEmpty() && !QFile::exists(localPath(url))) { diff --git a/selfdrive/ui/replay/route.h b/selfdrive/ui/replay/route.h index fd40d737f9..3f7725db96 100644 --- a/selfdrive/ui/replay/route.h +++ b/selfdrive/ui/replay/route.h @@ -38,7 +38,7 @@ class Segment : public QObject { Q_OBJECT public: - Segment(int n, const SegmentFile &segment_files); + Segment(int n, const SegmentFile &segment_files, bool load_dcam, bool load_ecam); ~Segment(); inline bool isValid() const { return valid_; }; inline bool isLoaded() const { return loaded_; }