#include #include #include #include #include #include #include #include #include "file_configuration.h" #include "gps_navigation_message.h" #include "gps_ephemeris.h" #include "gps_almanac.h" #include "gps_iono.h" #include "gps_utc_model.h" #include "gnss_sdr_supl_client.h" #include #include #include #include #include "front_end_cal.h" extern concurrent_map global_gps_ephemeris_map; extern concurrent_map global_gps_iono_map; extern concurrent_map global_gps_utc_model_map; extern concurrent_map global_gps_almanac_map; extern concurrent_map global_gps_acq_assist_map; FrontEndCal::FrontEndCal() { } FrontEndCal::~FrontEndCal() { } bool FrontEndCal::read_assistance_from_XML() { gnss_sdr_supl_client supl_client_ephemeris_; std::string eph_xml_filename="gps_ephemeris.xml"; std::cout<< "SUPL: Try read GPS ephemeris from XML file "<::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++) { std::cout<<"SUPL: Read XML Ephemeris for GPS SV "<first<property("GNSS-SDR.SUPL_gps_enabled",false); if (enable_gps_supl_assistance==true) //SUPL SERVER TEST. Not operational yet! { DLOG(INFO) << "SUPL RRLP GPS assistance enabled!"<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_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_mcc=configuration_->property("GNSS-SDR.SUPL_MCC",244); supl_mns=configuration_->property("GNSS-SDR.SUPL_MNS",5); std::string default_lac="0x59e2"; std::string default_ci="0x31b0"; try { supl_lac = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_LAC",default_lac)); } catch(boost::bad_lexical_cast &) { supl_lac=0x59e2; } try { supl_ci = boost::lexical_cast(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); if (SUPL_read_gps_assistance_xml==true) { // read assistance from file read_assistance_from_XML(); }else{ // Request ephemeris from SUPL server supl_client_ephemeris_.request=1; DLOG(INFO) << "SUPL: Try read GPS ephemeris from SUPL server.."<::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 "<first<::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 "<first<first,gps_alm_iter->second); } if (supl_client_ephemeris_.gps_iono.valid==true) { DLOG(INFO) <<"SUPL: Received GPS Iono"<::iterator gps_acq_iter; for(gps_acq_iter = supl_client_acquisition_.gps_acq_map.begin(); gps_acq_iter != supl_client_acquisition_.gps_acq_map.end(); gps_acq_iter++) { DLOG(INFO) <<"SUPL: Received Acquisition assistance for GPS SV "<first<second.i_satellite_PRN,gps_acq_iter->second); } }else{ DLOG(INFO) << "ERROR: SUPL client for Acquisition assistance returned "<property("GNSS-SDR.read_eph_from_xml",false); if (read_ephemeris_from_xml==true) { std::cout<< "Trying to read ephemeris from XML file..."< eph_map; eph_map=global_gps_ephemeris_map.get_map_copy(); std::map::iterator eph_it; 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;isecond.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); } } 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 ) { // % 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 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_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; }