1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-09-29 15:30:52 +00:00

Add RINEX validations

This commit is contained in:
Carles Fernandez 2016-12-22 16:58:09 +01:00
parent 7f9d3c385d
commit 2c393af75a

View File

@ -1,8 +1,11 @@
#include <iostream>
#include <unistd.h>
#include <sys/wait.h>
#include <exception>
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
@ -12,7 +15,12 @@
#include "concurrent_queue.h"
#include "in_memory_configuration.h"
DEFINE_string(generator_binary, std::string(SW_GENERATOR_BIN), "Path of Software Geenrator binary");
DEFINE_string(rinex_nav_file, std::string(DEFAULT_RINEX_NAV), "Input RINEX navigation file");
DEFINE_int32(duration, 100, "Duration of the experiment [in seconds]");
DEFINE_string(static_position, "30.286502,120.032669,100", "Static receiver position [log,lat,height]");
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");
// For GPS NAVIGATION (L1)
concurrent_queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
@ -31,18 +39,19 @@ public:
const int baseband_sampling_freq = 2.6e6;
std::string filename_rinex_obs = "sim.16o";
std::string filename_raw_data = "signal_out.bin";
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();
int check_results();
void check_results();
bool check_valid_rinex_nav(std::string filename); // return true if the file is a valid Rinex navigation file.
bool check_valid_rinex_obs(std::string filename); // return true if the file is a valid Rinex observation file.
std::shared_ptr<InMemoryConfiguration> config;
std::string generated_rinex_obs;
};
@ -64,16 +73,14 @@ bool Trk_System_Test::check_valid_rinex_obs(std::string filename)
int Trk_System_Test::configure_generator()
{
// Configure signal
generator_binary = std::string(SW_GENERATOR_BIN);
// Configure signal generator
generator_binary = FLAGS_generator_binary;
EXPECT_EQ(true, check_valid_rinex_nav(std::string(DEFAULT_RINEX_NAV)));
p1 = std::string("-rinex_nav_file=") + std::string(DEFAULT_RINEX_NAV);
p2_static = std::string("-static_position=30.286502,120.032669,100,1000");
p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file;
p2_static = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10);
p2_dynamic = std::string("-obs_pos_file=") + std::string(DEFAULT_POSITION_FILE); // Observer positions file, in .csv or .nmea format"
p3 = std::string("-rinex_obs_file=") + filename_rinex_obs; // RINEX 2.10 observation file output
p4 = std::string("-sig_out_file=") + filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples
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;
}
@ -277,16 +284,79 @@ int Trk_System_Test::run_receiver()
{
std::cout << "STD exception: " << ex.what();
}
// Get the name of the RINEX obs file generated by the receiver
FILE *fp;
std::string argum2 = std::string("/bin/ls *O | tail -1");
char buffer[1035];
fp = popen(&argum2[0], "r");
if (fp == NULL)
{
printf("Failed to run command\n" );
}
char * without_trailing;
while (fgets(buffer, sizeof(buffer), fp) != NULL)
{
std::string aux = std::string(buffer);
without_trailing = strtok(&aux[0], "\n");
}
generated_rinex_obs = std::string(without_trailing);
pclose(fp);
return 0;
}
int Trk_System_Test::check_results()
void Trk_System_Test::check_results()
{
// Open reference RINEX observables file
pid_t wait_result;
int child_status;
std::string RinDump = std::string("RinDump");
std::string path_RinDump = std::string(GPSTK_BINDIR) + RinDump;
std::string arg1 = std::string("--obs");
std::string arg2 = std::string("./") + FLAGS_filename_rinex_obs;
std::string arg3 = std::string("9");
std::string arg4 = std::string("C1C");
std::string arg5 = std::string("--headless");
FILE *fp;
FILE *fp2;
int status;
char buffer[1035];
/* Open the command for reading. */
std::string argum = path_RinDump + " " + arg1 + " " + arg2 + " " + arg3 + " " + arg4 + " " + arg5;
fp = popen(&argum[0], "r");
if (fp == NULL)
{
printf("Failed to run command\n" );
}
/* Read the output a line at a time - output it. */
while (fgets(buffer, sizeof(buffer), fp) != NULL)
{
printf("Reading line: %s", buffer);
}
pclose(fp);
// Open generated RINEX observables file
std::string arg2_gen = "./" + generated_rinex_obs;
std::string argum2 = path_RinDump + " " + arg1 + " " + arg2_gen + " " + arg3 + " " + arg4 + " " + arg5;
fp2 = popen(&argum2[0], "r");
if (fp2 == NULL)
{
printf("Failed to run command\n" );
}
/* Read the output a line at a time - output it. */
while (fgets(buffer, sizeof(buffer), fp2) != NULL)
{
printf("Reading generated line: %s", buffer);
}
pclose(fp2);
// Time alignment!
// Read reference pseudoranges from a given satellite
@ -300,24 +370,39 @@ int Trk_System_Test::check_results()
// Read obtained carrier phase from a given satellite
// Compute carrier phase error
return 0;
//return 0;
}
TEST_F(Trk_System_Test, Tracking_system_test)
{
std::cout << "Validating input RINEX nav file: " << FLAGS_rinex_nav_file << " ..." << std::endl;
bool is_rinex_nav_valid = check_valid_rinex_nav(FLAGS_rinex_nav_file);
ASSERT_EQ(true, is_rinex_nav_valid);
std::cout << "The file is valid." << std::endl;
// Configure the signal generator
configure_generator();
// Generate signal raw signal samples and observations RINEX file
generate_signal();
std::cout << "Validating generated reference RINEX obs file: " << FLAGS_filename_rinex_obs << " ..." << std::endl;
bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + FLAGS_filename_rinex_obs);
ASSERT_EQ(true, is_gen_rinex_obs_valid);
std::cout << "The file is valid." << std::endl;
// Configure receiver
configure_receiver();
// Run the receiver
run_receiver();
std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << generated_rinex_obs << " ..." << std::endl;
is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + generated_rinex_obs);
ASSERT_EQ(true, is_gen_rinex_obs_valid);
std::cout << "The file is valid." << std::endl;
// Check results
check_results();
}