mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 12:40:35 +00:00
Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into fpga
This commit is contained in:
commit
c3635d002d
@ -33,181 +33,103 @@
|
||||
|
||||
#ifndef GNSS_SDR_CIRCULAR_DEQUE_H_
|
||||
#define GNSS_SDR_CIRCULAR_DEQUE_H_
|
||||
#include <vector>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
template <class T>
|
||||
class Gnss_circular_deque
|
||||
{
|
||||
public:
|
||||
Gnss_circular_deque();
|
||||
Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann);
|
||||
~Gnss_circular_deque();
|
||||
unsigned int size(const unsigned int ch);
|
||||
T& at(const unsigned int ch, const unsigned int pos);
|
||||
T& front(const unsigned int ch);
|
||||
T& back(const unsigned int ch);
|
||||
void push_back(const unsigned int ch, const T& new_data);
|
||||
T pop_front(const unsigned int ch);
|
||||
void clear(const unsigned int ch);
|
||||
T* get_vector(const unsigned int ch);
|
||||
Gnss_circular_deque(); // Default constructor
|
||||
Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann); // nchann = number of channels; max_size = channel capacity
|
||||
unsigned int size(const unsigned int ch); // Returns the number of available elements in a channel
|
||||
T& at(const unsigned int ch, const unsigned int pos); // Returns a reference to an element
|
||||
T& front(const unsigned int ch); // Returns a reference to the first element in the deque
|
||||
T& back(const unsigned int ch); // Returns a reference to the last element in the deque
|
||||
void push_back(const unsigned int ch, const T& new_data); // Inserts an element at the end of the deque
|
||||
void pop_front(const unsigned int ch); // Removes the first element of the deque
|
||||
void clear(const unsigned int ch); // Removes all the elements of the deque (Sets size to 0). Capacity is not modified
|
||||
void reset(const unsigned int max_size, const unsigned int nchann); // Removes all the elements in all the channels. Re-sets the number of channels and their capacity
|
||||
void reset(); // Removes all the channels (Sets nchann to 0)
|
||||
|
||||
private:
|
||||
T** d_history;
|
||||
T d_return_void; // Void object for avoid compiler errors
|
||||
unsigned int* d_index_pop;
|
||||
unsigned int* d_index_push;
|
||||
unsigned int* d_size;
|
||||
unsigned int d_max_size;
|
||||
unsigned int d_nchannels;
|
||||
std::vector<boost::circular_buffer<T>> d_data;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
Gnss_circular_deque<T>::Gnss_circular_deque()
|
||||
{
|
||||
d_max_size = 0;
|
||||
d_nchannels = 0;
|
||||
d_size = nullptr;
|
||||
d_index_pop = nullptr;
|
||||
d_index_push = nullptr;
|
||||
d_history = nullptr;
|
||||
reset();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Gnss_circular_deque<T>::Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann)
|
||||
{
|
||||
d_max_size = max_size;
|
||||
d_nchannels = nchann;
|
||||
if (d_max_size > 0 and d_nchannels > 0)
|
||||
{
|
||||
d_size = new unsigned int[d_nchannels];
|
||||
d_index_pop = new unsigned int[d_nchannels];
|
||||
d_index_push = new unsigned int[d_nchannels];
|
||||
d_history = new T*[d_nchannels];
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
d_size[i] = 0;
|
||||
d_index_pop[i] = 0;
|
||||
d_index_push[i] = 0;
|
||||
d_history[i] = new T[d_max_size];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Gnss_circular_deque<T>::~Gnss_circular_deque()
|
||||
{
|
||||
if (d_max_size > 0 and d_nchannels > 0)
|
||||
{
|
||||
delete[] d_size;
|
||||
delete[] d_index_pop;
|
||||
delete[] d_index_push;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
delete[] d_history[i];
|
||||
}
|
||||
delete[] d_history;
|
||||
}
|
||||
reset(max_size, nchann);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
unsigned int Gnss_circular_deque<T>::size(const unsigned int ch)
|
||||
{
|
||||
return d_size[ch];
|
||||
return d_data.at(ch).size();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T& Gnss_circular_deque<T>::back(const unsigned int ch)
|
||||
{
|
||||
if (d_size[ch] > 0)
|
||||
{
|
||||
unsigned int index = 0;
|
||||
if (d_index_push[ch] > 0)
|
||||
{
|
||||
index = d_index_push[ch] - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = d_max_size;
|
||||
}
|
||||
return d_history[ch][index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return d_return_void;
|
||||
}
|
||||
return d_data.at(ch).back();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T& Gnss_circular_deque<T>::front(const unsigned int ch)
|
||||
{
|
||||
if (d_size[ch] > 0)
|
||||
{
|
||||
return d_history[ch][d_index_pop[ch]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return d_return_void;
|
||||
}
|
||||
return d_data.at(ch).front();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T& Gnss_circular_deque<T>::at(const unsigned int ch, const unsigned int pos)
|
||||
{
|
||||
if (d_size[ch] > 0 and pos < d_size[ch])
|
||||
{
|
||||
unsigned int index = (d_index_pop[ch] + pos) % d_max_size;
|
||||
return d_history[ch][index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return d_return_void;
|
||||
}
|
||||
return d_data.at(ch).at(pos);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Gnss_circular_deque<T>::clear(const unsigned int ch)
|
||||
{
|
||||
d_size[ch] = 0;
|
||||
d_index_pop[ch] = 0;
|
||||
d_index_push[ch] = 0;
|
||||
d_data.at(ch).clear();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T Gnss_circular_deque<T>::pop_front(const unsigned int ch)
|
||||
void Gnss_circular_deque<T>::reset(const unsigned int max_size, const unsigned int nchann)
|
||||
{
|
||||
T result;
|
||||
if (d_size[ch] > 0)
|
||||
d_data.clear();
|
||||
if (max_size > 0 and nchann > 0)
|
||||
{
|
||||
d_size[ch]--;
|
||||
result = d_history[ch][d_index_pop[ch]];
|
||||
d_index_pop[ch]++;
|
||||
d_index_pop[ch] %= d_max_size;
|
||||
for (unsigned int i = 0; i < nchann; i++)
|
||||
{
|
||||
d_data.push_back(boost::circular_buffer<T>(max_size));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Gnss_circular_deque<T>::reset()
|
||||
{
|
||||
d_data.clear();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Gnss_circular_deque<T>::pop_front(const unsigned int ch)
|
||||
{
|
||||
d_data.at(ch).pop_front();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Gnss_circular_deque<T>::push_back(const unsigned int ch, const T& new_data)
|
||||
{
|
||||
d_history[ch][d_index_push[ch]] = new_data;
|
||||
d_index_push[ch]++;
|
||||
d_index_push[ch] %= d_max_size;
|
||||
if (d_size[ch] < d_max_size)
|
||||
{
|
||||
d_size[ch]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_index_pop[ch]++;
|
||||
d_index_pop[ch] %= d_max_size;
|
||||
}
|
||||
d_data.at(ch).push_back(new_data);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* Gnss_circular_deque<T>::get_vector(const unsigned int ch)
|
||||
{
|
||||
return d_history[ch];
|
||||
}
|
||||
|
||||
|
||||
#endif /* GNSS_SDR_CIRCULAR_DEQUE_H_ */
|
||||
|
@ -63,10 +63,11 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in,
|
||||
d_dump_filename = dump_filename;
|
||||
T_rx_s = 0.0;
|
||||
T_rx_step_s = 0.001; // 1 ms
|
||||
max_delta = 0.15; // 150 ms
|
||||
max_delta = 3.5; // 3.5 s
|
||||
d_latency = 0.08; // 80 ms
|
||||
valid_channels.resize(d_nchannels, false);
|
||||
d_num_valid_channels = 0;
|
||||
d_gnss_synchro_history = new Gnss_circular_deque<Gnss_Synchro>(200, d_nchannels);
|
||||
d_gnss_synchro_history = new Gnss_circular_deque<Gnss_Synchro>(static_cast<unsigned int>(max_delta * 1000.0), d_nchannels);
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump)
|
||||
@ -86,7 +87,6 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in,
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << "SALIDA CONST HO. ()" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@ -308,55 +308,21 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i
|
||||
}
|
||||
std::pair<unsigned int, unsigned int> ind = find_interp_elements(ch, ti);
|
||||
|
||||
double m = 0.0;
|
||||
double c = 0.0;
|
||||
//Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1)
|
||||
|
||||
// CARRIER PHASE INTERPOLATION
|
||||
|
||||
m = (d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time);
|
||||
c = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads - m * d_gnss_synchro_history->at(ch, ind.first).RX_time;
|
||||
out.Carrier_phase_rads = m * ti + c;
|
||||
out.Carrier_phase_rads = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time);
|
||||
|
||||
// CARRIER DOPPLER INTERPOLATION
|
||||
m = (d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time);
|
||||
c = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz - m * d_gnss_synchro_history->at(ch, ind.first).RX_time;
|
||||
out.Carrier_Doppler_hz = m * ti + c;
|
||||
|
||||
out.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time);
|
||||
|
||||
// TOW INTERPOLATION
|
||||
m = (d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time);
|
||||
c = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s - m * d_gnss_synchro_history->at(ch, ind.first).RX_time;
|
||||
out.TOW_at_current_symbol_s = m * ti + c;
|
||||
|
||||
out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time);
|
||||
|
||||
return true;
|
||||
|
||||
/*
|
||||
arma::vec t = arma::vec(d_gnss_synchro_history.size(ch));
|
||||
arma::vec dop = t;
|
||||
arma::vec cph = t;
|
||||
arma::vec tow = t;
|
||||
arma::vec tiv = arma::vec(1);
|
||||
arma::vec result;
|
||||
tiv(0) = ti;
|
||||
|
||||
unsigned int aux = 0;
|
||||
for (it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
t(aux) = it->RX_time;
|
||||
dop(aux) = it->Carrier_Doppler_hz;
|
||||
cph(aux) = it->Carrier_phase_rads;
|
||||
tow(aux) = it->TOW_at_current_symbol_s;
|
||||
|
||||
aux++;
|
||||
}
|
||||
arma::interp1(t, dop, tiv, result);
|
||||
out.Carrier_Doppler_hz = result(0);
|
||||
arma::interp1(t, cph, tiv, result);
|
||||
out.Carrier_phase_rads = result(0);
|
||||
arma::interp1(t, tow, tiv, result);
|
||||
out.TOW_at_current_symbol_s = result(0);
|
||||
|
||||
return result.is_finite();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -379,8 +345,8 @@ std::pair<unsigned int, unsigned int> hybrid_observables_cc::find_interp_element
|
||||
double dt = 0.0;
|
||||
for (unsigned int i = 0; i < d_gnss_synchro_history->size(ch); i++)
|
||||
{
|
||||
dt = std::fabs(ti - d_gnss_synchro_history->at(ch, i).RX_time);
|
||||
if (dt < dif)
|
||||
dt = ti - d_gnss_synchro_history->at(ch, i).RX_time;
|
||||
if (dt < dif and dt > 0.0)
|
||||
{
|
||||
dif = dt;
|
||||
closest = i;
|
||||
@ -399,18 +365,10 @@ std::pair<unsigned int, unsigned int> hybrid_observables_cc::find_interp_element
|
||||
index2 = d_gnss_synchro_history->size(ch) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d_gnss_synchro_history->at(ch, closest).RX_time < ti)
|
||||
{
|
||||
index1 = closest;
|
||||
index2 = closest + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
index1 = closest - 1;
|
||||
index2 = closest;
|
||||
}
|
||||
}
|
||||
return std::pair<unsigned int, unsigned int>(index1, index2);
|
||||
}
|
||||
|
||||
@ -576,7 +534,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused)
|
||||
|
||||
// Check if there is any valid channel after computing the time distance between the Gnss_Synchro data and the receiver time
|
||||
d_num_valid_channels = valid_channels.count();
|
||||
double T_rx_s_out = T_rx_s - (max_delta / 2.0);
|
||||
double T_rx_s_out = T_rx_s - d_latency;
|
||||
if ((d_num_valid_channels == 0) or (T_rx_s_out < 0.0))
|
||||
{
|
||||
return 0;
|
||||
|
@ -78,6 +78,7 @@ private:
|
||||
double T_rx_s;
|
||||
double T_rx_step_s;
|
||||
double max_delta;
|
||||
double d_latency;
|
||||
bool d_dump;
|
||||
unsigned int d_nchannels;
|
||||
unsigned int d_num_valid_channels;
|
||||
|
@ -105,6 +105,8 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
|
||||
flag_PLL_180_deg_phase_locked = false;
|
||||
d_preamble_time_samples = 0;
|
||||
d_TOW_at_current_symbol_ms = 0;
|
||||
d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS + 1); // Change fixed buffer size
|
||||
d_symbol_history.clear(); // Clear all the elements in the buffer
|
||||
}
|
||||
|
||||
|
||||
@ -395,11 +397,6 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
|
||||
}
|
||||
}
|
||||
|
||||
// remove used symbols from history
|
||||
if (d_symbol_history.size() > required_symbols)
|
||||
{
|
||||
d_symbol_history.pop_front();
|
||||
}
|
||||
//3. Make the output (copy the object contents to the GNURadio reserved memory)
|
||||
*out[0] = current_symbol;
|
||||
|
||||
|
@ -36,9 +36,9 @@
|
||||
#include "gnss_satellite.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include <gnuradio/block.h>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
class gps_l1_ca_telemetry_decoder_cc;
|
||||
|
||||
@ -79,7 +79,7 @@ private:
|
||||
bool d_flag_frame_sync;
|
||||
|
||||
// symbols
|
||||
std::deque<Gnss_Synchro> d_symbol_history;
|
||||
boost::circular_buffer<Gnss_Synchro> d_symbol_history;
|
||||
|
||||
double d_symbol_accumulator;
|
||||
short int d_symbol_accumulator_counter;
|
||||
|
Loading…
Reference in New Issue
Block a user