mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	code cleaning
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@401 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
		| @@ -135,20 +135,18 @@ void gnss_sdr_supl_client::print_assistance() | |||||||
|                         } |                         } | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_ci) | int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_ci) | ||||||
| { | { | ||||||
|  |  | ||||||
|     // SET SUPL CLIENT INFORMATION |     // SET SUPL CLIENT INFORMATION | ||||||
|     // GSM CELL PARAMETERS |     // GSM CELL PARAMETERS | ||||||
|     mcc = i_mcc; |     mcc = i_mcc; | ||||||
|     mns = i_mns; |     mns = i_mns; | ||||||
|     lac = i_lac; |     lac = i_lac; | ||||||
|     ci = i_ci; |     ci = i_ci; | ||||||
|     supl_set_gsm_cell(&ctx,mcc,mns,lac,ci); |     supl_set_gsm_cell(&ctx, mcc, mns, lac, ci); | ||||||
|  |  | ||||||
|     // PERFORM SUPL COMMUNICATION |     // PERFORM SUPL COMMUNICATION | ||||||
|     char *cstr = new char[server_name.length() + 1]; |     char *cstr = new char[server_name.length() + 1]; | ||||||
| @@ -159,7 +157,7 @@ int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_ | |||||||
|  |  | ||||||
|     //std::cout<<"mcc="<<mcc<<"mns="<<mns<<"lac="<<lac<<"ci="<<ci<<std::endl; |     //std::cout<<"mcc="<<mcc<<"mns="<<mns<<"lac="<<lac<<"ci="<<ci<<std::endl; | ||||||
|     err = supl_get_assist(&ctx, cstr, &assist); |     err = supl_get_assist(&ctx, cstr, &assist); | ||||||
|     if (err==0) |     if (err == 0) | ||||||
|         { |         { | ||||||
|             read_supl_data(); |             read_supl_data(); | ||||||
|         } |         } | ||||||
| @@ -186,7 +184,6 @@ void gnss_sdr_supl_client::read_supl_data() | |||||||
|             gps_time.d_tv_sec = (double)assist.time.stamp.tv_sec; |             gps_time.d_tv_sec = (double)assist.time.stamp.tv_sec; | ||||||
|             gps_time.d_tv_usec = (double)assist.time.stamp.tv_usec; |             gps_time.d_tv_usec = (double)assist.time.stamp.tv_usec; | ||||||
|             gps_time.valid = true; |             gps_time.valid = true; | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     // READ UTC MODEL |     // READ UTC MODEL | ||||||
| @@ -215,8 +212,7 @@ void gnss_sdr_supl_client::read_supl_data() | |||||||
|             gps_iono.d_beta1 = (double)assist.iono.b1 * BETA_1_LSB; |             gps_iono.d_beta1 = (double)assist.iono.b1 * BETA_1_LSB; | ||||||
|             gps_iono.d_beta2 = (double)assist.iono.b2 * BETA_2_LSB; |             gps_iono.d_beta2 = (double)assist.iono.b2 * BETA_2_LSB; | ||||||
|             gps_iono.d_beta3 = (double)assist.iono.b3 * BETA_3_LSB; |             gps_iono.d_beta3 = (double)assist.iono.b3 * BETA_3_LSB; | ||||||
|             gps_iono.valid=true; |             gps_iono.valid = true; | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     // READ SV ALMANAC |     // READ SV ALMANAC | ||||||
| @@ -279,7 +275,7 @@ void gnss_sdr_supl_client::read_supl_data() | |||||||
|                     gps_eph_iterator->second.i_satellite_PRN = e->prn; |                     gps_eph_iterator->second.i_satellite_PRN = e->prn; | ||||||
|                     // SV navigation model |                     // SV navigation model | ||||||
|                     gps_eph_iterator->second.i_code_on_L2 = e->bits; |                     gps_eph_iterator->second.i_code_on_L2 = e->bits; | ||||||
|                     gps_eph_iterator->second.i_SV_accuracy = e->ura;//User Range Accuracy (URA) |                     gps_eph_iterator->second.i_SV_accuracy = e->ura; //User Range Accuracy (URA) | ||||||
|                     gps_eph_iterator->second.i_SV_health = e->health; |                     gps_eph_iterator->second.i_SV_health = e->health; | ||||||
|                     gps_eph_iterator->second.d_IODC = (double)e->IODC; |                     gps_eph_iterator->second.d_IODC = (double)e->IODC; | ||||||
|                     //miss P flag (1 bit) |                     //miss P flag (1 bit) | ||||||
| @@ -343,8 +339,8 @@ void gnss_sdr_supl_client::read_supl_data() | |||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) |  | ||||||
|  |  | ||||||
|  | bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) | ||||||
| { | { | ||||||
|     try |     try | ||||||
|     { |     { | ||||||
| @@ -356,14 +352,14 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) | |||||||
|     } |     } | ||||||
|     catch (std::exception& e) |     catch (std::exception& e) | ||||||
|     { |     { | ||||||
|             LOG_AT_LEVEL(ERROR)<< e.what() << "File: "<< file_name; |             LOG_AT_LEVEL(ERROR) << e.what() << "File: " << file_name; | ||||||
|             return false; |             return false; | ||||||
|     } |     } | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool gnss_sdr_supl_client::save_ephemeris_xml(const std::string file_name) |  | ||||||
|  |  | ||||||
|  | bool gnss_sdr_supl_client::save_ephemeris_xml(const std::string file_name) | ||||||
| { | { | ||||||
|     try |     try | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -31,13 +31,12 @@ | |||||||
|  * ------------------------------------------------------------------------- |  * ------------------------------------------------------------------------- | ||||||
|  */ |  */ | ||||||
| #ifndef GNSS_SDR_VERSION | #ifndef GNSS_SDR_VERSION | ||||||
| #define GNSS_SDR_VERSION "0.0.1" | #define GNSS_SDR_VERSION "0.0.2" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #include <boost/filesystem.hpp> | #include <boost/filesystem.hpp> | ||||||
| #include <boost/exception/diagnostic_information.hpp> | #include <boost/exception/diagnostic_information.hpp> | ||||||
| #include <boost/exception_ptr.hpp> | #include <boost/exception_ptr.hpp> | ||||||
|  |  | ||||||
| #include <gflags/gflags.h> | #include <gflags/gflags.h> | ||||||
| #include <glog/log_severity.h> | #include <glog/log_severity.h> | ||||||
| #include <glog/logging.h> | #include <glog/logging.h> | ||||||
| @@ -48,17 +47,14 @@ | |||||||
| #include <boost/thread/thread.hpp> | #include <boost/thread/thread.hpp> | ||||||
| #include "concurrent_queue.h" | #include "concurrent_queue.h" | ||||||
| #include "concurrent_map.h" | #include "concurrent_map.h" | ||||||
|  |  | ||||||
| #include "gps_ephemeris.h" | #include "gps_ephemeris.h" | ||||||
| #include "gps_almanac.h" | #include "gps_almanac.h" | ||||||
| #include "gps_iono.h" | #include "gps_iono.h" | ||||||
| #include "gps_utc_model.h" | #include "gps_utc_model.h" | ||||||
|  |  | ||||||
| #include "galileo_ephemeris.h" | #include "galileo_ephemeris.h" | ||||||
| #include "galileo_almanac.h" | #include "galileo_almanac.h" | ||||||
| #include "galileo_iono.h" | #include "galileo_iono.h" | ||||||
| #include "galileo_utc_model.h" | #include "galileo_utc_model.h" | ||||||
|  |  | ||||||
| #include <sys/time.h> | #include <sys/time.h> | ||||||
| #include <ctime> | #include <ctime> | ||||||
| #include <memory> | #include <memory> | ||||||
| @@ -143,7 +139,7 @@ int main(int argc, char** argv) | |||||||
|                     boost::filesystem::create_directory(p); |                     boost::filesystem::create_directory(p); | ||||||
|                 } |                 } | ||||||
|             std::cout << "Logging with be done at " |             std::cout << "Logging with be done at " | ||||||
|                 << FLAGS_log_dir << std::endl; |                       << FLAGS_log_dir << std::endl; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     std::unique_ptr<ControlThread> control_thread(new ControlThread()); |     std::unique_ptr<ControlThread> control_thread(new ControlThread()); | ||||||
| @@ -153,22 +149,24 @@ int main(int argc, char** argv) | |||||||
|     gettimeofday(&tv, NULL); |     gettimeofday(&tv, NULL); | ||||||
|     long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; |     long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; | ||||||
|  |  | ||||||
|     try{ |     try | ||||||
|     	control_thread->run(); |  | ||||||
|     }catch( boost::exception & e ) |  | ||||||
|     { |     { | ||||||
|     	DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e); |             control_thread->run(); | ||||||
|  |     } | ||||||
|  |     catch( boost::exception & e ) | ||||||
|  |     { | ||||||
|  |             DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e); | ||||||
|     } |     } | ||||||
|     catch(std::exception const&  ex) |     catch(std::exception const&  ex) | ||||||
|     { |     { | ||||||
|     	DLOG(FATAL) <<"STD exception: "<<ex.what(); |             DLOG(FATAL) << "STD exception: " << ex.what(); | ||||||
|     } |     } | ||||||
|     // report the elapsed time |     // report the elapsed time | ||||||
|     gettimeofday(&tv, NULL); |     gettimeofday(&tv, NULL); | ||||||
|     long long int end = tv.tv_sec * 1000000 + tv.tv_usec; |     long long int end = tv.tv_sec * 1000000 + tv.tv_usec; | ||||||
|     std::cout << "Total GNSS-SDR run time " |     std::cout << "Total GNSS-SDR run time " | ||||||
|         << ((double)(end - begin))/1000000.0 |               << ((double)(end - begin))/1000000.0 | ||||||
|         << " [seconds]" << std::endl; |               << " [seconds]" << std::endl; | ||||||
|  |  | ||||||
|     google::ShutDownCommandLineFlags(); |     google::ShutDownCommandLineFlags(); | ||||||
|     std::cout << "GNSS-SDR program ended." << std::endl; |     std::cout << "GNSS-SDR program ended." << std::endl; | ||||||
|   | |||||||
| @@ -1,16 +1,43 @@ | |||||||
|  | /*! | ||||||
|  |  * \file front_end_cal.cc | ||||||
|  |  * \brief Implementation of the Front-end calibration program. | ||||||
|  |  * \author Javier Arribas, 2013. jarribas(at)cttc.es | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  * ------------------------------------------------------------------------- | ||||||
|  |  * | ||||||
|  |  * Copyright (C) 2010-2013  (see AUTHORS file for a list of contributors) | ||||||
|  |  * | ||||||
|  |  * GNSS-SDR is a software defined Global Navigation | ||||||
|  |  *          Satellite Systems receiver | ||||||
|  |  * | ||||||
|  |  * This file is part of GNSS-SDR. | ||||||
|  |  * | ||||||
|  |  * GNSS-SDR is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or | ||||||
|  |  * at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * GNSS-SDR is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  * | ||||||
|  |  * ------------------------------------------------------------------------- | ||||||
|  |  */ | ||||||
|  |  | ||||||
| #include <exception> | #include <exception> | ||||||
| #include <boost/filesystem.hpp> | #include <boost/filesystem.hpp> | ||||||
| #include <gflags/gflags.h> | #include <gflags/gflags.h> | ||||||
| #include <glog/log_severity.h> | #include <glog/log_severity.h> | ||||||
| #include <glog/logging.h> | #include <glog/logging.h> | ||||||
|  |  | ||||||
| #include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | ||||||
| #include <boost/thread/thread.hpp> | #include <boost/thread/thread.hpp> | ||||||
| #include <boost/lexical_cast.hpp> | #include <boost/lexical_cast.hpp> | ||||||
|  |  | ||||||
| #include "file_configuration.h" | #include "file_configuration.h" | ||||||
|  |  | ||||||
| #include "gps_navigation_message.h" | #include "gps_navigation_message.h" | ||||||
| #include "gps_ephemeris.h" | #include "gps_ephemeris.h" | ||||||
| #include "gps_almanac.h" | #include "gps_almanac.h" | ||||||
| @@ -21,362 +48,377 @@ | |||||||
| #include <ctime> | #include <ctime> | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <math.h> | #include <math.h> | ||||||
|  |  | ||||||
| #include "front_end_cal.h" | #include "front_end_cal.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| extern	concurrent_map<Gps_Ephemeris> global_gps_ephemeris_map; | extern concurrent_map<Gps_Ephemeris> global_gps_ephemeris_map; | ||||||
| extern	concurrent_map<Gps_Iono> global_gps_iono_map; | extern concurrent_map<Gps_Iono> global_gps_iono_map; | ||||||
| extern	concurrent_map<Gps_Utc_Model> global_gps_utc_model_map; | extern concurrent_map<Gps_Utc_Model> global_gps_utc_model_map; | ||||||
| extern	concurrent_map<Gps_Almanac> global_gps_almanac_map; | extern concurrent_map<Gps_Almanac> global_gps_almanac_map; | ||||||
| extern	concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map; | extern concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map; | ||||||
|  |  | ||||||
| FrontEndCal::FrontEndCal() | FrontEndCal::FrontEndCal() | ||||||
| { | {} | ||||||
|  |  | ||||||
| } |  | ||||||
| FrontEndCal::~FrontEndCal() | FrontEndCal::~FrontEndCal() | ||||||
| { | {} | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bool FrontEndCal::read_assistance_from_XML() | bool FrontEndCal::read_assistance_from_XML() | ||||||
| { | { | ||||||
| 	gnss_sdr_supl_client supl_client_ephemeris_; |     gnss_sdr_supl_client supl_client_ephemeris_; | ||||||
| 	std::string eph_xml_filename="gps_ephemeris.xml"; |     std::string eph_xml_filename = "gps_ephemeris.xml"; | ||||||
| 	std::cout<< "SUPL: Try read GPS ephemeris from XML file "<<eph_xml_filename<<std::endl; |     std::cout <<  "SUPL: Try read GPS ephemeris from XML file " << eph_xml_filename << std::endl; | ||||||
| 	if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename)==true) |     if (supl_client_ephemeris_.load_ephemeris_xml(eph_xml_filename) == true) | ||||||
| 	{ |         { | ||||||
| 		std::map<int,Gps_Ephemeris>::iterator gps_eph_iter; |             std::map<int,Gps_Ephemeris>::iterator gps_eph_iter; | ||||||
| 		for(gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.begin(); |             for(gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.begin(); | ||||||
| 				gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.end(); |                     gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.end(); | ||||||
| 				gps_eph_iter++) |                     gps_eph_iter++) | ||||||
| 		{ |                 { | ||||||
| 			std::cout<<"SUPL: Read XML Ephemeris for GPS SV "<<gps_eph_iter->first<<std::endl; |                     std::cout << "SUPL: Read XML Ephemeris for GPS SV " << gps_eph_iter->first << std::endl; | ||||||
| 			std::cout << "New Ephemeris record inserted with Toe="<<gps_eph_iter->second.d_Toe<<" and GPS Week="<<gps_eph_iter->second.i_GPS_week<<std::endl; |                     std::cout << "New Ephemeris record inserted with Toe=" << gps_eph_iter->second.d_Toe << " and GPS Week=" << gps_eph_iter->second.i_GPS_week << std::endl; | ||||||
| 			global_gps_ephemeris_map.write(gps_eph_iter->second.i_satellite_PRN,gps_eph_iter->second); |                     global_gps_ephemeris_map.write(gps_eph_iter->second.i_satellite_PRN, gps_eph_iter->second); | ||||||
| 		} |                 } | ||||||
| 		return true; |             return true; | ||||||
| 	}else{ |         } | ||||||
| 		std::cout<< "ERROR: SUPL client error reading XML"<<std::endl; |     else | ||||||
| 		return false; |         { | ||||||
| 	} |             std::cout <<  "ERROR: SUPL client error reading XML" << std::endl; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| int FrontEndCal::Get_SUPL_Assist() | int FrontEndCal::Get_SUPL_Assist() | ||||||
| { | { | ||||||
| 	//#########GNSS Asistence ################################# |     //#########GNSS Asistence ################################# | ||||||
| 	gnss_sdr_supl_client supl_client_acquisition_; |     gnss_sdr_supl_client supl_client_acquisition_; | ||||||
| 	gnss_sdr_supl_client supl_client_ephemeris_; |     gnss_sdr_supl_client supl_client_ephemeris_; | ||||||
| 	int supl_mcc; // Current network MCC (Mobile country code), 3 digits. |     int supl_mcc; // Current network MCC (Mobile country code), 3 digits. | ||||||
| 	int supl_mns; //Current network MNC (Mobile Network code), 2 or 3 digits. |     int supl_mns; //Current network MNC (Mobile Network code), 2 or 3 digits. | ||||||
| 	int supl_lac; // Current network LAC (Location area code),16 bits, 1-65520 are valid values. |     int supl_lac; // Current network LAC (Location area code),16 bits, 1-65520 are valid values. | ||||||
| 	int supl_ci; // Cell Identity (16 bits, 0-65535 are valid values). |     int supl_ci;  // Cell Identity (16 bits, 0-65535 are valid values). | ||||||
| 	// GNSS Assistance configuration |     // GNSS Assistance configuration | ||||||
| 	int error=0; |     int error = 0; | ||||||
| 	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) | ||||||
| 		//SUPL SERVER TEST. Not operational yet! |         //SUPL SERVER TEST. Not operational yet! | ||||||
| 	{ |         { | ||||||
| 		DLOG(INFO) << "SUPL RRLP GPS assistance enabled!"<<std::endl; |             DLOG(INFO) << "SUPL RRLP GPS assistance enabled!" << std::endl; | ||||||
| 		std::string default_acq_server="supl.nokia.com"; |             std::string default_acq_server = "supl.nokia.com"; | ||||||
| 		std::string default_eph_server="supl.google.com"; |             std::string default_eph_server = "supl.google.com"; | ||||||
| 		supl_client_ephemeris_.server_name=configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server",default_acq_server); |             supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", default_acq_server); | ||||||
| 		supl_client_acquisition_.server_name=configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server",default_eph_server); |             supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", default_eph_server); | ||||||
| 		supl_client_ephemeris_.server_port=configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port",7275); |             supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); | ||||||
| 		supl_client_acquisition_.server_port=configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port",7275); |             supl_client_acquisition_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port", 7275); | ||||||
| 		supl_mcc=configuration_->property("GNSS-SDR.SUPL_MCC",244); |             supl_mcc = configuration_->property("GNSS-SDR.SUPL_MCC", 244); | ||||||
| 		supl_mns=configuration_->property("GNSS-SDR.SUPL_MNS",5); |             supl_mns = configuration_->property("GNSS-SDR.SUPL_MNS", 5); | ||||||
|  |  | ||||||
| 		std::string default_lac="0x59e2"; |             std::string default_lac = "0x59e2"; | ||||||
| 		std::string default_ci="0x31b0"; |             std::string default_ci = "0x31b0"; | ||||||
| 		try { |             try | ||||||
| 			supl_lac = boost::lexical_cast<int>(configuration_->property("GNSS-SDR.SUPL_LAC",default_lac)); |             { | ||||||
| 		} catch(boost::bad_lexical_cast &) { |                     supl_lac = boost::lexical_cast<int>(configuration_->property("GNSS-SDR.SUPL_LAC", default_lac)); | ||||||
| 			supl_lac=0x59e2; |             } | ||||||
| 		} |             catch(boost::bad_lexical_cast &) | ||||||
| 		try { |             { | ||||||
| 			supl_ci = boost::lexical_cast<int>(configuration_->property("GNSS-SDR.SUPL_CI",default_ci)); |                     supl_lac = 0x59e2; | ||||||
| 		} catch(boost::bad_lexical_cast &) { |             } | ||||||
| 			supl_ci=0x31b0; |             try | ||||||
| 		} |             { | ||||||
|  |                     supl_ci = boost::lexical_cast<int>(configuration_->property("GNSS-SDR.SUPL_CI", default_ci)); | ||||||
|  |             } | ||||||
|  |             catch(boost::bad_lexical_cast &) | ||||||
|  |             { | ||||||
|  |                     supl_ci = 0x31b0; | ||||||
|  |             } | ||||||
|  |  | ||||||
| 		bool SUPL_read_gps_assistance_xml=configuration_->property("GNSS-SDR.SUPL_read_gps_assistance_xml",false); |             bool SUPL_read_gps_assistance_xml = configuration_->property("GNSS-SDR.SUPL_read_gps_assistance_xml", false); | ||||||
| 		if (SUPL_read_gps_assistance_xml==true) |             if (SUPL_read_gps_assistance_xml == true) | ||||||
| 		{ |                 { | ||||||
| 			// read assistance from file |                     // read assistance from file | ||||||
| 			read_assistance_from_XML(); |                     read_assistance_from_XML(); | ||||||
| 		}else{ |                 } | ||||||
|  |             else | ||||||
|  |                 { | ||||||
|  |                     // Request ephemeris from SUPL server | ||||||
|  |                     supl_client_ephemeris_.request = 1; | ||||||
|  |                     DLOG(INFO) << "SUPL: Trying to read GPS ephemeris from SUPL server..."; | ||||||
|  |                     error = supl_client_ephemeris_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); | ||||||
|  |                     if (error == 0) | ||||||
|  |                         { | ||||||
|  |                             std::map<int,Gps_Ephemeris>::iterator gps_eph_iter; | ||||||
|  |                             for(gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.begin(); | ||||||
|  |                                     gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.end(); | ||||||
|  |                                     gps_eph_iter++) | ||||||
|  |                                 { | ||||||
|  |                                     DLOG(INFO)  << "SUPL: Received Ephemeris for GPS SV " << gps_eph_iter->first; | ||||||
|  |                                     DLOG(INFO)  << "New Ephemeris record inserted with Toe=" << gps_eph_iter->second.d_Toe << " and GPS Week=" << gps_eph_iter->second.i_GPS_week; | ||||||
|  |                                     global_gps_ephemeris_map.write(gps_eph_iter->second.i_satellite_PRN, gps_eph_iter->second); | ||||||
|  |                                 } | ||||||
|  |                             //Save ephemeris to XML file | ||||||
|  |                             std::string eph_xml_filename = "gps_ephemeris.xml"; | ||||||
|  |                             if (supl_client_ephemeris_.save_ephemeris_xml(eph_xml_filename) == true) | ||||||
|  |                                 { | ||||||
|  |                                     DLOG(INFO)  << "SUPL: XML Ephemeris file created."; | ||||||
|  |                                 } | ||||||
|  |                         } | ||||||
|  |                     else | ||||||
|  |                         { | ||||||
|  |                             DLOG(INFO) << "ERROR: SUPL client for Ephemeris returned " << error; | ||||||
|  |                             DLOG(INFO) << "Please check Internet connection and SUPL server configuration" << error; | ||||||
|  |                         } | ||||||
|  |  | ||||||
| 			// Request ephemeris from SUPL server |                     // Request almanac , IONO and UTC Model | ||||||
| 			supl_client_ephemeris_.request=1; |                     supl_client_ephemeris_.request = 0; | ||||||
| 			DLOG(INFO) << "SUPL: Try read GPS ephemeris from SUPL server.."<<std::endl; |                     DLOG(INFO) << "SUPL: Try read Almanac, Iono, Utc Model, Ref Time and Ref Location from SUPL server..."; | ||||||
| 			error=supl_client_ephemeris_.get_assistance(supl_mcc,supl_mns,supl_lac,supl_ci); |                     error = supl_client_ephemeris_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); | ||||||
| 			if (error==0) |                     if (error == 0) | ||||||
| 			{ |                         { | ||||||
| 				std::map<int,Gps_Ephemeris>::iterator gps_eph_iter; |                             std::map<int,Gps_Almanac>::iterator gps_alm_iter; | ||||||
| 				for(gps_eph_iter = supl_client_ephemeris_.gps_ephemeris_map.begin(); |                             for(gps_alm_iter = supl_client_ephemeris_.gps_almanac_map.begin(); | ||||||
| 						gps_eph_iter != supl_client_ephemeris_.gps_ephemeris_map.end(); |                                     gps_alm_iter != supl_client_ephemeris_.gps_almanac_map.end(); | ||||||
| 						gps_eph_iter++) |                                     gps_alm_iter++) | ||||||
| 				{ |                                 { | ||||||
| 					DLOG(INFO) <<"SUPL: Received Ephemeris for GPS SV "<<gps_eph_iter->first<<std::endl; |                                     DLOG(INFO)  << "SUPL: Received Almanac for GPS SV " << gps_alm_iter->first; | ||||||
| 					DLOG(INFO)  << "New Ephemeris record inserted with Toe="<<gps_eph_iter->second.d_Toe<<" and GPS Week="<<gps_eph_iter->second.i_GPS_week<<std::endl; |                                     global_gps_almanac_map.write(gps_alm_iter->first, gps_alm_iter->second); | ||||||
| 					global_gps_ephemeris_map.write(gps_eph_iter->second.i_satellite_PRN,gps_eph_iter->second); |                                 } | ||||||
| 				} |                             if (supl_client_ephemeris_.gps_iono.valid == true) | ||||||
| 				//Save ephemeris to XML file |                                 { | ||||||
| 				std::string eph_xml_filename="gps_ephemeris.xml"; |                                     DLOG(INFO)  << "SUPL: Received GPS Iono"; | ||||||
| 				if (supl_client_ephemeris_.save_ephemeris_xml(eph_xml_filename)==true) |                                     global_gps_iono_map.write(0,supl_client_ephemeris_.gps_iono); | ||||||
| 				{ |                                 } | ||||||
| 					DLOG(INFO) <<"SUPL: XML Ephemeris file created"<<std::endl; |                             if (supl_client_ephemeris_.gps_utc.valid == true) | ||||||
| 				} |                                 { | ||||||
| 			}else{ |                                     DLOG(INFO)  << "SUPL: Received GPS UTC Model"; | ||||||
| 				DLOG(INFO) << "ERROR: SUPL client for Ephemeris returned "<<error<<std::endl; |                                     global_gps_utc_model_map.write(0, supl_client_ephemeris_.gps_utc); | ||||||
| 				DLOG(INFO) << "Please check internet connection and SUPL server configuration"<<error<<std::endl; |                                 } | ||||||
| 			} |                         } | ||||||
|  |                     else | ||||||
|  |                         { | ||||||
|  |                             DLOG(INFO) << "ERROR: SUPL client for Almanac returned " << error; | ||||||
|  |                             DLOG(INFO) << "Please check Internet connection and SUPL server configuration" << error; | ||||||
|  |                         } | ||||||
|  |  | ||||||
| 			// Request almanac , IONO and UTC Model |                     // Request acquisition assistance | ||||||
| 			supl_client_ephemeris_.request=0; |                     supl_client_acquisition_.request = 2; | ||||||
| 			DLOG(INFO) << "SUPL: Try read Almanac, Iono, Utc Model, Ref Time and Ref Location from SUPL server.."<<std::endl; |                     DLOG(INFO) << "SUPL: Trying to read Acquisition assistance from SUPL server..."; | ||||||
| 			error=supl_client_ephemeris_.get_assistance(supl_mcc,supl_mns,supl_lac,supl_ci); |  | ||||||
| 			if (error==0) |  | ||||||
| 			{ |  | ||||||
| 				std::map<int,Gps_Almanac>::iterator gps_alm_iter; |  | ||||||
| 				for(gps_alm_iter = supl_client_ephemeris_.gps_almanac_map.begin(); |  | ||||||
| 						gps_alm_iter != supl_client_ephemeris_.gps_almanac_map.end(); |  | ||||||
| 						gps_alm_iter++) |  | ||||||
| 				{ |  | ||||||
| 					DLOG(INFO) <<"SUPL: Received Almanac for GPS SV "<<gps_alm_iter->first<<std::endl; |  | ||||||
| 					global_gps_almanac_map.write(gps_alm_iter->first,gps_alm_iter->second); |  | ||||||
| 				} |  | ||||||
| 				if (supl_client_ephemeris_.gps_iono.valid==true) |  | ||||||
| 				{ |  | ||||||
| 					DLOG(INFO) <<"SUPL: Received GPS Iono"<<std::endl; |  | ||||||
| 					global_gps_iono_map.write(0,supl_client_ephemeris_.gps_iono); |  | ||||||
| 				} |  | ||||||
| 				if (supl_client_ephemeris_.gps_utc.valid==true) |  | ||||||
| 				{ |  | ||||||
| 					DLOG(INFO) <<"SUPL: Received GPS UTC Model"<<std::endl; |  | ||||||
| 					global_gps_utc_model_map.write(0,supl_client_ephemeris_.gps_utc); |  | ||||||
| 				} |  | ||||||
| 			}else{ |  | ||||||
| 				DLOG(INFO) << "ERROR: SUPL client for Almanac returned "<<error<<std::endl; |  | ||||||
| 				DLOG(INFO) << "Please check internet connection and SUPL server configuration"<<error<<std::endl; |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			// Request acquisition assistance |                     error = supl_client_acquisition_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); | ||||||
| 			supl_client_acquisition_.request=2; |                     if (error == 0) | ||||||
| 			DLOG(INFO) << "SUPL: Try read Acquisition assistance from SUPL server.."<<std::endl; |                         { | ||||||
|  |                             std::map<int,Gps_Acq_Assist>::iterator gps_acq_iter; | ||||||
| 			error=supl_client_acquisition_.get_assistance(supl_mcc,supl_mns,supl_lac,supl_ci); |                             for(gps_acq_iter = supl_client_acquisition_.gps_acq_map.begin(); | ||||||
| 			if (error==0) |                                     gps_acq_iter != supl_client_acquisition_.gps_acq_map.end(); | ||||||
| 			{ |                                     gps_acq_iter++) | ||||||
| 				std::map<int,Gps_Acq_Assist>::iterator gps_acq_iter; |                                 { | ||||||
| 				for(gps_acq_iter = supl_client_acquisition_.gps_acq_map.begin(); |                                     DLOG(INFO) << "SUPL: Received Acquisition assistance for GPS SV " << gps_acq_iter->first; | ||||||
| 						gps_acq_iter != supl_client_acquisition_.gps_acq_map.end(); |                                     DLOG(INFO) << "New acq assist record inserted"; | ||||||
| 						gps_acq_iter++) |                                     global_gps_acq_assist_map.write(gps_acq_iter->second.i_satellite_PRN, gps_acq_iter->second); | ||||||
| 				{ |                                 } | ||||||
| 					DLOG(INFO) <<"SUPL: Received Acquisition assistance for GPS SV "<<gps_acq_iter->first<<std::endl; |                         } | ||||||
| 					DLOG(INFO)  << "New acq assist record inserted"<<std::endl; |                     else | ||||||
| 					global_gps_acq_assist_map.write(gps_acq_iter->second.i_satellite_PRN,gps_acq_iter->second); |                         { | ||||||
| 				} |                             DLOG(INFO) << "ERROR: SUPL client for Acquisition assistance returned " << error; | ||||||
| 			}else{ |                             DLOG(INFO) << "Please check internet connection and SUPL server configuration" << error; | ||||||
| 				DLOG(INFO) << "ERROR: SUPL client for Acquisition assistance returned "<<error<<std::endl; |                         } | ||||||
| 				DLOG(INFO) << "Please check internet connection and SUPL server configuration"<<error<<std::endl; |                 } | ||||||
| 			} |         } | ||||||
| 		} |     return error; | ||||||
| 	} |  | ||||||
| 	return error; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void FrontEndCal::set_configuration(ConfigurationInterface *configuration) | void FrontEndCal::set_configuration(ConfigurationInterface *configuration) | ||||||
| { | { | ||||||
|     configuration_= configuration; |     configuration_ = configuration; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| bool FrontEndCal::get_ephemeris() | bool FrontEndCal::get_ephemeris() | ||||||
| { | { | ||||||
| 	bool read_ephemeris_from_xml=configuration_->property("GNSS-SDR.read_eph_from_xml",false); |     bool read_ephemeris_from_xml=configuration_->property("GNSS-SDR.read_eph_from_xml", false); | ||||||
|  |  | ||||||
| 	if (read_ephemeris_from_xml==true) |     if (read_ephemeris_from_xml == true) | ||||||
| 	{ |         { | ||||||
| 		std::cout<< "Trying to read ephemeris from XML file..."<<std::endl; |             std::cout <<  "Trying to read ephemeris from XML file..." << std::endl; | ||||||
| 		if (read_assistance_from_XML()==false) |             if (read_assistance_from_XML() == false) | ||||||
| 		{ |                 { | ||||||
| 			std::cout<< "ERROR: Could not read Ephemeris file: Trying to get ephemeris from SUPL server.."<<std::endl; |                     std::cout <<  "ERROR: Could not read Ephemeris file: Trying to get ephemeris from SUPL server..." << std::endl; | ||||||
| 			if (Get_SUPL_Assist()==1) |                     if (Get_SUPL_Assist() == 1) | ||||||
| 			{ |                         { | ||||||
| 				return true; |                             return true; | ||||||
| 			}else{ |                         } | ||||||
| 				return false; |                     else | ||||||
| 			} |                         { | ||||||
| 		}else{ |                             return false; | ||||||
| 			return true; |                         } | ||||||
| 		} |                 } | ||||||
| 	}else{ |             else | ||||||
| 		std::cout<< "Trying to read ephemeris from SUPL server..."<<std::endl; |                 { | ||||||
| 		if (Get_SUPL_Assist()==0) |                     return true; | ||||||
| 		{ |                 } | ||||||
| 			return true; |         } | ||||||
| 		}else{ |     else | ||||||
| 			return false; |         { | ||||||
| 		} |             std::cout <<  "Trying to read ephemeris from SUPL server..." << std::endl; | ||||||
| 	} |             if (Get_SUPL_Assist() == 0) | ||||||
|  |                 { | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  |             else | ||||||
|  |                 { | ||||||
|  |                     return false; | ||||||
|  |                 } | ||||||
|  |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| arma::vec FrontEndCal::lla2ecef(arma::vec lla) | arma::vec FrontEndCal::lla2ecef(arma::vec lla) | ||||||
| { | { | ||||||
|  |     // WGS84 flattening | ||||||
|  |     double f; | ||||||
|  |     f  = 1/298.257223563; | ||||||
|  |  | ||||||
| 	// WGS84 flattening |     // WGS84 equatorial radius | ||||||
| 	double f; |     double R; | ||||||
| 	f  = 1/298.257223563; |     R =  6378137; | ||||||
|  |  | ||||||
| 	// WGS84 equatorial radius |     double phi, lambda; | ||||||
| 	double R; |     arma::vec ellipsoid = "0.0 0.0"; | ||||||
| 	R =  6378137; |     phi = (lla(0)/360.0) * GPS_TWO_PI; | ||||||
|  |     lambda = (lla(1)/360.0) * GPS_TWO_PI; | ||||||
|  |  | ||||||
| 	double phi,lambda; |     ellipsoid(0) = R; | ||||||
| 	arma::vec ellipsoid="0.0 0.0"; |     ellipsoid(1) = sqrt(1-(1-f)*(1-f)); | ||||||
| 	phi=(lla(0)/360.0)*GPS_TWO_PI; |  | ||||||
| 	lambda=(lla(1)/360.0)*GPS_TWO_PI; |  | ||||||
|  |  | ||||||
| 	ellipsoid(0)=R; |     arma::vec ecef = "0.0 0.0 0.0 0.0"; | ||||||
| 	ellipsoid(1)=sqrt(1-(1-f)*(1-f)); |     ecef = geodetic2ecef(phi, lambda, lla(3), ellipsoid); | ||||||
|  |  | ||||||
| 	arma::vec ecef="0.0 0.0 0.0 0.0"; |     return ecef; | ||||||
| 	ecef = geodetic2ecef(phi, lambda,lla(3),ellipsoid); |  | ||||||
|  |  | ||||||
| 	return ecef; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, arma::vec ellipsoid) | arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, arma::vec ellipsoid) | ||||||
| { | { | ||||||
|  |     double a; | ||||||
|  |     a  = ellipsoid(0); | ||||||
|  |     double e2; | ||||||
|  |     e2 = ellipsoid(1)*ellipsoid(1); | ||||||
|  |  | ||||||
| 	double a; |     double sinphi, cosphi; | ||||||
| 	a  = ellipsoid(0); |  | ||||||
| 	double e2; |  | ||||||
| 	e2 = ellipsoid(1)*ellipsoid(1); |  | ||||||
|  |  | ||||||
| 	double sinphi,cosphi; |     sinphi = sin(phi); | ||||||
|  |     cosphi = cos(phi); | ||||||
|  |     double N; | ||||||
|  |     N  = a / sqrt(1 - e2 * sinphi*sinphi); | ||||||
|  |  | ||||||
| 	sinphi = sin(phi); |     arma::vec ecef = "0.0 0.0 0.0 0.0"; | ||||||
| 	cosphi = cos(phi); |  | ||||||
| 	double N; |  | ||||||
| 	N  = a / sqrt(1 - e2 * sinphi*sinphi); |  | ||||||
|  |  | ||||||
| 	arma::vec ecef="0.0 0.0 0.0 0.0"; |     ecef(0) = (N + h) * cosphi * cos(lambda); | ||||||
|  |     ecef(1) = (N + h) * cosphi * sin(lambda); | ||||||
|  |     ecef(2) = (N*(1 - e2) + h) * sinphi; | ||||||
|  |  | ||||||
| 	ecef(0) = (N + h) * cosphi * cos(lambda); |     return ecef; | ||||||
| 	ecef(1) = (N + h) * cosphi * sin(lambda); |  | ||||||
| 	ecef(2)= (N*(1 - e2) + h) * sinphi; |  | ||||||
|  |  | ||||||
| 	return ecef; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) | double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) | ||||||
| { | { | ||||||
|  |     int num_secs = 10; | ||||||
|  |     double step_secs = 0.5; | ||||||
|  |  | ||||||
| 	int num_secs=10; |     //Observer position ECEF | ||||||
| 	double step_secs=0.5; |     arma::vec obs_ecef = "0.0 0.0 0.0 0.0"; | ||||||
|  |     arma::vec lla = "0.0 0.0 0.0 0.0"; | ||||||
|  |     lla(0) = lat; | ||||||
|  |     lla(1) = lon; | ||||||
|  |     lla(2) = height; | ||||||
|  |     obs_ecef = lla2ecef(lla); | ||||||
|  |  | ||||||
|  |     //Satellite positions ECEF | ||||||
|  |     std::map<int,Gps_Ephemeris> eph_map; | ||||||
|  |     eph_map = global_gps_ephemeris_map.get_map_copy(); | ||||||
|  |  | ||||||
| 	//Observer position ECEF |     std::map<int,Gps_Ephemeris>::iterator eph_it; | ||||||
| 	arma::vec obs_ecef= "0.0 0.0 0.0 0.0"; |     eph_it = eph_map.find(PRN); | ||||||
| 	arma::vec lla = "0.0 0.0 0.0 0.0"; |  | ||||||
| 	lla(0)=lat; |  | ||||||
| 	lla(1)=lon; |  | ||||||
| 	lla(2)=height; |  | ||||||
| 	obs_ecef=lla2ecef(lla); |  | ||||||
|  |  | ||||||
|  |     if (eph_it!=eph_map.end()) | ||||||
|  |         { | ||||||
|  |             arma::vec SV_pos_ecef = "0.0 0.0 0.0 0.0"; | ||||||
|  |             double obs_time_start, obs_time_stop; | ||||||
|  |             obs_time_start = TOW - num_secs/2; | ||||||
|  |             obs_time_stop = TOW + num_secs/2; | ||||||
|  |             int n_points = round((obs_time_stop - obs_time_start)/step_secs); | ||||||
|  |             arma::vec ranges = arma::zeros(n_points, 1); | ||||||
|  |             double obs_time = obs_time_start; | ||||||
|  |             for (int i=0; i<n_points; i++) | ||||||
|  |                 { | ||||||
|  |                     eph_it->second.satellitePosition(obs_time); | ||||||
|  |                     SV_pos_ecef(0) = eph_it->second.d_satpos_X; | ||||||
|  |                     SV_pos_ecef(1) = eph_it->second.d_satpos_Y; | ||||||
|  |                     SV_pos_ecef(2) = eph_it->second.d_satpos_Z; | ||||||
|  |                     // SV distances to observer (true range) | ||||||
|  |                     ranges(i) = arma::norm(SV_pos_ecef-obs_ecef, 2); | ||||||
|  |  | ||||||
| 	//Satellite positions ECEF |                     obs_time += step_secs; | ||||||
| 	std::map<int,Gps_Ephemeris> eph_map; |                 } | ||||||
| 	eph_map=global_gps_ephemeris_map.get_map_copy(); |             // Observer to satellite radial velocity | ||||||
|  |             // Numeric derivative: Positive slope means that the distance from obs to | ||||||
|  |             // satellite is increasing | ||||||
|  |             arma::vec obs_to_sat_velocity; | ||||||
|  |             obs_to_sat_velocity = (ranges.subvec(1, (n_points-1)) - ranges.subvec(0, (n_points-2)))/step_secs; | ||||||
|  |             // Doppler equations are formulated accounting for positive velocities if the | ||||||
|  |             // tx and rx are approaching to each other. So, the satellite velocity must | ||||||
|  |             // be redefined as: | ||||||
|  |  | ||||||
| 	std::map<int,Gps_Ephemeris>::iterator eph_it; |             obs_to_sat_velocity = -obs_to_sat_velocity; | ||||||
| 	eph_it=eph_map.find(PRN); |  | ||||||
|  |  | ||||||
| 	if (eph_it!=eph_map.end()) |  | ||||||
| 	{ |  | ||||||
|  |  | ||||||
| 		arma::vec SV_pos_ecef = "0.0 0.0 0.0 0.0"; |  | ||||||
| 		double obs_time_start,obs_time_stop; |  | ||||||
| 		obs_time_start=TOW-num_secs/2; |  | ||||||
| 		obs_time_stop=TOW+num_secs/2; |  | ||||||
| 		int n_points=round((obs_time_stop-obs_time_start)/step_secs); |  | ||||||
| 		arma::vec ranges=arma::zeros(n_points,1); |  | ||||||
| 		double obs_time=obs_time_start; |  | ||||||
| 		for (int i=0;i<n_points;i++) |  | ||||||
| 		{ |  | ||||||
| 			eph_it->second.satellitePosition(obs_time); |  | ||||||
| 			SV_pos_ecef(0)=eph_it->second.d_satpos_X; |  | ||||||
| 			SV_pos_ecef(1)=eph_it->second.d_satpos_Y; |  | ||||||
| 			SV_pos_ecef(2)=eph_it->second.d_satpos_Z; |  | ||||||
| 			// SV distances to observer (true range) |  | ||||||
| 			ranges(i)=arma::norm(SV_pos_ecef-obs_ecef,2); |  | ||||||
|  |  | ||||||
| 			obs_time+=step_secs; |  | ||||||
| 		} |  | ||||||
| 		//Observer to satellite radial velocity |  | ||||||
| 		//Numeric derivative: Positive slope means that the distance from obs to |  | ||||||
| 		//satellite is increasing |  | ||||||
| 	    arma::vec obs_to_sat_velocity; |  | ||||||
| 		obs_to_sat_velocity=(ranges.subvec(1,(n_points-1))-ranges.subvec(0,(n_points-2)))/step_secs; |  | ||||||
| 		//Doppler equations are formulated accounting for positive velocities if the |  | ||||||
| 		//tx and rx are aproaching to each other. So, the satellite velocity must |  | ||||||
| 		//be redefined as: |  | ||||||
|  |  | ||||||
| 		obs_to_sat_velocity=-obs_to_sat_velocity; |  | ||||||
|  |  | ||||||
| 		//Doppler estimation |  | ||||||
| 		arma::vec Doppler_Hz; |  | ||||||
| 		Doppler_Hz=(obs_to_sat_velocity/GPS_C_m_s)*GPS_L1_FREQ_HZ; |  | ||||||
| 		double mean_Doppler_Hz; |  | ||||||
| 		mean_Doppler_Hz=arma::mean(Doppler_Hz); |  | ||||||
| 		return mean_Doppler_Hz; |  | ||||||
| 	return 0; |  | ||||||
| 	}else{ |  | ||||||
| 		throw(1); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
|  |             //Doppler estimation | ||||||
|  |             arma::vec Doppler_Hz; | ||||||
|  |             Doppler_Hz = (obs_to_sat_velocity/GPS_C_m_s)*GPS_L1_FREQ_HZ; | ||||||
|  |             double mean_Doppler_Hz; | ||||||
|  |             mean_Doppler_Hz = arma::mean(Doppler_Hz); | ||||||
|  |             return mean_Doppler_Hz; | ||||||
|  |             return 0; | ||||||
|  |         } | ||||||
|  |     else | ||||||
|  |         { | ||||||
|  |             throw(1); | ||||||
|  |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| void FrontEndCal::GPS_L1_front_end_model_E4000(double f_bb_true_Hz,double f_bb_meas_Hz,double fs_nominal_hz, double *estimated_fs_Hz, double *estimated_f_if_Hz, double *f_osc_err_ppm ) |  | ||||||
|  | void FrontEndCal::GPS_L1_front_end_model_E4000(double f_bb_true_Hz, double f_bb_meas_Hz, double fs_nominal_hz, double *estimated_fs_Hz, double *estimated_f_if_Hz, double *f_osc_err_ppm) | ||||||
| { | { | ||||||
|  |     double f_osc_n = 28.8e6; | ||||||
|  |     //PLL registers settings (according to E4000 datasheet) | ||||||
|  |  | ||||||
|  |     double N = 109; | ||||||
|  |     double Y = 65536; | ||||||
|  |     double X = 26487; | ||||||
|  |     double R = 2; | ||||||
|  |     // Obtained RF center frequency | ||||||
|  |     double f_rf_pll; | ||||||
|  |     f_rf_pll = (f_osc_n*(N+X/Y))/R; | ||||||
|  |     // RF frequency error caused by fractional PLL roundings | ||||||
|  |     double f_bb_err_pll; | ||||||
|  |     f_bb_err_pll = GPS_L1_FREQ_HZ - f_rf_pll; | ||||||
|  |  | ||||||
|  |     // Measured F_rf error | ||||||
|  |     double f_rf_err; | ||||||
|  |     f_rf_err = (f_bb_meas_Hz - f_bb_true_Hz) - f_bb_err_pll; | ||||||
|  |  | ||||||
| 	double f_osc_n=28.8e6; |     double f_osc_err_hz; | ||||||
| 	//PLL registers settings (according to E4000 datasheet) |     f_osc_err_hz = (f_rf_err*R)/(N+X/Y); | ||||||
|  |  | ||||||
| 	double N=109; |     // OJO,segun los datos gnss, la IF positiva hace disminuir la fs!! | ||||||
| 	double Y=65536; |     f_osc_err_hz = -f_osc_err_hz; | ||||||
| 	double X=26487; |  | ||||||
| 	double R=2; |  | ||||||
| 	// Obtained RF center frequency |  | ||||||
| 	double f_rf_pll; |  | ||||||
| 	f_rf_pll=(f_osc_n*(N+X/Y))/R; |  | ||||||
| 	// RF frequency error caused by fractional PLL roundings |  | ||||||
| 	double f_bb_err_pll; |  | ||||||
| 	f_bb_err_pll=GPS_L1_FREQ_HZ-f_rf_pll; |  | ||||||
|  |  | ||||||
| 	// Measured F_rf error |     *f_osc_err_ppm = f_osc_err_hz/(f_osc_n/1e6); | ||||||
| 	double f_rf_err; |     double frac; | ||||||
| 	f_rf_err=(f_bb_meas_Hz-f_bb_true_Hz)-f_bb_err_pll; |     frac = fs_nominal_hz/f_osc_n; | ||||||
|  |  | ||||||
| 	double f_osc_err_hz; |  | ||||||
| 	f_osc_err_hz=(f_rf_err*R)/(N+X/Y); |  | ||||||
|  |  | ||||||
| 	// OJO,segun los datos gnss, la IF positiva hace disminuir la fs!! |  | ||||||
| 	f_osc_err_hz=-f_osc_err_hz; |  | ||||||
|  |  | ||||||
| 	*f_osc_err_ppm=f_osc_err_hz/(f_osc_n/1e6); |  | ||||||
| 	double frac; |  | ||||||
| 	frac=fs_nominal_hz/f_osc_n; |  | ||||||
|  |  | ||||||
| 	*estimated_fs_Hz=frac*(f_osc_n+f_osc_err_hz); |  | ||||||
| 	*estimated_f_if_Hz=f_rf_err; |  | ||||||
|  |  | ||||||
|  |     *estimated_fs_Hz = frac*(f_osc_n + f_osc_err_hz); | ||||||
|  |     *estimated_f_if_Hz = f_rf_err; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,99 +1,137 @@ | |||||||
|  | /*! | ||||||
|  |  * \file front_end_cal.h | ||||||
|  |  * \brief Interface of the Front-end calibration program. | ||||||
|  |  * \author Javier Arribas, 2013. jarribas(at)cttc.es | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  * ------------------------------------------------------------------------- | ||||||
|  |  * | ||||||
|  |  * Copyright (C) 2010-2013  (see AUTHORS file for a list of contributors) | ||||||
|  |  * | ||||||
|  |  * GNSS-SDR is a software defined Global Navigation | ||||||
|  |  *          Satellite Systems receiver | ||||||
|  |  * | ||||||
|  |  * This file is part of GNSS-SDR. | ||||||
|  |  * | ||||||
|  |  * GNSS-SDR is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or | ||||||
|  |  * at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * GNSS-SDR is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  * | ||||||
|  |  * ------------------------------------------------------------------------- | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef GNSS_SDR_FRONT_END_CAL_H_ | ||||||
|  | #define GNSS_SDR_FRONT_END_CAL_H_ | ||||||
|  |  | ||||||
| #include "concurrent_map.h" | #include "concurrent_map.h" | ||||||
| #include "armadillo" | #include "armadillo" | ||||||
|  |  | ||||||
| class FrontEndCal | class FrontEndCal | ||||||
| { | { | ||||||
| private: | private: | ||||||
| 	ConfigurationInterface *configuration_; |     ConfigurationInterface *configuration_; | ||||||
|  |  | ||||||
|  |     /*! | ||||||
|  |      * \brief LLA2ECEF Convert geodetic coordinates to Earth-centered Earth-fixed | ||||||
|  |      * (ECEF)  coordinates. P = LLA2ECEF( LLA ) converts an M-by-3 array of geodetic coordinates | ||||||
|  |      * (latitude, longitude and altitude), LLA, to an M-by-3 array of ECEF | ||||||
|  |      * coordinates, P.  LLA is in [degrees degrees meters].  P is in meters. | ||||||
|  |      * The default ellipsoid planet is WGS84. Original copyright (c) by Kai Borre. | ||||||
|  |      */ | ||||||
|  |     arma::vec lla2ecef(arma::vec lla); | ||||||
|  |     /*! | ||||||
|  |      * GEODETIC2ECEF Convert geodetic to geocentric (ECEF) coordinates | ||||||
|  |      * [X, Y, Z] = GEODETIC2ECEF(PHI, LAMBDA, H, ELLIPSOID) converts geodetic | ||||||
|  |      * point locations specified by the coordinate arrays PHI (geodetic | ||||||
|  |      * latitude in radians), LAMBDA (longitude in radians), and H (ellipsoidal | ||||||
|  |      * height) to geocentric Cartesian coordinates X, Y, and Z.  The geodetic | ||||||
|  |      * coordinates refer to the reference ellipsoid specified by ELLIPSOID (a | ||||||
|  |      * row vector with the form [semimajor axis, eccentricity]).  H must use | ||||||
|  |      * the same units as the semimajor axis;  X, Y, and Z will be expressed in | ||||||
|  |      * these units also. | ||||||
|  |      * | ||||||
|  |      * The geocentric Cartesian coordinate system is fixed with respect to the | ||||||
|  |      * Earth, with its origin at the center of the ellipsoid and its X-, Y-, | ||||||
|  |      * and Z-axes intersecting the surface at the following points: | ||||||
|  |      * PHI  LAMBDA | ||||||
|  |      * X-axis:    0     0      (Equator at the Prime Meridian) | ||||||
|  |      * Y-axis:    0   pi/2     (Equator at 90-degrees East | ||||||
|  |      * Z-axis:  pi/2    0      (North Pole) | ||||||
|  |      * | ||||||
|  |      * A common synonym is Earth-Centered, Earth-Fixed coordinates, or ECEF. | ||||||
|  |      * | ||||||
|  |      * See also ECEF2GEODETIC, ECEF2LV, GEODETIC2GEOCENTRICLAT, LV2ECEF. | ||||||
|  |      * | ||||||
|  |      * Copyright 2004-2009 The MathWorks, Inc. | ||||||
|  |      * $Revision: 1.1.6.4 $  $Date: 2009/04/15 23:34:46 $ | ||||||
|  |      * Reference | ||||||
|  |      * --------- | ||||||
|  |      * Paul R. Wolf and Bon A. Dewitt, "Elements of Photogrammetry with | ||||||
|  |      * Applications in GIS," 3rd Ed., McGraw-Hill, 2000 (Appendix F-3). | ||||||
|  |      */ | ||||||
|  |     arma::vec geodetic2ecef(double phi, double lambda, double h, arma::vec ellipsoid); | ||||||
|  |     /*! | ||||||
|  |      * \brief Reads the ephemeris data from an external XML file | ||||||
|  |      * | ||||||
|  |      */ | ||||||
|  |     bool read_assistance_from_XML(); | ||||||
|  |     /*! | ||||||
|  |      * \brief Connects to Secure User Location Protocol (SUPL) server to obtain | ||||||
|  |      * the current GPS ephemeris and GPS assistance data. | ||||||
|  |      * | ||||||
|  |      */ | ||||||
|  |     int Get_SUPL_Assist(); | ||||||
|  |  | ||||||
| 	/*! |  | ||||||
| 	 * \brief LLA2ECEF Convert geodetic coordinates to Earth-centered Earth-fixed |  | ||||||
| 	 * (ECEF)  coordinates. P = LLA2ECEF( LLA ) converts an M-by-3 array of geodetic coordinates |  | ||||||
| 	 * (latitude, longitude and altitude), LLA, to an M-by-3 array of ECEF |  | ||||||
| 	 * coordinates, P.  LLA is in [degrees degrees meters].  P is in meters. |  | ||||||
| 	 * The default ellipsoid planet is WGS84. Original copyright (c) by Kai Borre. |  | ||||||
| 	 */ |  | ||||||
| 	arma::vec lla2ecef(arma::vec lla); |  | ||||||
| 	/*! |  | ||||||
| 	 * GEODETIC2ECEF Convert geodetic to geocentric (ECEF) coordinates |  | ||||||
| 	 * [X, Y, Z] = GEODETIC2ECEF(PHI, LAMBDA, H, ELLIPSOID) converts geodetic |  | ||||||
| 	 * point locations specified by the coordinate arrays PHI (geodetic |  | ||||||
| 	 * latitude in radians), LAMBDA (longitude in radians), and H (ellipsoidal |  | ||||||
| 	 * height) to geocentric Cartesian coordinates X, Y, and Z.  The geodetic |  | ||||||
| 	 * coordinates refer to the reference ellipsoid specified by ELLIPSOID (a |  | ||||||
| 	 * row vector with the form [semimajor axis, eccentricity]).  H must use |  | ||||||
| 	 * the same units as the semimajor axis;  X, Y, and Z will be expressed in |  | ||||||
| 	 * these units also. |  | ||||||
| 	 * |  | ||||||
| 	 * The geocentric Cartesian coordinate system is fixed with respect to the |  | ||||||
| 	 * Earth, with its origin at the center of the ellipsoid and its X-, Y-, |  | ||||||
| 	 * and Z-axes intersecting the surface at the following points: |  | ||||||
| 	 * PHI  LAMBDA |  | ||||||
| 	 * X-axis:    0     0      (Equator at the Prime Meridian) |  | ||||||
| 	 * Y-axis:    0   pi/2     (Equator at 90-degrees East |  | ||||||
| 	 * Z-axis:  pi/2    0      (North Pole) |  | ||||||
| 	 * |  | ||||||
| 	 * A common synonym is Earth-Centered, Earth-Fixed coordinates, or ECEF. |  | ||||||
| 	 * |  | ||||||
| 	 * See also ECEF2GEODETIC, ECEF2LV, GEODETIC2GEOCENTRICLAT, LV2ECEF. |  | ||||||
| 	 * |  | ||||||
| 	 * Copyright 2004-2009 The MathWorks, Inc. |  | ||||||
| 	 * $Revision: 1.1.6.4 $  $Date: 2009/04/15 23:34:46 $ |  | ||||||
| 	 * Reference |  | ||||||
| 	 * --------- |  | ||||||
| 	 * Paul R. Wolf and Bon A. Dewitt, "Elements of Photogrammetry with |  | ||||||
| 	 * Applications in GIS," 3rd Ed., McGraw-Hill, 2000 (Appendix F-3). |  | ||||||
| 	 */ |  | ||||||
| 	arma::vec geodetic2ecef(double phi, double lambda, double h, arma::vec ellipsoid); |  | ||||||
| 	/*! |  | ||||||
| 	 * \brief Reads the ephemeris data from an external XML file |  | ||||||
| 	 * |  | ||||||
| 	 */ |  | ||||||
| 	bool read_assistance_from_XML(); |  | ||||||
| 	/*! |  | ||||||
| 	 * \brief Connects to Secure User Location Protocol (SUPL) server to obtain |  | ||||||
| 	 * the current GPS ephemeris and GPS assistance data. |  | ||||||
| 	 * |  | ||||||
| 	 */ |  | ||||||
| 	int Get_SUPL_Assist(); |  | ||||||
| public: | public: | ||||||
|  |     /*! | ||||||
|  |      * \brief Sets the configuration data required by get_ephemeris function | ||||||
|  |      * | ||||||
|  |      */ | ||||||
|  |     void set_configuration(ConfigurationInterface *configuration); | ||||||
|  |  | ||||||
|  |     /*! | ||||||
|  |      * \brief This function connects to a Secure User Location Protocol (SUPL) server to obtain | ||||||
|  |      * the current GPS ephemeris and GPS assistance data. It requires the configuration parameters set by | ||||||
|  |      * set_configuration function. | ||||||
|  |      * | ||||||
|  |      */ | ||||||
|  |     bool get_ephemeris(); | ||||||
|  |  | ||||||
| 	/*! |     /*! | ||||||
| 	 * \brief Sets the configuration data required by get_ephemeris function |      * \brief This function estimates the GPS L1 satellite Doppler frequency [Hz] using the following data: | ||||||
| 	 * |      * 1- Orbital model from the ephemeris | ||||||
| 	 */ |      * 2- Approximate GPS Time of Week (TOW) | ||||||
| 	void set_configuration(ConfigurationInterface *configuration); |      * 3- Approximate receiver Latitude and Longitude (WGS-84) | ||||||
| 	/*! |      * | ||||||
| 	 * \brief This function connects to a Secure User Location Protocol (SUPL) server to obtain |      */ | ||||||
| 	 * the current GPS ephemeris and GPS assistance data. It requires the configuration parameters set by |     double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height); | ||||||
| 	 * set_configuration function. |  | ||||||
| 	 * |  | ||||||
| 	 */ |  | ||||||
| 	bool get_ephemeris(); |  | ||||||
| 	/*! |  | ||||||
| 	 * \brief This function estimates the GPS L1 satellite Doppler frequency [Hz] using the following data: |  | ||||||
| 	 * 1- Orbital model from the ephemeris |  | ||||||
| 	 * 2- Approximate GPS Time of Week (TOW) |  | ||||||
| 	 * 3- Approximate receiver Latitude and Longitude (WGS-84) |  | ||||||
| 	 * |  | ||||||
| 	 */ |  | ||||||
| 	double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height); |  | ||||||
| 	/*! |  | ||||||
| 	 * \brief This function models the Elonics E4000 + RTL2832 front-end |  | ||||||
| 	 * Inputs: |  | ||||||
| 	 *  f_bb_true_Hz  - Ideal output frequency in baseband [Hz] |  | ||||||
| 	 *  f_in_bb_meas_Hz       - measured output frequency in baseband [Hz] |  | ||||||
| 	 * Outputs: |  | ||||||
| 	 *  estimated_fs_Hz  - Sampling frequency estimation based on the |  | ||||||
| 	 *  measurements and the front-end model |  | ||||||
| 	 *  estimated_f_if_bb_Hz    - Equivalent bb if frequency estimation based on the |  | ||||||
| 	 *  measurements and the front-end model |  | ||||||
| 	 *  Front-end TUNNER Elonics E4000 + RTL2832 sampler For GPS L1 1575.42 MHz |  | ||||||
| 	 * |  | ||||||
| 	 */ |  | ||||||
| 	void GPS_L1_front_end_model_E4000(double f_bb_true_Hz,double f_bb_meas_Hz,double fs_nominal_hz, double *estimated_fs_Hz, double *estimated_f_if_Hz, double *f_osc_err_ppm ); |  | ||||||
|  |  | ||||||
| 	FrontEndCal(); |     /*! | ||||||
| 	~FrontEndCal(); |      * \brief This function models the Elonics E4000 + RTL2832 front-end | ||||||
|  |      * Inputs: | ||||||
|  |      *  f_bb_true_Hz    - Ideal output frequency in baseband [Hz] | ||||||
|  |      *  f_in_bb_meas_Hz - measured output frequency in baseband [Hz] | ||||||
|  |      * Outputs: | ||||||
|  |      *  estimated_fs_Hz  - Sampling frequency estimation based on the | ||||||
|  |      *  measurements and the front-end model | ||||||
|  |      *  estimated_f_if_bb_Hz - Equivalent bb if frequency estimation based on the | ||||||
|  |      *  measurements and the front-end model | ||||||
|  |      *  Front-end TUNER Elonics E4000 + RTL2832 sampler For GPS L1 1575.42 MHz | ||||||
|  |      * | ||||||
|  |      */ | ||||||
|  |     void GPS_L1_front_end_model_E4000(double f_bb_true_Hz,double f_bb_meas_Hz,double fs_nominal_hz, double *estimated_fs_Hz, double *estimated_f_if_Hz, double *f_osc_err_ppm ); | ||||||
|  |  | ||||||
|  |     FrontEndCal(); | ||||||
|  |     ~FrontEndCal(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | #endif | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ using google::LogMessage; | |||||||
| DECLARE_string(log_dir); | DECLARE_string(log_dir); | ||||||
|  |  | ||||||
| DEFINE_string(config_file, "../conf/front-end-cal.conf", | DEFINE_string(config_file, "../conf/front-end-cal.conf", | ||||||
| 		"Path to the file containing the configuration parameters"); |         "Path to the file containing the configuration parameters"); | ||||||
|  |  | ||||||
| concurrent_queue<Gps_Ephemeris> global_gps_ephemeris_queue; | concurrent_queue<Gps_Ephemeris> global_gps_ephemeris_queue; | ||||||
| concurrent_queue<Gps_Iono> global_gps_iono_queue; | concurrent_queue<Gps_Iono> global_gps_iono_queue; | ||||||
| @@ -116,24 +116,24 @@ void wait_message() | |||||||
| { | { | ||||||
|     while (!stop) |     while (!stop) | ||||||
|         { |         { | ||||||
|     		int message; |             int message; | ||||||
|     		channel_internal_queue.wait_and_pop(message); |             channel_internal_queue.wait_and_pop(message); | ||||||
|     		//std::cout<<"Acq mesage rx="<<message<<std::endl; |             //std::cout<<"Acq mesage rx="<<message<<std::endl; | ||||||
|     		switch (message) |             switch (message) | ||||||
|     		{ |             { | ||||||
|     		case 1: // Positive acq |             case 1: // Positive acq | ||||||
|     		    gnss_sync_vector.push_back(*gnss_synchro); |                 gnss_sync_vector.push_back(*gnss_synchro); | ||||||
|     			//acquisition->reset(); |                 //acquisition->reset(); | ||||||
|     			break; |                 break; | ||||||
|     		case 2: // negative acq |             case 2: // negative acq | ||||||
|     			//acquisition->reset(); |                 //acquisition->reset(); | ||||||
|     			break; |                 break; | ||||||
|     		case 3: |             case 3: | ||||||
|         		stop=true; |                 stop = true; | ||||||
|         		break; |                 break; | ||||||
|     		default: |             default: | ||||||
|     			break; |                 break; | ||||||
|     		} |             } | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -146,12 +146,11 @@ bool front_end_capture(ConfigurationInterface *configuration) | |||||||
|     queue =  gr::msg_queue::make(0); |     queue =  gr::msg_queue::make(0); | ||||||
|     top_block = gr::make_top_block("Acquisition test"); |     top_block = gr::make_top_block("Acquisition test"); | ||||||
|  |  | ||||||
|  |  | ||||||
|     GNSSBlockInterface *source; |     GNSSBlockInterface *source; | ||||||
|     source=block_factory.GetSignalSource(configuration, queue); |     source = block_factory.GetSignalSource(configuration, queue); | ||||||
|  |  | ||||||
|     GNSSBlockInterface *conditioner; |     GNSSBlockInterface *conditioner; | ||||||
|     conditioner=block_factory.GetSignalConditioner(configuration,queue); |     conditioner = block_factory.GetSignalConditioner(configuration,queue); | ||||||
|  |  | ||||||
|     gr::block_sptr sink; |     gr::block_sptr sink; | ||||||
|     sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat"); |     sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat"); | ||||||
| @@ -160,53 +159,54 @@ bool front_end_capture(ConfigurationInterface *configuration) | |||||||
|     long fs_in_ = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); |     long fs_in_ = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); | ||||||
|     int samples_per_code = round(fs_in_ |     int samples_per_code = round(fs_in_ | ||||||
|             / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); |             / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); | ||||||
|     int nsamples=samples_per_code*50; |     int nsamples = samples_per_code * 50; | ||||||
|  |  | ||||||
|     int skip_samples=fs_in_*5; // skip 5 seconds |     int skip_samples = fs_in_ * 5; // skip 5 seconds | ||||||
|  |  | ||||||
|     gr::block_sptr head = gr::blocks::head::make(sizeof(gr_complex), nsamples); |     gr::block_sptr head = gr::blocks::head::make(sizeof(gr_complex), nsamples); | ||||||
|  |  | ||||||
|     gr::block_sptr skiphead = gr::blocks::skiphead::make(sizeof(gr_complex), skip_samples); |     gr::block_sptr skiphead = gr::blocks::skiphead::make(sizeof(gr_complex), skip_samples); | ||||||
|  |  | ||||||
|     try{ |     try | ||||||
|  |  | ||||||
|     	source->connect(top_block); |  | ||||||
|     	conditioner->connect(top_block); |  | ||||||
|         top_block->connect(source->get_right_block(), 0, conditioner->get_left_block(), 0); |  | ||||||
|         top_block->connect(conditioner->get_right_block(), 0, skiphead, 0); |  | ||||||
|         top_block->connect(skiphead, 0,head, 0); |  | ||||||
|         top_block->connect(head, 0, sink, 0); |  | ||||||
|         top_block->run(); |  | ||||||
|     }catch(std::exception& e) |  | ||||||
|     { |     { | ||||||
|     	std::cout<<"Failure connecting the GNU Radio blocks "<<e.what()<<std::endl; |             source->connect(top_block); | ||||||
|     	return false; |             conditioner->connect(top_block); | ||||||
|  |             top_block->connect(source->get_right_block(), 0, conditioner->get_left_block(), 0); | ||||||
|  |             top_block->connect(conditioner->get_right_block(), 0, skiphead, 0); | ||||||
|  |             top_block->connect(skiphead, 0, head, 0); | ||||||
|  |             top_block->connect(head, 0, sink, 0); | ||||||
|  |             top_block->run(); | ||||||
|  |     } | ||||||
|  |     catch(std::exception& e) | ||||||
|  |     { | ||||||
|  |             std::cout << "Failure connecting the GNU Radio blocks " << e.what() << std::endl; | ||||||
|  |             return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     delete conditioner; |     delete conditioner; | ||||||
|     delete source; |     delete source; | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static time_t utc_time(int week, long tow) { | static time_t utc_time(int week, long tow) { | ||||||
|   time_t t; |     time_t t; | ||||||
|  |  | ||||||
|   /* Jan 5/6 midnight 1980 - beginning of GPS time as Unix time */ |     /* Jan 5/6 midnight 1980 - beginning of GPS time as Unix time */ | ||||||
|   t = 315964801; |     t = 315964801; | ||||||
|  |  | ||||||
|   /* soon week will wrap again, uh oh... */ |     /* soon week will wrap again, uh oh... */ | ||||||
|   /* TS 44.031: GPSTOW, range 0-604799.92, resolution 0.08 sec, 23-bit presentation */ |     /* TS 44.031: GPSTOW, range 0-604799.92, resolution 0.08 sec, 23-bit presentation */ | ||||||
|   t += (1024 + week) * 604800 + tow*0.08; |     t += (1024 + week) * 604800 + tow*0.08; | ||||||
|  |  | ||||||
|   return t; |     return t; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| int main(int argc, char** argv) | int main(int argc, char** argv) | ||||||
| { | { | ||||||
|     const std::string intro_help( |     const std::string intro_help( | ||||||
|             std::string("\n RTL-SDR E4000 RF fornt-end center frequency and sampling rate calibration tool that uses GPS signals\n") |             std::string("\n RTL-SDR E4000 RF front-end center frequency and sampling rate calibration tool that uses GPS signals\n") | ||||||
|     + |     + | ||||||
|     "Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors)\n" |     "Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors)\n" | ||||||
|     + |     + | ||||||
| @@ -214,7 +214,6 @@ int main(int argc, char** argv) | |||||||
|     + |     + | ||||||
|     "See COPYING file to see a copy of the General Public License\n \n"); |     "See COPYING file to see a copy of the General Public License\n \n"); | ||||||
|  |  | ||||||
|  |  | ||||||
|     google::SetUsageMessage(intro_help); |     google::SetUsageMessage(intro_help); | ||||||
|     google::SetVersionString(FRONT_END_CAL_VERSION); |     google::SetVersionString(FRONT_END_CAL_VERSION); | ||||||
|     google::ParseCommandLineFlags(&argc, &argv, true); |     google::ParseCommandLineFlags(&argc, &argv, true); | ||||||
| @@ -224,12 +223,12 @@ int main(int argc, char** argv) | |||||||
|     google::InitGoogleLogging(argv[0]); |     google::InitGoogleLogging(argv[0]); | ||||||
|     if (FLAGS_log_dir.empty()) |     if (FLAGS_log_dir.empty()) | ||||||
|         { |         { | ||||||
|              std::cout << "Logging will be done at " |             std::cout << "Logging will be done at " | ||||||
|  |  | ||||||
|                  << "/tmp" |                      << "/tmp" | ||||||
|                  << std::endl |                      << std::endl | ||||||
|                  << "Use front-end-cal --log_dir=/path/to/log to change that." |                      << "Use front-end-cal --log_dir=/path/to/log to change that." | ||||||
|                  << std::endl; |                      << std::endl; | ||||||
|         } |         } | ||||||
|     else |     else | ||||||
|         { |         { | ||||||
| @@ -237,13 +236,13 @@ int main(int argc, char** argv) | |||||||
|             if (!boost::filesystem::exists(p)) |             if (!boost::filesystem::exists(p)) | ||||||
|                 { |                 { | ||||||
|                     std::cout << "The path " |                     std::cout << "The path " | ||||||
|                         << FLAGS_log_dir |                               << FLAGS_log_dir | ||||||
|                         << " does not exist, attempting to create it" |                               << " does not exist, attempting to create it" | ||||||
|                         << std::endl; |                               << std::endl; | ||||||
|                     boost::filesystem::create_directory(p); |                     boost::filesystem::create_directory(p); | ||||||
|                 } |                 } | ||||||
|             std::cout << "Logging with be done at " |             std::cout << "Logging with be done at " | ||||||
|                 << FLAGS_log_dir << std::endl; |                       << FLAGS_log_dir << std::endl; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -253,26 +252,30 @@ int main(int argc, char** argv) | |||||||
|     // 1. Load configuration parameters from config file |     // 1. Load configuration parameters from config file | ||||||
|  |  | ||||||
|     ConfigurationInterface *configuration; |     ConfigurationInterface *configuration; | ||||||
|     configuration= new FileConfiguration(FLAGS_config_file); |     configuration = new FileConfiguration(FLAGS_config_file); | ||||||
|     front_end_cal.set_configuration(configuration); |     front_end_cal.set_configuration(configuration); | ||||||
|  |  | ||||||
|  |  | ||||||
|     // 2. Get SUPL information from server: Ephemeris record, assistance info and TOW |     // 2. Get SUPL information from server: Ephemeris record, assistance info and TOW | ||||||
|     if (front_end_cal.get_ephemeris()==true) |     if (front_end_cal.get_ephemeris() == true) | ||||||
|     { |         { | ||||||
|     	std::cout<<"SUPL data received OK!"<<std::endl; |             std::cout << "SUPL data received OK!" << std::endl; | ||||||
|     }else{ |         } | ||||||
|     	std::cout<<"Failure connecting to SUPL server"<<std::endl; |     else | ||||||
|     } |         { | ||||||
|  |             std::cout << "Failure connecting to SUPL server" <<std::endl; | ||||||
|  |         } | ||||||
|  |  | ||||||
|     // 3. Capture some front-end samples to hard disk |     // 3. Capture some front-end samples to hard disk | ||||||
|  |  | ||||||
|     if (front_end_capture(configuration)) |     if (front_end_capture(configuration)) | ||||||
|     { |         { | ||||||
|     	std::cout<<"Front-end RAW samples captured"<<std::endl; |             std::cout << "Front-end RAW samples captured" << std::endl; | ||||||
|     }else{ |         } | ||||||
|     	std::cout<<"Failure capturing front-end samples"<<std::endl; |     else | ||||||
|     } |         { | ||||||
|  |             std::cout << "Failure capturing front-end samples" << std::endl; | ||||||
|  |         } | ||||||
|  |  | ||||||
|     // 4. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) |     // 4. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) | ||||||
|  |  | ||||||
| @@ -282,12 +285,12 @@ int main(int argc, char** argv) | |||||||
|     top_block = gr::make_top_block("Acquisition test"); |     top_block = gr::make_top_block("Acquisition test"); | ||||||
|  |  | ||||||
|     // Satellite signal definition |     // Satellite signal definition | ||||||
|     gnss_synchro=new Gnss_Synchro(); |     gnss_synchro = new Gnss_Synchro(); | ||||||
|     gnss_synchro->Channel_ID=0; |     gnss_synchro->Channel_ID = 0; | ||||||
|     gnss_synchro->System = 'G'; |     gnss_synchro->System = 'G'; | ||||||
|     std::string signal = "1C"; |     std::string signal = "1C"; | ||||||
|     signal.copy(gnss_synchro->Signal,2,0); |     signal.copy(gnss_synchro->Signal, 2, 0); | ||||||
|     gnss_synchro->PRN=1; |     gnss_synchro->PRN = 1; | ||||||
|  |  | ||||||
|     long fs_in_ = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); |     long fs_in_ = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); | ||||||
|  |  | ||||||
| @@ -301,7 +304,6 @@ int main(int argc, char** argv) | |||||||
|     acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); |     acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); | ||||||
|     acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); |     acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); | ||||||
|  |  | ||||||
|  |  | ||||||
|     gr::block_sptr source; |     gr::block_sptr source; | ||||||
|     source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat"); |     source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat"); | ||||||
|  |  | ||||||
| @@ -310,13 +312,14 @@ int main(int argc, char** argv) | |||||||
|     //head_sptr->set_length(nsamples); |     //head_sptr->set_length(nsamples); | ||||||
|     //head_sptr->reset(); |     //head_sptr->reset(); | ||||||
|  |  | ||||||
|     try{ |     try | ||||||
|  |  | ||||||
|     	acquisition->connect(top_block); |  | ||||||
|         top_block->connect(source, 0, acquisition->get_left_block(), 0); |  | ||||||
|     }catch(std::exception& e) |  | ||||||
|     { |     { | ||||||
|     	std::cout<<"Failure connecting the GNU Radio blocks "<<std::endl; |             acquisition->connect(top_block); | ||||||
|  |             top_block->connect(source, 0, acquisition->get_left_block(), 0); | ||||||
|  |     } | ||||||
|  |     catch(std::exception& e) | ||||||
|  |     { | ||||||
|  |             std::cout << "Failure connecting the GNU Radio blocks " << std::endl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // 5. Run the flowgraph |     // 5. Run the flowgraph | ||||||
| @@ -332,169 +335,174 @@ int main(int argc, char** argv) | |||||||
|     gettimeofday(&tv, NULL); |     gettimeofday(&tv, NULL); | ||||||
|     long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; |     long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; | ||||||
|  |  | ||||||
|     bool start_msg=true; |     bool start_msg = true; | ||||||
|  |  | ||||||
|     for (unsigned int PRN=1;PRN<33;PRN++) |     for (unsigned int PRN=1; PRN<33; PRN++) | ||||||
|     { |  | ||||||
|     	gnss_synchro->PRN=PRN; |  | ||||||
|         acquisition->set_gnss_synchro(gnss_synchro); |  | ||||||
|         acquisition->init(); |  | ||||||
|         acquisition->reset(); |  | ||||||
|         stop=false; |  | ||||||
|         ch_thread = boost::thread(wait_message); |  | ||||||
|         top_block->run(); |  | ||||||
|         if (start_msg==true) |  | ||||||
|         { |         { | ||||||
|         	std::cout<<"Searching for GPS Satellites in L1 band..."<<std::endl; |             gnss_synchro->PRN = PRN; | ||||||
|         	std::cout<<"["; |             acquisition->set_gnss_synchro(gnss_synchro); | ||||||
|         	start_msg=false; |             acquisition->init(); | ||||||
|  |             acquisition->reset(); | ||||||
|  |             stop = false; | ||||||
|  |             ch_thread = boost::thread(wait_message); | ||||||
|  |             top_block->run(); | ||||||
|  |             if (start_msg == true) | ||||||
|  |                 { | ||||||
|  |                     std::cout << "Searching for GPS Satellites in L1 band..." << std::endl; | ||||||
|  |                     std::cout << "["; | ||||||
|  |                     start_msg = false; | ||||||
|  |                 } | ||||||
|  |             if (gnss_sync_vector.size()>0) | ||||||
|  |                 { | ||||||
|  |                     std::cout << " " << PRN << " "; | ||||||
|  |                     double doppler_measurement_hz = 0; | ||||||
|  |                     for (std::vector<Gnss_Synchro>::iterator it = gnss_sync_vector.begin() ; it != gnss_sync_vector.end(); ++it) | ||||||
|  |                         { | ||||||
|  |                             doppler_measurement_hz += (*it).Acq_doppler_hz; | ||||||
|  |                         } | ||||||
|  |                     doppler_measurement_hz = doppler_measurement_hz/gnss_sync_vector.size(); | ||||||
|  |                     doppler_measurements_map.insert(std::pair<int,double>(PRN, doppler_measurement_hz)); | ||||||
|  |                 } | ||||||
|  |             else | ||||||
|  |                 { | ||||||
|  |                     std::cout << " . "; | ||||||
|  |                 } | ||||||
|  |             channel_internal_queue.push(3); | ||||||
|  |             ch_thread.join(); | ||||||
|  |             gnss_sync_vector.clear(); | ||||||
|  |             boost::dynamic_pointer_cast<gr::blocks::file_source>(source)->seek(0, 0); | ||||||
|  |             std::cout.flush(); | ||||||
|         } |         } | ||||||
|         if (gnss_sync_vector.size()>0) |     std::cout << "]" << std::endl; | ||||||
|         { |  | ||||||
|         	std::cout<<" "<<PRN<<" "; |  | ||||||
|         	double doppler_measurement_hz=0; |  | ||||||
|             for (std::vector<Gnss_Synchro>::iterator it = gnss_sync_vector.begin() ; it != gnss_sync_vector.end(); ++it) |  | ||||||
|               { |  | ||||||
|             	doppler_measurement_hz+=(*it).Acq_doppler_hz; |  | ||||||
|               } |  | ||||||
|             doppler_measurement_hz=doppler_measurement_hz/gnss_sync_vector.size(); |  | ||||||
|             doppler_measurements_map.insert(std::pair<int,double>(PRN,doppler_measurement_hz)); |  | ||||||
|         }else{ |  | ||||||
|         	std::cout<<" . "; |  | ||||||
|         } |  | ||||||
|         channel_internal_queue.push(3); |  | ||||||
|         ch_thread.join(); |  | ||||||
|         gnss_sync_vector.clear(); |  | ||||||
|         boost::dynamic_pointer_cast<gr::blocks::file_source>(source)->seek(0,0); |  | ||||||
|         std::cout.flush(); |  | ||||||
|     } |  | ||||||
|     std::cout<<"]"<<std::endl; |  | ||||||
|  |  | ||||||
|     // report the elapsed time |     // report the elapsed time | ||||||
|     gettimeofday(&tv, NULL); |     gettimeofday(&tv, NULL); | ||||||
|     long long int end = tv.tv_sec * 1000000 + tv.tv_usec; |     long long int end = tv.tv_sec * 1000000 + tv.tv_usec; | ||||||
|     std::cout << "Total signal acquisition run time " |     std::cout << "Total signal acquisition run time " | ||||||
|         << ((double)(end - begin))/1000000.0 |               << ((double)(end - begin))/1000000.0 | ||||||
|         << " [seconds]" << std::endl; |               << " [seconds]" << std::endl; | ||||||
|  |  | ||||||
|     //6. find TOW from SUPL assistance |     //6. find TOW from SUPL assistance | ||||||
|  |  | ||||||
|     double current_TOW=0; |     double current_TOW = 0; | ||||||
|     if (global_gps_ephemeris_map.size()>0) |     if (global_gps_ephemeris_map.size() > 0) | ||||||
|     { |         { | ||||||
|     	std::map<int,Gps_Ephemeris> Eph_map; |             std::map<int,Gps_Ephemeris> Eph_map; | ||||||
|     	Eph_map=global_gps_ephemeris_map.get_map_copy(); |             Eph_map = global_gps_ephemeris_map.get_map_copy(); | ||||||
|     	current_TOW=Eph_map.begin()->second.d_TOW; |             current_TOW = Eph_map.begin()->second.d_TOW; | ||||||
|  |  | ||||||
|     	time_t t = utc_time(Eph_map.begin()->second.i_GPS_week, (long int)current_TOW); |             time_t t = utc_time(Eph_map.begin()->second.i_GPS_week, (long int)current_TOW); | ||||||
|  |  | ||||||
|     	fprintf(stdout, "Reference Time:\n"); |             fprintf(stdout, "Reference Time:\n"); | ||||||
|     	fprintf(stdout, "  GPS Week: %ld\n", Eph_map.begin()->second.i_GPS_week); |             fprintf(stdout, "  GPS Week: %ld\n", Eph_map.begin()->second.i_GPS_week); | ||||||
|     	fprintf(stdout, "  GPS TOW:  %ld %lf\n", (long int)current_TOW, (long int)current_TOW*0.08); |             fprintf(stdout, "  GPS TOW:  %ld %lf\n", (long int)current_TOW, (long int)current_TOW*0.08); | ||||||
|     	fprintf(stdout, "  ~ UTC:    %s", ctime(&t)); |             fprintf(stdout, "  ~ UTC:    %s", ctime(&t)); | ||||||
|     	std::cout<<"Current TOW obtained from SUPL assistance = "<<current_TOW<<std::endl; |             std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl; | ||||||
|     }else{ |         } | ||||||
|     	std::cout<<"Unable to get Ephemeris SUPL assistance. TOW is unknown!"<<std::endl; |     else | ||||||
|         delete configuration; |         { | ||||||
|         delete acquisition; |             std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!" << std::endl; | ||||||
|         delete gnss_synchro; |             delete configuration; | ||||||
|         google::ShutDownCommandLineFlags(); |             delete acquisition; | ||||||
|         std::cout << "GNSS-SDR Front-end calibration program ended." << std::endl; |             delete gnss_synchro; | ||||||
|     	return 0; |             google::ShutDownCommandLineFlags(); | ||||||
|     } |             std::cout << "GNSS-SDR Front-end calibration program ended." << std::endl; | ||||||
|  |             return 0; | ||||||
|  |         } | ||||||
|  |  | ||||||
|     //Get user position from config file (or from SUPL using GSM Cell ID) |     //Get user position from config file (or from SUPL using GSM Cell ID) | ||||||
|     double lat_deg = configuration->property("GNSS-SDR.init_latitude_deg", 41.0); |     double lat_deg = configuration->property("GNSS-SDR.init_latitude_deg", 41.0); | ||||||
|     double lon_deg = configuration->property("GNSS-SDR.init_longitude_deg", 2.0); |     double lon_deg = configuration->property("GNSS-SDR.init_longitude_deg", 2.0); | ||||||
|     double altitude_m = configuration->property("GNSS-SDR.init_altitude_m", 100); |     double altitude_m = configuration->property("GNSS-SDR.init_altitude_m", 100); | ||||||
|  |  | ||||||
|     std::cout<<"Reference location (defined in config file):"<<std::endl; |     std::cout << "Reference location (defined in config file):" << std::endl; | ||||||
|  |  | ||||||
|     std::cout<<"Latitude="<<lat_deg<<" [º]"<<std::endl; |     std::cout << "Latitude=" << lat_deg << " [<EFBFBD>]" << std::endl; | ||||||
|     std::cout<<"Longitude="<<lon_deg<<" [º]"<<std::endl; |     std::cout << "Longitude=" << lon_deg << " [<EFBFBD>]" << std::endl; | ||||||
|     std::cout<<"Altitude="<<altitude_m<<" [m]"<<std::endl; |     std::cout << "Altitude=" << altitude_m << " [m]" << std::endl; | ||||||
|  |  | ||||||
|     if (doppler_measurements_map.size()==0) |     if (doppler_measurements_map.size() == 0) | ||||||
|     { |         { | ||||||
|     	std::cout<<"Sorry, no GPS satellites detected in the front-end capture, please check the antenna setup..."<<std::endl; |             std::cout << "Sorry, no GPS satellites detected in the front-end capture, please check the antenna setup..." << std::endl; | ||||||
|         delete configuration; |             delete configuration; | ||||||
|         delete acquisition; |             delete acquisition; | ||||||
|         delete gnss_synchro; |             delete gnss_synchro; | ||||||
|         google::ShutDownCommandLineFlags(); |             google::ShutDownCommandLineFlags(); | ||||||
|         std::cout << "GNSS-SDR Front-end calibration program ended." << std::endl; |             std::cout << "GNSS-SDR Front-end calibration program ended." << std::endl; | ||||||
|     	return 0; |             return 0; | ||||||
|     } |         } | ||||||
|  |  | ||||||
|     std::map<int,double> f_if_estimation_Hz_map; |     std::map<int,double> f_if_estimation_Hz_map; | ||||||
|     std::map<int,double> f_fs_estimation_Hz_map; |     std::map<int,double> f_fs_estimation_Hz_map; | ||||||
|     std::map<int,double> f_ppm_estimation_Hz_map; |     std::map<int,double> f_ppm_estimation_Hz_map; | ||||||
|  |  | ||||||
|     std::cout <<std::setiosflags(std::ios::fixed)<<std::setprecision(2)<< |     std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << | ||||||
| 			"Doppler analysis results:"<<std::endl; |             "Doppler analysis results:" << std::endl; | ||||||
|  |  | ||||||
|     std::cout << "SV ID  Measured [Hz]   Predicted [Hz]" <<std::endl; |     std::cout << "SV ID  Measured [Hz]   Predicted [Hz]" << std::endl; | ||||||
|  |  | ||||||
|     for (std::map<int,double>::iterator it = doppler_measurements_map.begin() ; it != doppler_measurements_map.end(); ++it) |     for (std::map<int,double>::iterator it = doppler_measurements_map.begin() ; it != doppler_measurements_map.end(); ++it) | ||||||
|       { |         { | ||||||
|     	try{ |             try | ||||||
|     		double doppler_estimated_hz; |             { | ||||||
|     		doppler_estimated_hz=front_end_cal.estimate_doppler_from_eph(it->first,current_TOW,lat_deg,lon_deg,altitude_m); |                     double doppler_estimated_hz; | ||||||
|     		std::cout << "  "<<it->first<<"   "<<it->second<<"   "<<doppler_estimated_hz<<std::endl; |                     doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it->first, current_TOW, lat_deg, lon_deg, altitude_m); | ||||||
|     		// 7. Compute front-end IF and sampling frequency estimation |                     std::cout << "  " << it->first << "   " << it->second << "   " << doppler_estimated_hz << std::endl; | ||||||
|     		// Compare with the measurements and compute clock drift using FE model |                     // 7. Compute front-end IF and sampling frequency estimation | ||||||
|     		double estimated_fs_Hz, estimated_f_if_Hz,f_osc_err_ppm; |                     // Compare with the measurements and compute clock drift using FE model | ||||||
|     		front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz,it->second,fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm ); |                     double estimated_fs_Hz, estimated_f_if_Hz, f_osc_err_ppm; | ||||||
|  |                     front_end_cal.GPS_L1_front_end_model_E4000(doppler_estimated_hz, it->second,fs_in_, &estimated_fs_Hz, &estimated_f_if_Hz, &f_osc_err_ppm ); | ||||||
|  |  | ||||||
|     		f_if_estimation_Hz_map.insert(std::pair<int,double>(it->first,estimated_f_if_Hz)); |                     f_if_estimation_Hz_map.insert(std::pair<int,double>(it->first,estimated_f_if_Hz)); | ||||||
|     		f_fs_estimation_Hz_map.insert(std::pair<int,double>(it->first,estimated_fs_Hz)); |                     f_fs_estimation_Hz_map.insert(std::pair<int,double>(it->first,estimated_fs_Hz)); | ||||||
|     		f_ppm_estimation_Hz_map.insert(std::pair<int,double>(it->first,f_osc_err_ppm)); |                     f_ppm_estimation_Hz_map.insert(std::pair<int,double>(it->first,f_osc_err_ppm)); | ||||||
|  |             } | ||||||
|     	}catch(int ex) |             catch(int ex) | ||||||
|     	{ |             { | ||||||
|     		std::cout << "  "<<it->first<<"   "<<it->second<<"  (Eph not found)"<<std::endl; |                     std::cout << "  " << it->first << "   " << it->second << "  (Eph not found)" << std::endl; | ||||||
|     	} |             } | ||||||
|       } |         } | ||||||
|  |  | ||||||
|     // FINAL FE estimations |     // FINAL FE estimations | ||||||
|     double mean_f_if_Hz=0; |     double mean_f_if_Hz = 0; | ||||||
|     double mean_fs_Hz=0; |     double mean_fs_Hz = 0; | ||||||
|     double mean_osc_err_ppm=0; |     double mean_osc_err_ppm = 0; | ||||||
|     int n_elements=f_if_estimation_Hz_map.size(); |     int n_elements = f_if_estimation_Hz_map.size(); | ||||||
|  |  | ||||||
|     for (std::map<int,double>::iterator it = f_if_estimation_Hz_map.begin() ; it != f_if_estimation_Hz_map.end(); ++it) |     for (std::map<int,double>::iterator it = f_if_estimation_Hz_map.begin() ; it != f_if_estimation_Hz_map.end(); ++it) | ||||||
|     { |         { | ||||||
|     	mean_f_if_Hz+=(*it).second; |             mean_f_if_Hz += (*it).second; | ||||||
|     	mean_fs_Hz+=f_fs_estimation_Hz_map.find((*it).first)->second; |             mean_fs_Hz += f_fs_estimation_Hz_map.find((*it).first)->second; | ||||||
|     	mean_osc_err_ppm+=f_ppm_estimation_Hz_map.find((*it).first)->second; |             mean_osc_err_ppm += f_ppm_estimation_Hz_map.find((*it).first)->second; | ||||||
|     } |         } | ||||||
|  |  | ||||||
|     mean_f_if_Hz/=n_elements; |     mean_f_if_Hz /= n_elements; | ||||||
|     mean_fs_Hz/=n_elements; |     mean_fs_Hz /= n_elements; | ||||||
|     mean_osc_err_ppm/=n_elements; |     mean_osc_err_ppm /= n_elements; | ||||||
|  |  | ||||||
| 	std::cout <<std::setiosflags(std::ios::fixed)<<std::setprecision(2)<<"Parameters estimation for Elonics E4000 Front-End:"<<std::endl; |     std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "Parameters estimation for Elonics E4000 Front-End:" << std::endl; | ||||||
|  |  | ||||||
| 	std::cout<<"Sampling frequency ="<<mean_fs_Hz<<" [Hz]"<<std::endl; |     std::cout << "Sampling frequency =" << mean_fs_Hz << " [Hz]" << std::endl; | ||||||
| 	std::cout<<"IF bias present in baseband="<<mean_f_if_Hz<<" [Hz]"<<std::endl; |     std::cout << "IF bias present in baseband=" << mean_f_if_Hz << " [Hz]" << std::endl; | ||||||
| 	std::cout<<"Reference oscillator error ="<<mean_osc_err_ppm<<" [ppm]"<<std::endl; |     std::cout << "Reference oscillator error =" << mean_osc_err_ppm << " [ppm]" << std::endl; | ||||||
|  |  | ||||||
|  |  | ||||||
|     std::cout <<std::setiosflags(std::ios::fixed)<<std::setprecision(2)<< |  | ||||||
| 			"Corrected Doppler vs. Predicted"<<std::endl; |  | ||||||
|     std::cout << "SV ID  Corrected [Hz]   Predicted [Hz]" <<std::endl; |  | ||||||
|  |  | ||||||
|  |     std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) | ||||||
|  |               << "Corrected Doppler vs. Predicted" << std::endl; | ||||||
|  |     std::cout << "SV ID  Corrected [Hz]   Predicted [Hz]" << std::endl; | ||||||
|  |  | ||||||
|     for (std::map<int,double>::iterator it = doppler_measurements_map.begin() ; it != doppler_measurements_map.end(); ++it) |     for (std::map<int,double>::iterator it = doppler_measurements_map.begin() ; it != doppler_measurements_map.end(); ++it) | ||||||
|       { |         { | ||||||
|     	try{ |             try | ||||||
|     		double doppler_estimated_hz; |             { | ||||||
|     		doppler_estimated_hz=front_end_cal.estimate_doppler_from_eph(it->first,current_TOW,lat_deg,lon_deg,altitude_m); |                     double doppler_estimated_hz; | ||||||
|     		std::cout << "  "<<it->first<<"   "<<it->second -mean_f_if_Hz<<"   "<<doppler_estimated_hz<<std::endl; |                     doppler_estimated_hz = front_end_cal.estimate_doppler_from_eph(it->first, current_TOW, lat_deg, lon_deg, altitude_m); | ||||||
|     	}catch(int ex) |                     std::cout  <<  "  " << it->first << "   " << it->second - mean_f_if_Hz  <<  "   " << doppler_estimated_hz << std::endl; | ||||||
|     	{ |             } | ||||||
|     		std::cout << "  "<<it->first<<"   "<<it->second-mean_f_if_Hz<<"  (Eph not found)"<<std::endl; |             catch(int ex) | ||||||
|     	} |             { | ||||||
|       } |                     std::cout << "  " << it->first << "   " << it->second - mean_f_if_Hz << "  (Eph not found)" << std::endl; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|     // 8. Generate GNSS-SDR config file. |     // 8. Generate GNSS-SDR config file. | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez