mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
GNSS simulator-in-the-loop completed for tracking and telemetry unit tests
This commit is contained in:
parent
92f1f90935
commit
dc910bca4e
@ -465,7 +465,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items __attribute__
|
||||
|
||||
// PLL commands
|
||||
d_dump_file.write(reinterpret_cast<char*>(&carr_error_hz), sizeof(double));
|
||||
d_dump_file.write(reinterpret_cast<char*>(&d_carrier_doppler_hz), sizeof(double));
|
||||
d_dump_file.write(reinterpret_cast<char*>(&carr_error_filt_hz), sizeof(double));
|
||||
|
||||
// DLL commands
|
||||
d_dump_file.write(reinterpret_cast<char*>(&code_error_chips), sizeof(double));
|
||||
|
@ -17,8 +17,10 @@
|
||||
#
|
||||
|
||||
|
||||
set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES
|
||||
tracking_obs_reader.cc
|
||||
set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES
|
||||
tracking_dump_reader.cc
|
||||
tlm_dump_reader.cc
|
||||
tracking_true_obs_reader.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -0,0 +1,73 @@
|
||||
//
|
||||
// Created by javier on 1/2/2017.
|
||||
//
|
||||
|
||||
#include "tlm_dump_reader.h"
|
||||
|
||||
bool tlm_dump_reader::read_binary_obs()
|
||||
{
|
||||
try {
|
||||
d_dump_file.read((char *) &TOW_at_current_symbol, sizeof(double));
|
||||
d_dump_file.read((char *) &Prn_timestamp_ms, sizeof(double));
|
||||
d_dump_file.read((char *) &d_TOW_at_Preamble, sizeof(double));
|
||||
}
|
||||
catch (const std::ifstream::failure &e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tlm_dump_reader::restart() {
|
||||
if (d_dump_file.is_open())
|
||||
{
|
||||
d_dump_file.clear();
|
||||
d_dump_file.seekg(0, std::ios::beg);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
long int tlm_dump_reader::num_epochs()
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
int number_of_vars_in_epoch=3;
|
||||
int epoch_size_bytes=sizeof(double)*number_of_vars_in_epoch;
|
||||
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
|
||||
if (tmpfile.is_open())
|
||||
{
|
||||
size = tmpfile.tellg();
|
||||
long int nepoch=size / epoch_size_bytes;
|
||||
return nepoch;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool tlm_dump_reader::open_obs_file(std::string out_file) {
|
||||
if (d_dump_file.is_open() == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_filename=out_file;
|
||||
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
|
||||
std::cout << "TLM dump enabled, Log file: " << d_dump_filename.c_str()<< std::endl;
|
||||
return true;
|
||||
}
|
||||
catch (const std::ifstream::failure & e)
|
||||
{
|
||||
std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str()<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tlm_dump_reader::~tlm_dump_reader() {
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Created by javier on 23/1/2017.
|
||||
//
|
||||
|
||||
#ifndef GNSS_SIM_tlm_dump_reader_H
|
||||
#define GNSS_SIM_tlm_dump_reader_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class tlm_dump_reader {
|
||||
|
||||
public:
|
||||
~tlm_dump_reader();
|
||||
bool read_binary_obs();
|
||||
bool restart();
|
||||
long int num_epochs();
|
||||
bool open_obs_file(std::string out_file);
|
||||
|
||||
//telemetry decoder dump variables
|
||||
double TOW_at_current_symbol;
|
||||
double Prn_timestamp_ms;
|
||||
double d_TOW_at_Preamble;
|
||||
|
||||
private:
|
||||
|
||||
std::string d_dump_filename;
|
||||
std::ifstream d_dump_file;
|
||||
|
||||
};
|
||||
|
||||
#endif //GNSS_SIM_tlm_dump_reader_H
|
@ -0,0 +1,93 @@
|
||||
//
|
||||
// Created by javier on 1/2/2017.
|
||||
//
|
||||
|
||||
#include "tracking_dump_reader.h"
|
||||
|
||||
bool tracking_dump_reader::read_binary_obs()
|
||||
{
|
||||
try {
|
||||
d_dump_file.read((char *) &abs_E, sizeof(float));
|
||||
d_dump_file.read((char *) &abs_P, sizeof(float));
|
||||
d_dump_file.read((char *) &abs_L, sizeof(float));
|
||||
d_dump_file.read((char *) &prompt_I, sizeof(float));
|
||||
d_dump_file.read((char *) &prompt_Q, sizeof(float));
|
||||
|
||||
d_dump_file.read((char *) &PRN_start_sample_count, sizeof(unsigned long int));
|
||||
|
||||
d_dump_file.read((char *) &acc_carrier_phase_rad, sizeof(double));
|
||||
d_dump_file.read((char *) &carrier_doppler_hz, sizeof(double));
|
||||
d_dump_file.read((char *) &code_freq_chips, sizeof(double));
|
||||
d_dump_file.read((char *) &carr_error_hz, sizeof(double));
|
||||
d_dump_file.read((char *) &carr_error_filt_hz, sizeof(double));
|
||||
d_dump_file.read((char *) &code_error_chips, sizeof(double));
|
||||
d_dump_file.read((char *) &code_error_filt_chips, sizeof(double));
|
||||
d_dump_file.read((char *) &CN0_SNV_dB_Hz, sizeof(double));
|
||||
d_dump_file.read((char *) &carrier_lock_test, sizeof(double));
|
||||
d_dump_file.read((char *) &aux1, sizeof(double));
|
||||
d_dump_file.read((char *) &aux2, sizeof(double));
|
||||
|
||||
}
|
||||
catch (const std::ifstream::failure &e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tracking_dump_reader::restart() {
|
||||
if (d_dump_file.is_open())
|
||||
{
|
||||
d_dump_file.clear();
|
||||
d_dump_file.seekg(0, std::ios::beg);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
long int tracking_dump_reader::num_epochs()
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
int number_of_double_vars=11;
|
||||
int number_of_float_vars=5;
|
||||
int epoch_size_bytes=sizeof(unsigned long int)+
|
||||
sizeof(double)*number_of_double_vars+
|
||||
sizeof(float)*number_of_float_vars;
|
||||
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
|
||||
if (tmpfile.is_open())
|
||||
{
|
||||
size = tmpfile.tellg();
|
||||
long int nepoch=size / epoch_size_bytes;
|
||||
return nepoch;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool tracking_dump_reader::open_obs_file(std::string out_file) {
|
||||
if (d_dump_file.is_open() == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_filename=out_file;
|
||||
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
|
||||
std::cout << "Tracking dump enabled, Log file: " << d_dump_filename.c_str()<< std::endl;
|
||||
return true;
|
||||
}
|
||||
catch (const std::ifstream::failure & e)
|
||||
{
|
||||
std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str()<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tracking_dump_reader::~tracking_dump_reader() {
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Created by javier on 23/1/2017.
|
||||
//
|
||||
|
||||
#ifndef GNSS_SIM_tracking_dump_reader_H
|
||||
#define GNSS_SIM_tracking_dump_reader_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class tracking_dump_reader {
|
||||
|
||||
public:
|
||||
~tracking_dump_reader();
|
||||
bool read_binary_obs();
|
||||
bool restart();
|
||||
long int num_epochs();
|
||||
bool open_obs_file(std::string out_file);
|
||||
|
||||
//tracking dump variables
|
||||
// EPR
|
||||
float abs_E;
|
||||
float abs_P;
|
||||
float abs_L;
|
||||
// PROMPT I and Q (to analyze navigation symbols)
|
||||
float prompt_I;
|
||||
float prompt_Q;
|
||||
// PRN start sample stamp
|
||||
unsigned long int PRN_start_sample_count;
|
||||
|
||||
// accumulated carrier phase
|
||||
double acc_carrier_phase_rad;
|
||||
|
||||
// carrier and code frequency
|
||||
double carrier_doppler_hz;
|
||||
double code_freq_chips;
|
||||
|
||||
// PLL commands
|
||||
double carr_error_hz;
|
||||
double carr_error_filt_hz;
|
||||
|
||||
// DLL commands
|
||||
double code_error_chips;
|
||||
double code_error_filt_chips;
|
||||
|
||||
// CN0 and carrier lock test
|
||||
double CN0_SNV_dB_Hz;
|
||||
double carrier_lock_test;
|
||||
|
||||
// AUX vars (for debug purposes)
|
||||
double aux1;
|
||||
double aux2;
|
||||
|
||||
private:
|
||||
|
||||
std::string d_dump_filename;
|
||||
std::ifstream d_dump_file;
|
||||
|
||||
};
|
||||
|
||||
#endif //GNSS_SIM_tracking_dump_reader_H
|
@ -1,33 +0,0 @@
|
||||
//
|
||||
// Created by javier on 23/1/2017.
|
||||
//
|
||||
|
||||
#ifndef GNSS_SIM_tracking_obs_reader_H
|
||||
#define GNSS_SIM_tracking_obs_reader_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class tracking_obs_reader {
|
||||
|
||||
public:
|
||||
~tracking_obs_reader();
|
||||
bool read_binary_obs(double &signal_timestamp_s,
|
||||
double &acc_carrier_phase_cycles,
|
||||
double &doppler_l1_hz,
|
||||
double &prn_delay_chips,
|
||||
double &tow);
|
||||
bool restart();
|
||||
bool open_obs_file(std::string out_file);
|
||||
bool d_dump;
|
||||
|
||||
private:
|
||||
|
||||
std::string d_dump_filename;
|
||||
std::ifstream d_dump_file;
|
||||
|
||||
};
|
||||
|
||||
#endif //GNSS_SIM_tracking_obs_reader_H
|
@ -2,13 +2,9 @@
|
||||
// Created by javier on 1/2/2017.
|
||||
//
|
||||
|
||||
#include "tracking_obs_reader.h"
|
||||
#include "tracking_true_obs_reader.h"
|
||||
|
||||
bool tracking_obs_reader::read_binary_obs(double &signal_timestamp_s,
|
||||
double &acc_carrier_phase_cycles,
|
||||
double &doppler_l1_hz,
|
||||
double &prn_delay_chips,
|
||||
double &tow)
|
||||
bool tracking_true_obs_reader::read_binary_obs()
|
||||
{
|
||||
try {
|
||||
d_dump_file.read((char *) &signal_timestamp_s, sizeof(double));
|
||||
@ -18,17 +14,39 @@ bool tracking_obs_reader::read_binary_obs(double &signal_timestamp_s,
|
||||
d_dump_file.read((char *) &tow, sizeof(double));
|
||||
}
|
||||
catch (const std::ifstream::failure &e) {
|
||||
std::cout << "Exception writing tracking obs dump file " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tracking_obs_reader::restart() {
|
||||
d_dump_file.clear();
|
||||
d_dump_file.seekg(0, std::ios::beg);
|
||||
bool tracking_true_obs_reader::restart() {
|
||||
if (d_dump_file.is_open())
|
||||
{
|
||||
d_dump_file.clear();
|
||||
d_dump_file.seekg(0, std::ios::beg);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool tracking_obs_reader::open_obs_file(std::string out_file) {
|
||||
long int tracking_true_obs_reader::num_epochs()
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
int number_of_vars_in_epoch=5;
|
||||
int epoch_size_bytes=sizeof(double)*number_of_vars_in_epoch;
|
||||
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
|
||||
if (tmpfile.is_open())
|
||||
{
|
||||
size = tmpfile.tellg();
|
||||
long int nepoch=size / epoch_size_bytes;
|
||||
return nepoch;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool tracking_true_obs_reader::open_obs_file(std::string out_file) {
|
||||
if (d_dump_file.is_open() == false)
|
||||
{
|
||||
try
|
||||
@ -49,7 +67,7 @@ bool tracking_obs_reader::open_obs_file(std::string out_file) {
|
||||
}
|
||||
}
|
||||
|
||||
tracking_obs_reader::~tracking_obs_reader() {
|
||||
tracking_true_obs_reader::~tracking_true_obs_reader() {
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
d_dump_file.close();
|
@ -0,0 +1,36 @@
|
||||
//
|
||||
// Created by javier on 23/1/2017.
|
||||
//
|
||||
|
||||
#ifndef GNSS_SIM_tracking_true_obs_reader_H
|
||||
#define GNSS_SIM_tracking_true_obs_reader_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class tracking_true_obs_reader {
|
||||
|
||||
public:
|
||||
~tracking_true_obs_reader();
|
||||
bool read_binary_obs();
|
||||
bool restart();
|
||||
long int num_epochs();
|
||||
bool open_obs_file(std::string out_file);
|
||||
bool d_dump;
|
||||
|
||||
double signal_timestamp_s;
|
||||
double acc_carrier_phase_cycles;
|
||||
double doppler_l1_hz;
|
||||
double prn_delay_chips;
|
||||
double tow;
|
||||
|
||||
private:
|
||||
|
||||
std::string d_dump_filename;
|
||||
std::ifstream d_dump_file;
|
||||
|
||||
};
|
||||
|
||||
#endif //GNSS_SIM_tracking_true_obs_reader_H
|
@ -31,8 +31,16 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <exception>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <numeric>
|
||||
#include <armadillo>
|
||||
#include <gnuradio/top_block.h>
|
||||
#include <gnuradio/blocks/file_source.h>
|
||||
#include <gnuradio/analog/sig_source_waveform.h>
|
||||
@ -42,6 +50,8 @@
|
||||
#include <gnuradio/blocks/null_sink.h>
|
||||
#include <gnuradio/blocks/skiphead.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "GPS_L1_CA.h"
|
||||
#include "gnss_block_factory.h"
|
||||
#include "gnss_block_interface.h"
|
||||
#include "tracking_interface.h"
|
||||
@ -50,9 +60,24 @@
|
||||
#include "gnss_sdr_valve.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include "gps_l1_ca_telemetry_decoder.h"
|
||||
|
||||
#include "../libs/tracking_true_obs_reader.h"
|
||||
#include "../libs/tracking_dump_reader.h"
|
||||
#include "../libs/tlm_dump_reader.h"
|
||||
|
||||
#include "gps_l1_ca_dll_pll_tracking.h"
|
||||
#include "gps_l1_ca_dll_pll_c_aid_tracking.h"
|
||||
#include "tracking_obs_reader.h"
|
||||
|
||||
DEFINE_string(generator_binary, std::string(SW_GENERATOR_BIN), "Path of software-defined signal generator binary");
|
||||
DEFINE_string(rinex_nav_file, std::string(DEFAULT_RINEX_NAV), "Input RINEX navigation file");
|
||||
DEFINE_int32(duration, 20, "Duration of the experiment [in seconds]");
|
||||
DEFINE_int32(fs_gen_hz, 2600000, "Samppling frequency [Hz]");
|
||||
DEFINE_string(static_position, "30.286502,120.032669,100", "Static receiver position [log,lat,height]");
|
||||
DEFINE_string(dynamic_position, "", "Observer positions file, in .csv or .nmea format");
|
||||
DEFINE_string(filename_rinex_obs, "sim.16o", "Filename of output RINEX navigation file");
|
||||
DEFINE_string(filename_raw_data, "signal_out.bin", "Filename of output raw data file");
|
||||
DEFINE_int32(test_satellite_PRN,1, "PRN of the satellite under test (must be visible during the observation time)");
|
||||
|
||||
|
||||
// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES #########
|
||||
class GpsL1CADllPllTelemetryDecoderTest_msg_rx;
|
||||
@ -164,7 +189,28 @@ GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::~GpsL1CADllPllTelemetryDecoderTest
|
||||
|
||||
class GpsL1CATelemetryDecoderTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
std::string generator_binary;
|
||||
std::string p1;
|
||||
std::string p2;
|
||||
std::string p3;
|
||||
std::string p4;
|
||||
std::string p5;
|
||||
|
||||
const int baseband_sampling_freq = FLAGS_fs_gen_hz;
|
||||
|
||||
std::string filename_rinex_obs = FLAGS_filename_rinex_obs;
|
||||
std::string filename_raw_data = FLAGS_filename_raw_data;
|
||||
std::string generated_rinex_obs;
|
||||
|
||||
int configure_generator();
|
||||
int generate_signal();
|
||||
void check_results(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value);
|
||||
|
||||
GpsL1CATelemetryDecoderTest()
|
||||
{
|
||||
factory = std::make_shared<GNSSBlockFactory>();
|
||||
@ -176,7 +222,7 @@ protected:
|
||||
~GpsL1CATelemetryDecoderTest()
|
||||
{}
|
||||
|
||||
void init();
|
||||
void configure_receiver();
|
||||
|
||||
gr::msg_queue::sptr queue;
|
||||
gr::top_block_sptr top_block;
|
||||
@ -186,16 +232,59 @@ protected:
|
||||
size_t item_size;
|
||||
};
|
||||
|
||||
int GpsL1CATelemetryDecoderTest::configure_generator()
|
||||
{
|
||||
// Configure signal generator
|
||||
generator_binary = FLAGS_generator_binary;
|
||||
|
||||
void GpsL1CATelemetryDecoderTest::init()
|
||||
p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file;
|
||||
if(FLAGS_dynamic_position.empty())
|
||||
{
|
||||
p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position);
|
||||
}
|
||||
p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output
|
||||
p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples
|
||||
p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps]
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GpsL1CATelemetryDecoderTest::generate_signal()
|
||||
{
|
||||
int child_status;
|
||||
|
||||
char *const parmList[] = { &generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL };
|
||||
|
||||
int pid;
|
||||
if ((pid = fork()) == -1)
|
||||
perror("fork err");
|
||||
else if (pid == 0)
|
||||
{
|
||||
execv(&generator_binary[0], parmList);
|
||||
std::cout << "Return not expected. Must be an execv err." << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
waitpid(pid, &child_status, 0);
|
||||
|
||||
std::cout << "Signal and Observables RINEX and RAW files created." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GpsL1CATelemetryDecoderTest::configure_receiver()
|
||||
{
|
||||
gnss_synchro.Channel_ID = 0;
|
||||
gnss_synchro.System = 'G';
|
||||
std::string signal = "1C";
|
||||
signal.copy(gnss_synchro.Signal, 2, 0);
|
||||
gnss_synchro.PRN = 1;
|
||||
gnss_synchro.PRN = FLAGS_test_satellite_PRN;
|
||||
|
||||
config->set_property("GNSS-SDR.internal_fs_hz", "2600000");
|
||||
config->set_property("GNSS-SDR.internal_fs_hz", std::to_string(baseband_sampling_freq));
|
||||
|
||||
// Set Tracking
|
||||
config->set_property("Tracking_1C.item_type", "gr_complex");
|
||||
@ -211,21 +300,57 @@ void GpsL1CATelemetryDecoderTest::init()
|
||||
|
||||
}
|
||||
|
||||
void GpsL1CATelemetryDecoderTest::check_results(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value)
|
||||
{
|
||||
//1. True value interpolation to match the measurement times
|
||||
|
||||
arma::vec true_value_interp;
|
||||
arma::interp1(true_time_s,true_value,meas_time_s,true_value_interp);
|
||||
|
||||
//2. RMSE
|
||||
arma::vec err;
|
||||
|
||||
err=meas_value-true_value_interp;
|
||||
arma::vec err2=arma::square(err);
|
||||
double rmse=sqrt(arma::mean(err2));
|
||||
|
||||
//3. Mean err and variance
|
||||
double error_mean=arma::mean(err);
|
||||
double error_var=arma::var(err);
|
||||
|
||||
//4. report
|
||||
|
||||
std::cout<< std::setprecision(10)<<"Telemetry reported TOW RMSE="<<rmse<<" [s], mean="<<error_mean<<" [s], stdev="<<sqrt(error_var)<<" [s]."<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
|
||||
{
|
||||
|
||||
// Configure the signal generator
|
||||
configure_generator();
|
||||
|
||||
// Generate signal raw signal samples and observations RINEX file
|
||||
generate_signal();
|
||||
|
||||
struct timeval tv;
|
||||
long long int begin = 0;
|
||||
long long int end = 0;
|
||||
int fs_in = 2600000;
|
||||
|
||||
init();
|
||||
|
||||
//todo: call here the gnss simulator
|
||||
configure_receiver();
|
||||
|
||||
//open true observables log file written by the simulator
|
||||
tracking_obs_reader true_obs_data;
|
||||
tracking_true_obs_reader true_obs_data;
|
||||
int test_satellite_PRN = FLAGS_test_satellite_PRN;
|
||||
std::cout<<"Testing satellite PRN="<<test_satellite_PRN<<std::endl;
|
||||
std::string true_obs_file=std::string("./gps_l1_ca_obs_prn");
|
||||
true_obs_file.append(std::to_string(test_satellite_PRN));
|
||||
true_obs_file.append(".dat");
|
||||
ASSERT_NO_THROW({
|
||||
if (true_obs_data.open_obs_file("signal_samples/gps_l1_ca_obs_prn1.dat")==false)
|
||||
if (true_obs_data.open_obs_file(true_obs_file)==false)
|
||||
{
|
||||
throw std::exception();
|
||||
};
|
||||
@ -239,8 +364,20 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
|
||||
|
||||
boost::shared_ptr<GpsL1CADllPllTelemetryDecoderTest_msg_rx> msg_rx = GpsL1CADllPllTelemetryDecoderTest_msg_rx_make();
|
||||
|
||||
gnss_synchro.Acq_delay_samples = (1023-994.622/1023)*fs_in*1e-3;
|
||||
gnss_synchro.Acq_doppler_hz = -2583.86;
|
||||
// load acquisition data based on the first epoch of the true observations
|
||||
ASSERT_NO_THROW({
|
||||
if (true_obs_data.read_binary_obs()==false)
|
||||
{
|
||||
throw std::exception();
|
||||
};
|
||||
})<< "Failure reading true observables file" << std::endl;
|
||||
|
||||
//restart the epoch counter
|
||||
true_obs_data.restart();
|
||||
|
||||
std::cout<<"Initial Doppler [Hz]="<<true_obs_data.doppler_l1_hz<<" Initial code delay [Chips]="<<true_obs_data.prn_delay_chips<<std::endl;
|
||||
gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS-true_obs_data.prn_delay_chips/GPS_L1_CA_CODE_LENGTH_CHIPS)*baseband_sampling_freq*GPS_L1_CA_CODE_PERIOD;
|
||||
gnss_synchro.Acq_doppler_hz = true_obs_data.doppler_l1_hz;
|
||||
gnss_synchro.Acq_samplestamp_samples = 0;
|
||||
|
||||
std::shared_ptr<TelemetryDecoderInterface> tlm(new GpsL1CaTelemetryDecoder(config.get(), "TelemetryDecoder_1C",1, 1));
|
||||
@ -261,20 +398,17 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
|
||||
}) << "Failure connecting tracking to the top_block." << std::endl;
|
||||
|
||||
ASSERT_NO_THROW( {
|
||||
std::string path = std::string(TEST_PATH);
|
||||
std::string file = path + "signal_samples/signal_out.dat";
|
||||
std::string file = "./" + filename_raw_data;
|
||||
const char * file_name = file.c_str();
|
||||
gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false);
|
||||
//boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);
|
||||
gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make();
|
||||
gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro));
|
||||
top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0);
|
||||
//top_block->connect(gr_interleaved_char_to_complex, 0, valve, 0);
|
||||
top_block->connect(gr_interleaved_char_to_complex, 0, tracking->get_left_block(), 0);
|
||||
top_block->connect(tracking->get_right_block(), 0, tlm->get_left_block(), 0);
|
||||
top_block->connect(tlm->get_right_block(), 0, sink, 0);
|
||||
top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
|
||||
}) << "Failure connecting the blocks of tracking test." << std::endl;
|
||||
}) << "Failure connecting the blocks." << std::endl;
|
||||
|
||||
tracking->start_tracking();
|
||||
|
||||
@ -286,7 +420,63 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
|
||||
end = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
}) << "Failure running the top_block." << std::endl;
|
||||
|
||||
// TODO: Verify tracking results
|
||||
std::cout << "Signal tracking completed in " << (end - begin) << " microseconds" << std::endl;
|
||||
//check results
|
||||
//load the true values
|
||||
long int nepoch =true_obs_data.num_epochs();
|
||||
std::cout<<"True observation epochs="<<nepoch<<std::endl;
|
||||
|
||||
arma::vec true_timestamp_s=arma::zeros(nepoch,1);
|
||||
arma::vec true_acc_carrier_phase_cycles=arma::zeros(nepoch,1);
|
||||
arma::vec true_Doppler_Hz=arma::zeros(nepoch,1);
|
||||
arma::vec true_prn_delay_chips=arma::zeros(nepoch,1);
|
||||
arma::vec true_tow_s=arma::zeros(nepoch,1);
|
||||
|
||||
long int epoch_counter=0;
|
||||
while(true_obs_data.read_binary_obs())
|
||||
{
|
||||
true_timestamp_s(epoch_counter)=true_obs_data.signal_timestamp_s;
|
||||
true_acc_carrier_phase_cycles(epoch_counter)=true_obs_data.acc_carrier_phase_cycles;
|
||||
true_Doppler_Hz(epoch_counter)=true_obs_data.doppler_l1_hz;
|
||||
true_prn_delay_chips(epoch_counter)=true_obs_data.prn_delay_chips;
|
||||
true_tow_s(epoch_counter)=true_obs_data.tow;
|
||||
epoch_counter++;
|
||||
}
|
||||
|
||||
|
||||
//load the measured values
|
||||
tlm_dump_reader tlm_dump;
|
||||
ASSERT_NO_THROW({
|
||||
if (tlm_dump.open_obs_file(std::string("./telemetry0.dat"))==false)
|
||||
{
|
||||
throw std::exception();
|
||||
};
|
||||
})<< "Failure opening telemetry dump file" << std::endl;
|
||||
|
||||
nepoch =tlm_dump.num_epochs();
|
||||
std::cout<<"Measured observation epochs="<<nepoch<<std::endl;
|
||||
|
||||
arma::vec tlm_timestamp_s=arma::zeros(nepoch,1);
|
||||
arma::vec tlm_TOW_at_Preamble=arma::zeros(nepoch,1);
|
||||
arma::vec tlm_tow_s=arma::zeros(nepoch,1);
|
||||
|
||||
epoch_counter=0;
|
||||
while(tlm_dump.read_binary_obs())
|
||||
{
|
||||
tlm_timestamp_s(epoch_counter)=tlm_dump.Prn_timestamp_ms/1000.0;
|
||||
tlm_TOW_at_Preamble(epoch_counter)=tlm_dump.d_TOW_at_Preamble;
|
||||
tlm_tow_s(epoch_counter)=tlm_dump.TOW_at_current_symbol;
|
||||
epoch_counter++;
|
||||
|
||||
}
|
||||
|
||||
//Cut measurement initial transitory of the measurements
|
||||
arma::uvec initial_meas_point = arma::find(tlm_tow_s >= true_tow_s(0), 1, "first");
|
||||
|
||||
tlm_timestamp_s=tlm_timestamp_s.subvec(initial_meas_point(0),tlm_timestamp_s.size()-1);
|
||||
tlm_tow_s=tlm_tow_s.subvec(initial_meas_point(0),tlm_tow_s.size()-1);
|
||||
|
||||
check_results(true_timestamp_s,true_tow_s,tlm_timestamp_s,tlm_tow_s);
|
||||
|
||||
std::cout << "Test completed in " << (end - begin) << " microseconds" << std::endl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user