1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-03-13 23:18:15 +00:00

Print test results in file in a more elegant way

This commit is contained in:
Carles Fernandez 2017-11-10 10:46:53 +01:00
parent 09e9220764
commit f55f3d34a6
2 changed files with 70 additions and 96 deletions

View File

@ -60,6 +60,13 @@ concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map;
class StaticPositionSystemTest: public ::testing::Test
{
public:
int configure_generator();
int generate_signal();
int configure_receiver();
int run_receiver();
void check_results();
private:
std::string generator_binary;
std::string p1;
std::string p2;
@ -72,12 +79,6 @@ public:
std::string filename_rinex_obs = FLAGS_filename_rinex_obs;
std::string filename_raw_data = FLAGS_filename_raw_data;
int configure_generator();
int generate_signal();
int configure_receiver();
int run_receiver();
void check_results();
void print_results(const std::vector<double> & east,
const std::vector<double> & north,
const std::vector<double> & up);
@ -88,13 +89,12 @@ public:
void geodetic2Enu(const double latitude, const double longitude, const double altitude,
double* east, double* north, double* up);
void geodetic2Ecef(const double latitude, const double longitude, const double altitude,
double* x, double* y, double* z);
std::shared_ptr<InMemoryConfiguration> config;
std::shared_ptr<FileConfiguration> config_f;
std::string generated_kml_file;
private:
void geodetic2Ecef(const double latitude, const double longitude, const double altitude,
double* x, double* y, double* z);
};
@ -521,29 +521,41 @@ void StaticPositionSystemTest::check_results()
double sum__u = std::accumulate(pos_u.begin(), pos_u.end(), 0.0);
double mean__u = sum__u / pos_u.size();
std::stringstream stm;
std::ofstream position_test_file;
if(FLAGS_config_file_ptest.empty())
{
std::cout << "---- ACCURACY ----" << std::endl;
std::cout << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
std::cout << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
std::cout << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl;
std::cout << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl;
std::cout << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl;
std::cout << std::endl;
stm << "---- ACCURACY ----" << std::endl;
stm << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
stm << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
stm << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl;
stm << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl;
stm << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl;
stm << std::endl;
}
std::cout << "---- PRECISION ----" << std::endl;
std::cout << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
std::cout << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
std::cout << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl;
std::cout << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "---- PRECISION ----" << std::endl;
stm << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
stm << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
stm << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl;
stm << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << stm.rdbuf();
std::string output_filename = "position_test_output_" + StaticPositionSystemTest::generated_kml_file.erase(StaticPositionSystemTest::generated_kml_file.length() - 3,3) + "txt";
position_test_file.open(output_filename.c_str());
if(position_test_file.is_open())
{
position_test_file << stm.str();
position_test_file.close();
}
// Sanity Check
double precision_SEP = 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision);

View File

@ -359,96 +359,58 @@ void TfttGpsL1CATest::print_TTFF_report(const std::vector<double> & ttff_v, std:
std::string default_str = "default";
source = config_->property("SignalSource.implementation", default_str);
if (ttff_report_file.is_open())
{
ttff_report_file << "---------------------------" << std::endl;
ttff_report_file << " Time-To-First-Fix Report" << std::endl;
ttff_report_file << "---------------------------" << std::endl;
ttff_report_file << "Initial receiver status: ";
if (read_ephemeris)
{
ttff_report_file << "Hot start." << std::endl;
}
else
{
ttff_report_file << "Cold start." << std::endl;
}
ttff_report_file << "A-GNSS: ";
if (agnss && read_ephemeris)
{
ttff_report_file << "Enabled." << std::endl;
}
else
{
ttff_report_file << "Disabled." << std::endl;
}
ttff_report_file << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): ";
for(double ttff_ : ttff) ttff_report_file << ttff_ << " ";
ttff_report_file << std::endl;
ttff_report_file << "TTFF mean: " << mean << " [s]" << std::endl;
if (ttff.size() > 0)
{
ttff_report_file << "TTFF max: " << *max_ttff << " [s]" << std::endl;
ttff_report_file << "TTFF min: " << *min_ttff << " [s]" << std::endl;
}
ttff_report_file << "TTFF stdev: " << stdev << " [s]" << std::endl;
ttff_report_file << "Operating System: " << std::string(HOST_SYSTEM) << std::endl;
ttff_report_file << "Navigation mode: " << "3D" << std::endl;
std::stringstream stm;
if(source.compare("UHD_Signal_Source"))
{
ttff_report_file << "Source: File" << std::endl;
}
else
{
ttff_report_file << "Source: Live" << std::endl;
}
ttff_report_file << "---------------------------" << std::endl;
}
ttff_report_file.close();
std::cout << "---------------------------" << std::endl;
std::cout << " Time-To-First-Fix Report" << std::endl;
std::cout << "---------------------------" << std::endl;
std::cout << "Initial receiver status: ";
stm << "---------------------------" << std::endl;
stm << " Time-To-First-Fix Report" << std::endl;
stm << "---------------------------" << std::endl;
stm << "Initial receiver status: ";
if (read_ephemeris)
{
std::cout << "Hot start." << std::endl;
stm << "Hot start." << std::endl;
}
else
{
std::cout << "Cold start." << std::endl;
stm << "Cold start." << std::endl;
}
std::cout << "A-GNSS: ";
stm << "A-GNSS: ";
if (agnss && read_ephemeris)
{
std::cout << "Enabled." << std::endl;
stm << "Enabled." << std::endl;
}
else
{
std::cout << "Disabled." << std::endl;
stm << "Disabled." << std::endl;
}
std::cout << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): ";
for(double ttff_ : ttff) std::cout << ttff_ << " ";
std::cout << std::endl;
std::cout << "TTFF mean: " << mean << " [s]" << std::endl;
stm << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): ";
for(double ttff_ : ttff) stm << ttff_ << " ";
stm << std::endl;
stm << "TTFF mean: " << mean << " [s]" << std::endl;
if (ttff.size() > 0)
{
std::cout << "TTFF max: " << *max_ttff << " [s]" << std::endl;
std::cout << "TTFF min: " << *min_ttff << " [s]" << std::endl;
stm << "TTFF max: " << *max_ttff << " [s]" << std::endl;
stm << "TTFF min: " << *min_ttff << " [s]" << std::endl;
}
std::cout << "TTFF stdev: " << stdev << " [s]" << std::endl;
std::cout << "Operating System: " << std::string(HOST_SYSTEM) << std::endl;
std::cout << "Navigation mode: " << "3D" << std::endl;
stm << "TTFF stdev: " << stdev << " [s]" << std::endl;
stm << "Operating System: " << std::string(HOST_SYSTEM) << std::endl;
stm << "Navigation mode: " << "3D" << std::endl;
if(source.compare("UHD_Signal_Source"))
{
std::cout << "Source: File" << std::endl;
stm << "Source: File" << std::endl;
}
else
{
std::cout << "Source: Live" << std::endl;
stm << "Source: Live" << std::endl;
}
stm << "---------------------------" << std::endl;
std::cout << stm.rdbuf();
if (ttff_report_file.is_open())
{
ttff_report_file << stm.str();
ttff_report_file.close();
}
std::cout << "---------------------------" << std::endl;
}