Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit c3c3d2c

Browse files
author
Adel Mamin
committed
Fix unit tests
1 parent 2c72d02 commit c3c3d2c

File tree

6 files changed

+48
-29
lines changed

6 files changed

+48
-29
lines changed

peregrine/analysis/tracking_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main():
102102

103103
ms_to_process = int(args.ms_to_process)
104104

105-
if args.short_long_cycles is not None:
105+
if args.short_long_cycles:
106106
tracker_options = {'mode': 'short-long-cycles'}
107107
else:
108108
tracker_options = None

peregrine/defaults.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
'pll_bw': (40, 35, 30, 25, 20, 18, 16, 14, 12, 10, 8, 7, 6.5, 6, 5.5, 5),
137137
'coherent_ms': (1, 2, 4, 5, 10, 20) }
138138

139+
l2c_track_params = {
140+
'fll_bw': (1, 0),
141+
'pll_bw': (20, 18, 16, 14, 12, 10, 8, 7, 6.5, 6, 5.5, 5),
142+
'coherent_ms': (20,) }
143+
139144
l1ca_loop_filter_params_template = {
140145
'code_params': (1., 0.7, 1.), # NBW, zeta, k
141146
'carr_params': (20., 0.7, 1.), # NBW, zeta, k
@@ -144,6 +149,14 @@
144149
'carr_to_code': 1540. # carr_to_code
145150
}
146151

152+
l2c_loop_filter_params_template = {
153+
'code_params': (1., 0.7, 1.), # NBW, zeta, k
154+
'carr_params': (20., 0.7, 1.), # NBW, zeta, k
155+
'loop_freq': 1000., # 1000/coherent_ms
156+
'carr_freq_b1': 1., # FLL NBW
157+
'carr_to_code': 1200. # carr_to_code
158+
}
159+
147160
# Tracking stages. See track.c for more details.
148161
# 1;20 ms stages
149162
l1ca_stage_params_slow = \

peregrine/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def populate_peregrine_cmd_line_arguments(parser):
140140

141141
fpgaSim.add_argument("--short-long-cycles",
142142
help="Use FPGA short-long cycle simulation.",
143+
default=False,
143144
action="store_true")
144145

145146
signalParam = parser.add_argument_group('Signal tracking',
@@ -186,7 +187,7 @@ def main():
186187
else:
187188
raise NotImplementedError()
188189

189-
if args.short_long_cycles is not None:
190+
if args.short_long_cycles:
190191
tracker_options = {'mode': 'short-long-cycles'}
191192
else:
192193
tracker_options = None

peregrine/tracking.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,13 @@ def __init__(self, params):
235235
if mode == 'short-long-cycles':
236236
self.short_n_long = True
237237

238+
self.bit_sync_prev = self.bit_sync
239+
238240
self.track_settled = False
239241
self.fsm_index = 0
240242
self.fsm_states = get_fsm_states(ms=self.coherent_ms,
241243
short_n_long=self.short_n_long,
242-
bit_sync=False)
244+
bit_sync=self.bit_sync)
243245

244246
self.lock_detect = lock_detect.LockDetector(
245247
k1=self.lock_detect_params["k1"],
@@ -472,11 +474,10 @@ def _run_track_profile_selection(self):
472474
473475
"""
474476

475-
bit_sync = self.nav_bit_sync.bit_sync_acquired()
476-
if bit_sync and not self.bit_sync:
477+
if self.bit_sync and not self.bit_sync_prev:
477478
# we just got bit sync
478479
self.track_profile_timer_ms = 0
479-
self.bit_sync = bit_sync
480+
self.bit_sync_prev = self.bit_sync
480481

481482
if self.lock_detect_outp:
482483

@@ -956,6 +957,8 @@ def __init__(self, params):
956957
params['sample_index'] = params['samples']['sample_index']
957958
params['carrier_freq'] = gps_constants.l1
958959

960+
self.bit_sync = False
961+
959962
TrackingChannel.__init__(self, params)
960963

961964
self.nav_msg = NavMsg()
@@ -1012,6 +1015,8 @@ def _run_nav_data_decoding(self):
10121015
self.track_result.tow[self.i] = tow if tow >= 0 else (
10131016
self.track_result.tow[self.i - 1] + self.coherent_ms)
10141017

1018+
self.bit_sync = self.nav_bit_sync.bit_sync_acquired()
1019+
10151020
# Handover to L2C if possible
10161021
if self.l2c_handover and not self.l2c_handover_acq and \
10171022
'samples' in self.samples[gps_constants.L2C] and sync:
@@ -1051,16 +1056,23 @@ def __init__(self, params):
10511056
cn0_0 = 10 * np.log10(params['acq'].snr)
10521057
cn0_0 += 10 * np.log10(defaults.L2C_CHANNEL_BANDWIDTH_HZ)
10531058
params['cn0_0'] = cn0_0
1054-
params['track_profiles'] = defaults.l2c_track_profiles
1059+
10551060
params['lock_detect_params'] = defaults.l2c_lock_detect_params_20ms
10561061
params['IF'] = params['samples'][gps_constants.L2C]['IF']
10571062
params['prn_code'] = L2CMCodes[params['acq'].prn]
10581063
params['code_freq_init'] = params['acq'].doppler * \
10591064
gps_constants.l2c_chip_rate / gps_constants.l2
1065+
1066+
params['track_params'] = defaults.l2c_track_params
1067+
params['loop_filter_params_template'] = \
1068+
defaults.l2c_loop_filter_params_template
1069+
10601070
params['chipping_rate'] = gps_constants.l2c_chip_rate
10611071
params['sample_index'] = 0
10621072
params['carrier_freq'] = gps_constants.l2
10631073

1074+
self.bit_sync = True
1075+
10641076
TrackingChannel.__init__(self, params)
10651077

10661078
self.cnav_msg = CNavMsg()

tests/test_common.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ def run_peregrine(file_name, file_format, freq_profile,
149149
skip_param, skip_val,
150150
skip_tracking=True,
151151
skip_navigation=True,
152-
pipelining=None,
153-
short_long_cycles=None):
152+
short_long_cycles=False):
154153

155154
parameters = [
156155
'peregrine',
@@ -166,11 +165,8 @@ def run_peregrine(file_name, file_format, freq_profile,
166165
if skip_navigation:
167166
parameters += ['-n']
168167

169-
if pipelining:
170-
parameters += ['--pipelining', str(pipelining)]
171-
172168
if short_long_cycles:
173-
parameters += ['--short-long-cycles', str(short_long_cycles)]
169+
parameters += ['--short-long-cycles']
174170

175171
# Replace argv with args to skip tracking and navigation.
176172
with patch.object(sys, 'argv', parameters):

tests/test_tracking.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
def run_tracking_loop(prn, signal, dopp, phase, file_name, file_format,
3030
freq_profile, skip_val, norun=False, l2chandover=False,
31-
pipelining=None, short_long_cycles=None):
31+
short_long_cycles=False):
3232
parameters = [
3333
'tracking_loop',
3434
'-P', str(prn),
@@ -41,10 +41,8 @@ def run_tracking_loop(prn, signal, dopp, phase, file_name, file_format,
4141
'--skip-samples', str(skip_val)
4242
]
4343

44-
if pipelining:
45-
parameters += ['--pipelining', str(pipelining)]
46-
elif short_long_cycles:
47-
parameters += ['--short-long-cycles', str(short_long_cycles)]
44+
if short_long_cycles:
45+
parameters += ['--short-long-cycles']
4846

4947
if norun:
5048
parameters.append('--no-run')
@@ -78,34 +76,33 @@ def get_tr_loop_res_file_name(sample_file, prn, band):
7876
def run_track_test(samples_file, expected_lock_ratio, init_doppler,
7977
init_code_phase, prn, file_format, freq_profile,
8078
skip_samples=None, skip_ms=None,
81-
pipelining=None, short_long_cycles=None):
79+
short_long_cycles=False):
8280

8381
bands = fileformat_to_bands(file_format)
8482

8583
skip_param, skip_val = get_skip_params(skip_samples, skip_ms)
8684

8785
run_peregrine(samples_file, file_format, freq_profile,
8886
skip_param, skip_val, skip_tracking=False,
89-
pipelining=pipelining, short_long_cycles=short_long_cycles)
87+
short_long_cycles=short_long_cycles)
9088

9189
for band in bands:
9290
dopp_ratio = 1
9391
if band == "l2c":
9492
dopp_ratio = l2 / l1
9593
run_tracking_loop(prn, band, init_doppler * dopp_ratio, init_code_phase,
9694
samples_file, file_format, freq_profile, 0,
97-
pipelining=pipelining,
9895
short_long_cycles=short_long_cycles)
9996

10097
#code_phase = propagate_code_phase(init_code_phase,
10198
#get_sampling_freq(freq_profile),
10299
#skip_param, skip_val)
103100

104101
check_per_track_results(expected_lock_ratio, samples_file, prn, bands,
105-
pipelining, short_long_cycles)
102+
short_long_cycles)
106103

107104
check_tr_loop_track(expected_lock_ratio, samples_file, prn, bands,
108-
pipelining, short_long_cycles)
105+
short_long_cycles)
109106

110107
# Clean-up.
111108
os.remove(get_acq_result_file_name(samples_file))
@@ -115,7 +112,7 @@ def run_track_test(samples_file, expected_lock_ratio, init_doppler,
115112

116113

117114
def check_per_track_results(expected_lock_ratio, filename, prn, bands,
118-
pipelining, short_long_cycles):
115+
short_long_cycles):
119116
ret = {}
120117
print "Peregrine tracking:"
121118
for band in bands:
@@ -137,14 +134,14 @@ def check_per_track_results(expected_lock_ratio, filename, prn, bands,
137134
print "band =", band
138135
lock_ratio = float(lock_detect_outp_sum) / lock_detect_outp_len
139136
print "lock_ratio =", lock_ratio
140-
if (not short_long_cycles and not pipelining) or band != L2C:
137+
if not short_long_cycles or band != L2C:
141138
assert lock_ratio >= expected_lock_ratio
142139
ret[band]['lock_ratio'] = lock_ratio
143140
return ret
144141

145142

146143
def check_tr_loop_track(expected_lock_ratio, filename, prn, bands,
147-
pipelining, short_long_cycles):
144+
short_long_cycles):
148145
ret = {}
149146
print "Tracking loop:"
150147
for band in bands:
@@ -161,7 +158,7 @@ def check_tr_loop_track(expected_lock_ratio, filename, prn, bands,
161158
print "band =", band
162159
lock_ratio = float(lock_detect_outp_sum) / lock_detect_outp_len
163160
print "lock_ratio =", lock_ratio
164-
if (not short_long_cycles and not pipelining) or band != L2C:
161+
if not short_long_cycles or band != L2C:
165162
assert lock_ratio >= expected_lock_ratio
166163
ret[band]['lock_ratio'] = lock_ratio
167164
return ret
@@ -185,9 +182,9 @@ def test_tracking():
185182
run_track_test(samples, 0.6, init_doppler, init_code_phase, prn, file_format,
186183
freq_profile)
187184
run_track_test(samples, 0.3, init_doppler, init_code_phase, prn, file_format,
188-
freq_profile, pipelining=0.5)
185+
freq_profile)
189186
run_track_test(samples, 0.3, init_doppler, init_code_phase, prn, file_format,
190-
freq_profile, short_long_cycles=0.5)
187+
freq_profile, short_long_cycles=True)
191188

192189
os.remove(samples)
193190

0 commit comments

Comments
 (0)