diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 680e39a90b..a812948efd 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -80,6 +80,7 @@ MapWindow::~MapWindow() { void MapWindow::initLayers() { // This doesn't work from initializeGL if (!m_map->layerExists("modelPathLayer")) { + qDebug() << "Initializing modelPathLayer"; QVariantMap modelPath; modelPath["id"] = "modelPathLayer"; modelPath["type"] = "line"; @@ -90,6 +91,7 @@ void MapWindow::initLayers() { m_map->setLayoutProperty("modelPathLayer", "line-cap", "round"); } if (!m_map->layerExists("navLayer")) { + qDebug() << "Initializing navLayer"; QVariantMap nav; nav["id"] = "navLayer"; nav["type"] = "line"; @@ -100,6 +102,7 @@ void MapWindow::initLayers() { m_map->setLayoutProperty("navLayer", "line-cap", "round"); } if (!m_map->layerExists("carPosLayer")) { + qDebug() << "Initializing carPosLayer"; m_map->addImage("label-arrow", QImage("../assets/images/triangle.svg")); QVariantMap carPos; @@ -207,7 +210,7 @@ void MapWindow::timerUpdate() { recompute_backoff = std::max(0, recompute_backoff - 1); recompute_countdown = 0; } else { - // Destination reached + qWarning() << "Destination reached"; Params().remove("NavDestination"); // Clear route if driving away from destination @@ -279,6 +282,7 @@ void MapWindow::recomputeRoute() { } if (*new_destination != nav_destination) { + qWarning() << "Got new destination from NavDestination param" << *new_destination; setVisible(true); // Show map on destination set/change // TODO: close sidebar should_recompute = true; @@ -321,7 +325,8 @@ void MapWindow::updateETA() { } void MapWindow::calculateRoute(QMapbox::Coordinate destination) { - LOGW("calculating route"); + qWarning() << "Calculating route to" << destination; + nav_destination = destination; QGeoRouteRequest request(to_QGeoCoordinate(*last_position), to_QGeoCoordinate(destination)); request.setFeatureWeight(QGeoRouteRequest::TrafficFeature, QGeoRouteRequest::AvoidFeatureWeight); @@ -337,20 +342,28 @@ void MapWindow::calculateRoute(QMapbox::Coordinate destination) { } void MapWindow::routeCalculated(QGeoRouteReply *reply) { - LOGW("new route calculated"); - if (reply->routes().size() != 0) { - route = reply->routes().at(0); - segment = route.firstRouteSegment(); - - auto route_points = coordinate_list_to_collection(route.path()); - QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {}); - QVariantMap navSource; - navSource["type"] = "geojson"; - navSource["data"] = QVariant::fromValue(feature); - m_map->updateSource("navSource", navSource); - m_map->setLayoutProperty("navLayer", "visibility", "visible"); - - updateETA(); + if (reply->error() == QGeoRouteReply::NoError) { + if (reply->routes().size() != 0) { + qWarning() << "Got route response"; + + route = reply->routes().at(0); + segment = route.firstRouteSegment(); + + auto route_points = coordinate_list_to_collection(route.path()); + QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {}); + QVariantMap navSource; + navSource["type"] = "geojson"; + navSource["data"] = QVariant::fromValue(feature); + m_map->updateSource("navSource", navSource); + m_map->setLayoutProperty("navLayer", "visibility", "visible"); + + updateETA(); + } else { + qWarning() << "Got empty route response"; + } + } else { + qWarning() << "Got error in route reply" << reply->errorString(); + } reply->deleteLater(); diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index fcd28c3768..ca3c6f13fe 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -88,8 +88,13 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { QObject::connect(repeater, &RequestRepeater::receivedResponse, [](QString resp) { auto params = Params(); - if (resp != "null" && params.get("NavDestination").empty()) { - params.put("NavDestination", resp.toStdString()); + if (resp != "null") { + if (params.get("NavDestination").empty()) { + qWarning() << "Setting NavDestination from /next" << resp; + params.put("NavDestination", resp.toStdString()); + } else { + qWarning() << "Got location from /next, but NavDestination already set"; + } } }); }