Skip to content

Commit 9536d92

Browse files
committed
Fix
1 parent 39d6e07 commit 9536d92

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

selfdrive/locationd/laikad.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def process_ublox_msg(self, ublox_msg, ublox_mono_time: int, block=False):
7070
processed_measurements = process_measurements(new_meas, self.astro_dog)
7171

7272
min_measurements = 4
73+
# If glonass is one of the measurements we need 5 measurements for calculating the pos fix
7374
for p in processed_measurements:
7475
if p.constellation_id == ConstellationId.GLONASS > 0:
7576
min_measurements += 1
@@ -84,15 +85,15 @@ def process_ublox_msg(self, ublox_msg, ublox_mono_time: int, block=False):
8485
# If localizer is valid use its position to correct measurements
8586
if kf_pos_std is not None and linalg.norm(kf_pos_std) < 100:
8687
est_pos = self.gnss_kf.x[GStates.ECEF_POS]
87-
elif len(pos_fix) > 0 and abs(np.array(pos_fix[1])).mean() < 1000:
88-
est_pos = pos_fix[0][:3]
88+
elif pos_fix is not None:
89+
est_pos = pos_fix[:3]
8990
else:
9091
est_pos = None
9192
corrected_measurements = []
9293
if est_pos is not None:
9394
corrected_measurements = correct_measurements(processed_measurements, est_pos, self.astro_dog)
9495

95-
self.update_localizer(pos_fix, t, corrected_measurements)
96+
self.update_localizer(est_pos, t, corrected_measurements)
9697
kf_valid = all(self.kf_valid(t))
9798

9899
ecef_pos = self.gnss_kf.x[GStates.ECEF_POS].tolist()
@@ -118,7 +119,7 @@ def process_ublox_msg(self, ublox_msg, ublox_mono_time: int, block=False):
118119
# elif ublox_msg.which == 'ionoData':
119120
# todo add this. Needed to better correct messages offline. First fix ublox_msg.cc to sent them.
120121

121-
def update_localizer(self, pos_fix, t: float, measurements: List[GNSSMeasurement]):
122+
def update_localizer(self, est_pos, t: float, measurements: List[GNSSMeasurement]):
122123
# Check time and outputs are valid
123124
valid = self.kf_valid(t)
124125
if not all(valid):
@@ -131,10 +132,10 @@ def update_localizer(self, pos_fix, t: float, measurements: List[GNSSMeasurement
131132
else:
132133
cloudlog.error("Gnss kalman std too far")
133134

134-
if len(pos_fix) == 0:
135+
if est_pos is None:
135136
cloudlog.info("Position fix not available when resetting kalman filter")
136137
return
137-
post_est = pos_fix[0][:3].tolist()
138+
post_est = est_pos.tolist()
138139
self.init_gnss_localizer(post_est)
139140
if len(measurements) > 0:
140141
kf_add_observations(self.gnss_kf, t, measurements)
@@ -247,7 +248,7 @@ def calc_pos_fix_gauss_newton(measurements, posfix_functions, x0=None, signal='C
247248
x0 = [0, 0, 0, 0, 0]
248249
n = len(measurements)
249250
if n < min_measurements:
250-
return []
251+
return None
251252

252253
Fx_pos = pr_residual(measurements, posfix_functions, signal=signal)
253254
return gauss_newton(Fx_pos, x0)

0 commit comments

Comments
 (0)