This commit is contained in:
Carles Fernandez
2026-01-28 19:47:17 +01:00
parent 6307752e82
commit 939ba5f32b
5 changed files with 65 additions and 8 deletions
@@ -1302,6 +1302,7 @@ void dll_pll_veml_tracking::configure_bit_synchronizer()
HistogramBitSynchronizer::Config cfg;
cfg.bit_period_ms = d_symbols_per_bit * d_correlation_length_ms;
cfg.epoch_ms = d_correlation_length_ms;
cfg.min_events_for_lock = 5;
d_bit_sync = HistogramBitSynchronizer(cfg);
}
@@ -1945,13 +1946,35 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused)
{
if (d_use_histogram_bit_sync)
{
next_state = d_bit_sync.update(d_P_accu, true);
const bool lock_event = d_bit_sync.update(d_P_accu, true);
if (lock_event)
{
d_wait_for_bit_edge = true;
const std::int64_t k_now = d_bit_sync.get_epoch_count() - 1;
const int wait = d_bit_sync.epochs_until_next_edge(); // computed from k_now internally
d_bit_sync_target_epoch = k_now + wait; // <-- add this member (int64_t)
}
if (d_wait_for_bit_edge)
{
const std::int64_t k_now = d_bit_sync.get_epoch_count() - 1;
if (k_now == d_bit_sync_target_epoch)
{
next_state = true;
d_wait_for_bit_edge = false;
}
}
if (next_state)
{
LOG(INFO) << d_systemName << " " << d_signal_pretty_name << " histogram bit synchronization locked in channel " << d_channel
<< " for satellite " << Gnss_Satellite(d_systemName, d_acquisition_gnss_synchro->PRN);
std::cout << d_systemName << " " << d_signal_pretty_name << " histogram bit synchronization locked in channel " << d_channel
<< " for satellite " << Gnss_Satellite(d_systemName, d_acquisition_gnss_synchro->PRN) << '\n';
}
}
@@ -217,6 +217,12 @@ private:
bool d_enable_extended_integration;
bool d_Flag_PLL_180_deg_phase_locked;
bool d_use_histogram_bit_sync;
bool d_wait_for_bit_edge{false};
int64_t d_bit_sync_lock_epoch{0};
int64_t d_bit_sync_target_epoch{0};
};
@@ -147,4 +147,31 @@ void HistogramBitSynchronizer::best_bin_and_count(int& best_bin, int& best_count
best_bin = i;
}
}
}
int HistogramBitSynchronizer::epochs_until_next_edge() const
{
if (!locked_ || edge_phase_ < 0)
return -1;
const int B = bins();
if (B <= 0)
return -1;
// Current epoch index (last processed)
const std::int64_t k_now = epoch_count_ - 1;
// Phase of the current epoch
const int cur_phase = static_cast<int>(k_now % B);
// Forward distance (modulo B) to the next epoch whose phase equals edge_phase_
// This returns:
// 0 -> the current epoch IS the first epoch of a new bit
// 1+ -> number of epochs to wait until the next bit boundary
return (edge_phase_ - cur_phase + B) % B;
}
@@ -128,7 +128,7 @@ public:
Config()
: bit_period_ms(20),
epoch_ms(1),
min_events_for_lock(30),
min_events_for_lock(20),
dominance_ratio(0.6),
stable_best_required(5),
min_prompt_mag(0.0f),
@@ -163,6 +163,8 @@ public:
hist_.assign(bins(), 0);
}
int epochs_until_next_edge() const;
/**
* @brief Reset the synchronizer state.
*
@@ -279,7 +281,6 @@ private:
int last_best_bin_; // Stability tracking for best bin
int stable_best_count_; // Stability tracking for best bin
bool locked_;
bool has_last_prompt_; // Prompt history (for dot detector)
bool has_last_sign_; // Sign history (for simple detector)
+1 -1
View File
@@ -415,7 +415,7 @@ int PositionSystemTest::configure_receiver()
config->set_property("PVT.flag_rtcm_tty_port", "false");
config->set_property("PVT.rtcm_dump_devname", "/dev/pts/1");
config->set_property("PVT.dump", "true");
config->set_property("PVT.rinex_version", std::to_string(2));
config->set_property("PVT.rinex_version", std::to_string(3));
config->set_property("PVT.iono_model", "OFF");
config->set_property("PVT.trop_model", "OFF");
config->set_property("PVT.AR_GPS", "PPP-AR");