1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-16 12:12:57 +00:00

read and compare measurements

This commit is contained in:
Carles Fernandez 2016-12-24 15:58:04 +01:00
parent 4c8a74936c
commit c2c96e5391

View File

@ -321,7 +321,6 @@ 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");
@ -339,62 +338,58 @@ int Trk_System_Test::run_receiver()
}
generated_rinex_obs = std::string(without_trailing);
pclose(fp);
return 0;
}
void Trk_System_Test::check_results()
{
std::vector<std::vector<std::map<double, double>> > pseudorange_ref(33);
std::vector<std::vector<std::map<double, double>> > carrierphase_ref(33);
std::vector<std::vector<std::pair<double, double>> > pseudorange_ref(33);
std::vector<std::vector<std::pair<double, double>> > carrierphase_ref(33);
std::vector<std::vector<std::map<double, double>> > pseudorange_meas(33);
std::vector<std::vector<std::map<double, double>> > carrierphase_meas(33);
std::vector<std::vector<std::pair<double, double>> > pseudorange_meas(33);
std::vector<std::vector<std::pair<double, double>> > carrierphase_meas(33);
// Open reference RINEX observables file
// Open and read reference RINEX observables file
try
{
gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs);
r_ref.exceptions(std::ios::failbit);
gpstk::Rinex3ObsData r_ref_data;
gpstk::Rinex3ObsHeader r_ref_header;
gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs);
r_ref.exceptions(std::ios::failbit);
gpstk::Rinex3ObsData r_ref_data;
gpstk::Rinex3ObsHeader r_ref_header;
gpstk::RinexDatum dataobj;
gpstk::RinexDatum dataobj;
r_ref >> r_ref_header;
r_ref >> r_ref_header;
while (r_ref >> r_ref_data)
{
for (int myprn = 1; myprn < 33; myprn++)
{
gpstk::SatID prn( myprn, gpstk::SatID::systemGPS );
//std::cout << " PRN " << myprn << std::endl;
gpstk::CommonTime time = r_ref_data.time;
//std::cout << time << " " << std::endl;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
//std::cout << "Time: " << sow << std::endl;
gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn);
if( pointer == r_ref_data.obs.end() )
while (r_ref >> r_ref_data)
{
// PRN not present; do nothing
}
else
{
dataobj = r_ref_data.getObs(prn, "P1", r_ref_header);
double P1 = dataobj.data;
std::map<double, double> pseudo;
pseudo[sow] = P1;
pseudorange_ref.at(myprn).push_back(pseudo);
for (int myprn = 1; myprn < 33; myprn++)
{
gpstk::SatID prn( myprn, gpstk::SatID::systemGPS );
gpstk::CommonTime time = r_ref_data.time;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header);
double L1 = dataobj.data;
std::map<double, double> carrier;
carrier[sow]= L1;
carrierphase_ref.at(myprn).push_back(carrier);
} // End of 'if( pointer == roe.obs.end() )'
} // end for
} // end while
gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn);
if( pointer == r_ref_data.obs.end() )
{
// PRN not present; do nothing
}
else
{
dataobj = r_ref_data.getObs(prn, "P1", r_ref_header);
double P1 = dataobj.data;
std::pair<double, double> pseudo(sow,P1);
pseudorange_ref.at(myprn).push_back(pseudo);
dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header);
double L1 = dataobj.data;
std::pair<double, double> carrier(sow, L1);
carrierphase_ref.at(myprn).push_back(carrier);
} // End of 'if( pointer == roe.obs.end() )'
} // end for
} // end while
} // End of 'try' block
catch(gpstk::FFStreamError& e)
{
@ -413,58 +408,54 @@ void Trk_System_Test::check_results()
}
// Example: count observations per sat:
std::vector<std::vector<std::map<double, double>> >::iterator iter;
/* std::vector<std::vector<std::pair<double, double>> >::iterator iter;
int prn_id=0;
for(iter = pseudorange_ref.begin(); iter != pseudorange_ref.end(); iter++)
{
double size_v = iter->size();
std::cout << "Size for sat " << prn_id << ": " << size_v << std::endl;
prn_id++;
}
{
double size_v = iter->size();
std::cout << "Size for sat " << prn_id << ": " << size_v << std::endl;
prn_id++;
}*/
// Open GNSS-SDR-generated RINEX observables file
// Open and read GNSS-SDR-generated RINEX observables file
try
{
std::string arg2_gen = std::string("./") + generated_rinex_obs;
gpstk::Rinex3ObsStream r_meas(arg2_gen);
gpstk::Rinex3ObsData r_meas_data;
gpstk::Rinex3ObsHeader r_meas_header;
gpstk::RinexDatum dataobj;
std::string arg2_gen = std::string("./") + generated_rinex_obs;
gpstk::Rinex3ObsStream r_meas(arg2_gen);
r_meas.exceptions(std::ios::failbit);
gpstk::Rinex3ObsData r_meas_data;
gpstk::Rinex3ObsHeader r_meas_header;
gpstk::RinexDatum dataobj;
r_meas >> r_meas_header;
r_meas >> r_meas_header;
while (r_meas >> r_meas_data)
{
for (int myprn = 1; myprn < 33; myprn++)
{
gpstk::SatID prn( myprn, gpstk::SatID::systemGPS );
//std::cout << " PRN " << myprn << std::endl;
gpstk::CommonTime time = r_meas_data.time;
//std::cout << time << " " << std::endl;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
//std::cout << "Time: " << sow << std::endl;
gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn);
if( pointer == r_meas_data.obs.end() )
while (r_meas >> r_meas_data)
{
// PRN not present; do nothing
}
else
{
dataobj = r_meas_data.getObs(prn, "C1", r_meas_header);
double P1 = dataobj.data;
std::map<double, double> pseudo;
pseudo[sow] = P1;
pseudorange_meas.at(myprn).push_back(pseudo);
for (int myprn = 1; myprn < 33; myprn++)
{
gpstk::SatID prn( myprn, gpstk::SatID::systemGPS );
gpstk::CommonTime time = r_meas_data.time;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
dataobj = r_meas_data.getObs(prn, "L1C", r_meas_header);
double L1 = dataobj.data;
std::map<double, double> carrier;
carrier[sow]= L1;
carrierphase_meas.at(myprn).push_back(carrier);
} // End of 'if( pointer == roe.obs.end() )'
} // end for
} // end while
gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn);
if( pointer == r_meas_data.obs.end() )
{
// PRN not present; do nothing
}
else
{
dataobj = r_meas_data.getObs(prn, "C1", r_meas_header);
double P1 = dataobj.data;
std::pair<double, double> pseudo(sow, P1);
pseudorange_meas.at(myprn).push_back(pseudo);
dataobj = r_meas_data.getObs(prn, "L1C", r_meas_header);
double L1 = dataobj.data;
std::pair<double, double> carrier(sow,L1);
carrierphase_meas.at(myprn).push_back(carrier);
} // End of 'if( pointer == roe.obs.end() )'
} // end for
} // end while
} // End of 'try' block
catch(gpstk::FFStreamError& e)
{
@ -482,19 +473,108 @@ void Trk_System_Test::check_results()
exit(1);
}
// Time alignment!
// Time alignment
std::vector<std::vector<std::pair<double, double>> > pseudorange_ref_aligned(33);
std::vector<std::vector<std::pair<double, double>> > carrierphase_ref_aligned(33);
// Read reference pseudoranges from a given satellite
std::vector<std::vector<std::pair<double, double>> >::iterator iter;
std::vector<std::pair<double, double>>::iterator it;
std::vector<std::pair<double, double>>::iterator it2;
// Read obtained pseudoranges from a given satellite
std::vector<std::vector<double>> pr_diff(33);
std::vector<std::vector<double>> cp_diff(33);
std::vector<std::vector<double>>::iterator iter_diff;
std::vector<double>::iterator iter_v;
int prn_id = 0;
for(iter = pseudorange_ref.begin(); iter != pseudorange_ref.end(); iter++)
{
for(it = iter->begin(); it != iter->end(); it++)
{
// If a measure exists for this sow, store it
for(it2 = pseudorange_meas.at(prn_id).begin(); it2 != pseudorange_meas.at(prn_id).end(); it2++)
{
if(std::abs(it->first - it2->first) < 0.001) // store measures closer than 1 ms.
{
pseudorange_ref_aligned.at(prn_id).push_back(*it);
pr_diff.at(prn_id).push_back(it->second - it2->second );
}
}
}
prn_id++;
}
prn_id = 0;
for(iter = carrierphase_ref.begin(); iter != carrierphase_ref.end(); iter++)
{
for(it = iter->begin(); it != iter->end(); it++)
{
// If a measure exists for this sow, store it
for(it2 = carrierphase_meas.at(prn_id).begin(); it2 != carrierphase_meas.at(prn_id).end(); it2++)
{
if(std::abs(it->first - it2->first) < 0.001) // store measures closer than 1 ms.
{
carrierphase_ref_aligned.at(prn_id).push_back(*it);
cp_diff.at(prn_id).push_back(it->second - it2->second );
}
}
}
prn_id++;
}
// Compute pseudorange error
prn_id = 0;
for(iter_diff = pr_diff.begin(); iter_diff != pr_diff.end(); iter_diff++)
{
// For each satellite with reference and measurements aligned in time
int number_obs = 0;
double mean_diff = 0.0;
for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++)
{
//std::cout << *iter_v << std::endl;
mean_diff = mean_diff + *iter_v;
number_obs = number_obs + 1;
}
if(number_obs > 0)
{
mean_diff = mean_diff / number_obs;
std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << mean_diff << std::endl;
}
else
{
mean_diff = 0.0;
}
// Read reference carrier phase from a given satellite
// Read obtained carrier phase from a given satellite
prn_id++;
}
// Compute carrier phase error
prn_id = 0;
for(iter_diff = cp_diff.begin(); iter_diff != cp_diff.end(); iter_diff++)
{
// For each satellite with reference and measurements aligned in time
int number_obs = 0;
double mean_diff = 0.0;
for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++)
{
//std::cout << *iter_v << std::endl;
mean_diff = mean_diff + *iter_v;
number_obs = number_obs + 1;
}
if(number_obs > 0)
{
mean_diff = mean_diff / number_obs;
std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << mean_diff << std::endl;
}
else
{
mean_diff = 0.0;
}
prn_id++;
}
//return 0;
}