Skip to content

Commit

Permalink
Merge ozmaden/Tracking#14
Browse files Browse the repository at this point in the history
  • Loading branch information
coezmaden committed Nov 14, 2021
1 parent 63d21d2 commit 465b422
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/tracking_loop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Track the signal `signal` based on the current tracking `state`, the sampling fr
function track(
signal,
state::TrackingState{S, C, CALF, COLF, CN, DS, CAR, COR},
prn::Integer,
sampling_frequency;
post_corr_filter = get_default_post_corr_filter(get_correlator(state)),
intermediate_frequency = 0.0Hz,
Expand All @@ -43,6 +42,7 @@ function track(
CAR,
COR
}
prn = get_prn(state)
system = get_system(state)
if get_data_frequency(system) != 0Hz
@assert rem(1 / get_data_frequency(system), max_integration_time) == 0ms
Expand Down Expand Up @@ -194,6 +194,7 @@ function track(
signal_start_sample += num_samples_left
end
next_state = TrackingState{S, C, CALF, COLF, CN, DS, CAR, COR}(
prn,
system,
init_carrier_doppler,
init_code_doppler,
Expand Down
6 changes: 4 additions & 2 deletions src/tracking_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct TrackingState{
CAR <: Union{CarrierReplicaCPU, CarrierReplicaGPU},
COR <: Union{Vector{Int8}, Nothing}
}
prn::Int
system::S
init_carrier_doppler::typeof(1.0Hz)
init_code_doppler::typeof(1.0Hz)
Expand Down Expand Up @@ -146,6 +147,7 @@ carrier doppler `carrier_doppler` and the code phase `code_phase`. Optional para
- CN0 estimator `cn0_estimator`, that defaults to `MomentsCN0Estimator(20)`
"""
function TrackingState(
prn::Integer,
system::S,
carrier_doppler,
code_phase;
Expand Down Expand Up @@ -179,6 +181,7 @@ function TrackingState(
code = Vector{Int8}(undef, 0)

TrackingState{S, C, CALF, COLF, CN, typeof(downconverted_signal), typeof(carrier), typeof(code)}(
prn,
system,
carrier_doppler,
code_doppler,
Expand Down Expand Up @@ -270,5 +273,4 @@ end
@inline get_downconverted_signal(state::TrackingState) = state.downconverted_signal
@inline get_carrier(state::TrackingState) = state.carrier
@inline get_code(state::TrackingState) = state.code
@inline get_gnss(state::TrackingState) = state.gnss

@inline get_prn(state::TrackingState) = state.prn
12 changes: 5 additions & 7 deletions test/tracking_loop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ end
prn = 1
range = 0:3999
start_carrier_phase = π / 2
state = TrackingState(gpsl1, carrier_doppler - 20Hz, start_code_phase)
state = TrackingState(prn, gpsl1, carrier_doppler - 20Hz, start_code_phase)

signal_temp = cis.(
2π .* carrier_doppler .* range ./ sampling_frequency .+ start_carrier_phase
Expand All @@ -168,7 +168,7 @@ end
scaling = 512
signal = type <: Integer ? complex.(floor.(type, real.(signal_temp) * scaling), floor.(type, imag.(signal_temp) * scaling)) : Complex{type}.(signal_temp)

track_result = @inferred track(signal, state, prn, sampling_frequency)
track_result = @inferred track(signal, state, sampling_frequency)

iterations = 2000
code_phases = zeros(iterations)
Expand Down Expand Up @@ -196,7 +196,6 @@ end
track_result = @inferred track(
signal,
get_state(track_result),
prn,
sampling_frequency
)
comp_carrier_phase = mod2pi(2π * carrier_doppler * 4000 * (i + 1) /
Expand Down Expand Up @@ -242,7 +241,7 @@ end
prn = 1
range = 0:3999
start_carrier_phase = π / 2
state = TrackingState(gpsl1, carrier_doppler - 20Hz, start_code_phase, num_ants = NumAnts(3))
state = TrackingState(prn, gpsl1, carrier_doppler - 20Hz, start_code_phase, num_ants = NumAnts(3))

signal = cis.(
2π .* carrier_doppler .* range ./ sampling_frequency .+ start_carrier_phase
Expand All @@ -256,9 +255,9 @@ end
scaling = 512
signal_mat = type <: Integer ? complex.(floor.(type, real.(signal_mat_temp) * scaling), floor.(type, imag.(signal_mat_temp) * scaling)) : Complex{type}.(signal_mat_temp)

@test_throws ArgumentError track(signal_mat', state, prn, sampling_frequency)
@test_throws ArgumentError track(signal_mat', state, sampling_frequency)

track_result = @inferred track(signal_mat, state, prn, sampling_frequency)
track_result = @inferred track(signal_mat, state, sampling_frequency)

iterations = 2000
code_phases = zeros(iterations)
Expand Down Expand Up @@ -286,7 +285,6 @@ end
track_result = @inferred track(
signal_mat,
get_state(track_result),
prn,
sampling_frequency
)
comp_carrier_phase = mod2pi(2π * carrier_doppler * 4000 * (i + 1) /
Expand Down
4 changes: 2 additions & 2 deletions test/tracking_results.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@testset "Tracking results" begin
gpsl1 = GPSL1()
results = Tracking.TrackingResults(
TrackingState(gpsl1, 100Hz, 100),
TrackingState(1, gpsl1, 100Hz, 100),
EarlyPromptLateCorrelator(NumAnts(2)),
SVector(-1, 0, 1),
1,
Expand Down Expand Up @@ -31,7 +31,7 @@
@test @inferred(get_cn0(results)) == 45dBHz

results = Tracking.TrackingResults(
TrackingState(gpsl1, 100Hz, 100),
TrackingState(1, gpsl1, 100Hz, 100),
EarlyPromptLateCorrelator(NumAnts(2)),
SVector(-1, 0, 1),
1,
Expand Down
7 changes: 5 additions & 2 deletions test/tracking_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
carrier_doppler = 100Hz
code_phase = 100
gpsl1 = GPSL1()
state = TrackingState(gpsl1, carrier_doppler, code_phase)
state = TrackingState(1, gpsl1, carrier_doppler, code_phase)

@test @inferred(Tracking.get_prn(state)) == 1
@test @inferred(Tracking.get_code_phase(state)) == 100
@test @inferred(Tracking.get_carrier_phase(state)) == 0.0
@test @inferred(Tracking.get_init_code_doppler(state)) == 100Hz / 1540
Expand All @@ -19,6 +20,7 @@
@test @inferred(Tracking.get_integrated_samples(state)) == 0

state = TrackingState(
1,
gpsl1,
carrier_doppler,
code_phase;
Expand All @@ -32,6 +34,7 @@
prompt_accumulator = zero(ComplexF64)
)

@test @inferred(Tracking.get_prn(state)) == 1
@test @inferred(Tracking.get_code_phase(state)) == 100
@test @inferred(Tracking.get_carrier_phase(state)) == 0.0
@test @inferred(Tracking.get_init_code_doppler(state)) == 100Hz / 1540
Expand All @@ -45,7 +48,7 @@
@test @inferred(Tracking.get_prompt_accumulator(state)) == 0.0
@test @inferred(Tracking.get_integrated_samples(state)) == 0

state = TrackingState(gpsl1, carrier_doppler, code_phase, num_ants = NumAnts(2))
state = TrackingState(1, gpsl1, carrier_doppler, code_phase, num_ants = NumAnts(2))
@test @inferred(Tracking.get_correlator(state)) == EarlyPromptLateCorrelator(NumAnts(2))

end

0 comments on commit 465b422

Please sign in to comment.