Skip to content

Commit 6161e47

Browse files
pd0wmnetadvanced
authored andcommitted
navd: speed limits only when localizer is valid (commaai#24845)
1 parent 794f80c commit 6161e47

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

selfdrive/navd/navd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, sm, pm):
3232
self.last_bearing = None
3333

3434
self.gps_ok = False
35+
self.localizer_valid = False
3536

3637
self.nav_destination = None
3738
self.step_idx = None
@@ -73,9 +74,9 @@ def update_location(self):
7374
location = self.sm['liveLocationKalman']
7475
self.gps_ok = location.gpsOK
7576

76-
localizer_valid = (location.status == log.LiveLocationKalman.Status.valid) and location.positionGeodetic.valid
77+
self.localizer_valid = (location.status == log.LiveLocationKalman.Status.valid) and location.positionGeodetic.valid
7778

78-
if localizer_valid:
79+
if self.localizer_valid:
7980
self.last_bearing = math.degrees(location.calibratedOrientationNED.value[2])
8081
self.last_position = Coordinate(location.positionGeodetic.value[0], location.positionGeodetic.value[1])
8182

@@ -202,7 +203,7 @@ def send_instruction(self):
202203
if along_geometry < distance_along_geometry(geometry, geometry[closest_idx]):
203204
closest = geometry[closest_idx - 1]
204205

205-
if 'maxspeed' in closest.annotations:
206+
if ('maxspeed' in closest.annotations) and self.localizer_valid:
206207
msg.navInstruction.speedLimit = closest.annotations['maxspeed']
207208

208209
# Speed limit sign type

0 commit comments

Comments
 (0)