Re-enabling the GPS L1 warm start ephemeris assistance stored in XML file

This commit is contained in:
Javier Arribas 2016-05-03 12:34:38 +02:00
parent eb8539a725
commit 3d2e72c790
11 changed files with 234 additions and 118 deletions

View File

@ -33,6 +33,9 @@
#include "gps_l1_ca_pvt.h"
#include <glog/logging.h>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/map.hpp>
#include "configuration_interface.h"
using google::LogMessage;
@ -79,14 +82,115 @@ GpsL1CaPvt::GpsL1CaPvt(ConfigurationInterface* configuration,
bool flag_rtcm_server;
flag_rtcm_server = configuration->property(role + ".flag_rtcm_server", false);
// getting names from the config file, if available
// default filename for assistance data
const std::string eph_default_xml_filename = "./gps_ephemeris.xml";
const std::string utc_default_xml_filename = "./gps_utc_model.xml";
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";
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 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);
// make PVT object
pvt_ = gps_l1_ca_make_pvt_cc(in_streams_, dump_, dump_filename_, averaging_depth, flag_averaging, output_rate_ms, display_rate_ms, flag_nmea_tty_port, nmea_dump_filename, nmea_dump_devname, flag_rtcm_server, flag_rtcm_tty_port, rtcm_dump_devname );
DLOG(INFO) << "pvt(" << pvt_->unique_id() << ")";
}
bool GpsL1CaPvt::save_assistance_to_XML()
{
// return variable (true == succeeded)
bool ret = false;
LOG(INFO) << "SUPL: Try to save GPS ephemeris to XML file " << eph_xml_filename_;
std::map<int,Gps_Ephemeris> eph_map=pvt_->get_GPS_L1_ephemeris_map();
if (eph_map.size() > 0)
{
try
{
std::ofstream ofs(eph_xml_filename_.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map);
ofs.close();
LOG(INFO) << "Saved GPS L1 Ephemeris map data";
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
return false;
}
return true;
}
else
{
LOG(WARNING) << "Failed to save Ephemeris, map is empty";
return false;
}
// Only try to save {utc, iono, ref time, ref location} if SUPL is enabled
// bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false);
// if (enable_gps_supl_assistance == true)
// {
// // try to save utc model xml file
// std::map<int, Gps_Utc_Model> utc_copy = global_gps_utc_model_map.get_map_copy();
// if (supl_client_acquisition_.save_utc_map_xml(utc_xml_filename, utc_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved UTC Model XML file";
// //ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save utc XML file";
// //ret = false;
// }
// // try to save iono model xml file
// std::map<int, Gps_Iono> iono_copy = global_gps_iono_map.get_map_copy();
// if (supl_client_acquisition_.save_iono_map_xml(iono_xml_filename, iono_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved IONO Model XML file";
// //ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save iono XML file";
// //ret = false;
// }
// // try to save ref time xml file
// std::map<int, Gps_Ref_Time> ref_time_copy = global_gps_ref_time_map.get_map_copy();
// if (supl_client_acquisition_.save_ref_time_map_xml(ref_time_xml_filename, ref_time_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved Ref Time XML file";
// //ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save ref time XML file";
// //ref = false;
// }
// // try to save ref location xml file
// std::map<int, Gps_Ref_Location> ref_location_copy = global_gps_ref_location_map.get_map_copy();
// if (supl_client_acquisition_.save_ref_location_map_xml(ref_location_xml_filename, ref_location_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved Ref Location XML file";
// //ref = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save ref location XML file";
// //ret = false;
// }
// }
return ret;
}
GpsL1CaPvt::~GpsL1CaPvt()
{}
{
save_assistance_to_XML();
}
void GpsL1CaPvt::connect(gr::top_block_sptr top_block)

View File

@ -90,6 +90,9 @@ private:
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
std::string eph_xml_filename_;
bool save_assistance_to_XML();
};
#endif

View File

@ -33,6 +33,9 @@
#include "hybrid_pvt.h"
#include <glog/logging.h>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/map.hpp>
#include "configuration_interface.h"
@ -79,15 +82,62 @@ HybridPvt::HybridPvt(ConfigurationInterface* configuration,
rtcm_dump_devname = configuration->property(role + ".rtcm_dump_devname", default_rtcm_dump_devname);
bool flag_rtcm_server;
flag_rtcm_server = configuration->property(role + ".flag_rtcm_server", false);
// getting names from the config file, if available
// default filename for assistance data
const std::string eph_default_xml_filename = "./gps_ephemeris.xml";
const std::string utc_default_xml_filename = "./gps_utc_model.xml";
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";
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 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);
// make PVT object
pvt_ = hybrid_make_pvt_cc(in_streams_, dump_, dump_filename_, averaging_depth, flag_averaging, output_rate_ms, display_rate_ms, flag_nmea_tty_port, nmea_dump_filename, nmea_dump_devname, flag_rtcm_server, flag_rtcm_tty_port, rtcm_dump_devname);
DLOG(INFO) << "pvt(" << pvt_->unique_id() << ")";
}
HybridPvt::~HybridPvt()
{}
bool HybridPvt::save_assistance_to_XML()
{
// return variable (true == succeeded)
bool ret = false;
LOG(INFO) << "SUPL: Try to save GPS ephemeris to XML file " << eph_xml_filename_;
std::map<int,Gps_Ephemeris> eph_map=pvt_->get_GPS_L1_ephemeris_map();
if (eph_map.size() > 0)
{
try
{
std::ofstream ofs(eph_xml_filename_.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map);
ofs.close();
LOG(INFO) << "Saved GPS L1 Ephemeris map data";
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
return false;
}
return true;
}
else
{
LOG(WARNING) << "Failed to save Ephemeris, map is empty";
return false;
}
}
HybridPvt::~HybridPvt()
{
save_assistance_to_XML();
}
void HybridPvt::connect(gr::top_block_sptr top_block)
{

View File

@ -88,6 +88,9 @@ private:
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
std::string eph_xml_filename_;
bool save_assistance_to_XML();
};
#endif

View File

@ -144,6 +144,11 @@ void gps_l1_ca_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg)
}
std::map<int,Gps_Ephemeris> gps_l1_ca_pvt_cc::get_GPS_L1_ephemeris_map()
{
return d_ls_pvt->gps_ephemeris_map;
}
gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels,
bool dump, std::string dump_filename,
int averaging_depth,

View File

@ -125,6 +125,14 @@ private:
std::map<int,Gnss_Synchro> gnss_pseudoranges_map;
public:
/*!
* \brief Get latest set of GPS L1 ephemeris from PVT block
*
* It is used to save the assistance data at the receiver shutdown
*/
std::map<int,Gps_Ephemeris> get_GPS_L1_ephemeris_map();
~gps_l1_ca_pvt_cc (); //!< Default destructor
int general_work (int noutput_items, gr_vector_int &ninput_items,

View File

@ -130,6 +130,11 @@ void hybrid_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg)
}
std::map<int,Gps_Ephemeris> hybrid_pvt_cc::get_GPS_L1_ephemeris_map()
{
return d_ls_pvt->gps_ephemeris_map;
}
hybrid_pvt_cc::hybrid_pvt_cc(unsigned int nchannels, bool dump, std::string dump_filename,
int averaging_depth, bool flag_averaging, int output_rate_ms, int display_rate_ms, bool flag_nmea_tty_port,

View File

@ -124,6 +124,13 @@ private:
bool pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b);
public:
/*!
* \brief Get latest set of GPS L1 ephemeris from PVT block
*
* It is used to save the assistance data at the receiver shutdown
*/
std::map<int,Gps_Ephemeris> get_GPS_L1_ephemeris_map();
~hybrid_pvt_cc (); //!< Default destructor
int general_work (int noutput_items, gr_vector_int &ninput_items,

View File

@ -172,21 +172,20 @@ int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_
if (err == 0)
{
read_supl_data();
if (supl_ctx_free(&ctx)) {} // clean it up before leaving
if (supl_ctx_free(&ctx)) {} // clean it up before leaving
}
else
{
/*
* If supl_get_assist() fails, the connection remains open
* and the memory/files are not released.
*/
supl_close(&ctx);
/*
* If supl_get_assist() fails, the connection remains open
* and the memory/files are not released.
*/
supl_close(&ctx);
}
delete [] cstr;
return err;
}
void gnss_sdr_supl_client::read_supl_data()
{
// READ REFERENCE LOCATION
@ -373,11 +372,11 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name)
gps_ephemeris_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gps_ephemeris_map);
ifs.close();
LOG(INFO) << "Loaded Ephemeris map data";
LOG(INFO) << "Loaded Ephemeris map data with "<<this->gps_ephemeris_map.size()<<" satellites";
}
catch (std::exception& e)
{
LOG(ERROR) << e.what() << "File: " << file_name;
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
@ -397,7 +396,7 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
LOG(WARNING) << e.what();
return false;
}
return true;
@ -421,7 +420,7 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
}
catch (std::exception& e)
{
LOG(ERROR) << e.what() << "File: " << file_name;
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
@ -441,7 +440,7 @@ bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::ma
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
LOG(WARNING) << e.what();
return false;
}
return true;
@ -465,7 +464,7 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
}
catch (std::exception& e)
{
LOG(ERROR) << e.what() << "File: " << file_name;
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
@ -485,7 +484,7 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
LOG(WARNING) << e.what();
return false;
}
return true;
@ -509,7 +508,7 @@ bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name)
}
catch (std::exception& e)
{
LOG(ERROR) << e.what() << "File: " << file_name;
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
@ -529,7 +528,7 @@ bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, st
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
LOG(WARNING) << e.what();
return false;
}
return true;
@ -553,7 +552,7 @@ bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name)
}
catch (std::exception& e)
{
LOG(ERROR) << e.what() << "File: " << file_name;
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
return true;
@ -573,7 +572,7 @@ bool gnss_sdr_supl_client::save_ref_location_map_xml(const std::string file_name
}
catch (std::exception& e)
{
LOG(ERROR) << e.what();
LOG(WARNING) << e.what();
return false;
}
return true;

View File

@ -121,6 +121,9 @@ void ControlThread::run()
LOG(ERROR) << "Unable to start flowgraph";
return;
}
//launch GNSS assistance process AFTER the flowgraph is running because the GNURadio asynchronous queues must be already running to transport msgs
assist_GNSS();
// start the keyboard_listener thread
keyboard_thread_ = boost::thread(&ControlThread::keyboard_listener, this);
@ -247,98 +250,8 @@ bool ControlThread::read_assistance_from_XML()
return ret;
}
//todo: The save assistance function needs to be moved to the PVT block because now the global maps are deprecated, and PVT is the only block that have all the information
//bool ControlThread::save_assistance_to_XML()
//{
// // return variable (true == succeeded)
// bool ret = false;
// // getting names from the config file, if available
// 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 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);
//
// LOG(INFO) << "SUPL: Try to save GPS ephemeris to XML file " << eph_xml_filename;
// std::map<int, Gps_Ephemeris> eph_copy = global_gps_ephemeris_map.get_map_copy();
// if (supl_client_ephemeris_.save_ephemeris_map_xml(eph_xml_filename, eph_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved ephemeris XML file";
// ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save ephemeris XML file. Maybe an empty map?";
// ret = false;
// }
// // Only try to save {utc, iono, ref time, ref location} if SUPL is enabled
// bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false);
// if (enable_gps_supl_assistance == true)
// {
// // try to save utc model xml file
// std::map<int, Gps_Utc_Model> utc_copy = global_gps_utc_model_map.get_map_copy();
// if (supl_client_acquisition_.save_utc_map_xml(utc_xml_filename, utc_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved UTC Model XML file";
// //ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save utc XML file";
// //ret = false;
// }
// // try to save iono model xml file
// std::map<int, Gps_Iono> iono_copy = global_gps_iono_map.get_map_copy();
// if (supl_client_acquisition_.save_iono_map_xml(iono_xml_filename, iono_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved IONO Model XML file";
// //ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save iono XML file";
// //ret = false;
// }
// // try to save ref time xml file
// std::map<int, Gps_Ref_Time> ref_time_copy = global_gps_ref_time_map.get_map_copy();
// if (supl_client_acquisition_.save_ref_time_map_xml(ref_time_xml_filename, ref_time_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved Ref Time XML file";
// //ret = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save ref time XML file";
// //ref = false;
// }
// // try to save ref location xml file
// std::map<int, Gps_Ref_Location> ref_location_copy = global_gps_ref_location_map.get_map_copy();
// if (supl_client_acquisition_.save_ref_location_map_xml(ref_location_xml_filename, ref_location_copy) == true)
// {
// LOG(INFO) << "SUPL: Successfully saved Ref Location XML file";
// //ref = true;
// }
// else
// {
// LOG(INFO) << "SUPL: Error while trying to save ref location XML file";
// //ret = false;
// }
// }
// return ret;
//}
void ControlThread::init()
void ControlThread::assist_GNSS()
{
// Instantiates a control queue, a GNSS flowgraph, and a control message factory
control_queue_ = gr::msg_queue::make(0);
flowgraph_ = std::make_shared<GNSSFlowgraph>(configuration_, control_queue_);
control_message_factory_ = std::make_shared<ControlMessageFactory>();
stop_ = false;
processed_control_messages_ = 0;
applied_actions_ = 0;
//######### GNSS Assistance #################################
// GNSS Assistance configuration
bool enable_gps_supl_assistance = configuration_->property("GNSS-SDR.SUPL_gps_enabled", false);
@ -379,7 +292,9 @@ void ControlThread::init()
if (SUPL_read_gps_assistance_xml == true)
{
// read assistance from file
//if (read_assistance_from_XML()) {}
if (read_assistance_from_XML()) {
std::cout<<"GPS assistance data loaded from local XML file."<<std::endl;
}
}
else
{
@ -414,11 +329,11 @@ void ControlThread::init()
{
std::cout << "ERROR: SUPL client for Ephemeris returned " << error << std::endl;
std::cout << "Please check internet connection and SUPL server configuration" << error << std::endl;
//std::cout << "Trying to read ephemeris from XML file" << std::endl;
//if (read_assistance_from_XML() == false)
// {
// std::cout << "ERROR: Could not read Ephemeris file: Disabling SUPL assistance.." << std::endl;
// }
std::cout << "Trying to read ephemeris from XML file" << std::endl;
if (read_assistance_from_XML() == false)
{
std::cout << "ERROR: Could not read Ephemeris file: Disabling SUPL assistance.." << std::endl;
}
}
// Request almanac , IONO and UTC Model
@ -492,6 +407,17 @@ void ControlThread::init()
}
}
}
void ControlThread::init()
{
// Instantiates a control queue, a GNSS flowgraph, and a control message factory
control_queue_ = gr::msg_queue::make(0);
flowgraph_ = std::make_shared<GNSSFlowgraph>(configuration_, control_queue_);
control_message_factory_ = std::make_shared<ControlMessageFactory>();
stop_ = false;
processed_control_messages_ = 0;
applied_actions_ = 0;
}
void ControlThread::read_control_messages()

View File

@ -138,6 +138,12 @@ private:
*/
void gps_acq_assist_data_collector();
/*
* Read initial GNSS assistance from SUPL server or local XML files
*/
void assist_GNSS();
void apply_action(unsigned int what);
std::shared_ptr<GNSSFlowgraph> flowgraph_;
std::shared_ptr<ConfigurationInterface> configuration_;