Pick the band rule from the estimator that produced the fix:
prange() pairing for single-point fixes, vsat[] for DGPS/RTK.
Check that each signal's slot holds its own obs code, via the new
rtklib_obs_code() helper shared with insert_obs_to_rtklib(), so
B1I next to B1C and excluded E5/E6 signals are not reported as used.
Move prange_band_pair() to rtklib_pntpos and document the per-signal
semantics in monitor_pvt.proto.
Resolve the CHANGELOG conflict, and fix the EVK1029 shared-memory input
on top of the merge:
- In shared-memory mode, Evk1029SignalSource is real-time and cannot
wait, so the deterministic mode refuses it and the Signal Conditioner
no longer plans it as an unthrottled replay. Read
shm_stop_on_buffer_overflow only on Linux, avoiding an unused variable
warning elsewhere.
- Stopping the receiver no longer hangs when EVK1029_CtrlApp is idle,
has crashed or has been restarted. ReadBlock() waits at most 100 ms at
a time, RawStreamReader::read() then returns to its caller (see
end_of_stream()), and Evk1029Source releases a decode worker waiting
for data when GNU Radio stops the flowgraph. The stream ends if the
producer publishes nothing for SignalSource.shm_stall_timeout_s
seconds (default 5, 0 waits forever).
- request_stop() bumps data_event before waking the reader, and
ReadBlock() takes its snapshot of data_event before checking the stop
flag, the ring and the stream state, so that no wake-up is lost.
- Count overflows and producer silence from the first sample read, not
from the attach: nothing reads the ring while the flowgraph is built,
so shm_stop_on_buffer_overflow=true stopped the receiver at startup.
Update the CHANGELOG entry with the actual parameter names and the new
shm_stall_timeout_s parameter.
Extend the change of the previous merge to the remaining tracking
blocks: kf_tracking and gps_l1_ca_gaussian_tracking_cc (binary dump and
.mat file; records grow from 96 to 100 bytes), and the GPS L1 C/A and
Galileo E1 TCP connector and GPS L1 C/A GPU blocks (records grow from 88
to 92 bytes). The Galileo E1 TCP connector block accumulated the carrier
phase in a float, which is now a double.
Update the KF readers in utils/matlab and utils/python accordingly.
Tracking_Dump_Reader now takes the record layout, since the FPGA and
Gaussian tests read dumps that lack the TOW and WN fields (and, for the
Gaussian block, have the carrier noise variance in place of the code
frequency rate) with the dll_pll_veml_tracking layout.
Add a CHANGELOG entry.
Resolve the conflicts with the deterministic processing mode: keep the
deterministic loss-of-lock dispatch together with the "forced" suffix in
the loss-of-lock log line, and convert the two deterministic telemetry
fault paths in dll_pll_veml_tracking and kf_tracking, which still forced
the loss of lock by writing 200000 into the carrier lock fail counter,
to d_force_loss_of_lock.
Remove the conflict markers left in docs/CHANGELOG.md by the merge of
the deterministic branch, and add a CHANGELOG entry for this fix.
Add a deterministic processing mode for recorded signals
Processing the same file twice was not repeatable, even with
Acquisition_XX.blocking=true: the control thread started searches,
assigned satellites and applied channel events at whatever sample
each block had reached, and the PVT and observables applied each
other's messages whenever they arrived.
With GNSS-SDR.deterministic=true (default: false), events and
messages carry the sample at which they happened, the control
thread handles channel events in sample order, and their effects
take place a fixed lookahead later (deterministic_lookahead_ms,
default 100 ms). A gate at the Signal Conditioner output keeps the
stream within that horizon, blocks take their stamped messages at
the start of each work call, maintenance runs on signal time
(deterministic_tick_ms), and the receiver stops once the whole
input has reached the PVT. Dumps, RINEX, NMEA, KML, GPX and GeoJSON
outputs are then bit-identical from run to run on the same machine
(same FFTW wisdom and VOLK configuration), whatever the CPU load.
Supported: all file sources (throttled or not, including LabSat,
EVK1029 and ION), all acquisitions except assisted and FPGA, and
the DLL/PLL VEML, KF and Gaussian trackers. Live front ends, HAS
and NTRIP corrections, strict OSNMA, Galileo E6 with the TOW map,
GNSS assistance and visibility-aware search are refused.
carlesfernandez's review of this PR (gnss-sdr/gnss-sdr#1154) raised several
issues. This addresses all but the DCO/signing requirement (handled
separately via rebase) and the GPL licensing question on shm_ring.h (his
call, not mine to answer in code):
- Build: shared_memory_stream_reader.cc/shm_ring.h are now gated to Linux
only (CMAKE_SYSTEM_NAME), matching the EVK1029_SHM_INPUT compile
definition the adapter checks before including/constructing
SharedMemoryStreamReader; an unavailable shared_memory input now throws
std::invalid_argument instead of failing to build.
- librt is linked on glibc < 2.34, same as core_receiver already does for
its own shm_open use.
- ReadBlock() now treats StreamState::Error as terminal (it previously
blocked forever), and rejects a length prefix larger than the block can
hold instead of reading past it (reproduced his reported 64 MiB ASan
overread).
- An unrecognized SignalSource.input value now throws instead of silently
falling back to file mode; enable_throttle_control is ignored with a
warning in shared_memory mode.
- Dangling references to the (not-in-repo) spec doc removed; diagnostics
moved from std::cout to LOG(INFO)/LOG(WARNING); added the missing
gnss_sdr_make_unique.h include; fixed the clang-tidy violations he listed
(brace-less ifs, long -> int64_t).
Backpressure and loss detection redesigned per further discussion: the SHM
ring's WriteBlock() blocks (not drops) a full ring, so a stalled GNSS-SDR
consumer backs up through EVK1029_CtrlApp's own buffering instead of ever
reaching the USB/target side -- the target must never see an overflow
condition from this path. Real, unrecoverable loss is instead detected on
EVK1029_CtrlApp's side via the existing IF_TO_AXIS hardware overflow flag
(now also polled during SHM streaming, not just recording) and surfaced
through the ring's Header as overflow_event_count (protocol bumped to v3).
It's a count of occurrences, not bytes -- the hardware only latches a
sticky bit -- so SharedMemoryStreamReader can't zero-fill a known gap; it
either stops the stream (new SignalSource.shm_stop_on_buffer_overflow,
default false) or logs and continues, leaving the sample count to jump in
place.
Also fixes request_stop() not waking a blocked read(): setting the stop
flag alone doesn't wake a ReadBlock() already asleep in FUTEX_WAIT on
data_event, so Evk1029Source's join() of the decode-ahead thread could hang
on shutdown with an idle producer -- the same class of bug his review
caught elsewhere, found while re-checking this change for others like it.
Verified with standalone tests (plain and under AddressSanitizer), not
just a clean build: round-trip, terminal Error, corrupted-length
rejection, WriteBlock's blocking-plus-abortFlag-wake behavior, overflow
detection (both log-and-continue and stop-on-overflow), and request_stop()
unblocking a waiting read(). Full gnss-sdr build (including install/)
clean throughout.
Signed-off-by: joebre <joel.brenner@saphyrion.ch>
First step of EVK1029_shared_memory_input_spec(2).md on the GNSS-SDR side:
Evk1029Source now reads raw bytes through a RawStreamReader interface
instead of owning an ifstream directly, so the exact same OBA-decode/FIR/
CUDA pipeline can run against either a recorded capture file or a live
shared-memory stream from EVK1029_CtrlApp.
- raw_stream_reader.h: the interface (read(), request_stop()).
- file_stream_reader.{h,cc}: wraps the original file-reading behavior
(open, optional word-aligned seek, buffered read) verbatim.
- shm_ring.h: verbatim copy of EVK1029_CtrlApp's evk1029/shm_ring.hpp wire
protocol -- the two repos build completely separately; only the struct
layout and kMagic/kVersion need to match, since both sides mmap the same
region. Keep both copies in sync if the format ever changes.
- shared_memory_stream_reader.{h,cc}: attaches to the ring (retrying up to
30s if the producer hasn't started yet -- a late producer is recoverable,
not a hard failure like a missing file), bridges SHM block granularity
into read()'s byte-stream semantics, EOF on Stopped/EndOfStream with the
ring drained. Wakes a producer that might be stuck waiting for space on
destruction.
- Evk1029Source's destructor now calls reader_->request_stop() before
joining the decode-ahead thread -- that thread's read() can block
indefinitely on a live stream, so without this the join could hang
forever on shutdown (a no-op for FileStreamReader, which never blocks).
- evk1029_signal_source.cc: new SignalSource.input=file|shared_memory
(default file, every existing config keeps working untouched) and
.shm_name config keys.
Verified: file-mode regression (same capture file, full GPS+Galileo
tracking lock, unchanged from before this refactor) and a synthetic
SHM-mode smoke test (sustained attach/read/EOF/shutdown with no real
hardware). Confirmed on real hardware: EVK1029_CtrlApp's live SHM stream
reaches a real position fix through this path.
Signed-off-by: joebre <joel.brenner@saphyrion.ch>
The Monitor is fed from the Observables, which since ed5a75e31 fill
channels without a valid time reference with their latest tracking
data. That never worked in Galileo E6-only configurations: the GPS L1
C/A, GPS L5, Galileo, BeiDou D1/D2 and BeiDou B1C telemetry decoders
produced no output until they decoded the time of week, so the
Observables never received E6 tracking data. The GLONASS, GPS L2C,
BeiDou B2a and SBAS decoders already forwarded every symbol with
Flag_valid_word unset; now all telemetry decoders do. Dumps,
telemetry_to_trk and nav-data monitor messages are still issued only
with a valid time of week.
The tracking-only entries also had fs set to 0, which gnss-sdr-monitor
takes as an empty channel, hiding SBAS channels. fs is now kept, with
the validity flags still unset; the PVT only uses observations with
Flag_valid_pseudorange.
As a side effect, the secondary-band acquisition assistance can use a
primary-band channel as soon as its tracking locks, instead of after
its time of week is decoded. The Galileo F/NAV test sink now records
the first item with a valid word.
Alternative to PR #1122, without new options or changes to tracking
and to the PVT time-of-week reset handling. Related to #1018.
log_data() in dll_pll_veml_tracking and dll_pll_veml_tracking_fpga casts
d_acc_carrier_phase_rad, a double, to float before writing it to the
binary dump, and save_matfile() reads it back as a float. The
accumulated phase grows by 2*pi times the Doppler shift every second
(about 31400 rad/s at 5 kHz), so it reaches 1e6 rad after about 30 s of
tracking at 5 kHz, or under 3 minutes at 1 kHz. The float spacing is
0.0625 rad at 1e6 rad, 0.25 rad at 3e6 rad and 1 rad at 1e7 rad. At
3e6 rad, for instance, the phase difference between two 1 ms epochs of
the dump is only known to within +/-0.25 rad, about 40 Hz in frequency
terms. The phase used by the receiver (Gnss_Synchro::Carrier_phase_rads)
is a double and is not affected; only the dump is.
Write the field as a double, and read it back as a double in
save_matfile(), so that the .mat file also holds a double.
This changes the dump record layout. The field keeps its position but
grows from 4 to 8 bytes, so a record is now 112 bytes long in
dll_pll_veml_tracking (it was 108) and 100 bytes long in
dll_pll_veml_tracking_fpga (it was 96). The readers of this format are
updated accordingly: Tracking_Dump_Reader, used by the unit tests, and
dll_pll_veml_read_tracking_dump in utils/matlab and utils/python.
Signed-off-by: ObvMamut <obvmamut@proton.me>
Two fail-safes in the tracking blocks force a loss of lock: the bit or
secondary code synchronization time limit
(bit_synchronization_time_limit_s), and the telemetry fault message sent
by the telemetry decoders. Both did it by writing a large value into
d_carrier_lock_fail_counter (300000 and 200000, respectively) and
relying on the lock check to find it above max_carrier_lock_fail. When
max_carrier_lock_fail is configured above those values, neither
fail-safe drops the channel: unless the lock detectors drop it for
other reasons, a channel that never achieves bit synchronization keeps
tracking past the time limit, and a channel whose telemetry decoder
reports a fault keeps tracking.
Replace the magic counter values with a d_force_loss_of_lock flag. Both
fail-safes set it, cn0_and_tracking_lock_status() declares the loss of
lock when it is set, whatever the lock fail counters, and it is cleared
when the loss of lock is declared and when a new tracking attempt
starts. The loss-of-lock log line now says when the loss was forced,
since the counter values no longer show it.
The same change is applied to dll_pll_veml_tracking,
dll_pll_veml_tracking_fpga and kf_tracking, the three blocks that used
this pattern.
Add two tests to trk_test that set max_carrier_lock_fail = 1000000 and
check that a telemetry fault and the synchronization time limit still
drop the channel.
Signed-off-by: ObvMamut <obvmamut@proton.me>
A one-code-period PCPS window starts at an arbitrary code phase, so a
secondary-code or data sign transition at the code epoch inside it
splits the correlation peak up to +-0.74/T away from the true Doppler.
For GPS L5 (the I5 NH10 code changes sign at 6 of every 10 epochs),
about 40 % of the acquisitions started tracking 250-900 Hz off. The
1 ms Costas loop then either held a false lock at exactly +-500 Hz
(lock test 0.97, C/N0 3.9 dB low, secondary-code sync impossible)
until bit_synchronization_time_limit_s, or never locked and lost lock
a few seconds after pull-in.
After a positive decision, refine_doppler() despreads the dwells with
the replica aligned to the detected code epoch, scores the two sides
of the epoch under both sign hypotheses (summed non-coherently over
dwells), and re-estimates the Doppler over +-1/T around the grid peak.
It only runs on positive acquisitions, so its cost is negligible, also
with the CUDA grid. It applies to every pcps_acquisition search over
one code period without bit_transition_flag. The new
Acquisition_XX.refine_doppler parameter (default true) disables it.
With -DENABLE_CUDA=ON, band<n>_cuda=true computes that band's
frequency-translating FIR (complex composite taps applied to the real
capture) on an NVIDIA GPU through the new CudaDdcEngine, instead of on
a CPU worker thread. As with the CUDA acquisition engine, the public
interface has no CUDA types and hides the implementation behind a
PIMPL. Each band falls back to the CPU, with a warning in the log, if
its engine cannot be created or a GPU call fails. Builds without CUDA,
and bands without the flag, are unchanged.
Taken from PR #1144, plus:
- Report the CUDA status per band with LOG instead of std::cout/cerr
- Check cudaGetLastError() after the kernel launch, so a failed launch
is not mistaken for valid output
- Select the engine's device in set_taps(), compute() and the
destructor, since compute() runs on the band worker threads
- Build the engine only with both ENABLE_CUDA and ENABLE_EVK1029
With enable_freq_xlating=true, Evk1029Source translates, filters and
decimates each band itself and exposes one gr_complex output port per
band, so Bypass Signal Conditioners can connect the channels straight
to the source. Each band's FIR runs on its own worker thread, and the
next chunk of the capture is decoded while the current one is filtered.
Per-band filter design: band<n>_IF, _decimation_factor, _bw, _tw,
_window, _attenuation_dB and _kaiser_beta.
Taken from PR #1143 without its SignalConditioner Bypass commits (next
already provides Bypass), plus:
- Center shorter band filters on the longest one, so every band has the
same group delay (mismatched tap counts biased pseudoranges between
bands by up to km)
- Fix source dump in fused mode: one gr_complex file per band (_ch<n>)
- Reject unequal or non-positive band decimation factors
- Build with GNU Radio < 3.9 (firdes window type) and VOLK < 2.5
(rotator), use volk_gnsssdr::vector
- Link Gnuradio::filter privately and only with ENABLE_EVK1029
- Start worker threads after the capture file is opened
With blocking=false and max_dwells > 1, copy the whole integration window
into a per-block buffer, so that general_work() keeps consuming input while
the worker integrates. The shared conditioner buffer no longer holds back
every channel during a search.
- set_history() keeps the last window readable, so a search starts as soon
as one new dwell arrives. Dwell offsets in the window follow the
dwell-residual skip, and the sample stamp is the end of the window (the
end of the first dwell while the window starts at stream index 0).
- The buffer is allocated at the first search and freed on a positive
acquisition or when the channel is deactivated.
- Deactivation stops the worker and drops the search, so the next
activation starts a new one. stop() replaces the destructor wait.
- Idle input is consumed in one call per wakeup, keeping the history.
Based on #1108 by Vladislav P.
Replace the fixed 20 ms limit on SignalConditioner.batch_size_ms and
max_batch_latency_ms. A configured batch is accepted if it is no longer
than the automatic one (min(10 ms, observable_interval_ms)), or if the
buffer it needs (whole batches, with room for one on top of the largest
reader window) fits the alignment budget: the signal time channels can
trail the receiver clock before the observables miss epochs. Batches
are also limited to 4 MiB, since GNU Radio allocates two of them on
each side of the batching block.
At observable_interval_ms=20 and 4 MSps gr_complex this allows about
90 ms instead of 20 ms. At 5 ms it now rejects batches that the old
limit let through. In automatic mode, an explicit max_batch_latency_ms
sets the batch size, so that batch gets the same check. Defaults are
unchanged.
add_obs_sat_record_line() formatted every observable group (pseudorange,
carrier phase, Doppler, CN0) unconditionally, even for the placeholder
Gnss_Synchro{} slot get_constellation_observables_map() creates for a
signal with no valid observation for a given satellite (e.g. untracked,
or simply a frequency that satellite doesn't transmit, such as a GPS
PRN5/PRN7 which has an L5 slot but only tracks/transmits L1). That
placeholder is all-zero, so it printed as a formatted "0.000" value with
a Signal Strength Indicator floored to its minimum class (1), which
reads as a real but degraded observation rather than "no data".
Per RINEX 3/4, an unavailable observation must be a fully blank field,
not a zero value. Gate the formatter on Flag_valid_pseudorange, which
already reliably distinguishes a real observable (set true by the
Observables block) from the placeholder (defaults false) -- write 64
spaces instead when false.
Found during a self-review double-check: with a fixed base (NTRIP RTK),
d_obs_data holds the rover's observations in [0, rover_observation_count)
and the base's own in [rover_observation_count, rover_observation_count +
base_observation_count) -- and a satellite common to both (the normal
RTK case) gets an entry in each range with the same .sat. The previous
loop scanned the whole array, so std::map::operator[]'s last-write-wins
semantics meant the base's entry could silently overwrite the rover's for
that satellite, making the monitor's combined/used computation read the
base's tracked bands instead of the rover's own.
merge_duplicated_rover_observations() already guarantees no duplicate
.sat within [0, rover_observation_count) (that's its whole purpose), so
bounding the loop to it is both necessary (avoids the base collision)
and sufficient (no other duplicates to worry about inside that range).
rtkpos() is called as rtkpos(&d_rtk, d_obs_data.data(), ...), confirming
this is exactly the array prange() itself reads.
No regression for the normal (non-fixed-base) path, where
rover_observation_count already equals the full valid-observation count:
confirmed via test suite and a real-data run (476 PVT fixes, matching
the known reference location). Have not been able to verify the
fixed-base path itself against a real RTK/NTRIP capture -- no base
station data on hand -- so that part relies on the code trace above
plus the merge function's own guarantee, not an end-to-end run.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Addresses points 2, 3 and 4 of the maintainer's review in one shared
refactor (point 1 was fixed separately in a703c4288, and is superseded
by this commit's more general version).
- New prange_band_pair(obs, &i, &j) in rtklib_rtkcmn.cc, extracted
verbatim from prange()'s own band-selection logic (rtklib_pntpos.cc):
(0,2) for Galileo/SBAS, bds_observation_slots() for BeiDou, (0,1) for
GPS/GLONASS/QZSS unless only L5 is present. prange() now calls it
instead of duplicating the logic (point 4).
- The monitor loop in rtklib_solver.cc now looks up each satellite's own
obsd_t record in d_obs_data and calls prange_band_pair() on it
directly, instead of inferring the combinable slots from the
Galileo-only d_rtklib_band_index heuristic. This naturally extends the
point-1 fix to every system (GPS/QZSS L1+L2/L5, BeiDou), not just
Galileo (point 2).
- Rule applied, per the maintainer's suggestion: under IONOOPT_IFLC, a
signal is used/combined together if the satellite is used, its slot
is i or j, and both bands carry a pseudorange; under any other
ionoopt, used requires occupying the slot prange() actually picks and
combined is always false. Since an excluded E6 (PVT.use_e6_for_pvt=
false) never gets inserted into d_obs_data, its slot has no
pseudorange and it is naturally excluded without special-casing
(point 3) -- is_galileo_signal_used_in_pvt() is kept as an additional
gate for safety, not removed.
Verified against two real dual-band captures (Galileo E1+E5a + GPS
L1+L5), one per ionoopt:
- PVT.iono_model=Broadcast (non-IFLC): ~26000 sampled epochs across both
GPS and Galileo satellites tracking two bands each -- in every case
exactly one signal per satellite per epoch showed used=true, matching
whichever band prange() actually picks (code[i]!=CODE_NONE ? i : j).
combined was false throughout.
- PVT.iono_model=Iono-Free-LC: ~26000 sampled epochs -- every satellite
with both bands present showed combined=true and used=true for BOTH
signals; every satellite with only one band present was excluded from
the solve entirely at the satellite level (matching prange()'s own
early return when either band is missing under IFLC), with
combined=used=false.
- Both runs' final PVT fixes matched the known reference location
(46.012965, 8.907565) to within a few meters.
Full existing test suite (38+20+62+33 tests) passes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Point 1 of the maintainer's review: with any ionoopt other than
IONOOPT_IFLC, prange()'s single-frequency branch (rtklib_pntpos.cc)
still only reads ONE rtklib band-index slot per satellite -- slot i if
it carries a measurement, slot j otherwise -- never both. A second
Galileo signal tracked on the other slot (e.g. 5X alongside 1B, with
PVT.iono_model=Broadcast) never reaches the LSQ solve at all, but the
monitor's used flag only checked the satellite-level flag and per-signal
eligibility, so it reported used=true for both.
Added the same slot-pick logic prange() uses (slot 0 if tracked, else
slot 2) and gate info.used on the signal actually occupying that slot
whenever ionoopt != IONOOPT_IFLC. combined is unaffected (already
correctly false for any non-IFLC model). Corrected the comment's
previous claim that each tracked signal becomes "its own independent
observation" under non-IFLC models -- confirmed against prange()'s
source that this isn't what happens.
Verified against a real dual-band Galileo E1+E5a capture with
PVT.iono_model=Broadcast (6 satellites tracking both 1B and 5X over an
11+ minute run, 7416 sampled epochs): 5X never once showed in_solve=1,
1B never once showed in_solve=0 -- the fix consistently picks exactly
one signal per satellite per epoch, matching prange()'s actual slot
selection. Full existing test suite (38+20+62+33 tests) still passes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
combined was set from contributing_signals.size() > 1 alone -- true
for any satellite with multiple tracked signals, regardless of
whether the solver actually builds an iono-free combination out of
them. With any iono_model other than Iono-Free-LC, each tracked
signal of a multi-frequency satellite is used as its own independent
observation in the LSQ solve, not combined, so reporting
combined=true in that case misrepresents what the solver actually
did.
For Galileo specifically, prange()'s IFLC branch (rtklib_pntpos.cc)
always combines whatever occupies rtklib band-index slots 0 and 2
(hardcoded i=0/j=2 for SYS_GAL) -- normally 1B+5X/7X, but 1B+E6 when
no E5 signal is selected for PVT. A signal that isn't in slot 0 or 2
(e.g. E6 alongside an actual 5X/7X pair, where it lands in slot 1) is
never part of the combination, regardless of ionoopt.
used had the same problem in miniature: every signal of a satellite
shared one, satellite-level used flag, so E6 reported used=true even
when PVT.use_e6_for_pvt=false excluded it from the solve entirely.
is_galileo_signal_used_in_pvt() (already used elsewhere to gate
ephemeris selection) is now also applied per-signal here.
Gate combined on d_rtk.opt.ionoopt == IONOOPT_IFLC plus the actual
band-index slot occupied, and used on is_galileo_signal_used_in_pvt(),
both in addition to the existing checks.