Skip to content

Commit

Permalink
Use code generation from GNSSSignals.jl (#29)
Browse files Browse the repository at this point in the history
* Use `GNSSSignals.jl` for code calculation

* Increase minimum Julia version to 1.6

Co-authored-by: Soeren Schoenbrod <[email protected]>
  • Loading branch information
dominformant and Soeren Schoenbrod authored Sep 9, 2021
1 parent 379c19f commit 73a7f9b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.4' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
Expand Down
6 changes: 3 additions & 3 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 <[email protected]>"]
version = "0.14.6"
version = "0.14.7"

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

[compat]
DocStringExtensions = "0.6, 0.7, 0.8"
GNSSSignals = "0.15"
GNSSSignals = "0.15.3"
LoopVectorization = "0.8, 0.9, 0.10, 0.11, 0.12"
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"
julia = "1.4"
julia = "1.6"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
31 changes: 13 additions & 18 deletions src/code_replica.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
$(SIGNATURES)
Generate a code replica for a signal from satellite system `S`. The
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
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
in the array `code_replica` with the first generated sample written to
index start_sample.
"""
function gen_code_replica!(
Expand All @@ -23,20 +23,15 @@ function gen_code_replica!(
)
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)
total_code_length = get_code_length(system) * get_secondary_code_length(system)
fixed_point_total_code_length = total_code_length * 1 << fixed_point
modded_start_code_phase = mod(start_code_phase, total_code_length)
fixed_point_start_code_phase = floor(Int, modded_start_code_phase * 1 << fixed_point)
delta = floor(Int, code_frequency * 1 << fixed_point / sampling_frequency)
fixed_point_code_phase = fixed_point_start_code_phase + (most_late_sample_shift - 1) * delta
@inbounds for i = start_sample:num_samples + num_early_late_samples + start_sample - 1
fixed_point_code_phase += delta
fixed_point_code_phase -= (fixed_point_code_phase >= fixed_point_total_code_length) * fixed_point_total_code_length
code_index = fixed_point_code_phase >> fixed_point
code_replica[i] = get_code_unsafe(system, code_index, prn)
end
total_samples = num_samples + most_early_sample_shift - most_late_sample_shift
gen_code!(
view(code_replica, start_sample:start_sample+total_samples-1),
system,
prn,
sampling_frequency,
code_frequency,
start_code_phase + most_late_sample_shift * code_frequency/sampling_frequency
)
code_replica
end

Expand All @@ -56,7 +51,7 @@ function update_code_phase(
secondary_code_or_bit_length = get_data_frequency(system) == 0Hz ?
get_secondary_code_length(system) :
Int(get_code_frequency(system) / (get_data_frequency(system) * get_code_length(system)))

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)
Expand Down
12 changes: 6 additions & 6 deletions test/code_replica.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Tracking.gen_code_replica!(
code,
gpsl1,
1023e3,
2.5e6,
1023e3Hz,
2.5e6Hz,
2.0,
11,
2480,
Expand All @@ -22,8 +22,8 @@
Tracking.gen_code_replica!(
code,
gpsl1,
1023e3,
2.5e6,
1023e3Hz,
2.5e6Hz,
2.0,
11,
6480,
Expand All @@ -40,8 +40,8 @@
Tracking.gen_code_replica!(
code,
gpsl1,
1023e3 * 3,
7.5e6,
1023e3Hz * 3,
7.5e6Hz,
2.0,
11,
2480,
Expand Down
8 changes: 4 additions & 4 deletions test/tracking_loop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ end
gpsl1 = GPSL1()
carrier_doppler = 200Hz
start_code_phase = 100
code_frequency = carrier_doppler / 1540 + 1023kHz
sampling_frequency = 4MHz
code_frequency = carrier_doppler / 1540 + 1023e3Hz
sampling_frequency = 4e6Hz
prn = 1
range = 0:3999
start_carrier_phase = π / 2
Expand Down Expand Up @@ -237,8 +237,8 @@ end
gpsl1 = GPSL1()
carrier_doppler = 200Hz
start_code_phase = 100
code_frequency = carrier_doppler / 1540 + 1023kHz
sampling_frequency = 4MHz
code_frequency = carrier_doppler / 1540 + 1023e3Hz
sampling_frequency = 4e6Hz
prn = 1
range = 0:3999
start_carrier_phase = π / 2
Expand Down

2 comments on commit 73a7f9b

@dominformant
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/44569

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.7 -m "<description of version>" 73a7f9b10966fc8ac5369cff5f3ebc3bf611dac6
git push origin v0.14.7

Please sign in to comment.