@@ -70,6 +70,7 @@ def process_ublox_msg(self, ublox_msg, ublox_mono_time: int, block=False):
70
70
processed_measurements = process_measurements (new_meas , self .astro_dog )
71
71
72
72
min_measurements = 4
73
+ # If glonass is one of the measurements we need 5 measurements for calculating the pos fix
73
74
for p in processed_measurements :
74
75
if p .constellation_id == ConstellationId .GLONASS > 0 :
75
76
min_measurements += 1
@@ -84,15 +85,15 @@ def process_ublox_msg(self, ublox_msg, ublox_mono_time: int, block=False):
84
85
# If localizer is valid use its position to correct measurements
85
86
if kf_pos_std is not None and linalg .norm (kf_pos_std ) < 100 :
86
87
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 ]
89
90
else :
90
91
est_pos = None
91
92
corrected_measurements = []
92
93
if est_pos is not None :
93
94
corrected_measurements = correct_measurements (processed_measurements , est_pos , self .astro_dog )
94
95
95
- self .update_localizer (pos_fix , t , corrected_measurements )
96
+ self .update_localizer (est_pos , t , corrected_measurements )
96
97
kf_valid = all (self .kf_valid (t ))
97
98
98
99
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):
118
119
# elif ublox_msg.which == 'ionoData':
119
120
# todo add this. Needed to better correct messages offline. First fix ublox_msg.cc to sent them.
120
121
121
- def update_localizer (self , pos_fix , t : float , measurements : List [GNSSMeasurement ]):
122
+ def update_localizer (self , est_pos , t : float , measurements : List [GNSSMeasurement ]):
122
123
# Check time and outputs are valid
123
124
valid = self .kf_valid (t )
124
125
if not all (valid ):
@@ -131,10 +132,10 @@ def update_localizer(self, pos_fix, t: float, measurements: List[GNSSMeasurement
131
132
else :
132
133
cloudlog .error ("Gnss kalman std too far" )
133
134
134
- if len ( pos_fix ) == 0 :
135
+ if est_pos is None :
135
136
cloudlog .info ("Position fix not available when resetting kalman filter" )
136
137
return
137
- post_est = pos_fix [ 0 ][: 3 ] .tolist ()
138
+ post_est = est_pos .tolist ()
138
139
self .init_gnss_localizer (post_est )
139
140
if len (measurements ) > 0 :
140
141
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
247
248
x0 = [0 , 0 , 0 , 0 , 0 ]
248
249
n = len (measurements )
249
250
if n < min_measurements :
250
- return []
251
+ return None
251
252
252
253
Fx_pos = pr_residual (measurements , posfix_functions , signal = signal )
253
254
return gauss_newton (Fx_pos , x0 )
0 commit comments