From 2a69e63534e7acea619d0ef2ea4ddf575f1459c4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 17 Oct 2018 18:22:04 +0200 Subject: [PATCH 1/4] Enable Assited GNSS for Galileo signals --- src/core/libs/gnss_sdr_supl_client.cc | 41 +++++++++++++++++++++++++++ src/core/libs/gnss_sdr_supl_client.h | 16 ++++++++++- src/core/receiver/control_thread.cc | 16 ++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 4d3668adc..4d86dc8be 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -388,6 +388,47 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) } +bool gnss_sdr_supl_client::load_gal_ephemeris_xml(const std::string file_name) +{ + std::ifstream ifs; + try + { + ifs.close(); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gal_ephemeris_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gal_ephemeris_map); + LOG(INFO) << "Loaded Ephemeris map data with " << this->gal_ephemeris_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + + +bool gnss_sdr_supl_client::load_cnav_ephemeris_xml(const std::string file_name) +{ + std::ifstream ifs; + try + { + ifs.close(); + ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); + boost::archive::xml_iarchive xml(ifs); + gps_cnav_ephemeris_map.clear(); + xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gps_cnav_ephemeris_map); + LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_cnav_ephemeris_map.size() << " satellites"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what() << "File: " << file_name; + return false; + } + return true; +} + bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, std::map eph_map) { if (eph_map.empty() == false) diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index 381045edb..eaa594390 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -46,6 +46,8 @@ extern "C" #include "gps_acq_assist.h" #include "gps_ref_time.h" #include "gps_ref_location.h" +#include "gps_cnav_ephemeris.h" +#include "galileo_ephemeris.h" #include #include #include @@ -77,6 +79,8 @@ public: int request; // ephemeris map std::map gps_ephemeris_map; + std::map gal_ephemeris_map; + std::map gps_cnav_ephemeris_map; // almanac map std::map gps_almanac_map; @@ -107,10 +111,20 @@ public: void read_supl_data(); /*! - * \brief Read ephemeris map from XML file + * \brief Read GPS NAV ephemeris map from XML file */ bool load_ephemeris_xml(const std::string file_name); + /*! + * \brief Read GPS CNAV ephemeris map from XML file + */ + bool load_cnav_ephemeris_xml(const std::string file_name); + + /*! + * \brief Read Galileo ephemeris map from XML file + */ + bool load_gal_ephemeris_xml(const std::string file_name); + /*! * \brief Save ephemeris map to XML file. */ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 8eb49563c..cab08ccb7 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -204,7 +204,7 @@ bool ControlThread::read_assistance_from_XML() 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::cout << "SUPL: Try read GPS ephemeris from XML file " << eph_xml_filename << std::endl; + std::cout << "SUPL: Try read GNSS ephemeris from XML file " << eph_xml_filename << std::endl; if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) { std::map::const_iterator gps_eph_iter; @@ -218,6 +218,20 @@ bool ControlThread::read_assistance_from_XML() } ret = true; } + else if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) + { + std::map::const_iterator gal_eph_iter; + for (gal_eph_iter = supl_client_ephemeris_.gal_ephemeris_map.cbegin(); + gal_eph_iter != supl_client_ephemeris_.gal_ephemeris_map.cend(); + gal_eph_iter++) + { + std::cout << "SUPL: Read XML Ephemeris for Galileo SV " << gal_eph_iter->first << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gal_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } + else { std::cout << "ERROR: SUPL client error reading XML" << std::endl; From cc71d0e1a8c0532d3cda7f74883a2d7224376b68 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 17 Oct 2018 19:17:37 +0200 Subject: [PATCH 2/4] Add reading of CNAV ephemeris (L2C and L5 signals) --- src/core/receiver/control_thread.cc | 18 ++++++++++++++++-- src/core/receiver/control_thread.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index cab08ccb7..32a816e5e 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -203,6 +203,8 @@ bool ControlThread::read_assistance_from_XML() std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", 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_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_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); std::cout << "SUPL: Try read GNSS ephemeris from XML file " << eph_xml_filename << std::endl; if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) @@ -218,7 +220,7 @@ bool ControlThread::read_assistance_from_XML() } ret = true; } - else if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) + else if (supl_client_ephemeris_.load_gal_ephemeris_xml(eph_gal_xml_filename) == true) { std::map::const_iterator gal_eph_iter; for (gal_eph_iter = supl_client_ephemeris_.gal_ephemeris_map.cbegin(); @@ -231,7 +233,19 @@ bool ControlThread::read_assistance_from_XML() } ret = true; } - + else if (supl_client_ephemeris_.load_cnav_ephemeris_xml(eph_cnav_xml_filename) == true) + { + std::map::const_iterator gps_cnav_eph_iter; + for (gps_cnav_eph_iter = supl_client_ephemeris_.gps_cnav_ephemeris_map.cbegin(); + gps_cnav_eph_iter != supl_client_ephemeris_.gps_cnav_ephemeris_map.cend(); + gps_cnav_eph_iter++) + { + std::cout << "SUPL: Read XML CNAV Ephemeris for GPS SV " << gps_cnav_eph_iter->first << std::endl; + std::shared_ptr tmp_obj = std::make_shared(gps_cnav_eph_iter->second); + flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); + } + ret = true; + } else { std::cout << "ERROR: SUPL client error reading XML" << std::endl; diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index c49ddba53..d4f1dccf3 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -167,6 +167,8 @@ private: const std::string iono_default_xml_filename = "./gps_iono.xml"; const std::string ref_time_default_xml_filename = "./gps_ref_time.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_cnav_default_xml_filename = "./gps_cnav_ephemeris.xml"; }; #endif /*GNSS_SDR_CONTROL_THREAD_H_*/ From 37a2a899f7584ec95e2a4223f459b7c8bf1790cc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 17 Oct 2018 20:39:06 +0200 Subject: [PATCH 3/4] Fix reading ephemeris from multiple files --- src/core/libs/gnss_sdr_supl_client.cc | 3 +-- src/core/receiver/control_thread.cc | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 4d86dc8be..2e43e9708 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -393,7 +393,6 @@ bool gnss_sdr_supl_client::load_gal_ephemeris_xml(const std::string file_name) std::ifstream ifs; try { - ifs.close(); ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); gal_ephemeris_map.clear(); @@ -414,7 +413,6 @@ bool gnss_sdr_supl_client::load_cnav_ephemeris_xml(const std::string file_name) std::ifstream ifs; try { - ifs.close(); ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in); boost::archive::xml_iarchive xml(ifs); gps_cnav_ephemeris_map.clear(); @@ -429,6 +427,7 @@ bool gnss_sdr_supl_client::load_cnav_ephemeris_xml(const std::string file_name) return true; } + bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, std::map eph_map) { if (eph_map.empty() == false) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 32a816e5e..bfcdc01aa 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -205,8 +205,13 @@ bool ControlThread::read_assistance_from_XML() 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_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); - - std::cout << "SUPL: Try read GNSS ephemeris from XML file " << eph_xml_filename << std::endl; + // clang-format off + std::cout << "Trying to read GNSS ephemeris from XML file(s): " + << ((eph_xml_filename.compare(eph_default_xml_filename) != 0) ? eph_xml_filename + " " : "") + << ((eph_gal_xml_filename.compare(eph_gal_default_xml_filename) != 0) ? eph_gal_xml_filename + " " : "") + << ((eph_cnav_xml_filename.compare(eph_cnav_default_xml_filename) != 0) ? eph_gal_xml_filename : "") + << std::endl; + // clang-format on if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) { std::map::const_iterator gps_eph_iter; @@ -214,39 +219,41 @@ bool ControlThread::read_assistance_from_XML() gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); gps_eph_iter++) { - std::cout << "SUPL: Read XML Ephemeris for GPS SV " << gps_eph_iter->first << std::endl; + std::cout << "From XML file: Read NAV ephemeris for GPS SV " << Gnss_Satellite("GPS", gps_eph_iter->first) << std::endl; std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; } - else if (supl_client_ephemeris_.load_gal_ephemeris_xml(eph_gal_xml_filename) == true) + + if (supl_client_ephemeris_.load_gal_ephemeris_xml(eph_gal_xml_filename) == true) { std::map::const_iterator gal_eph_iter; for (gal_eph_iter = supl_client_ephemeris_.gal_ephemeris_map.cbegin(); gal_eph_iter != supl_client_ephemeris_.gal_ephemeris_map.cend(); gal_eph_iter++) { - std::cout << "SUPL: Read XML Ephemeris for Galileo SV " << gal_eph_iter->first << std::endl; + std::cout << "From XML file: Read ephemeris for Galileo SV " << Gnss_Satellite("Galileo", gal_eph_iter->first) << std::endl; std::shared_ptr tmp_obj = std::make_shared(gal_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; } - else if (supl_client_ephemeris_.load_cnav_ephemeris_xml(eph_cnav_xml_filename) == true) + + if (supl_client_ephemeris_.load_cnav_ephemeris_xml(eph_cnav_xml_filename) == true) { std::map::const_iterator gps_cnav_eph_iter; for (gps_cnav_eph_iter = supl_client_ephemeris_.gps_cnav_ephemeris_map.cbegin(); gps_cnav_eph_iter != supl_client_ephemeris_.gps_cnav_ephemeris_map.cend(); gps_cnav_eph_iter++) { - std::cout << "SUPL: Read XML CNAV Ephemeris for GPS SV " << gps_cnav_eph_iter->first << std::endl; + std::cout << "From XML file: Read CNAV ephemeris for GPS SV " << Gnss_Satellite("GPS", gps_cnav_eph_iter->first) << std::endl; std::shared_ptr tmp_obj = std::make_shared(gps_cnav_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } ret = true; } - else + if (ret == false) { std::cout << "ERROR: SUPL client error reading XML" << std::endl; std::cout << "Disabling SUPL assistance..." << std::endl; From 7e410553594c038e2cecd58e0be1bf21368c3f7b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 18 Oct 2018 09:29:21 +0200 Subject: [PATCH 4/4] Improve messages in terminal output --- src/core/receiver/control_thread.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index bfcdc01aa..d92a846b1 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -205,13 +205,13 @@ bool ControlThread::read_assistance_from_XML() 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_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename); - // clang-format off + std::cout << "Trying to read GNSS ephemeris from XML file(s): " << ((eph_xml_filename.compare(eph_default_xml_filename) != 0) ? eph_xml_filename + " " : "") - << ((eph_gal_xml_filename.compare(eph_gal_default_xml_filename) != 0) ? eph_gal_xml_filename + " " : "") + << ((eph_gal_xml_filename.compare(eph_gal_default_xml_filename) != 0) ? eph_gal_xml_filename + " " : "") << ((eph_cnav_xml_filename.compare(eph_cnav_default_xml_filename) != 0) ? eph_gal_xml_filename : "") << std::endl; - // clang-format on + if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) { std::map::const_iterator gps_eph_iter; @@ -219,7 +219,7 @@ bool ControlThread::read_assistance_from_XML() gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.cend(); gps_eph_iter++) { - std::cout << "From XML file: Read NAV ephemeris for GPS SV " << Gnss_Satellite("GPS", gps_eph_iter->first) << std::endl; + std::cout << "From XML file: Read NAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_eph_iter->first) << std::endl; std::shared_ptr tmp_obj = std::make_shared(gps_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } @@ -233,7 +233,7 @@ bool ControlThread::read_assistance_from_XML() gal_eph_iter != supl_client_ephemeris_.gal_ephemeris_map.cend(); gal_eph_iter++) { - std::cout << "From XML file: Read ephemeris for Galileo SV " << Gnss_Satellite("Galileo", gal_eph_iter->first) << std::endl; + std::cout << "From XML file: Read ephemeris for satellite " << Gnss_Satellite("Galileo", gal_eph_iter->first) << std::endl; std::shared_ptr tmp_obj = std::make_shared(gal_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } @@ -247,7 +247,7 @@ bool ControlThread::read_assistance_from_XML() gps_cnav_eph_iter != supl_client_ephemeris_.gps_cnav_ephemeris_map.cend(); gps_cnav_eph_iter++) { - std::cout << "From XML file: Read CNAV ephemeris for GPS SV " << Gnss_Satellite("GPS", gps_cnav_eph_iter->first) << std::endl; + std::cout << "From XML file: Read CNAV ephemeris for satellite " << Gnss_Satellite("GPS", gps_cnav_eph_iter->first) << std::endl; std::shared_ptr tmp_obj = std::make_shared(gps_cnav_eph_iter->second); flowgraph_->send_telemetry_msg(pmt::make_any(tmp_obj)); } @@ -359,7 +359,7 @@ void ControlThread::assist_GNSS() // read assistance from file if (read_assistance_from_XML()) { - std::cout << "GPS assistance data loaded from local XML file." << std::endl; + std::cout << "GNSS assistance data loaded from local XML file(s)." << std::endl; } } else