1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Add Galileo UTC and iono model parameters to the assistance system

This commit is contained in:
Carles Fernandez 2018-10-18 15:46:48 +02:00
parent 5181c640a3
commit aca2b28a4d
5 changed files with 153 additions and 26 deletions

View File

@ -474,6 +474,25 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
} }
bool gnss_sdr_supl_client::load_gal_utc_xml(const std::string file_name)
{
std::ifstream ifs;
try
{
ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in);
boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_gal_utc_map", this->gal_utc);
LOG(INFO) << "Loaded Galileo UTC model data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
}
bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::map<int, Gps_Utc_Model> utc_map) bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::map<int, Gps_Utc_Model> utc_map)
{ {
if (utc_map.empty() == false) if (utc_map.empty() == false)
@ -520,6 +539,25 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
} }
bool gnss_sdr_supl_client::load_gal_iono_xml(const std::string file_name)
{
std::ifstream ifs;
try
{
ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in);
boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_iono_gal_map", this->gal_iono);
LOG(INFO) << "Loaded Galileo IONO model data";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
}
bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::map<int, Gps_Iono> iono_map) bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::map<int, Gps_Iono> iono_map)
{ {
if (iono_map.empty() == false) if (iono_map.empty() == false)

View File

@ -48,6 +48,8 @@ extern "C"
#include "gps_ref_location.h" #include "gps_ref_location.h"
#include "gps_cnav_ephemeris.h" #include "gps_cnav_ephemeris.h"
#include "galileo_ephemeris.h" #include "galileo_ephemeris.h"
#include "galileo_utc_model.h"
#include "galileo_iono.h"
#include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/map.hpp> #include <boost/serialization/map.hpp>
@ -86,10 +88,12 @@ public:
// ionospheric model // ionospheric model
Gps_Iono gps_iono; Gps_Iono gps_iono;
Galileo_Iono gal_iono;
// reference time // reference time
Gps_Ref_Time gps_time; Gps_Ref_Time gps_time;
// UTC model // UTC model
Gps_Utc_Model gps_utc; Gps_Utc_Model gps_utc;
Galileo_Utc_Model gal_utc;
// reference location // reference location
Gps_Ref_Location gps_ref_loc; Gps_Ref_Location gps_ref_loc;
// Acquisition Assistance map // Acquisition Assistance map
@ -132,10 +136,15 @@ public:
std::map<int, Gps_Ephemeris> eph_map); std::map<int, Gps_Ephemeris> eph_map);
/*! /*!
* \brief Read utc model from XML file * \brief Read GPS utc model from XML file
*/ */
bool load_utc_xml(const std::string file_name); bool load_utc_xml(const std::string file_name);
/*!
* \brief Read Galileo utc model from XML file
*/
bool load_gal_utc_xml(const std::string file_name);
/*! /*!
* \brief Save utc model map to XML file * \brief Save utc model map to XML file
* To be called by ControlThread::gps_utc_model_data_write_to_XML() * To be called by ControlThread::gps_utc_model_data_write_to_XML()
@ -148,6 +157,11 @@ public:
*/ */
bool load_iono_xml(const std::string file_name); bool load_iono_xml(const std::string file_name);
/*!
* \brief Read Galileo iono from XML file
*/
bool load_gal_iono_xml(const std::string file_name);
/*! /*!
* \brief Save iono map to XML file * \brief Save iono map to XML file
*/ */

View File

@ -201,10 +201,12 @@ bool ControlThread::read_assistance_from_XML()
std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename); std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename);
std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model.xml", utc_default_xml_filename); std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model.xml", utc_default_xml_filename);
std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename); std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename);
std::string gal_iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_iono_xml", gal_iono_default_xml_filename);
std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename); std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename);
std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename); std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename);
std::string eph_gal_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_ephemeris_xml", eph_gal_default_xml_filename); std::string eph_gal_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_ephemeris_xml", eph_gal_default_xml_filename);
std::string eph_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); std::string eph_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename);
std::string gal_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_utc_model.xml", gal_utc_default_xml_filename);
std::cout << "Trying to read GNSS ephemeris from XML file(s): " std::cout << "Trying to read GNSS ephemeris from XML file(s): "
<< ((eph_xml_filename.compare(eph_default_xml_filename) != 0) ? eph_xml_filename + " " : "") << ((eph_xml_filename.compare(eph_default_xml_filename) != 0) ? eph_xml_filename + " " : "")
@ -253,39 +255,49 @@ bool ControlThread::read_assistance_from_XML()
} }
ret = true; ret = true;
} }
if (supl_client_acquisition_.load_utc_xml(utc_xml_filename) == true)
{
std::shared_ptr<Gps_Utc_Model> tmp_obj = std::make_shared<Gps_Utc_Model>(supl_client_acquisition_.gps_utc);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
std::cout << "From XML file: Read GPS UTC parameters." << std::endl;
ret = true;
}
if (supl_client_acquisition_.load_iono_xml(iono_xml_filename) == true)
{
std::shared_ptr<Gps_Iono> tmp_obj = std::make_shared<Gps_Iono>(supl_client_acquisition_.gps_iono);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
std::cout << "From XML file: Read GPS iono parameters." << std::endl;
ret = true;
}
if (supl_client_acquisition_.load_gal_iono_xml(gal_iono_xml_filename) == true)
{
std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(supl_client_acquisition_.gal_iono);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
std::cout << "From XML file: Read Galileo iono parameters." << std::endl;
ret = true;
}
if (supl_client_acquisition_.load_gal_utc_xml(gal_utc_xml_filename) == true)
{
std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(supl_client_acquisition_.gal_utc);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
std::cout << "From XML file: Read Galileo iono parameters." << std::endl;
ret = true;
}
if (ret == false) if (ret == false)
{ {
std::cout << "ERROR: SUPL client error reading XML" << std::endl; std::cout << "ERROR: SUPL client error reading XML" << std::endl;
std::cout << "Disabling SUPL assistance..." << std::endl; std::cout << "Disabling SUPL assistance..." << std::endl;
} }
// Only look for {utc, iono, ref time, ref location} if SUPL is enabled
// Only look for {ref time, ref location} if SUPL is enabled
bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false); bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false);
if (enable_gps_supl_assistance == true) if (enable_gps_supl_assistance == true)
{ {
// Try to read UTC model from XML
if (supl_client_acquisition_.load_utc_xml(utc_xml_filename) == true)
{
LOG(INFO) << "SUPL: Read XML UTC model";
std::shared_ptr<Gps_Utc_Model> tmp_obj = std::make_shared<Gps_Utc_Model>(supl_client_acquisition_.gps_utc);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
}
else
{
LOG(INFO) << "SUPL: couldn't read UTC model XML";
}
// Try to read Iono model from XML
if (supl_client_acquisition_.load_iono_xml(iono_xml_filename) == true)
{
LOG(INFO) << "SUPL: Read XML IONO model";
std::shared_ptr<Gps_Iono> tmp_obj = std::make_shared<Gps_Iono>(supl_client_acquisition_.gps_iono);
flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj));
}
else
{
LOG(INFO) << "SUPL: couldn't read IONO model XML";
}
// Try to read Ref Time from XML // Try to read Ref Time from XML
if (supl_client_acquisition_.load_ref_time_xml(ref_time_xml_filename) == true) if (supl_client_acquisition_.load_ref_time_xml(ref_time_xml_filename) == true)
{ {

View File

@ -169,6 +169,8 @@ private:
const std::string ref_location_default_xml_filename = "./gps_ref_location.xml"; const std::string ref_location_default_xml_filename = "./gps_ref_location.xml";
const std::string eph_gal_default_xml_filename = "./gal_ephemeris.xml"; const std::string eph_gal_default_xml_filename = "./gal_ephemeris.xml";
const std::string eph_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml"; const std::string eph_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml";
const std::string gal_iono_default_xml_filename = "./gal_iono.xml";
const std::string gal_utc_default_xml_filename = "./gal_utc_model.xml";
}; };
#endif /*GNSS_SDR_CONTROL_THREAD_H_*/ #endif /*GNSS_SDR_CONTROL_THREAD_H_*/

View File

@ -34,6 +34,8 @@
#include "galileo_ephemeris.h" #include "galileo_ephemeris.h"
#include "gps_utc_model.h" #include "gps_utc_model.h"
#include "gps_iono.h" #include "gps_iono.h"
#include "galileo_utc_model.h"
#include "galileo_iono.h"
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <gpstk/Rinex3NavHeader.hpp> #include <gpstk/Rinex3NavHeader.hpp>
#include <gpstk/Rinex3NavData.hpp> #include <gpstk/Rinex3NavData.hpp>
@ -73,6 +75,8 @@ int main(int argc, char** argv)
Gps_Utc_Model gps_utc_model; Gps_Utc_Model gps_utc_model;
Gps_Iono gps_iono; Gps_Iono gps_iono;
Galileo_Utc_Model gal_utc_model;
Galileo_Iono gal_iono;
int i = 0; int i = 0;
int j = 0; int j = 0;
@ -118,6 +122,27 @@ int main(int argc, char** argv)
gps_iono.d_beta2 = hdr.mapIonoCorr["GPSB"].param[2]; gps_iono.d_beta2 = hdr.mapIonoCorr["GPSB"].param[2];
gps_iono.d_beta3 = hdr.mapIonoCorr["GPSB"].param[3]; gps_iono.d_beta3 = hdr.mapIonoCorr["GPSB"].param[3];
} }
if (hdr.fileSys.compare("E: (GAL)") == 0 || hdr.fileSys.compare("MIXED") == 0)
{
gal_utc_model.A0_6 = hdr.mapTimeCorr["GAUT"].A0;
gal_utc_model.A1_6 = hdr.mapTimeCorr["GAUT"].A1;
gal_utc_model.Delta_tLS_6 = hdr.leapSeconds;
gal_utc_model.t0t_6 = hdr.mapTimeCorr["GAUT"].refSOW;
gal_utc_model.WNot_6 = hdr.mapTimeCorr["GAUT"].refWeek;
gal_utc_model.WN_LSF_6 = hdr.leapWeek;
gal_utc_model.DN_6 = hdr.leapDay;
gal_utc_model.Delta_tLSF_6 = hdr.leapDelta;
gal_iono.ai0_5 = hdr.mapIonoCorr["GAL"].param[0];
gal_iono.ai1_5 = hdr.mapIonoCorr["GAL"].param[1];
gal_iono.ai2_5 = hdr.mapIonoCorr["GAL"].param[2];
gal_iono.Region1_flag_5 = false;
gal_iono.Region2_flag_5 = false;
gal_iono.Region3_flag_5 = false;
gal_iono.Region4_flag_5 = false;
gal_iono.Region5_flag_5 = false;
gal_iono.TOW_5 = 0.0;
gal_iono.WN_5 = 0.0;
}
// Read navigation data // Read navigation data
while (rnffs >> rne) while (rnffs >> rne)
@ -292,6 +317,42 @@ int main(int argc, char** argv)
std::cout << "Generated file: " << xml_filename << std::endl; std::cout << "Generated file: " << xml_filename << std::endl;
} }
if (gal_utc_model.A0_6 != 0)
{
std::ofstream ofs5;
xml_filename = "gal_utc.xml";
try
{
ofs5.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs5);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc", gal_utc_model);
}
catch (std::exception& e)
{
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl;
google::ShutDownCommandLineFlags();
return 1;
}
std::cout << "Generated file: " << xml_filename << std::endl;
}
if (gal_iono.ai0_5 != 0)
{
std::ofstream ofs7;
xml_filename = "gal_iono.xml";
try
{
ofs7.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs7);
xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono", gal_iono);
}
catch (std::exception& e)
{
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << std::endl;
google::ShutDownCommandLineFlags();
return 1;
}
std::cout << "Generated file: " << xml_filename << std::endl;
}
google::ShutDownCommandLineFlags(); google::ShutDownCommandLineFlags();
return 0; return 0;
} }