Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From fixedpoint to float #17

Merged
merged 23 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cf77b52
Implemented correlator for custom number of taps
dominformant Nov 12, 2020
03c52ee
Added required functions for GenericBOC signals
dominformant Nov 17, 2020
22f8bd0
Bug fixes for generic correlator
dominformant Nov 17, 2020
41d9908
Fix functions for GenericBOC signals
dominformant Nov 17, 2020
ed5f1fb
Fix wrong type inheritance
dominformant Nov 18, 2020
81ec216
[GenericCorrelator] Fix multi antenna correlation
dominformant Nov 18, 2020
7b5f2ee
Fix integration time calculation for short codes
dominformant Nov 18, 2020
ad13be7
Fix order of early and late
dominformant Nov 19, 2020
3bb262c
Switch to full declaration of correlator shifts
dominformant Nov 19, 2020
da501f4
Fixed integer based replica generation
dominformant Nov 20, 2020
e276e2c
Merge branch 'rework_correlation' into generic_correlator
dominformant Nov 23, 2020
0a98ae5
Adapt generic correlator to new spacing definition
dominformant Nov 23, 2020
afc726a
Performance improvements
dominformant Nov 24, 2020
56fd5b5
Fix typo
dominformant Nov 24, 2020
db2f7ea
Use SVector for GenericCorrelator
dominformant Nov 25, 2020
6b956a5
Performance improvements
zsoerenm Nov 26, 2020
21d6a20
Re-Added defaults for GenericBOC signals
dominformant Nov 26, 2020
9642d92
Replace SVector{SVector} by Vector{SVector}
dominformant Jan 21, 2021
1a4b87d
Adjust to changes in GNSSSignals
Feb 2, 2021
d1fb40b
Change carrier fixed point calculation to float
Feb 2, 2021
edcbf76
Renamed `generic_boc.jl` to `boc.jl`
dominformant Feb 3, 2021
8771c92
Fix infinite recursion error
dominformant Feb 3, 2021
c0a0a6b
Added tests for BOCcos
dominformant Feb 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tracking"
uuid = "10b2438b-ffd4-5096-aa58-44041d5c8f3b"
authors = ["Soeren Zorn <soeren.zorn@nav.rwth-aachen.de>"]
version = "0.13.0"
version = "0.14.0"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand All @@ -15,9 +15,9 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
DocStringExtensions = "0.6, 0.7, 0.8"
GNSSSignals = "0.13"
LoopVectorization = "0.8"
StaticArrays = "0.9, 0.10, 0.11, 0.12"
GNSSSignals = "0.14"
LoopVectorization = "0.8, 0.9, 0.10, 0.11"
StaticArrays = "0.9, 0.10, 0.11, 0.12, 1.0"
StructArrays = "0.4"
TrackingLoopFilters = "0.1"
Unitful = "0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 1.0"
Expand Down
18 changes: 16 additions & 2 deletions src/Tracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ module Tracking
get_early,
get_prompt,
get_late,
get_tap,
get_taps,
get_num_taps,
get_early_index,
get_prompt_index,
get_late_index,
get_correlator,
get_carrier_doppler,
get_carrier_phase,
get_code_doppler,
get_code_phase,
get_early_late_sample_shift,
get_correlator_sample_shifts,
get_early_late_sample_spacing,
get_secondary_code_or_bit_found,
get_correlator_carrier_phase,
get_correlator_carrier_frequency,
Expand All @@ -27,12 +34,14 @@ module Tracking
track,
TrackingState,
NumAnts,
NumTaps,
MomentsCN0Estimator,
AbstractCN0Estimator,
get_bits,
get_num_bits,
EarlyPromptLateCorrelator,
VeryEarlyPromptLateCorrelator,
GenericCorrelator,
SecondaryCodeOrBitDetector,
GainControlledSignal

Expand All @@ -41,7 +50,11 @@ module Tracking

NumAnts(x) = NumAnts{x}()

include("agc.jl")
struct NumTaps{x}
end

NumTaps(x) = NumTaps{x}()

include("code_replica.jl")
include("carrier_replica.jl")
include("downconvert.jl")
Expand All @@ -56,4 +69,5 @@ module Tracking
include("gpsl1.jl")
include("gpsl5.jl")
include("galileo_e1b.jl")
include("boc.jl")
end
67 changes: 0 additions & 67 deletions src/agc.jl

This file was deleted.

6 changes: 3 additions & 3 deletions src/bit_buffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ $(SIGNATURES)
Buffer data bits based on the prompt accumulation and the current prompt value.
"""
function buffer(
::Type{S},
system::AbstractGNSS,
bit_buffer,
prompt_accumulator,
secondary_code_or_bit_found,
prev_code_phase,
code_phase,
integration_time,
prompt_correlator
) where S <: AbstractGNSSSystem
)
prompt_accumulator = prompt_accumulator + secondary_code_or_bit_found *
prompt_correlator

if secondary_code_or_bit_found &&
(code_phase - prev_code_phase < 0 || integration_time == 1 / get_data_frequency(S))
(code_phase - prev_code_phase < 0 || integration_time == 1 / get_data_frequency(system))
bit = real(prompt_accumulator) > 0
bit_buffer = BitBuffer(
get_bits(bit_buffer) << 1 + UInt64(bit),
Expand Down
19 changes: 19 additions & 0 deletions src/boc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
$(SIGNATURES)

Checks if upcoming integration is a new bit for generic BOC signal
"""
function is_upcoming_integration_new_bit(
boc::BOCcos,
prns,
num_prns
)
is_upcoming_integration_new_bit(boc.system, prns, num_prns)
end

function get_default_correlator(
::BOCcos,
numAnts::NumAnts
)
EarlyPromptLateCorrelator(numAnts)
end
33 changes: 10 additions & 23 deletions src/carrier_replica.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
function gen_carrier_replica!(
carrier_replica::StructArray{Complex{Int16}},
carrier_replica::StructArray{Complex{T}},
carrier_frequency,
sampling_frequency,
start_phase,
carrier_amplitude_power::Val{N},
start_sample,
num_samples
) where N
fpcarrier!(
carrier_replica,
carrier_frequency,
sampling_frequency,
start_phase,
start_sample = start_sample,
num_samples = num_samples,
bits = carrier_amplitude_power
)
) where T
c_re = carrier_replica.re; c_im = carrier_replica.im
@avx for i in 0:num_samples - 1
c_im[i + start_sample], c_re[i + start_sample] =
sincos(T(2π) * (i * T(upreferred(carrier_frequency / Hz)) / T(upreferred(sampling_frequency / Hz)) + T(start_phase)))
end
carrier_replica
end

Expand All @@ -29,17 +24,9 @@ function update_carrier_phase(
carrier_frequency,
sampling_frequency,
start_phase,
carrier_amplitude_power::Val{N}
) where N
n = N + 2
fixed_point = 32 - n - 2
delta = floor(Int32, carrier_frequency * 1 << (fixed_point + n) / sampling_frequency)
fixed_point_start_phase = floor(Int32, start_phase * 1 << (fixed_point + n))
phase_fixed_point = delta * num_samples + fixed_point_start_phase
mod(
phase_fixed_point / 1 << (fixed_point + n) + 0.5,
1
) - 0.5
)
phase = num_samples * carrier_frequency / sampling_frequency + start_phase
mod(phase + 0.5, 1) - 0.5
end

"""
Expand Down
52 changes: 34 additions & 18 deletions src/code_replica.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
"""
$(SIGNATURES)

Generate a code replica for a signal from satellite system `S`. The
replica contains `num_samples` prompt samples as well as an additional
number of early and late samples specified by `correlator_sample_shifts`.
The codefrequency is specified by `code_frequency`, while the sampling
rate is given by `sampling_frequency`. The phase of the first prompt
sample is given by `start_code_phase`. The generated signal is returned
in the array `code_replica` with the first generated sample written to
index start_sample.
"""
function gen_code_replica!(
code_replica,
::Type{S},
system::AbstractGNSS,
code_frequency,
sampling_frequency,
start_code_phase::AbstractFloat,
start_sample::Integer,
num_samples::Integer,
early_late_sample_shift,
correlator_sample_shifts::SVector,
prn::Integer
) where S <: AbstractGNSSSystem
fixed_point = sizeof(Int) * 8 - 1 - min_bits_for_code_length(S)
)
most_early_sample_shift = correlator_sample_shifts[end]
most_late_sample_shift = correlator_sample_shifts[1]
num_early_late_samples = most_early_sample_shift - most_late_sample_shift
fixed_point = sizeof(Int) * 8 - 1 - min_bits_for_code_length(system)
delta = floor(Int, code_frequency * 1 << fixed_point / sampling_frequency)
((most_late_sample_shift * delta) >> fixed_point < -get_code_length(system) ||
(most_early_sample_shift * delta) >> fixed_point > get_code_length(system)) &&
throw(ArgumentError("The number of taps or the tab spacing is too large."))
modded_start_code_phase = mod(
start_code_phase,
get_code_length(S) * get_secondary_code_length(S)
get_code_length(system) * get_secondary_code_length(system)
)
fixed_point_start_code_phase = floor(Int, modded_start_code_phase * 1 << fixed_point)
max_sample_shift = maximum(early_late_sample_shift)
# Assumes, that the number of early shifts is identical to the number of late shifts
early_late_samples = 2 * max_sample_shift
@inbounds for i = start_sample:num_samples + early_late_samples + start_sample - 1
fixed_point_code_phase = (i - max_sample_shift - start_sample) * delta +
@inbounds for i = start_sample:num_samples + num_early_late_samples + start_sample - 1
fixed_point_code_phase = (i + most_late_sample_shift - start_sample) * delta +
fixed_point_start_code_phase
code_index = fixed_point_code_phase >> fixed_point
code_replica[i] = get_code_unsafe(S, code_index, prn)
code_replica[i] = get_code_unsafe(system, code_index, prn)
end
code_replica
end
Expand All @@ -34,20 +50,20 @@ $(SIGNATURES)
Updates the code phase.
"""
function update_code_phase(
::Type{S},
system::AbstractGNSS,
num_samples,
code_frequency,
sampling_frequency,
start_code_phase,
secondary_code_or_bit_found
) where S <: AbstractGNSSSystem
if get_data_frequency(S) == 0Hz
secondary_code_or_bit_length = get_secondary_code_length(S)
)
if get_data_frequency(system) == 0Hz
secondary_code_or_bit_length = get_secondary_code_length(system)
else
secondary_code_or_bit_length =
Int(get_code_frequency(S) / (get_data_frequency(S) * get_code_length(S)))
Int(get_code_frequency(system) / (get_data_frequency(system) * get_code_length(system)))
end
code_length = get_code_length(S) *
code_length = get_code_length(system) *
(secondary_code_or_bit_found ? secondary_code_or_bit_length : 1)
mod(code_frequency * num_samples / sampling_frequency + start_code_phase, code_length)
# fixed_point = sizeof(Int) * 8 - 1 - min_bits_for_code_length(S)
Expand All @@ -62,6 +78,6 @@ $(SIGNATURES)

Calculates the current code frequency.
"""
function get_current_code_frequency(::Type{S}, code_doppler) where S <: AbstractGNSSSystem
code_doppler + get_code_frequency(S)
function get_current_code_frequency(system::AbstractGNSS, code_doppler)
code_doppler + get_code_frequency(system)
end
Loading