nav: improve logging (#21477)

* nav: add logging

* handle errors in route reply
old-commit-hash: 32d5239912
commatwo_master
Willem Melching 4 years ago committed by GitHub
parent 9999af4d91
commit c266cffa97
  1. 45
      selfdrive/ui/qt/maps/map.cc
  2. 9
      selfdrive/ui/qt/maps/map_settings.cc

@ -80,6 +80,7 @@ MapWindow::~MapWindow() {
void MapWindow::initLayers() { void MapWindow::initLayers() {
// 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";
QVariantMap modelPath; QVariantMap modelPath;
modelPath["id"] = "modelPathLayer"; modelPath["id"] = "modelPathLayer";
modelPath["type"] = "line"; modelPath["type"] = "line";
@ -90,6 +91,7 @@ void MapWindow::initLayers() {
m_map->setLayoutProperty("modelPathLayer", "line-cap", "round"); m_map->setLayoutProperty("modelPathLayer", "line-cap", "round");
} }
if (!m_map->layerExists("navLayer")) { if (!m_map->layerExists("navLayer")) {
qDebug() << "Initializing navLayer";
QVariantMap nav; QVariantMap nav;
nav["id"] = "navLayer"; nav["id"] = "navLayer";
nav["type"] = "line"; nav["type"] = "line";
@ -100,6 +102,7 @@ void MapWindow::initLayers() {
m_map->setLayoutProperty("navLayer", "line-cap", "round"); m_map->setLayoutProperty("navLayer", "line-cap", "round");
} }
if (!m_map->layerExists("carPosLayer")) { if (!m_map->layerExists("carPosLayer")) {
qDebug() << "Initializing carPosLayer";
m_map->addImage("label-arrow", QImage("../assets/images/triangle.svg")); m_map->addImage("label-arrow", QImage("../assets/images/triangle.svg"));
QVariantMap carPos; QVariantMap carPos;
@ -207,7 +210,7 @@ void MapWindow::timerUpdate() {
recompute_backoff = std::max(0, recompute_backoff - 1); recompute_backoff = std::max(0, recompute_backoff - 1);
recompute_countdown = 0; recompute_countdown = 0;
} else { } else {
// Destination reached qWarning() << "Destination reached";
Params().remove("NavDestination"); Params().remove("NavDestination");
// Clear route if driving away from destination // Clear route if driving away from destination
@ -279,6 +282,7 @@ void MapWindow::recomputeRoute() {
} }
if (*new_destination != nav_destination) { if (*new_destination != nav_destination) {
qWarning() << "Got new destination from NavDestination param" << *new_destination;
setVisible(true); // Show map on destination set/change setVisible(true); // Show map on destination set/change
// TODO: close sidebar // TODO: close sidebar
should_recompute = true; should_recompute = true;
@ -321,7 +325,8 @@ void MapWindow::updateETA() {
} }
void MapWindow::calculateRoute(QMapbox::Coordinate destination) { void MapWindow::calculateRoute(QMapbox::Coordinate destination) {
LOGW("calculating route"); qWarning() << "Calculating route to" << destination;
nav_destination = destination; nav_destination = destination;
QGeoRouteRequest request(to_QGeoCoordinate(*last_position), to_QGeoCoordinate(destination)); QGeoRouteRequest request(to_QGeoCoordinate(*last_position), to_QGeoCoordinate(destination));
request.setFeatureWeight(QGeoRouteRequest::TrafficFeature, QGeoRouteRequest::AvoidFeatureWeight); request.setFeatureWeight(QGeoRouteRequest::TrafficFeature, QGeoRouteRequest::AvoidFeatureWeight);
@ -337,20 +342,28 @@ void MapWindow::calculateRoute(QMapbox::Coordinate destination) {
} }
void MapWindow::routeCalculated(QGeoRouteReply *reply) { void MapWindow::routeCalculated(QGeoRouteReply *reply) {
LOGW("new route calculated"); if (reply->error() == QGeoRouteReply::NoError) {
if (reply->routes().size() != 0) { if (reply->routes().size() != 0) {
route = reply->routes().at(0); qWarning() << "Got route response";
segment = route.firstRouteSegment();
route = reply->routes().at(0);
auto route_points = coordinate_list_to_collection(route.path()); segment = route.firstRouteSegment();
QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {});
QVariantMap navSource; auto route_points = coordinate_list_to_collection(route.path());
navSource["type"] = "geojson"; QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {});
navSource["data"] = QVariant::fromValue<QMapbox::Feature>(feature); QVariantMap navSource;
m_map->updateSource("navSource", navSource); navSource["type"] = "geojson";
m_map->setLayoutProperty("navLayer", "visibility", "visible"); navSource["data"] = QVariant::fromValue<QMapbox::Feature>(feature);
m_map->updateSource("navSource", navSource);
updateETA(); m_map->setLayoutProperty("navLayer", "visibility", "visible");
updateETA();
} else {
qWarning() << "Got empty route response";
}
} else {
qWarning() << "Got error in route reply" << reply->errorString();
} }
reply->deleteLater(); reply->deleteLater();

@ -88,8 +88,13 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
QObject::connect(repeater, &RequestRepeater::receivedResponse, [](QString resp) { QObject::connect(repeater, &RequestRepeater::receivedResponse, [](QString resp) {
auto params = Params(); auto params = Params();
if (resp != "null" && params.get("NavDestination").empty()) { if (resp != "null") {
params.put("NavDestination", resp.toStdString()); 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";
}
} }
}); });
} }

Loading…
Cancel
Save