1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-31 03:14:56 +00:00

Apply clang-tidy, document new flags

This commit is contained in:
Carles Fernandez 2020-02-25 08:25:19 +01:00
parent be8ea389b5
commit d3f4b1d5a0
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 68 additions and 64 deletions

View File

@ -71,8 +71,8 @@ Despite this flexibility, we recommend using only a single form: `--variable=val
Available command-line flags:
| **Command-line flag** | **Default value** | **Description** |
|:------------------------------:|:-----------------:|:-----------------|
| **Command-line flag** | **Default value** | **Description** |
|:-------------------------:|:-----------------:|:-----------------|
| `--skip_obs_transitory_s` | `30.0` | Skip the initial observable outputs to avoid transitory results [s]. |
| `--skip_obs_ends_s` | `5.0` | Skip the lasts observable outputs to avoid transitory results [s]. |
| `--single_diffs` | `false` | [`true`, `false`]: If `true`, the program also computes the single difference errors for [Carrier Phase](https://gnss-sdr.org/docs/sp-blocks/observables/#carrier-phase-measurement) and [Doppler](https://gnss-sdr.org/docs/sp-blocks/observables/#doppler-shift-measurement) measurements (requires LO synchronization between receivers). |
@ -81,4 +81,6 @@ Available command-line flags:
| `--dupli_sat_prns` | `1,2,3,4` | List of duplicated satellites PRN pairs (_i.e._, `1,2,3,4` indicates that the PRNs 1,2 share the same orbit. The same applies for PRNs 3,4). |
| `--ref_rinex_obs` | `reference.obs` | Filename of reference RINEX observation file. |
| `--test_rinex_obs` | `test.obs` | Filename of tested RINEX observation file. |
| `--remove_rx_clock_error` | `false` | Compute and remove the receivers clock error prior to compute observable differences (requires a valid RINEX nav file for both receivers) |
| `--rinex_nav` | `reference.nav` | Filename of reference RINEX navigation file. Only needed if `remove_rx_clock_error` is set to `true`. |
| `--show_plots` | `true` | [`true`, `false`]: If `true`, and if [gnuplot](http://www.gnuplot.info/) is found on the system, displays results plots on screen. Please set it to `false` for non-interactive testing. |

View File

@ -81,7 +81,7 @@ bool file_exist(const char* fileName)
}
std::map<int, arma::mat> ReadRinexObs(std::string rinex_file, char system, std::string signal)
std::map<int, arma::mat> ReadRinexObs(const std::string& rinex_file, char system, const std::string& signal)
{
std::map<int, arma::mat> obs_map;
if (not file_exist(rinex_file.c_str()))
@ -121,9 +121,9 @@ std::map<int, arma::mat> ReadRinexObs(std::string rinex_file, char system, std::
std::cout << "Reading RINEX OBS file " << rinex_file << " ...\n";
while (r_ref >> r_ref_data)
{
for (std::set<int>::iterator prn_it = PRN_set.begin(); prn_it != PRN_set.end(); ++prn_it)
for (auto& prn_it : PRN_set)
{
prn.id = *prn_it;
prn.id = prn_it;
gpstk::CommonTime time = r_ref_data.time;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
@ -334,7 +334,7 @@ void carrier_phase_double_diff(
std::vector<double>
time_vector(measurement_time.colptr(0), measurement_time.colptr(0) + measurement_time.n_rows);
if (measurement_time.size() > 0)
if (!measurement_time.empty())
{
// debug
// std::vector<double> tmp_time_vec(measurement_time.colptr(0),
@ -424,7 +424,7 @@ void carrier_phase_single_diff(
std::vector<double>
time_vector(measurement_time.colptr(0), measurement_time.colptr(0) + measurement_time.n_rows);
if (measurement_time.size() > 0)
if (!measurement_time.empty())
{
// 2. RMSE
arma::vec err;
@ -517,7 +517,7 @@ void carrier_doppler_double_diff(
std::vector<double>
time_vector(measurement_time.colptr(0), measurement_time.colptr(0) + measurement_time.n_rows);
if (measurement_time.size() > 0)
if (!measurement_time.empty())
{
// debug
// std::vector<double> tmp_time_vec(measurement_time.colptr(0),
@ -606,7 +606,7 @@ void carrier_doppler_single_diff(
std::vector<double>
time_vector(measurement_time.colptr(0), measurement_time.colptr(0) + measurement_time.n_rows);
if (measurement_time.size() > 0)
if (!measurement_time.empty())
{
// 2. RMSE
arma::vec err;
@ -698,7 +698,7 @@ void code_pseudorange_double_diff(
std::vector<double>
time_vector(measurement_time.colptr(0), measurement_time.colptr(0) + measurement_time.n_rows);
if (measurement_time.size() > 0)
if (!measurement_time.empty())
{
// debug
// std::vector<double> tmp_time_vec(measurement_time.colptr(0),
@ -789,7 +789,7 @@ void code_pseudorange_single_diff(
std::vector<double>
time_vector(measurement_time.colptr(0), measurement_time.colptr(0) + measurement_time.n_rows);
if (measurement_time.size() > 0)
if (!measurement_time.empty())
{
// 2. RMSE
arma::vec err;
@ -843,7 +843,7 @@ void code_pseudorange_single_diff(
}
double compute_rx_clock_error(std::string rinex_nav_filename, std::string rinex_obs_file)
double compute_rx_clock_error(const std::string& rinex_nav_filename, const std::string& rinex_obs_file)
{
std::cout << "Computing receiver's clock error..." << std::endl;
if (not file_exist(rinex_nav_filename.c_str()))
@ -879,7 +879,10 @@ double compute_rx_clock_error(std::string rinex_nav_filename, std::string rinex_
rnffs >> hdr;
// Storing the ephemeris in "bcstore"
while (rnffs >> rne) bcestore.addEphemeris(rne);
while (rnffs >> rne)
{
bcestore.addEphemeris(rne);
}
// Setting the criteria for looking up ephemeris
bcestore.SearchNear();
@ -1063,7 +1066,7 @@ void RINEX_doublediff_dupli_sat()
// special test mode for duplicated satellites
// read rinex receiver-under-test observations
std::map<int, arma::mat> test_obs = ReadRinexObs(FLAGS_test_rinex_obs, 'G', std::string("1C\0"));
if (test_obs.size() == 0)
if (test_obs.empty())
{
return;
}
@ -1071,12 +1074,12 @@ void RINEX_doublediff_dupli_sat()
double initial_transitory_s = FLAGS_skip_obs_transitory_s;
std::cout << "Skipping initial transitory of " << initial_transitory_s << " [s]" << std::endl;
arma::uvec index;
for (std::map<int, arma::mat>::iterator it = test_obs.begin(); it != test_obs.end(); ++it)
for (auto& test_ob : test_obs)
{
index = arma::find(it->second.col(0) >= (it->second.col(0)(0) + initial_transitory_s), 1, "first");
index = arma::find(test_ob.second.col(0) >= (test_ob.second.col(0)(0) + initial_transitory_s), 1, "first");
if ((!index.empty()) and (index(0) > 0))
{
it->second.shed_rows(0, index(0));
test_ob.second.shed_rows(0, index(0));
}
}
@ -1134,7 +1137,7 @@ void RINEX_doublediff(bool remove_rx_clock_error)
// read rinex receiver-under-test observations
std::map<int, arma::mat> test_obs = ReadRinexObs(FLAGS_test_rinex_obs, 'G', std::string("1C\0"));
if (ref_obs.size() == 0 or test_obs.size() == 0)
if (ref_obs.empty() or test_obs.empty())
{
return;
}
@ -1155,12 +1158,12 @@ void RINEX_doublediff(bool remove_rx_clock_error)
double initial_transitory_s = FLAGS_skip_obs_transitory_s;
std::cout << "Skipping initial transitory of " << initial_transitory_s << " [s]" << std::endl;
arma::uvec index;
for (std::map<int, arma::mat>::iterator it = test_obs.begin(); it != test_obs.end(); ++it)
for (auto& test_ob : test_obs)
{
index = arma::find(it->second.col(0) >= (it->second.col(0)(0) + initial_transitory_s), 1, "first");
index = arma::find(test_ob.second.col(0) >= (test_ob.second.col(0)(0) + initial_transitory_s), 1, "first");
if ((!index.empty()) and (index(0) > 0))
{
it->second.shed_rows(0, index(0));
test_ob.second.shed_rows(0, index(0));
}
}
@ -1174,12 +1177,12 @@ void RINEX_doublediff(bool remove_rx_clock_error)
// cut rover vector
std::cout << "Cutting rover observations vector end.." << std::endl;
arma::uvec index2;
for (std::map<int, arma::mat>::iterator it = test_obs.begin(); it != test_obs.end(); ++it)
for (auto& test_ob : test_obs)
{
index = arma::find(it->second.col(0) >= ref_obs_time.back(), 1, "first");
index = arma::find(test_ob.second.col(0) >= ref_obs_time.back(), 1, "first");
if ((!index.empty()) and (index(0) > 0))
{
it->second.shed_rows(index(0), it->second.n_rows - 1);
test_ob.second.shed_rows(index(0), test_ob.second.n_rows - 1);
}
}
}
@ -1188,12 +1191,12 @@ void RINEX_doublediff(bool remove_rx_clock_error)
// there are more base observations than rover observations
// cut base vector
std::cout << "Cutting base observations vector end.." << std::endl;
for (std::map<int, arma::mat>::iterator it = ref_obs.begin(); it != ref_obs.end(); ++it)
for (auto& ref_ob : ref_obs)
{
index = arma::find(it->second.col(0) >= test_obs_time.back(), 1, "first");
index = arma::find(ref_ob.second.col(0) >= test_obs_time.back(), 1, "first");
if ((!index.empty()) and (index(0) > 0))
{
it->second.shed_rows(index(0), it->second.n_rows - 1);
ref_ob.second.shed_rows(index(0), ref_ob.second.n_rows - 1);
}
}
}
@ -1204,74 +1207,74 @@ void RINEX_doublediff(bool remove_rx_clock_error)
double skip_ends_s = FLAGS_skip_obs_ends_s;
std::cout << "Skipping last " << skip_ends_s << " [s] of observations" << std::endl;
for (std::map<int, arma::mat>::iterator it = test_obs.begin(); it != test_obs.end(); ++it)
for (auto& test_ob : test_obs)
{
index = arma::find(it->second.col(0) >= (test_obs_time.back() - skip_ends_s), 1, "first");
index = arma::find(test_ob.second.col(0) >= (test_obs_time.back() - skip_ends_s), 1, "first");
if ((!index.empty()) and (index(0) > 0))
{
it->second.shed_rows(index(0), it->second.n_rows - 1);
test_ob.second.shed_rows(index(0), test_ob.second.n_rows - 1);
}
}
for (std::map<int, arma::mat>::iterator it = ref_obs.begin(); it != ref_obs.end(); ++it)
for (auto& ref_ob : ref_obs)
{
index = arma::find(it->second.col(0) >= (ref_obs_time.back() - skip_ends_s), 1, "first");
index = arma::find(ref_ob.second.col(0) >= (ref_obs_time.back() - skip_ends_s), 1, "first");
if ((!index.empty()) and (index(0) > 0))
{
it->second.shed_rows(index(0), it->second.n_rows - 1);
ref_ob.second.shed_rows(index(0), ref_ob.second.n_rows - 1);
}
}
// Save observations in .mat files
std::cout << "Saving RAW observables inputs to .mat files...\n";
for (std::map<int, arma::mat>::iterator it = ref_obs.begin(); it != ref_obs.end(); ++it)
for (auto& ref_ob : ref_obs)
{
// std::cout << it->first << " => " << it->second.n_rows << '\n';
// std::cout << it->first << " has NaN values: " << it->second.has_nan() << '\n';
std::vector<double> tmp_time_vec(it->second.col(0).colptr(0),
it->second.col(0).colptr(0) + it->second.n_rows);
std::vector<double> tmp_vector(it->second.col(2).colptr(0),
it->second.col(2).colptr(0) + it->second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector, std::string("ref_doppler_sat" + std::to_string(it->first)));
std::vector<double> tmp_time_vec(ref_ob.second.col(0).colptr(0),
ref_ob.second.col(0).colptr(0) + ref_ob.second.n_rows);
std::vector<double> tmp_vector(ref_ob.second.col(2).colptr(0),
ref_ob.second.col(2).colptr(0) + ref_ob.second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector, std::string("ref_doppler_sat" + std::to_string(ref_ob.first)));
std::vector<double> tmp_vector2(it->second.col(3).colptr(0),
it->second.col(3).colptr(0) + it->second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector2, std::string("ref_carrier_phase_sat" + std::to_string(it->first)));
std::vector<double> tmp_vector2(ref_ob.second.col(3).colptr(0),
ref_ob.second.col(3).colptr(0) + ref_ob.second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector2, std::string("ref_carrier_phase_sat" + std::to_string(ref_ob.first)));
std::vector<double> tmp_vector3(it->second.col(1).colptr(0),
it->second.col(1).colptr(0) + it->second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector3, std::string("ref_pseudorange_sat" + std::to_string(it->first)));
std::vector<double> tmp_vector3(ref_ob.second.col(1).colptr(0),
ref_ob.second.col(1).colptr(0) + ref_ob.second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector3, std::string("ref_pseudorange_sat" + std::to_string(ref_ob.first)));
}
for (std::map<int, arma::mat>::iterator it = test_obs.begin(); it != test_obs.end(); ++it)
for (auto& test_ob : test_obs)
{
// std::cout << it->first << " => " << it->second.n_rows << '\n';
// std::cout << it->first << " has NaN values: " << it->second.has_nan() << '\n';
std::vector<double> tmp_time_vec(it->second.col(0).colptr(0),
it->second.col(0).colptr(0) + it->second.n_rows);
std::vector<double> tmp_vector(it->second.col(2).colptr(0),
it->second.col(2).colptr(0) + it->second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector, std::string("measured_doppler_sat" + std::to_string(it->first)));
std::vector<double> tmp_time_vec(test_ob.second.col(0).colptr(0),
test_ob.second.col(0).colptr(0) + test_ob.second.n_rows);
std::vector<double> tmp_vector(test_ob.second.col(2).colptr(0),
test_ob.second.col(2).colptr(0) + test_ob.second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector, std::string("measured_doppler_sat" + std::to_string(test_ob.first)));
std::vector<double> tmp_vector2(it->second.col(3).colptr(0),
it->second.col(3).colptr(0) + it->second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector2, std::string("measured_carrier_phase_sat" + std::to_string(it->first)));
std::vector<double> tmp_vector2(test_ob.second.col(3).colptr(0),
test_ob.second.col(3).colptr(0) + test_ob.second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector2, std::string("measured_carrier_phase_sat" + std::to_string(test_ob.first)));
std::vector<double> tmp_vector3(it->second.col(1).colptr(0),
it->second.col(1).colptr(0) + it->second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector3, std::string("measured_pseudorange_sat" + std::to_string(it->first)));
std::vector<double> tmp_vector3(test_ob.second.col(1).colptr(0),
test_ob.second.col(1).colptr(0) + test_ob.second.n_rows);
save_mat_xy(tmp_time_vec, tmp_vector3, std::string("measured_pseudorange_sat" + std::to_string(test_ob.first)));
}
// select reference satellite
std::set<int> PRN_set = available_gps_prn;
double min_range = std::numeric_limits<double>::max();
int ref_sat_id = 1;
for (std::set<int>::iterator ref_prn_it = PRN_set.begin(); ref_prn_it != PRN_set.end(); ++ref_prn_it)
for (auto& ref_prn_it : PRN_set)
{
if (ref_obs.find(*ref_prn_it) != ref_obs.end() and test_obs.find(*ref_prn_it) != test_obs.end())
if (ref_obs.find(ref_prn_it) != ref_obs.end() and test_obs.find(ref_prn_it) != test_obs.end())
{
if (test_obs.at(*ref_prn_it).at(0, 1) < min_range)
if (test_obs.at(ref_prn_it).at(0, 1) < min_range)
{
min_range = test_obs.at(*ref_prn_it).at(0, 1);
ref_sat_id = *ref_prn_it;
min_range = test_obs.at(ref_prn_it).at(0, 1);
ref_sat_id = ref_prn_it;
}
}
}
@ -1280,9 +1283,8 @@ void RINEX_doublediff(bool remove_rx_clock_error)
if (ref_obs.find(ref_sat_id) != ref_obs.end() and test_obs.find(ref_sat_id) != test_obs.end())
{
std::cout << "Using reference satellite SV " << ref_sat_id << " with minimum range of " << min_range << " [meters]" << std::endl;
for (std::set<int>::iterator current_prn_it = PRN_set.begin(); current_prn_it != PRN_set.end(); ++current_prn_it)
for (auto& current_sat_id : PRN_set)
{
int current_sat_id = *current_prn_it;
if (current_sat_id != ref_sat_id)
{
if (ref_obs.find(current_sat_id) != ref_obs.end() and test_obs.find(current_sat_id) != test_obs.end())