mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +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,13 +135,11 @@ 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) | ||||
| { | ||||
|  | ||||
|     // SET SUPL CLIENT INFORMATION | ||||
|     // GSM CELL PARAMETERS | ||||
|     mcc = i_mcc; | ||||
| @@ -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_usec = (double)assist.time.stamp.tv_usec; | ||||
|             gps_time.valid = true; | ||||
|  | ||||
|         } | ||||
|  | ||||
|     // READ UTC MODEL | ||||
| @@ -216,7 +213,6 @@ void gnss_sdr_supl_client::read_supl_data() | ||||
|             gps_iono.d_beta2 = (double)assist.iono.b2 * BETA_2_LSB; | ||||
|             gps_iono.d_beta3 = (double)assist.iono.b3 * BETA_3_LSB; | ||||
|             gps_iono.valid = true; | ||||
|  | ||||
|         } | ||||
|  | ||||
|     // READ SV ALMANAC | ||||
| @@ -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 | ||||
|     { | ||||
| @@ -362,8 +358,8 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) | ||||
|     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 | ||||
|     { | ||||
|   | ||||
| @@ -31,13 +31,12 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
| #ifndef GNSS_SDR_VERSION | ||||
| #define GNSS_SDR_VERSION "0.0.1" | ||||
| #define GNSS_SDR_VERSION "0.0.2" | ||||
| #endif | ||||
|  | ||||
| #include <boost/filesystem.hpp> | ||||
| #include <boost/exception/diagnostic_information.hpp> | ||||
| #include <boost/exception_ptr.hpp> | ||||
|  | ||||
| #include <gflags/gflags.h> | ||||
| #include <glog/log_severity.h> | ||||
| #include <glog/logging.h> | ||||
| @@ -48,17 +47,14 @@ | ||||
| #include <boost/thread/thread.hpp> | ||||
| #include "concurrent_queue.h" | ||||
| #include "concurrent_map.h" | ||||
|  | ||||
| #include "gps_ephemeris.h" | ||||
| #include "gps_almanac.h" | ||||
| #include "gps_iono.h" | ||||
| #include "gps_utc_model.h" | ||||
|  | ||||
| #include "galileo_ephemeris.h" | ||||
| #include "galileo_almanac.h" | ||||
| #include "galileo_iono.h" | ||||
| #include "galileo_utc_model.h" | ||||
|  | ||||
| #include <sys/time.h> | ||||
| #include <ctime> | ||||
| #include <memory> | ||||
| @@ -153,9 +149,11 @@ int main(int argc, char** argv) | ||||
|     gettimeofday(&tv, NULL); | ||||
|     long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; | ||||
|  | ||||
|     try{ | ||||
|     try | ||||
|     { | ||||
|             control_thread->run(); | ||||
|     }catch( boost::exception & e ) | ||||
|     } | ||||
|     catch( boost::exception & e ) | ||||
|     { | ||||
|             DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e); | ||||
|     } | ||||
|   | ||||
| @@ -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 <boost/filesystem.hpp> | ||||
| #include <gflags/gflags.h> | ||||
| #include <glog/log_severity.h> | ||||
| #include <glog/logging.h> | ||||
|  | ||||
| #include <boost/thread/mutex.hpp> | ||||
| #include <boost/thread/thread.hpp> | ||||
| #include <boost/lexical_cast.hpp> | ||||
|  | ||||
| #include "file_configuration.h" | ||||
|  | ||||
| #include "gps_navigation_message.h" | ||||
| #include "gps_ephemeris.h" | ||||
| #include "gps_almanac.h" | ||||
| @@ -21,7 +48,6 @@ | ||||
| #include <ctime> | ||||
| #include <memory> | ||||
| #include <math.h> | ||||
|  | ||||
| #include "front_end_cal.h" | ||||
|  | ||||
|  | ||||
| @@ -32,13 +58,10 @@ extern	concurrent_map<Gps_Almanac> global_gps_almanac_map; | ||||
| extern concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map; | ||||
|  | ||||
| FrontEndCal::FrontEndCal() | ||||
| { | ||||
| {} | ||||
|  | ||||
| } | ||||
| FrontEndCal::~FrontEndCal() | ||||
| { | ||||
|  | ||||
| } | ||||
| {} | ||||
|  | ||||
| bool FrontEndCal::read_assistance_from_XML() | ||||
| { | ||||
| @@ -57,7 +80,9 @@ bool FrontEndCal::read_assistance_from_XML() | ||||
|                     global_gps_ephemeris_map.write(gps_eph_iter->second.i_satellite_PRN, gps_eph_iter->second); | ||||
|                 } | ||||
|             return true; | ||||
| 	}else{ | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             std::cout <<  "ERROR: SUPL client error reading XML" << std::endl; | ||||
|             return false; | ||||
|         } | ||||
| @@ -90,14 +115,20 @@ int FrontEndCal::Get_SUPL_Assist() | ||||
|  | ||||
|             std::string default_lac = "0x59e2"; | ||||
|             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 &) { | ||||
|             } | ||||
|             catch(boost::bad_lexical_cast &) | ||||
|             { | ||||
|                     supl_lac = 0x59e2; | ||||
|             } | ||||
| 		try { | ||||
|             try | ||||
|             { | ||||
|                     supl_ci = boost::lexical_cast<int>(configuration_->property("GNSS-SDR.SUPL_CI", default_ci)); | ||||
| 		} catch(boost::bad_lexical_cast &) { | ||||
|             } | ||||
|             catch(boost::bad_lexical_cast &) | ||||
|             { | ||||
|                     supl_ci = 0x31b0; | ||||
|             } | ||||
|  | ||||
| @@ -106,11 +137,12 @@ int FrontEndCal::Get_SUPL_Assist() | ||||
|                 { | ||||
|                     // read assistance from file | ||||
|                     read_assistance_from_XML(); | ||||
| 		}else{ | ||||
|  | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     // Request ephemeris from SUPL server | ||||
|                     supl_client_ephemeris_.request = 1; | ||||
| 			DLOG(INFO) << "SUPL: Try read GPS ephemeris from SUPL server.."<<std::endl; | ||||
|                     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) | ||||
|                         { | ||||
| @@ -119,24 +151,26 @@ int FrontEndCal::Get_SUPL_Assist() | ||||
|                                     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<<std::endl; | ||||
| 					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; | ||||
|                                     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"<<std::endl; | ||||
|                                     DLOG(INFO)  << "SUPL: XML Ephemeris file created."; | ||||
|                                 } | ||||
| 			}else{ | ||||
| 				DLOG(INFO) << "ERROR: SUPL client for Ephemeris returned "<<error<<std::endl; | ||||
| 				DLOG(INFO) << "Please check internet connection and SUPL server configuration"<<error<<std::endl; | ||||
|                         } | ||||
|                     else | ||||
|                         { | ||||
|                             DLOG(INFO) << "ERROR: SUPL client for Ephemeris returned " << error; | ||||
|                             DLOG(INFO) << "Please check Internet connection and SUPL server configuration" << error; | ||||
|                         } | ||||
|  | ||||
|                     // Request almanac , IONO and UTC Model | ||||
|                     supl_client_ephemeris_.request = 0; | ||||
| 			DLOG(INFO) << "SUPL: Try read Almanac, Iono, Utc Model, Ref Time and Ref Location 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); | ||||
|                     if (error == 0) | ||||
|                         { | ||||
| @@ -145,27 +179,29 @@ int FrontEndCal::Get_SUPL_Assist() | ||||
|                                     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; | ||||
|                                     DLOG(INFO)  << "SUPL: Received Almanac for GPS SV " << gps_alm_iter->first; | ||||
|                                     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; | ||||
|                                     DLOG(INFO)  << "SUPL: Received GPS Iono"; | ||||
|                                     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; | ||||
|                                     DLOG(INFO)  << "SUPL: Received GPS UTC Model"; | ||||
|                                     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; | ||||
|                         } | ||||
|                     else | ||||
|                         { | ||||
|                             DLOG(INFO) << "ERROR: SUPL client for Almanac returned " << error; | ||||
|                             DLOG(INFO) << "Please check Internet connection and SUPL server configuration" << error; | ||||
|                         } | ||||
|  | ||||
|                     // Request acquisition assistance | ||||
|                     supl_client_acquisition_.request = 2; | ||||
| 			DLOG(INFO) << "SUPL: Try read Acquisition assistance from SUPL server.."<<std::endl; | ||||
|                     DLOG(INFO) << "SUPL: Trying to read Acquisition assistance from SUPL server..."; | ||||
|  | ||||
|                     error = supl_client_acquisition_.get_assistance(supl_mcc, supl_mns, supl_lac, supl_ci); | ||||
|                     if (error == 0) | ||||
| @@ -175,13 +211,15 @@ int FrontEndCal::Get_SUPL_Assist() | ||||
|                                     gps_acq_iter != supl_client_acquisition_.gps_acq_map.end(); | ||||
|                                     gps_acq_iter++) | ||||
|                                 { | ||||
| 					DLOG(INFO) <<"SUPL: Received Acquisition assistance for GPS SV "<<gps_acq_iter->first<<std::endl; | ||||
| 					DLOG(INFO)  << "New acq assist record inserted"<<std::endl; | ||||
|                                     DLOG(INFO) << "SUPL: Received Acquisition assistance for GPS SV " << gps_acq_iter->first; | ||||
|                                     DLOG(INFO) << "New acq assist record inserted"; | ||||
|                                     global_gps_acq_assist_map.write(gps_acq_iter->second.i_satellite_PRN, gps_acq_iter->second); | ||||
|                                 } | ||||
| 			}else{ | ||||
| 				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; | ||||
|                         } | ||||
|                     else | ||||
|                         { | ||||
|                             DLOG(INFO) << "ERROR: SUPL client for Acquisition assistance returned " << error; | ||||
|                             DLOG(INFO) << "Please check internet connection and SUPL server configuration" << error; | ||||
|                         } | ||||
|                 } | ||||
|         } | ||||
| @@ -194,6 +232,7 @@ void FrontEndCal::set_configuration(ConfigurationInterface *configuration) | ||||
|     configuration_ = configuration; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool FrontEndCal::get_ephemeris() | ||||
| { | ||||
|     bool read_ephemeris_from_xml=configuration_->property("GNSS-SDR.read_eph_from_xml", false); | ||||
| @@ -203,30 +242,38 @@ bool FrontEndCal::get_ephemeris() | ||||
|             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: 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) | ||||
|                         { | ||||
|                             return true; | ||||
| 			}else{ | ||||
|                         } | ||||
|                     else | ||||
|                         { | ||||
|                             return false; | ||||
|                         } | ||||
| 		}else{ | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     return true; | ||||
|                 } | ||||
| 	}else{ | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             std::cout <<  "Trying to read ephemeris from SUPL server..." << std::endl; | ||||
|             if (Get_SUPL_Assist() == 0) | ||||
|                 { | ||||
|                     return true; | ||||
| 		}else{ | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     return false; | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| arma::vec FrontEndCal::lla2ecef(arma::vec lla) | ||||
| { | ||||
|  | ||||
|     // WGS84 flattening | ||||
|     double f; | ||||
|     f  = 1/298.257223563; | ||||
| @@ -249,9 +296,9 @@ arma::vec FrontEndCal::lla2ecef(arma::vec lla) | ||||
|     return ecef; | ||||
| } | ||||
|  | ||||
|  | ||||
| arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, arma::vec ellipsoid) | ||||
| { | ||||
|  | ||||
|     double a; | ||||
|     a  = ellipsoid(0); | ||||
|     double e2; | ||||
| @@ -273,13 +320,12 @@ arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, arma:: | ||||
|     return ecef; | ||||
| } | ||||
|  | ||||
|  | ||||
| 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; | ||||
|  | ||||
|  | ||||
|     //Observer position ECEF | ||||
|     arma::vec obs_ecef = "0.0 0.0 0.0 0.0"; | ||||
|     arma::vec lla = "0.0 0.0 0.0 0.0"; | ||||
| @@ -288,7 +334,6 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub | ||||
|     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(); | ||||
| @@ -298,7 +343,6 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub | ||||
|  | ||||
|     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; | ||||
| @@ -323,7 +367,7 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub | ||||
|             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 | ||||
|             // tx and rx are approaching to each other. So, the satellite velocity must | ||||
|             // be redefined as: | ||||
|  | ||||
|             obs_to_sat_velocity = -obs_to_sat_velocity; | ||||
| @@ -335,17 +379,16 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub | ||||
|             mean_Doppler_Hz = arma::mean(Doppler_Hz); | ||||
|             return mean_Doppler_Hz; | ||||
|             return 0; | ||||
| 	}else{ | ||||
|         } | ||||
|     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) | ||||
| { | ||||
|  | ||||
|  | ||||
|  | ||||
|     double f_osc_n = 28.8e6; | ||||
|     //PLL registers settings (according to E4000 datasheet) | ||||
|  | ||||
| @@ -376,7 +419,6 @@ void FrontEndCal::GPS_L1_front_end_model_E4000(double f_bb_true_Hz,double f_bb_m | ||||
|  | ||||
|     *estimated_fs_Hz = frac*(f_osc_n + f_osc_err_hz); | ||||
|     *estimated_f_if_Hz = f_rf_err; | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,3 +1,37 @@ | ||||
| /*! | ||||
|  * \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 "armadillo" | ||||
|  | ||||
| @@ -56,14 +90,14 @@ private: | ||||
|      * | ||||
|      */ | ||||
|     int Get_SUPL_Assist(); | ||||
|  | ||||
| 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 | ||||
| @@ -71,6 +105,7 @@ public: | ||||
|      * | ||||
|      */ | ||||
|     bool get_ephemeris(); | ||||
|  | ||||
|     /*! | ||||
|      * \brief This function estimates the GPS L1 satellite Doppler frequency [Hz] using the following data: | ||||
|      * 1- Orbital model from the ephemeris | ||||
| @@ -79,6 +114,7 @@ public: | ||||
|      * | ||||
|      */ | ||||
|     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: | ||||
| @@ -89,7 +125,7 @@ public: | ||||
|      *  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 | ||||
|      *  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 ); | ||||
| @@ -97,3 +133,5 @@ public: | ||||
|     FrontEndCal(); | ||||
|     ~FrontEndCal(); | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -146,7 +146,6 @@ bool front_end_capture(ConfigurationInterface *configuration) | ||||
|     queue =  gr::msg_queue::make(0); | ||||
|     top_block = gr::make_top_block("Acquisition test"); | ||||
|  | ||||
|  | ||||
|     GNSSBlockInterface *source; | ||||
|     source = block_factory.GetSignalSource(configuration, queue); | ||||
|  | ||||
| @@ -168,8 +167,8 @@ bool front_end_capture(ConfigurationInterface *configuration) | ||||
|  | ||||
|     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); | ||||
| @@ -177,7 +176,8 @@ bool front_end_capture(ConfigurationInterface *configuration) | ||||
|             top_block->connect(skiphead, 0, head, 0); | ||||
|             top_block->connect(head, 0, sink, 0); | ||||
|             top_block->run(); | ||||
|     }catch(std::exception& e) | ||||
|     } | ||||
|     catch(std::exception& e) | ||||
|     { | ||||
|             std::cout << "Failure connecting the GNU Radio blocks " << e.what() << std::endl; | ||||
|             return false; | ||||
| @@ -185,11 +185,10 @@ bool front_end_capture(ConfigurationInterface *configuration) | ||||
|  | ||||
|     delete conditioner; | ||||
|     delete source; | ||||
|  | ||||
|     return true; | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| static time_t utc_time(int week, long tow) { | ||||
|     time_t t; | ||||
|  | ||||
| @@ -203,10 +202,11 @@ static time_t utc_time(int week, long tow) { | ||||
|     return t; | ||||
| } | ||||
|  | ||||
|  | ||||
| int main(int argc, char** argv) | ||||
| { | ||||
|     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" | ||||
|     + | ||||
| @@ -214,7 +214,6 @@ int main(int argc, char** argv) | ||||
|     + | ||||
|     "See COPYING file to see a copy of the General Public License\n \n"); | ||||
|  | ||||
|  | ||||
|     google::SetUsageMessage(intro_help); | ||||
|     google::SetVersionString(FRONT_END_CAL_VERSION); | ||||
|     google::ParseCommandLineFlags(&argc, &argv, true); | ||||
| @@ -261,7 +260,9 @@ int main(int argc, char** argv) | ||||
|     if (front_end_cal.get_ephemeris() == true) | ||||
|         { | ||||
|             std::cout << "SUPL data received OK!" << std::endl; | ||||
|     }else{ | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             std::cout << "Failure connecting to SUPL server" <<std::endl; | ||||
|         } | ||||
|  | ||||
| @@ -270,7 +271,9 @@ int main(int argc, char** argv) | ||||
|     if (front_end_capture(configuration)) | ||||
|         { | ||||
|             std::cout << "Front-end RAW samples captured" << std::endl; | ||||
|     }else{ | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             std::cout << "Failure capturing front-end samples" << std::endl; | ||||
|         } | ||||
|  | ||||
| @@ -301,7 +304,6 @@ int main(int argc, char** argv) | ||||
|     acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); | ||||
|     acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); | ||||
|  | ||||
|  | ||||
|     gr::block_sptr source; | ||||
|     source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat"); | ||||
|  | ||||
| @@ -310,11 +312,12 @@ int main(int argc, char** argv) | ||||
|     //head_sptr->set_length(nsamples); | ||||
|     //head_sptr->reset(); | ||||
|  | ||||
|     try{ | ||||
|  | ||||
|     try | ||||
|     { | ||||
|             acquisition->connect(top_block); | ||||
|             top_block->connect(source, 0, acquisition->get_left_block(), 0); | ||||
|     }catch(std::exception& e) | ||||
|     } | ||||
|     catch(std::exception& e) | ||||
|     { | ||||
|             std::cout << "Failure connecting the GNU Radio blocks " << std::endl; | ||||
|     } | ||||
| @@ -359,7 +362,9 @@ int main(int argc, char** argv) | ||||
|                         } | ||||
|                     doppler_measurement_hz = doppler_measurement_hz/gnss_sync_vector.size(); | ||||
|                     doppler_measurements_map.insert(std::pair<int,double>(PRN, doppler_measurement_hz)); | ||||
|         }else{ | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     std::cout << " . "; | ||||
|                 } | ||||
|             channel_internal_queue.push(3); | ||||
| @@ -393,7 +398,9 @@ int main(int argc, char** argv) | ||||
|             fprintf(stdout, "  GPS TOW:  %ld %lf\n", (long int)current_TOW, (long int)current_TOW*0.08); | ||||
|             fprintf(stdout, "  ~ UTC:    %s", ctime(&t)); | ||||
|             std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl; | ||||
|     }else{ | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!" << std::endl; | ||||
|             delete configuration; | ||||
|             delete acquisition; | ||||
| @@ -410,8 +417,8 @@ int main(int argc, char** argv) | ||||
|  | ||||
|     std::cout << "Reference location (defined in config file):" << std::endl; | ||||
|  | ||||
|     std::cout<<"Latitude="<<lat_deg<<" [º]"<<std::endl; | ||||
|     std::cout<<"Longitude="<<lon_deg<<" [º]"<<std::endl; | ||||
|     std::cout << "Latitude=" << lat_deg << " [<EFBFBD>]" << std::endl; | ||||
|     std::cout << "Longitude=" << lon_deg << " [<EFBFBD>]" << std::endl; | ||||
|     std::cout << "Altitude=" << altitude_m << " [m]" << std::endl; | ||||
|  | ||||
|     if (doppler_measurements_map.size() == 0) | ||||
| @@ -436,7 +443,8 @@ int main(int argc, char** argv) | ||||
|  | ||||
|     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); | ||||
|                     std::cout << "  " << it->first << "   " << it->second << "   " << doppler_estimated_hz << std::endl; | ||||
| @@ -448,8 +456,8 @@ int main(int argc, char** argv) | ||||
|                     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_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; | ||||
|             } | ||||
| @@ -478,19 +486,19 @@ int main(int argc, char** argv) | ||||
|     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 <<std::setiosflags(std::ios::fixed)<<std::setprecision(2)<< | ||||
| 			"Corrected Doppler vs. Predicted"<<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) | ||||
|         { | ||||
|     	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); | ||||
|                     std::cout  <<  "  " << it->first << "   " << it->second - mean_f_if_Hz  <<  "   " << doppler_estimated_hz << std::endl; | ||||
|     	}catch(int ex) | ||||
|             } | ||||
|             catch(int ex) | ||||
|             { | ||||
|                     std::cout << "  " << it->first << "   " << it->second - mean_f_if_Hz << "  (Eph not found)" << std::endl; | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez