load d/e camera by command line flags (#22341)

old-commit-hash: e888a7e939
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent 69826b5487
commit bac9a01cb2
  1. 4
      selfdrive/ui/replay/main.cc
  2. 5
      selfdrive/ui/replay/replay.cc
  3. 4
      selfdrive/ui/replay/replay.h
  4. 9
      selfdrive/ui/replay/route.cc
  5. 2
      selfdrive/ui/replay/route.h

@ -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>", "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

@ -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<const char*> 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<Segment>(i, route_->at(i));
segments[i] = std::make_unique<Segment>(i, route_->at(i), load_dcam, load_ecam);
QObject::connect(segments[i].get(), &Segment::loadFinished, this, &Replay::queueSegment);
}
end_idx = i;

@ -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<int> seek_ts = 0;

@ -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))) {

@ -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_; }

Loading…
Cancel
Save