1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-07-26 13:52:54 +00:00

Avoid potential division by zero

This commit is contained in:
Carles Fernandez 2025-01-27 14:56:52 +01:00
parent 8adc2b26c2
commit 003bb82765
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -612,7 +612,7 @@ void hybrid_observables_gs::set_tag_timestamp_in_sdr_timeframe(const std::vector
// to an absolute GPS TOW samplestamp associated with the current set of pseudoranges // to an absolute GPS TOW samplestamp associated with the current set of pseudoranges
if (!d_TimeChannelTagTimestamps.empty()) if (!d_TimeChannelTagTimestamps.empty())
{ {
double fs = 0; double fs = 0.0;
std::vector<Gnss_Synchro>::const_iterator it; std::vector<Gnss_Synchro>::const_iterator it;
for (it = data.begin(); it != data.end(); it++) for (it = data.begin(); it != data.end(); it++)
{ {
@ -622,21 +622,24 @@ void hybrid_observables_gs::set_tag_timestamp_in_sdr_timeframe(const std::vector
break; break;
} }
} }
if (fs < 1.0)
{
return;
}
double delta_rxtime_to_tag; double delta_rxtime_to_tag;
GnssTime current_tag; GnssTime current_tag;
do do
{ {
current_tag = d_TimeChannelTagTimestamps.front(); current_tag = d_TimeChannelTagTimestamps.front();
delta_rxtime_to_tag = (static_cast<double>(rx_clock) / fs) - current_tag.rx_time; // delta time relative to receiver's start time delta_rxtime_to_tag = (static_cast<double>(rx_clock) / fs) - current_tag.rx_time; // delta time relative to receiver's start time
if (delta_rxtime_to_tag >= 0) if (delta_rxtime_to_tag >= 0.0)
{ {
d_TimeChannelTagTimestamps.pop(); d_TimeChannelTagTimestamps.pop();
} }
} }
while (delta_rxtime_to_tag >= 0.1 and !d_TimeChannelTagTimestamps.empty()); while (delta_rxtime_to_tag >= 0.1 && !d_TimeChannelTagTimestamps.empty());
if (delta_rxtime_to_tag >= 0 and delta_rxtime_to_tag <= 0.1) if (delta_rxtime_to_tag >= 0.0 && delta_rxtime_to_tag <= 0.1)
{ {
// std::cout << "[Time ch][" << delta_rxtime_to_tag // std::cout << "[Time ch][" << delta_rxtime_to_tag
// << "] OBS RX TimeTag Week: " << current_tag.week // << "] OBS RX TimeTag Week: " << current_tag.week