mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-02-22 22:10:19 +00:00
Fix bugs and defects detected by coverity scan
This commit is contained in:
parent
92cc773067
commit
7bc57587d8
@ -300,8 +300,8 @@ TEST_F(DataTypeAdapter, IbyteToCbyteValidationOfResults)
|
||||
std::cerr << e.code().message() << std::endl;
|
||||
}
|
||||
ifs.close();
|
||||
remove(file_name_input.c_str());
|
||||
remove(file_name_output.c_str());
|
||||
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
||||
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
||||
}
|
||||
|
||||
|
||||
@ -326,8 +326,8 @@ TEST_F(DataTypeAdapter, IbyteToComplexValidationOfResults)
|
||||
std::cerr << e.code().message() << std::endl;
|
||||
}
|
||||
ifs.close();
|
||||
remove(file_name_input.c_str());
|
||||
remove(file_name_output.c_str());
|
||||
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
||||
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
||||
}
|
||||
|
||||
|
||||
@ -352,8 +352,8 @@ TEST_F(DataTypeAdapter, IbyteToCshortValidationOfResults)
|
||||
std::cerr << e.code().message() << std::endl;
|
||||
}
|
||||
ifs.close();
|
||||
remove(file_name_input.c_str());
|
||||
remove(file_name_output.c_str());
|
||||
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
||||
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
||||
}
|
||||
|
||||
|
||||
@ -378,8 +378,8 @@ TEST_F(DataTypeAdapter, IshortToComplexValidationOfResults)
|
||||
std::cerr << e.code().message() << std::endl;
|
||||
}
|
||||
ifs.close();
|
||||
remove(file_name_input.c_str());
|
||||
remove(file_name_output.c_str());
|
||||
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
||||
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
||||
}
|
||||
|
||||
|
||||
@ -404,6 +404,6 @@ TEST_F(DataTypeAdapter, IshortToCshortValidationOfResults)
|
||||
std::cerr << e.code().message() << std::endl;
|
||||
}
|
||||
ifs.close();
|
||||
remove(file_name_input.c_str());
|
||||
remove(file_name_output.c_str());
|
||||
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
||||
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ bool tracking_dump_reader::read_binary_obs()
|
||||
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));
|
||||
|
||||
d_dump_file.read((char *) &PRN, sizeof(unsigned int));
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
@ -61,6 +61,7 @@ bool tracking_dump_reader::read_binary_obs()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool tracking_dump_reader::restart()
|
||||
{
|
||||
if (d_dump_file.is_open())
|
||||
|
@ -79,6 +79,8 @@ public:
|
||||
double aux1;
|
||||
double aux2;
|
||||
|
||||
unsigned int PRN;
|
||||
|
||||
private:
|
||||
std::string d_dump_filename;
|
||||
std::ifstream d_dump_file;
|
||||
|
@ -195,11 +195,11 @@ public:
|
||||
int configure_generator();
|
||||
int generate_signal();
|
||||
void check_results(
|
||||
arma::vec true_ch0_dist_m, arma::vec true_ch1_dist_m,
|
||||
arma::vec true_ch0_tow_s,
|
||||
arma::vec measuded_ch0_Pseudorange_m,
|
||||
arma::vec measuded_ch1_Pseudorange_m,
|
||||
arma::vec measuded_ch0_RX_time_s);
|
||||
arma::vec & true_ch0_dist_m, arma::vec & true_ch1_dist_m,
|
||||
arma::vec & true_ch0_tow_s,
|
||||
arma::vec & measuded_ch0_Pseudorange_m,
|
||||
arma::vec & measuded_ch1_Pseudorange_m,
|
||||
arma::vec & measuded_ch0_RX_time_s);
|
||||
|
||||
HybridObservablesTest()
|
||||
{
|
||||
@ -303,12 +303,12 @@ void HybridObservablesTest::configure_receiver()
|
||||
}
|
||||
|
||||
void HybridObservablesTest::check_results(
|
||||
arma::vec true_ch0_dist_m,
|
||||
arma::vec true_ch1_dist_m,
|
||||
arma::vec true_ch0_tow_s,
|
||||
arma::vec measuded_ch0_Pseudorange_m,
|
||||
arma::vec measuded_ch1_Pseudorange_m,
|
||||
arma::vec measuded_ch0_RX_time_s)
|
||||
arma::vec & true_ch0_dist_m,
|
||||
arma::vec & true_ch1_dist_m,
|
||||
arma::vec & true_ch0_tow_s,
|
||||
arma::vec & measuded_ch0_Pseudorange_m,
|
||||
arma::vec & measuded_ch1_Pseudorange_m,
|
||||
arma::vec & measuded_ch0_RX_time_s)
|
||||
{
|
||||
//1. True value interpolation to match the measurement times
|
||||
|
||||
@ -343,13 +343,14 @@ void HybridObservablesTest::check_results(
|
||||
double min_error = arma::min(err);
|
||||
|
||||
//5. report
|
||||
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(10) << "Delta Observables RMSE="
|
||||
<< rmse << ", mean=" << error_mean
|
||||
<< ", stdev=" << sqrt(error_var)
|
||||
<< " (max,min)=" << max_error
|
||||
<< "," << min_error
|
||||
<< " [meters]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
|
||||
ASSERT_LT(rmse, 10E-3);
|
||||
ASSERT_LT(error_mean, 10E-3);
|
||||
|
@ -190,10 +190,10 @@ public:
|
||||
|
||||
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);
|
||||
void check_results(arma::vec & true_time_s,
|
||||
arma::vec & true_value,
|
||||
arma::vec & meas_time_s,
|
||||
arma::vec & meas_value);
|
||||
|
||||
GpsL1CATelemetryDecoderTest()
|
||||
{
|
||||
@ -283,10 +283,10 @@ void GpsL1CATelemetryDecoderTest::configure_receiver()
|
||||
|
||||
}
|
||||
|
||||
void GpsL1CATelemetryDecoderTest::check_results(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value)
|
||||
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
|
||||
|
||||
@ -309,13 +309,14 @@ void GpsL1CATelemetryDecoderTest::check_results(arma::vec true_time_s,
|
||||
double min_error = arma::min(err);
|
||||
|
||||
//5. report
|
||||
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(10) << "TLM TOW RMSE="
|
||||
<< rmse << ", mean=" << error_mean
|
||||
<< ", stdev=" << sqrt(error_var)
|
||||
<< " (max,min)=" << max_error
|
||||
<< "," << min_error
|
||||
<< " [Seconds]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
|
||||
ASSERT_LT(rmse, 0.2E-6);
|
||||
ASSERT_LT(error_mean, 0.2E-6);
|
||||
|
@ -128,18 +128,18 @@ public:
|
||||
|
||||
int configure_generator();
|
||||
int generate_signal();
|
||||
void check_results_doppler(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value);
|
||||
void check_results_acc_carrier_phase(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value);
|
||||
void check_results_codephase(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value);
|
||||
void check_results_doppler(arma::vec & true_time_s,
|
||||
arma::vec & true_value,
|
||||
arma::vec & meas_time_s,
|
||||
arma::vec & meas_value);
|
||||
void check_results_acc_carrier_phase(arma::vec & true_time_s,
|
||||
arma::vec & true_value,
|
||||
arma::vec & meas_time_s,
|
||||
arma::vec & meas_value);
|
||||
void check_results_codephase(arma::vec & true_time_s,
|
||||
arma::vec & true_value,
|
||||
arma::vec & meas_time_s,
|
||||
arma::vec & meas_value);
|
||||
|
||||
GpsL1CADllPllTrackingTest()
|
||||
{
|
||||
@ -226,14 +226,22 @@ void GpsL1CADllPllTrackingTest::configure_receiver()
|
||||
config->set_property("Tracking_1C.early_late_space_chips", "0.5");
|
||||
}
|
||||
|
||||
void GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value)
|
||||
|
||||
void GpsL1CADllPllTrackingTest::check_results_doppler(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::uvec true_time_s_valid = find(true_time_s > 0);
|
||||
true_time_s = true_time_s(true_time_s_valid);
|
||||
true_value = true_value(true_time_s_valid);
|
||||
arma::uvec meas_time_s_valid = find(meas_time_s > 0);
|
||||
meas_time_s = meas_time_s(meas_time_s_valid);
|
||||
meas_value = meas_value(meas_time_s_valid);
|
||||
|
||||
arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp);
|
||||
|
||||
//2. RMSE
|
||||
@ -252,26 +260,32 @@ void GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec true_time_s,
|
||||
double min_error = arma::min(err);
|
||||
|
||||
//5. report
|
||||
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(10) << "TRK Doppler RMSE=" << rmse
|
||||
<< ", mean=" << error_mean
|
||||
<< ", stdev="<< sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl;
|
||||
|
||||
std::cout.precision (ss);
|
||||
}
|
||||
|
||||
void GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value)
|
||||
|
||||
void GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(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::uvec true_time_s_valid = find(true_time_s > 0);
|
||||
true_time_s = true_time_s(true_time_s_valid);
|
||||
true_value = true_value(true_time_s_valid);
|
||||
arma::uvec meas_time_s_valid = find(meas_time_s > 0);
|
||||
meas_time_s = meas_time_s(meas_time_s_valid);
|
||||
meas_value = meas_value(meas_time_s_valid);
|
||||
|
||||
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));
|
||||
@ -285,21 +299,28 @@ void GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(arma::vec true_t
|
||||
double min_error = arma::min(err);
|
||||
|
||||
//5. report
|
||||
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(10) << "TRK acc carrier phase RMSE=" << rmse
|
||||
<< ", mean=" << error_mean
|
||||
<< ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Hz]" << std::endl;
|
||||
|
||||
std::cout.precision (ss);
|
||||
}
|
||||
|
||||
void GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec true_time_s,
|
||||
arma::vec true_value,
|
||||
arma::vec meas_time_s,
|
||||
arma::vec meas_value)
|
||||
|
||||
void GpsL1CADllPllTrackingTest::check_results_codephase(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::uvec true_time_s_valid = find(true_time_s > 0);
|
||||
true_time_s = true_time_s(true_time_s_valid);
|
||||
true_value = true_value(true_time_s_valid);
|
||||
arma::uvec meas_time_s_valid = find(meas_time_s > 0);
|
||||
meas_time_s = meas_time_s(meas_time_s_valid);
|
||||
meas_value = meas_value(meas_time_s_valid);
|
||||
|
||||
arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp);
|
||||
|
||||
//2. RMSE
|
||||
@ -318,13 +339,14 @@ void GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec true_time_s,
|
||||
double min_error = arma::min(err);
|
||||
|
||||
//5. report
|
||||
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(10) << "TRK code phase RMSE=" << rmse
|
||||
<< ", mean=" << error_mean
|
||||
<< ", stdev=" << sqrt(error_var) << " (max,min)=" << max_error << "," << min_error << " [Chips]" << std::endl;
|
||||
|
||||
std::cout.precision (ss);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
{
|
||||
// Configure the signal generator
|
||||
@ -418,31 +440,23 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
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
|
||||
tracking_dump_reader trk_dump;
|
||||
ASSERT_NO_THROW({
|
||||
@ -456,7 +470,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
nepoch = trk_dump.num_epochs();
|
||||
std::cout << "Measured observation epochs=" << nepoch << std::endl;
|
||||
|
||||
|
||||
arma::vec trk_timestamp_s = arma::zeros(nepoch, 1);
|
||||
arma::vec trk_acc_carrier_phase_cycles = arma::zeros(nepoch, 1);
|
||||
arma::vec trk_Doppler_Hz = arma::zeros(nepoch, 1);
|
||||
@ -469,9 +482,8 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI;
|
||||
trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz;
|
||||
|
||||
double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS
|
||||
- GPS_L1_CA_CODE_LENGTH_CHIPS
|
||||
* (fmod((static_cast<double>(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast<double>(baseband_sampling_freq), 1.0e-3) /1.0e-3);
|
||||
double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS
|
||||
* (fmod((static_cast<double>(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast<double>(baseband_sampling_freq), 1.0e-3) / 1.0e-3);
|
||||
|
||||
trk_prn_delay_chips(epoch_counter) = delay_chips;
|
||||
epoch_counter++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user