pull/24632/head
Shane Smiskol 3 years ago
parent edc7a2b3d9
commit f37084fd89
  1. 1
      SConstruct
  2. 1
      selfdrive/ui/navd/map_renderer.cc
  3. 150
      selfdrive/ui/qt/maps/map.cc
  4. 3
      selfdrive/ui/qt/maps/map.h

@ -165,7 +165,6 @@ env = Environment(
"-g", "-g",
"-fPIC", "-fPIC",
"-O2", "-O2",
"-Wunused",
"-Werror", "-Werror",
"-Wshadow", "-Wshadow",
"-Wno-unknown-warning-option", "-Wno-unknown-warning-option",

@ -140,6 +140,7 @@ void MapRenderer::updateRoute(QList<QGeoCoordinate> coordinates) {
} }
void MapRenderer::initLayers() { void MapRenderer::initLayers() {
qDebug() << "SHOULDN'T BE HERE";
if (!m_map->layerExists("navLayer")) { if (!m_map->layerExists("navLayer")) {
QVariantMap nav; QVariantMap nav;
nav["id"] = "navLayer"; nav["id"] = "navLayer";

@ -64,6 +64,9 @@ MapWindow::~MapWindow() {
} }
void MapWindow::initLayers() { void MapWindow::initLayers() {
if (layers_initialized) return;
// if (!gl_initialized) return;
layers_initialized = true;
// This doesn't work from initializeGL // This doesn't work from initializeGL
if (!m_map->layerExists("modelPathLayer")) { if (!m_map->layerExists("modelPathLayer")) {
qDebug() << "Initializing modelPathLayer"; qDebug() << "Initializing modelPathLayer";
@ -102,6 +105,7 @@ void MapWindow::initLayers() {
m_map->setLayoutProperty("carPosLayer", "icon-ignore-placement", true); m_map->setLayoutProperty("carPosLayer", "icon-ignore-placement", true);
m_map->setLayoutProperty("carPosLayer", "icon-allow-overlap", true); m_map->setLayoutProperty("carPosLayer", "icon-allow-overlap", true);
m_map->setLayoutProperty("carPosLayer", "symbol-sort-key", 0); m_map->setLayoutProperty("carPosLayer", "symbol-sort-key", 0);
// if (m_map->layerExists("carPosLayer")) car_layer_initialized = true;
} }
} }
@ -109,17 +113,17 @@ void MapWindow::updateState(const UIState &s) {
if (!uiState()->scene.started) { if (!uiState()->scene.started) {
return; return;
} }
double t = millis_since_boot(); // double t = millis_since_boot();
double e; // double e;
update(); // update();
qDebug() << "updateState()"; // qDebug() << "updateState()";
const SubMaster &sm = *(s.sm); const SubMaster &sm = *(s.sm);
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "update():" << e << "ms"; // qDebug() << "update():" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
// sm.update(0); //// sm.update(0);
if (sm.updated("liveLocationKalman")) { if (sm.updated("liveLocationKalman")) {
auto location = sm["liveLocationKalman"].getLiveLocationKalman(); auto location = sm["liveLocationKalman"].getLiveLocationKalman();
auto pos = location.getPositionGeodetic(); auto pos = location.getPositionGeodetic();
@ -135,11 +139,11 @@ void MapWindow::updateState(const UIState &s) {
velocity_filter.update(velocity.getValue()[0]); velocity_filter.update(velocity.getValue()[0]);
} }
} }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "liveLocationKalman:" << e << "ms"; // qDebug() << "liveLocationKalman:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
if (sm.updated("navRoute") && sm["navRoute"].getNavRoute().getCoordinates().size()) { if (sm.updated("navRoute") && sm["navRoute"].getNavRoute().getCoordinates().size()) {
qWarning() << "Got new navRoute from navd. Opening map:" << allow_open; qWarning() << "Got new navRoute from navd. Opening map:" << allow_open;
@ -149,31 +153,39 @@ void MapWindow::updateState(const UIState &s) {
allow_open = false; allow_open = false;
} }
} }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "navRoute:" << e << "ms"; // qDebug() << "navRoute:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
if (m_map.isNull()) { if (m_map.isNull()) {
return; return;
} }
//
loaded_once = loaded_once || m_map->isFullyLoaded(); // loaded_once = loaded_once || m_map->isFullyLoaded();
if (!loaded_once) { // if (!loaded_once) {
map_instructions->showError("Map Loading"); // map_instructions->showError("Map Loading");
return; // return;
} // }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "instructions:" << e << "ms"; // qDebug() << "instructions:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
initLayers(); if (gl_initialized) {
qDebug() << "About to initialize layers";
e = millis_since_boot() - t; initLayers();
qDebug() << "initLayers:" << e << "ms"; QVector<QString> layers = m_map->layerIds();
t = millis_since_boot(); qDebug() << "layer size:" << layers.size();
// for (auto layer_id : layers) {
// qDebug() << layer_id;
// }
}
//
// e = millis_since_boot() - t;
// qDebug() << "initLayers:" << e << "ms";
// t = millis_since_boot();
//
if (!localizer_valid) { if (!localizer_valid) {
map_instructions->showError("Waiting for GPS"); map_instructions->showError("Waiting for GPS");
} else { } else {
@ -187,32 +199,37 @@ void MapWindow::updateState(const UIState &s) {
carPosSource["data"] = QVariant::fromValue<QMapbox::Feature>(feature1); carPosSource["data"] = QVariant::fromValue<QMapbox::Feature>(feature1);
m_map->updateSource("carPosSource", carPosSource); m_map->updateSource("carPosSource", carPosSource);
} }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "location marker:" << e << "ms"; // qDebug() << "location marker:" << an_counter == 0) {
t = millis_since_boot(); // if (last_position) m_map->setCoordinate(*last_position);
// if (last_bearing) m_map->setBearing(*last_bearing);
// } else {
// pan_counter--;
// }e << "ms";
// t = millis_since_boot();
//
if (pan_counter == 0) { if (pan_counter == 0) {
if (last_position) m_map->setCoordinate(*last_position); if (last_position) m_map->setCoordinate(*last_position);
if (last_bearing) m_map->setBearing(*last_bearing); if (last_bearing) m_map->setBearing(*last_bearing);
} else { } else {
pan_counter--; pan_counter--;
} }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "pan counter:" << e << "ms"; // qDebug() << "pan counter:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
if (zoom_counter == 0) { if (zoom_counter == 0) {
m_map->setZoom(util::map_val<float>(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM)); m_map->setZoom(util::map_val<float>(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM));
} else { } else {
zoom_counter--; zoom_counter--;
} }
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "zoom counter:" << e << "ms"; // qDebug() << "zoom counter:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
if (sm.updated("navInstruction")) { if (sm.updated("navInstruction")) {
if (sm.valid("navInstruction")) { if (sm.valid("navInstruction")) {
auto i = sm["navInstruction"].getNavInstruction(); auto i = sm["navInstruction"].getNavInstruction();
@ -228,11 +245,11 @@ void MapWindow::updateState(const UIState &s) {
clearRoute(); clearRoute();
} }
} }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "navInstruction:" << e << "ms"; // qDebug() << "navInstruction:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
//
if (sm.rcv_frame("navRoute") != route_rcv_frame) { if (sm.rcv_frame("navRoute") != route_rcv_frame) {
qWarning() << "Updating navLayer with new route"; qWarning() << "Updating navLayer with new route";
auto route = sm["navRoute"].getNavRoute(); auto route = sm["navRoute"].getNavRoute();
@ -246,19 +263,22 @@ void MapWindow::updateState(const UIState &s) {
route_rcv_frame = sm.rcv_frame("navRoute"); route_rcv_frame = sm.rcv_frame("navRoute");
} }
//
e = millis_since_boot() - t; // e = millis_since_boot() - t;
qDebug() << "navRoute:" << e << "ms"; // qDebug() << "navRoute:" << e << "ms";
t = millis_since_boot(); // t = millis_since_boot();
qDebug() << "\n\n"; // qDebug() << "\n\n";
update();
} }
void MapWindow::resizeGL(int w, int h) { void MapWindow::resizeGL(int w, int h) {
qDebug() << "resizeGL";
m_map->resize(size() / MAP_SCALE); m_map->resize(size() / MAP_SCALE);
map_instructions->setFixedWidth(width()); map_instructions->setFixedWidth(width());
} }
void MapWindow::initializeGL() { void MapWindow::initializeGL() {
qDebug() << "initializeGL";
m_map.reset(new QMapboxGL(this, m_settings, size(), 1)); m_map.reset(new QMapboxGL(this, m_settings, size(), 1));
if (last_position) { if (last_position) {
@ -276,11 +296,12 @@ void MapWindow::initializeGL() {
loaded_once = true; loaded_once = true;
} }
}); });
gl_initialized = true;
} }
void MapWindow::paintGL() { void MapWindow::paintGL() {
if (!isVisible() || m_map.isNull()) return;
double t = millis_since_boot(); double t = millis_since_boot();
if (!isVisible() || m_map.isNull()) return;
m_map->render(); m_map->render();
double e = millis_since_boot() - t; double e = millis_since_boot() - t;
qDebug() << "MapWindow::paintGL():" << e << "ms"; qDebug() << "MapWindow::paintGL():" << e << "ms";
@ -313,12 +334,15 @@ void MapWindow::mouseDoubleClickEvent(QMouseEvent *ev) {
} }
void MapWindow::mouseMoveEvent(QMouseEvent *ev) { void MapWindow::mouseMoveEvent(QMouseEvent *ev) {
double t = millis_since_boot();
QPointF delta = ev->localPos() - m_lastPos; QPointF delta = ev->localPos() - m_lastPos;
if (!delta.isNull()) { if (!delta.isNull()) {
pan_counter = PAN_TIMEOUT; pan_counter = PAN_TIMEOUT;
m_map->moveBy(delta / MAP_SCALE); m_map->moveBy(delta / MAP_SCALE);
// update(); update();
double e = millis_since_boot() - t;
qDebug() << "MapWindow::mouseMoveEvent():" << e << "ms";
} }
m_lastPos = ev->localPos(); m_lastPos = ev->localPos();
@ -429,6 +453,7 @@ MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) {
} }
void MapInstructions::updateDistance(float d) { void MapInstructions::updateDistance(float d) {
qDebug() << "updateDistance";
d = std::max(d, 0.0f); d = std::max(d, 0.0f);
QString distance_str; QString distance_str;
@ -627,6 +652,7 @@ void MapETA::updateETA(float s, float s_typical, float d) {
hide(); hide();
return; return;
} }
qDebug() << "updateETA";
// ETA // ETA
auto eta_time = QDateTime::currentDateTime().addSecs(s).time(); auto eta_time = QDateTime::currentDateTime().addSecs(s).time();

@ -80,6 +80,9 @@ private:
QMapboxGLSettings m_settings; QMapboxGLSettings m_settings;
QScopedPointer<QMapboxGL> m_map; QScopedPointer<QMapboxGL> m_map;
bool car_layer_initialized = false;
bool layers_initialized = false;
bool gl_initialized = false;
void initLayers(); void initLayers();

Loading…
Cancel
Save