Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,38 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LsqFit = "2fda8390-95c7-5789-9bda-21331edee243"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Tracking = "10b2438b-ffd4-5096-aa58-44041d5c8f3b"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[weakdeps]
Tracking = "10b2438b-ffd4-5096-aa58-44041d5c8f3b"

[extensions]
PositionVelocityTimeTrackingExt = "Tracking"

[compat]
Aqua = "0.8"
AstroTime = "0.7"
BitIntegers = "0.2.6, 0.3.5"
CoordinateTransformations = "0.6"
Dates = "1"
DocStringExtensions = "0.6, 0.7, 0.8, 0.9"
GNSSDecoder = "0.1.5, 0.2, 1"
GNSSSignals = "0.17, 1"
GNSSDecoder = "1.3"
GNSSSignals = "2"
Geodesy = "0.5, 1.0"
LinearAlgebra = "1"
LsqFit = "0.12, 0.13, 0.14, 0.15"
StaticArrays = "1"
Statistics = "1"
Test = "1"
Tracking = "0.17.1, 0.18, 1"
Tracking = "2"
Unitful = "1"
julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Tracking = "10b2438b-ffd4-5096-aa58-44041d5c8f3b"

[targets]
test = ["Test", "BitIntegers", "Aqua"]
test = ["Test", "BitIntegers", "Aqua", "Tracking"]
1,993 changes: 999 additions & 994 deletions benchmark/fixtures.jl

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions ext/PositionVelocityTimeTrackingExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module PositionVelocityTimeTrackingExt

using PositionVelocityTime: PositionVelocityTime, SatelliteState
using GNSSDecoder: GNSSDecoderState
using GNSSSignals: AbstractGNSSSignal
using Tracking: Tracking, get_code_phase, get_carrier_doppler, get_carrier_phase

# The name of the per-satellite tracking state changed between Tracking major versions:
# `SatState` up to Tracking 1, `TrackedSat` from Tracking 2 on. Bind to whichever exists so
# the extension supports both.
const TrackingSatState = isdefined(Tracking, :TrackedSat) ? Tracking.TrackedSat : Tracking.SatState

function PositionVelocityTime.SatelliteState(
decoder::GNSSDecoderState,
system::AbstractGNSSSignal,
sat_state::TrackingSatState,
)
SatelliteState(
decoder,
system,
get_code_phase(sat_state),
get_carrier_doppler(sat_state),
get_carrier_phase(sat_state),
)
end

end
27 changes: 7 additions & 20 deletions src/PositionVelocityTime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ using CoordinateTransformations,
AstroTime,
LsqFit,
StaticArrays,
Tracking,
Unitful,
Statistics,
Dates
Expand All @@ -33,46 +32,34 @@ export calc_pvt,
get_frequency_offset

"""
SatelliteState{CP<:Real,D<:GNSSDecoderState,S<:AbstractGNSS}
SatelliteState{CP<:Real,D<:GNSSDecoderState,S<:AbstractGNSSSignal}

Combines the GNSS decoder state with code and carrier phase measurements for a single satellite.

# Fields
- `decoder::GNSSDecoderState`: GNSS decoder state containing decoded navigation data
- `system::AbstractGNSS`: GNSS system (e.g., `GPSL1()`, `GalileoE1B()`)
- `system::AbstractGNSSSignal`: GNSS system (e.g., `GPSL1CA()`, `GalileoE1B()`)
- `code_phase::CP`: Code phase measurement
- `carrier_doppler`: Carrier Doppler frequency in Hz
- `carrier_phase::CP`: Carrier phase measurement (default: `0.0`)

# Constructors
SatelliteState(; decoder, system, code_phase, carrier_doppler, carrier_phase=0.0)
SatelliteState(decoder, system, sat_state::SatState)
SatelliteState(decoder, system, sat_state)

The second constructor extracts code phase, carrier Doppler, and carrier phase from a
`Tracking.SatState`.
`Tracking` satellite state (`Tracking.SatState` for Tracking ≤ 1, `Tracking.TrackedSat` for
Tracking ≥ 2). It is provided by a package extension that is loaded automatically once
`Tracking` is available, so `Tracking` is only a weak dependency of this package.
"""
@kwdef struct SatelliteState{CP<:Real,D<:GNSSDecoder.GNSSDecoderState,S<:AbstractGNSS}
@kwdef struct SatelliteState{CP<:Real,D<:GNSSDecoder.GNSSDecoderState,S<:AbstractGNSSSignal}
decoder::D
system::S
code_phase::CP
carrier_doppler::typeof(1.0Hz)
carrier_phase::CP = 0.0
end

function SatelliteState(
decoder::GNSSDecoder.GNSSDecoderState,
system::AbstractGNSS,
sat_state::SatState,
)
SatelliteState(
decoder,
system,
get_code_phase(sat_state),
get_carrier_doppler(sat_state),
get_carrier_phase(sat_state),
)
end

"""
DOP

Expand Down
4 changes: 2 additions & 2 deletions test/get_week.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using PositionVelocityTime: get_week
using GNSSDecoder: GNSSDecoderState, GPSL1Data
using GNSSSignals: GPSL1, GalileoE1B
using GNSSSignals: GPSL1CA, GalileoE1B

# Build a minimal GNSSDecoderState{GPSL1Data} with the given broadcast
# 10-bit `trans_week`. `get_week` only reads `decoder.data.trans_week`
# so the rest of the state can stay at its default zero values.
function decoder_with_trans_week(trans_week)
base = GNSSDecoderState(GPSL1(), 1)
base = GNSSDecoderState(GPSL1CA(), 1)
GNSSDecoderState(base; data = GPSL1Data(base.data; trans_week))
end

Expand Down
Loading
Loading