Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nav: fix receiving navRoute while map is loading #22929

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion selfdrive/ui/qt/maps/map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings) :
m_settings(settings), velocity_filter(0, 10, 0.1) {
sm = new SubMaster({"liveLocationKalman", "navInstruction", "navRoute"});

// Connect now, so any navRoutes sent while the map is initializing are not dropped
sm->update(0);

timer = new QTimer(this);
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
timer->start(100);
Expand All @@ -50,6 +53,7 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings) :
}

grabGesture(Qt::GestureType::PinchGesture);
qDebug() << "MapWindow initialized";
}

MapWindow::~MapWindow() {
Expand Down Expand Up @@ -178,7 +182,8 @@ void MapWindow::timerUpdate() {
}
}

if (sm->updated("navRoute")) {
if (sm->rcv_frame("navRoute") != route_rcv_frame) {
qWarning() << "Got new navRoute from navd";
auto route = (*sm)["navRoute"].getNavRoute();
auto route_points = capnp_coordinate_list_to_collection(route.getCoordinates());
QMapbox::Feature feature(QMapbox::Feature::LineStringType, route_points, {}, {});
Expand All @@ -193,6 +198,7 @@ void MapWindow::timerUpdate() {
setVisible(true); // Show map on destination set/change
allow_open = false;
}
route_rcv_frame = sm->rcv_frame("navRoute");
}
}

Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/qt/maps/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class MapWindow : public QOpenGLWidget {
MapETA* map_eta;

void clearRoute();
uint64_t route_rcv_frame = 0;

private slots:
void timerUpdate();
Expand Down