mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 04:00:34 +00:00
Merge branch 'common_solver' of https://github.com/gnss-sdr/gnss-sdr into pvtconsumeall
This commit is contained in:
commit
5fe34321f2
@ -1,8 +1,7 @@
|
||||
/*!
|
||||
* \file hybrid_observables_cc.cc
|
||||
* \brief Implementation of the pseudorange computation block for Galileo E1
|
||||
* \author Mara Branzanti 2013. mara.branzanti(at)gmail.com
|
||||
* \author Javier Arribas 2013. jarribas(at)cttc.es
|
||||
* \author Javier Arribas 2017. jarribas(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
@ -39,7 +38,6 @@
|
||||
#include <armadillo>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <glog/logging.h>
|
||||
#include "gnss_synchro.h"
|
||||
#include "Galileo_E1.h"
|
||||
#include "GPS_L1_CA.h"
|
||||
|
||||
@ -56,39 +54,43 @@ hybrid_make_observables_cc(unsigned int nchannels, bool dump, std::string dump_f
|
||||
|
||||
|
||||
hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history) :
|
||||
gr::block("hybrid_observables_cc", gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)),
|
||||
gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)))
|
||||
gr::block("hybrid_observables_cc", gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)),
|
||||
gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)))
|
||||
{
|
||||
// initialize internal vars
|
||||
d_dump = dump;
|
||||
d_nchannels = nchannels;
|
||||
d_dump_filename = dump_filename;
|
||||
history_deep = deep_history;
|
||||
|
||||
T_rx_s=0.0;
|
||||
T_rx_step_s=1e-3;// todo: move to gnss-sdr config
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
d_acc_carrier_phase_queue_rads.push_back(std::deque<double>(d_nchannels));
|
||||
d_carrier_doppler_queue_hz.push_back(std::deque<double>(d_nchannels));
|
||||
d_symbol_TOW_queue_s.push_back(std::deque<double>(d_nchannels));
|
||||
}
|
||||
{
|
||||
d_gnss_synchro_history_queue.push_back(std::deque<Gnss_Synchro>());
|
||||
}
|
||||
//todo: this is a gnuradio scheduler hack.
|
||||
// Migrate the queues to gnuradio set_history to see if the scheduler can handle
|
||||
// the multiple output flow
|
||||
d_max_noutputs=100;
|
||||
this->set_min_noutput_items(100);
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump == true)
|
||||
{
|
||||
if (d_dump_file.is_open() == false)
|
||||
{
|
||||
if (d_dump_file.is_open() == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.exceptions (std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
|
||||
LOG(INFO) << "Observables dump enabled Log file: " << d_dump_filename.c_str();
|
||||
}
|
||||
catch (const std::ifstream::failure & e)
|
||||
{
|
||||
LOG(WARNING) << "Exception opening observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
d_dump_file.exceptions (std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
|
||||
LOG(INFO) << "Observables dump enabled Log file: " << d_dump_filename.c_str();
|
||||
}
|
||||
catch (const std::ifstream::failure & e)
|
||||
{
|
||||
LOG(WARNING) << "Exception opening observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -98,163 +100,219 @@ hybrid_observables_cc::~hybrid_observables_cc()
|
||||
}
|
||||
|
||||
|
||||
bool Hybrid_pairCompare_gnss_synchro_d_TOW_at_current_symbol(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
||||
bool Hybrid_pairCompare_gnss_synchro_sample_counter(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
||||
{
|
||||
return (a.second.TOW_at_current_symbol_s) < (b.second.TOW_at_current_symbol_s);
|
||||
return (a.second.Tracking_sample_counter) < (b.second.Tracking_sample_counter);
|
||||
}
|
||||
|
||||
bool Hybrid_valueCompare_gnss_synchro_sample_counter(const Gnss_Synchro& a, unsigned long int b)
|
||||
{
|
||||
return (a.Tracking_sample_counter) < (b);
|
||||
}
|
||||
|
||||
bool Hybrid_valueCompare_gnss_synchro_receiver_time(const Gnss_Synchro& a, double b)
|
||||
{
|
||||
return ((double)a.Tracking_sample_counter/(double)a.fs) < (b);
|
||||
}
|
||||
|
||||
bool Hybrid_pairCompare_gnss_synchro_d_TOW(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
||||
{
|
||||
return (a.second.TOW_at_current_symbol_s) < (b.second.TOW_at_current_symbol_s);
|
||||
}
|
||||
bool Hybrid_valueCompare_gnss_synchro_d_TOW(const Gnss_Synchro& a, double b)
|
||||
{
|
||||
return (a.TOW_at_current_symbol_s) < (b);
|
||||
}
|
||||
|
||||
int hybrid_observables_cc::general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; // Get the input pointer
|
||||
Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; // Get the output pointer
|
||||
int n_outputs=0;
|
||||
int n_consume[d_nchannels];
|
||||
double past_history_s=100e-3;
|
||||
|
||||
Gnss_Synchro current_gnss_synchro[d_nchannels];
|
||||
std::map<int,Gnss_Synchro> current_gnss_synchro_map;
|
||||
std::map<int,Gnss_Synchro>::iterator gnss_synchro_iter;
|
||||
|
||||
if (d_nchannels != ninput_items.size())
|
||||
{
|
||||
LOG(WARNING) << "The Observables block is not well connected";
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Read the GNSS SYNCHRO objects from available channels
|
||||
* 1. Read the GNSS SYNCHRO objects from available channels.
|
||||
* Multi-rate GNURADIO Block. Read how many input items are avaliable in each channel
|
||||
* Record all synchronization data into queues
|
||||
*/
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
n_consume[i]=ninput_items[i];// full throttle
|
||||
for (int j=0;j<n_consume[i];j++)
|
||||
{
|
||||
//Copy the telemetry decoder data to local copy
|
||||
current_gnss_synchro[i] = in[i][0];
|
||||
/*
|
||||
* 1.2 Assume no valid pseudoranges
|
||||
*/
|
||||
current_gnss_synchro[i].Flag_valid_pseudorange = false;
|
||||
current_gnss_synchro[i].Pseudorange_m = 0.0;
|
||||
if (current_gnss_synchro[i].Flag_valid_word)
|
||||
{
|
||||
//record the word structure in a map for pseudorange computation
|
||||
current_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(current_gnss_synchro[i].Channel_ID, current_gnss_synchro[i]));
|
||||
//################### SAVE DOPPLER AND ACC CARRIER PHASE HISTORIC DATA FOR INTERPOLATION IN OBSERVABLE MODULE #######
|
||||
d_carrier_doppler_queue_hz[i].push_back(current_gnss_synchro[i].Carrier_Doppler_hz);
|
||||
d_acc_carrier_phase_queue_rads[i].push_back(current_gnss_synchro[i].Carrier_phase_rads);
|
||||
// save TOW history
|
||||
d_symbol_TOW_queue_s[i].push_back(current_gnss_synchro[i].TOW_at_current_symbol_s);
|
||||
if (d_carrier_doppler_queue_hz[i].size() > history_deep)
|
||||
{
|
||||
d_carrier_doppler_queue_hz[i].pop_front();
|
||||
}
|
||||
if (d_acc_carrier_phase_queue_rads[i].size() > history_deep)
|
||||
{
|
||||
d_acc_carrier_phase_queue_rads[i].pop_front();
|
||||
}
|
||||
if (d_symbol_TOW_queue_s[i].size() > history_deep)
|
||||
{
|
||||
d_symbol_TOW_queue_s[i].pop_front();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear the observables history for this channel
|
||||
if (d_symbol_TOW_queue_s[i].size() > 0)
|
||||
{
|
||||
d_symbol_TOW_queue_s[i].clear();
|
||||
d_carrier_doppler_queue_hz[i].clear();
|
||||
d_acc_carrier_phase_queue_rads[i].clear();
|
||||
}
|
||||
}
|
||||
d_gnss_synchro_history_queue[i].push_back(in[i][j]);
|
||||
}
|
||||
//std::cout<<"push["<<i<<"] items "<<n_consume[i]
|
||||
/// <<" latest T_rx: "<<(double)in[i][ninput_items[i]-1].Tracking_sample_counter/(double)in[i][ninput_items[i]-1].fs
|
||||
// <<" [s] q size: "
|
||||
// <<d_gnss_synchro_history_queue[i].size()
|
||||
// <<std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
* 2. Compute RAW pseudoranges using COMMON RECEPTION TIME algorithm. Use only the valid channels (channels that are tracking a satellite)
|
||||
*/
|
||||
if(current_gnss_synchro_map.size() > 0)
|
||||
bool channel_history_ok;
|
||||
do{
|
||||
channel_history_ok=true;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
/*
|
||||
* 2.1 Use CURRENT set of measurements and find the nearest satellite
|
||||
* common RX time algorithm
|
||||
*/
|
||||
// what is the most recent symbol TOW in the current set? -> this will be the reference symbol
|
||||
gnss_synchro_iter = max_element(current_gnss_synchro_map.begin(), current_gnss_synchro_map.end(), Hybrid_pairCompare_gnss_synchro_d_TOW_at_current_symbol);
|
||||
double d_TOW_reference = gnss_synchro_iter->second.TOW_at_current_symbol_s;
|
||||
double d_ref_PRN_phase_samples = gnss_synchro_iter->second.Code_phase_samples;
|
||||
//std::cout<<"OBS SV REF SAT: "<<gnss_synchro_iter->second.PRN<<std::endl;
|
||||
unsigned long int d_ref_PRN_sample_counter = gnss_synchro_iter->second.Tracking_sample_counter;
|
||||
if (d_gnss_synchro_history_queue[i].size()<history_deep)
|
||||
{
|
||||
channel_history_ok=false;
|
||||
}
|
||||
|
||||
// Now compute RX time differences due to the PRN alignment in the correlators
|
||||
double traveltime_ms;
|
||||
double pseudorange_m;
|
||||
int delta_sample_counter;
|
||||
double delta_sample_counter_s;
|
||||
double delta_PRN_phase_s;
|
||||
}
|
||||
if (channel_history_ok==true)
|
||||
{
|
||||
std::map<int,Gnss_Synchro>::iterator gnss_synchro_map_iter;
|
||||
std::deque<Gnss_Synchro>::iterator gnss_synchro_deque_iter;
|
||||
|
||||
for(gnss_synchro_iter = current_gnss_synchro_map.begin(); gnss_synchro_iter != current_gnss_synchro_map.end(); gnss_synchro_iter++)
|
||||
//1. If the RX time is not set, set the Rx time
|
||||
if (T_rx_s==0)
|
||||
{
|
||||
//0. Read a gnss_synchro snapshot from the queue and store it in a map
|
||||
std::map<int,Gnss_Synchro> gnss_synchro_map;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(
|
||||
d_gnss_synchro_history_queue[i].front().Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].front()));
|
||||
|
||||
}
|
||||
gnss_synchro_map_iter = min_element(gnss_synchro_map.begin(),
|
||||
gnss_synchro_map.end(),
|
||||
Hybrid_pairCompare_gnss_synchro_sample_counter);
|
||||
T_rx_s = (double)gnss_synchro_map_iter->second.Tracking_sample_counter/(double)gnss_synchro_map_iter->second.fs;
|
||||
T_rx_s +=past_history_s; //increase T_rx to have a minimum past history to interpolate
|
||||
}
|
||||
|
||||
//2. Realign RX time in all valid channels
|
||||
std::map<int,Gnss_Synchro> realigned_gnss_synchro_map;//container for the aligned set of observables for the selected T_rx
|
||||
std::map<int,Gnss_Synchro> adjacent_gnss_synchro_map; //container for the previous observable values to interpolate
|
||||
//shift channels history to match the reference TOW
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
gnss_synchro_deque_iter = std::lower_bound(d_gnss_synchro_history_queue[i].begin(),
|
||||
d_gnss_synchro_history_queue[i].end(),
|
||||
T_rx_s,
|
||||
Hybrid_valueCompare_gnss_synchro_receiver_time);
|
||||
if (gnss_synchro_deque_iter!=d_gnss_synchro_history_queue[i].end())
|
||||
{
|
||||
if (gnss_synchro_deque_iter->Flag_valid_word==true)
|
||||
{
|
||||
double T_rx_channel=(double)gnss_synchro_deque_iter->Tracking_sample_counter/(double)gnss_synchro_deque_iter->fs;
|
||||
double delta_T_rx_s=T_rx_channel-T_rx_s;
|
||||
|
||||
//check that T_rx difference is less than a threshold (the correlation interval)
|
||||
if (delta_T_rx_s*1000.0<(double)gnss_synchro_deque_iter->correlation_length_ms)
|
||||
{
|
||||
//record the word structure in a map for pseudorange computation
|
||||
//save the previous observable
|
||||
int distance=std::distance(d_gnss_synchro_history_queue[i].begin(), gnss_synchro_deque_iter);
|
||||
if (distance>0)
|
||||
{
|
||||
double T_rx_channel_prev=(double)d_gnss_synchro_history_queue[i].at(distance-1).Tracking_sample_counter/(double)gnss_synchro_deque_iter->fs;
|
||||
double delta_T_rx_s_prev=T_rx_channel_prev-T_rx_s;
|
||||
if (fabs(delta_T_rx_s_prev)<fabs(delta_T_rx_s))
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(
|
||||
d_gnss_synchro_history_queue[i].at(distance-1).Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].at(distance-1)));
|
||||
adjacent_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID,
|
||||
*gnss_synchro_deque_iter));
|
||||
}else{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID,
|
||||
*gnss_synchro_deque_iter));
|
||||
adjacent_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(
|
||||
d_gnss_synchro_history_queue[i].at(distance-1).Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].at(distance-1)));
|
||||
}
|
||||
}else{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID,
|
||||
*gnss_synchro_deque_iter));
|
||||
}
|
||||
|
||||
}else{
|
||||
//std::cout<<"ch["<<i<<"] delta_T_rx:"<<delta_T_rx_s*1000.0<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!realigned_gnss_synchro_map.empty())
|
||||
{
|
||||
/*
|
||||
* 2.1 Use CURRENT set of measurements and find the nearest satellite
|
||||
* common RX time algorithm
|
||||
*/
|
||||
// what is the most recent symbol TOW in the current set? -> this will be the reference symbol
|
||||
gnss_synchro_map_iter = max_element(realigned_gnss_synchro_map.begin(),
|
||||
realigned_gnss_synchro_map.end(),
|
||||
Hybrid_pairCompare_gnss_synchro_d_TOW);
|
||||
double d_TOW_reference = gnss_synchro_map_iter->second.TOW_at_current_symbol_s;
|
||||
double d_ref_PRN_phase_samples = gnss_synchro_map_iter->second.Code_phase_samples;
|
||||
//std::cout<<"OBS SV REF SAT: "<<gnss_synchro_map_iter->second.PRN<<std::endl;
|
||||
|
||||
// Now compute RX time differences due to the PRN alignment in the correlators
|
||||
double traveltime_ms;
|
||||
double pseudorange_m;
|
||||
double delta_T_rx_s;
|
||||
double delta_PRN_phase_s;
|
||||
//std::cout<<"T_rx_s: "<<T_rx_s<<std::endl;
|
||||
for(gnss_synchro_map_iter = realigned_gnss_synchro_map.begin(); gnss_synchro_map_iter != realigned_gnss_synchro_map.end(); gnss_synchro_map_iter++)
|
||||
{
|
||||
|
||||
delta_sample_counter = (gnss_synchro_iter->second.Tracking_sample_counter - d_ref_PRN_sample_counter);
|
||||
delta_sample_counter_s=(double)delta_sample_counter/(double)gnss_synchro_iter->second.fs;
|
||||
delta_PRN_phase_s = (gnss_synchro_iter->second.Code_phase_samples - d_ref_PRN_phase_samples)/(double)gnss_synchro_iter->second.fs;
|
||||
delta_T_rx_s = ((double)gnss_synchro_map_iter->second.Tracking_sample_counter/(double)gnss_synchro_map_iter->second.fs - T_rx_s);
|
||||
delta_PRN_phase_s = (gnss_synchro_map_iter->second.Code_phase_samples - d_ref_PRN_phase_samples)/(double)gnss_synchro_map_iter->second.fs;
|
||||
//compute the pseudorange (no rx time offset correction)
|
||||
traveltime_ms = (d_TOW_reference - gnss_synchro_iter->second.TOW_at_current_symbol_s) * 1000.0
|
||||
+ delta_sample_counter_s*1000.0 + delta_PRN_phase_s*1000.0
|
||||
+ GPS_STARTOFFSET_ms;
|
||||
traveltime_ms = (d_TOW_reference - gnss_synchro_map_iter->second.TOW_at_current_symbol_s) * 1000.0
|
||||
+ delta_T_rx_s*1000.0 + delta_PRN_phase_s*1000.0
|
||||
+ GPS_STARTOFFSET_ms;
|
||||
//convert to meters
|
||||
pseudorange_m = traveltime_ms * GPS_C_m_ms; // [m]
|
||||
//std::cout<<"["<<gnss_synchro_iter->second.PRN<<"] delta_rx_t: "<<delta_rx_time_ms
|
||||
// <<" [ms] delta_TOW_ms: "<<(d_TOW_reference - gnss_synchro_iter->second.d_TOW_at_current_symbol) * 1000.0
|
||||
// <<" Pr: "<<pseudorange_m<<" [m]"
|
||||
// <<std::endl;
|
||||
// update the pseudorange object
|
||||
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID] = gnss_synchro_iter->second;
|
||||
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_m = pseudorange_m;
|
||||
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Flag_valid_pseudorange = true;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID] = gnss_synchro_map_iter->second;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Pseudorange_m = pseudorange_m;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Flag_valid_pseudorange = true;
|
||||
// Save the estimated RX time (no RX clock offset correction yet!)
|
||||
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].RX_time = d_TOW_reference + GPS_STARTOFFSET_ms / 1000.0;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].RX_time = d_TOW_reference + GPS_STARTOFFSET_ms / 1000.0;
|
||||
|
||||
if (d_symbol_TOW_queue_s[gnss_synchro_iter->second.Channel_ID].size() >= history_deep)
|
||||
{
|
||||
arma::vec symbol_TOW_vec_s;
|
||||
arma::vec dopper_vec_hz;
|
||||
arma::vec dopper_vec_interp_hz;
|
||||
arma::vec acc_phase_vec_rads;
|
||||
arma::vec acc_phase_vec_interp_rads;
|
||||
arma::vec desired_symbol_TOW(1);
|
||||
// compute interpolated observation values for Doppler and Accumulate carrier phase
|
||||
symbol_TOW_vec_s = arma::vec(std::vector<double>(d_symbol_TOW_queue_s[gnss_synchro_iter->second.Channel_ID].begin(), d_symbol_TOW_queue_s[gnss_synchro_iter->second.Channel_ID].end()));
|
||||
acc_phase_vec_rads = arma::vec(std::vector<double>(d_acc_carrier_phase_queue_rads[gnss_synchro_iter->second.Channel_ID].begin(), d_acc_carrier_phase_queue_rads[gnss_synchro_iter->second.Channel_ID].end()));
|
||||
dopper_vec_hz = arma::vec(std::vector<double>(d_carrier_doppler_queue_hz[gnss_synchro_iter->second.Channel_ID].begin(), d_carrier_doppler_queue_hz[gnss_synchro_iter->second.Channel_ID].end()));
|
||||
// compute interpolated observation values for Doppler and Accumulate carrier phase
|
||||
// two points linear interpolation using adjacent (adj) values: y=y1+(x-x1)*(y2-y1)/(x2-x1)
|
||||
int element_key=gnss_synchro_map_iter->second.Channel_ID;
|
||||
Gnss_Synchro adj_obs=adjacent_gnss_synchro_map.at(element_key);
|
||||
double adj_delta_T_rx_s=((double)adj_obs.Tracking_sample_counter/(double)adj_obs.fs - T_rx_s);
|
||||
double Carrier_phase_lin_rads = adj_obs.Carrier_phase_rads+adj_delta_T_rx_s
|
||||
*(gnss_synchro_map_iter->second.Carrier_phase_rads-adj_obs.Carrier_phase_rads)/(delta_T_rx_s-adj_delta_T_rx_s);
|
||||
double Carrier_Doppler_lin_hz = adj_obs.Carrier_Doppler_hz+adj_delta_T_rx_s
|
||||
*(gnss_synchro_map_iter->second.Carrier_Doppler_hz-adj_obs.Carrier_Doppler_hz)/(delta_T_rx_s-adj_delta_T_rx_s);
|
||||
|
||||
desired_symbol_TOW[0] = symbol_TOW_vec_s[history_deep - 1] + delta_sample_counter_s+delta_PRN_phase_s;
|
||||
// arma::interp1(symbol_TOW_vec_s,dopper_vec_hz,desired_symbol_TOW,dopper_vec_interp_hz);
|
||||
// arma::interp1(symbol_TOW_vec_s,acc_phase_vec_rads,desired_symbol_TOW,acc_phase_vec_interp_rads);
|
||||
// Curve fitting to quadratic function
|
||||
arma::mat A = arma::ones<arma::mat> (history_deep, 2);
|
||||
A.col(1) = symbol_TOW_vec_s;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Carrier_phase_rads = Carrier_phase_lin_rads;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Carrier_Doppler_hz = Carrier_Doppler_lin_hz;
|
||||
//debug
|
||||
// double delta_T_rx_s_previous=((double)adjacent_gnss_synchro_map.at(gnss_synchro_map_iter->second.Channel_ID).Tracking_sample_counter/(double)gnss_synchro_map_iter->second.fs - T_rx_s);
|
||||
|
||||
// std::cout<<"["<<gnss_synchro_map_iter->second.PRN<<"] delta_rx_t: "<<delta_T_rx_s*1000.0
|
||||
// <<" [ms] (prev: "<<delta_T_rx_s_previous*1000.0<<") delta_TOW_ms: "<<(d_TOW_reference - gnss_synchro_map_iter->second.TOW_at_current_symbol_s) * 1000.0
|
||||
// <<" Pr: "<<pseudorange_m<<" [m]"
|
||||
// <<" Doppler estim: "<<gnss_synchro_map_iter->second.Carrier_Doppler_hz
|
||||
// <<" Doppler inter: "<<Carrier_Doppler_lin_hz
|
||||
// <<std::endl;
|
||||
|
||||
arma::mat coef_acc_phase(1,3);
|
||||
arma::mat pinv_A = arma::pinv(A.t() * A) * A.t();
|
||||
coef_acc_phase = pinv_A * acc_phase_vec_rads;
|
||||
arma::mat coef_doppler(1,3);
|
||||
coef_doppler = pinv_A * dopper_vec_hz;
|
||||
arma::vec acc_phase_lin;
|
||||
arma::vec carrier_doppler_lin;
|
||||
acc_phase_lin = coef_acc_phase[0] + coef_acc_phase[1] * desired_symbol_TOW[0];
|
||||
carrier_doppler_lin = coef_doppler[0] + coef_doppler[1] * desired_symbol_TOW[0];
|
||||
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Carrier_phase_rads = acc_phase_lin[0];
|
||||
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Carrier_Doppler_hz = carrier_doppler_lin[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(d_dump == true)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
try
|
||||
{
|
||||
double tmp_double;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
//std::cout<<std::endl;
|
||||
if(d_dump == true)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
try
|
||||
{
|
||||
double tmp_double;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
tmp_double = current_gnss_synchro[i].RX_time;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
@ -269,21 +327,41 @@ int hybrid_observables_cc::general_work (int noutput_items,
|
||||
tmp_double = current_gnss_synchro[i].PRN;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
}
|
||||
}
|
||||
catch (const std::ifstream::failure& e)
|
||||
{
|
||||
LOG(WARNING) << "Exception writing observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::ifstream::failure& e)
|
||||
{
|
||||
LOG(WARNING) << "Exception writing observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
consume_each(1); //one by one
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
*out[i] = current_gnss_synchro[i];
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
out[i][n_outputs] = current_gnss_synchro[i];
|
||||
}
|
||||
|
||||
n_outputs++;
|
||||
}
|
||||
|
||||
//Move RX time
|
||||
T_rx_s=T_rx_s+T_rx_step_s;
|
||||
//pop old elements from queue
|
||||
for (unsigned int i=0; i<d_nchannels;i++)
|
||||
{
|
||||
while (d_gnss_synchro_history_queue[i].front().Tracking_sample_counter/(double)d_gnss_synchro_history_queue[i].front().fs<(T_rx_s-past_history_s))
|
||||
{
|
||||
d_gnss_synchro_history_queue[i].pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (noutput_items == 0)
|
||||
{
|
||||
LOG(WARNING) << "noutput_items = 0";
|
||||
}
|
||||
return 1;
|
||||
}while(channel_history_ok==true && d_max_noutputs>n_outputs);
|
||||
|
||||
//Multi-rate consume!
|
||||
for (unsigned int i=0; i<d_nchannels;i++)
|
||||
{
|
||||
consume(i,n_consume[i]); //which input, how many items
|
||||
}
|
||||
|
||||
//std::cout<<"OBS noutput_items: "<<noutput_items<<std::endl;
|
||||
return n_outputs;
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <gnuradio/block.h>
|
||||
#include "gnss_synchro.h"
|
||||
|
||||
|
||||
class hybrid_observables_cc;
|
||||
@ -61,11 +62,11 @@ private:
|
||||
hybrid_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history);
|
||||
|
||||
//Tracking observable history
|
||||
std::vector<std::deque<double>> d_acc_carrier_phase_queue_rads;
|
||||
std::vector<std::deque<double>> d_carrier_doppler_queue_hz;
|
||||
std::vector<std::deque<double>> d_symbol_TOW_queue_s;
|
||||
std::vector<std::deque<Gnss_Synchro>> d_gnss_synchro_history_queue;
|
||||
|
||||
// class private vars
|
||||
double T_rx_s;
|
||||
double T_rx_step_s;
|
||||
int d_max_noutputs;
|
||||
bool d_dump;
|
||||
unsigned int d_nchannels;
|
||||
unsigned int history_deep;
|
||||
|
Loading…
Reference in New Issue
Block a user