diff --git a/src/algorithms/PVT/adapters/gps_l1_ca_pvt.cc b/src/algorithms/PVT/adapters/gps_l1_ca_pvt.cc index 27d911289..6c871843d 100644 --- a/src/algorithms/PVT/adapters/gps_l1_ca_pvt.cc +++ b/src/algorithms/PVT/adapters/gps_l1_ca_pvt.cc @@ -1,7 +1,7 @@ /*! * \file gps_l1_ca_pvt.cc * \brief Implementation of an adapter of a GPS L1 C/A PVT solver block to a - * PVTInterface + * PvtInterface * \author Javier Arribas, 2011. jarribas(at)cttc.es * * diff --git a/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h b/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h index d9dac58e5..4f73ec4b7 100644 --- a/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h +++ b/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h @@ -1,7 +1,7 @@ /*! * \file gps_l1_ca_pvt.h * \brief Interface of an adapter of a GPS L1 C/A PVT solver block to a - * PVTInterface + * PvtInterface * Position Velocity and Time * \author Javier Arribas, 2011. jarribas(at)cttc.es * diff --git a/src/algorithms/PVT/libs/rinex_2_1_printer.cc b/src/algorithms/PVT/libs/rinex_2_1_printer.cc index 8fd8b7cb8..96ebac6ff 100644 --- a/src/algorithms/PVT/libs/rinex_2_1_printer.cc +++ b/src/algorithms/PVT/libs/rinex_2_1_printer.cc @@ -55,6 +55,8 @@ rinex_printer::rinex_printer() } + + rinex_printer::~rinex_printer() { // close RINEX files @@ -614,9 +616,6 @@ int rinex_printer::signalStrength(double snr) /* - - - enum RINEX_enumObservationType { RINEX_OBS_TYPE_PSEUDORANGE = 'C', //!< 'C' Pseudorange observation diff --git a/src/algorithms/PVT/libs/rinex_2_1_printer.h b/src/algorithms/PVT/libs/rinex_2_1_printer.h index f4e0e7bfa..313816bab 100644 --- a/src/algorithms/PVT/libs/rinex_2_1_printer.h +++ b/src/algorithms/PVT/libs/rinex_2_1_printer.h @@ -45,8 +45,7 @@ private: std::ofstream navFile ; std::ofstream obsFile ; - /*! - * \brief Creates RINEX file names according to the naming convention + /* Creates RINEX file names according to the naming convention * * See http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf * Section 4, page 6 @@ -64,18 +63,18 @@ private: */ std::string createFilename(std::string type); - /*! - * \brief Generates the data for the PGM / RUN BY / DATE line + /* + * Generates the data for the PGM / RUN BY / DATE line */ std::string getLocalTime(); - /*! - * \brief Checks that the line is 80 characters length + /* + * Checks that the line is 80 characters length */ void lengthCheck(std::string line); - /*! - * \brief If the string is bigger than length, truncate it from the right. + /* + * If the string is bigger than length, truncate it from the right. * otherwise, add pad characters to its right. * * Left-justifies the input in a string of the specified @@ -91,8 +90,8 @@ private: const std::string::size_type length, const char pad = ' '); - /*! - * \brief If the string is bigger than length, truncate it from the right. + /* + * If the string is bigger than length, truncate it from the right. * otherwise, add pad characters to its right. * * Left-justifies the receiver in a string of the specified @@ -111,18 +110,18 @@ private: - /*! - * \brief Generates the Navigation Data header + /* + * Generates the Navigation Data header */ void Rinex2NavHeader(std::ofstream& out); - /*! - * \brief Generates the Observation data header + /* + * Generates the Observation data header */ void Rinex2ObsHeader(std::ofstream& out); - /*! - * \brief Generation of RINEX signal strength indicators + /* + * Generation of RINEX signal strength indicators */ int signalStrength(double snr); diff --git a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc index a2962e167..99af3c665 100644 --- a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc +++ b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc @@ -1,6 +1,36 @@ +/*! + * \file gps_l1_ca_subframe_fsm.cc + * \brief Implementation of a GPS NAV message word-to-subframe decoder state machine + * \author Javier Arribas, 2011. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (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 . + * + * ------------------------------------------------------------------------- + */ #include "gps_l1_ca_subframe_fsm.h" + //************ GPS WORD TO SUBFRAME DECODER STATE MACHINE ********** struct Ev_gps_word_valid : sc::event {}; @@ -15,6 +45,10 @@ public: //std::cout<<"Enter S0 "< { public: typedef mpl::list, @@ -25,6 +59,9 @@ public: } }; + + + struct gps_subframe_fsm_S2: public sc::state { public: typedef mpl::list, @@ -35,6 +72,10 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(0); } }; + + + + struct gps_subframe_fsm_S3: public sc::state { public: typedef mpl::list, @@ -45,6 +86,10 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(1); } }; + + + + struct gps_subframe_fsm_S4: public sc::state { public: typedef mpl::list, @@ -55,6 +100,10 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(2); } }; + + + + struct gps_subframe_fsm_S5: public sc::state { public: typedef mpl::list, @@ -65,6 +114,11 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(3); } }; + + + + + struct gps_subframe_fsm_S6: public sc::state { public: typedef mpl::list, @@ -75,6 +129,9 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(4); } }; + + + struct gps_subframe_fsm_S7: public sc::state { public: typedef mpl::list, @@ -85,6 +142,9 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(5); } }; + + + struct gps_subframe_fsm_S8: public sc::state { public: typedef mpl::list, @@ -95,6 +155,10 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(6); } }; + + + + struct gps_subframe_fsm_S9: public sc::state { public: typedef mpl::list, @@ -105,6 +169,9 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(7); } }; + + + struct gps_subframe_fsm_S10: public sc::state { public: typedef mpl::list, @@ -115,6 +182,9 @@ public: context< GpsL1CaSubframeFsm >().gps_word_to_subframe(8); } }; + + + struct gps_subframe_fsm_S11: public sc::state { public: typedef sc::transition< Ev_gps_word_preamble, gps_subframe_fsm_S1 > reactions; @@ -128,18 +198,28 @@ public: } }; + + + GpsL1CaSubframeFsm::GpsL1CaSubframeFsm() { d_nav.reset(); initiate(); //start the FSM } + + + void GpsL1CaSubframeFsm::gps_word_to_subframe(int position) { // insert the word in the correct position of the subframe std::memcpy(&d_subframe[position*GPS_WORD_LENGTH],&d_GPS_frame_4bytes,sizeof(char)*GPS_WORD_LENGTH); } + + + + void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg() { int subframe_ID; @@ -165,16 +245,24 @@ void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg() } + + + void GpsL1CaSubframeFsm::Event_gps_word_valid() { this->process_event(Ev_gps_word_valid()); } + + + void GpsL1CaSubframeFsm::Event_gps_word_invalid() { this->process_event(Ev_gps_word_invalid()); } + + void GpsL1CaSubframeFsm::Event_gps_word_preamble() { this->process_event(Ev_gps_word_preamble()); diff --git a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h index a8f859dac..7b18692cf 100644 --- a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h +++ b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h @@ -1,13 +1,36 @@ -/** - * Copyright notice +/*! + * \file gps_l1_ca_subframe_fsm.h + * \brief Interface of a GPS NAV message word-to-subframe decoder state machine + * \author Javier Arribas, 2011. jarribas(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (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 . + * + * ------------------------------------------------------------------------- */ -/** - * Author: Javier Arribas, 2011. jarribas(at)cttc.es - */ -//************ GPS WORD TO SUBFRAME DECODER STATE MACHINE ********** -#ifndef GPS_L1_CA_SUBFRAME_FSM_H -#define GPS_L1_CA_SUBFRAME_FSM_H + +#ifndef GNSS_SDR_GPS_L1_CA_SUBFRAME_FSM_H_ +#define GNSS_SDR_GPS_L1_CA_SUBFRAME_FSM_H_ #include #include @@ -15,15 +38,12 @@ #include #include #include - #include #include #include #include "concurrent_queue.h" - #include #include - #include "GPS_L1_CA.h" #include "gps_telemetry.h" #include "gps_navigation_message.h" @@ -54,7 +74,7 @@ public: int d_satellite_PRN; // ephemeris queue - concurrent_queue *d_nav_queue; + concurrent_queue *d_nav_queue; // navigation message class gps_navigation_message d_nav; diff --git a/src/core/system_parameters/GPS_L1_CA.h b/src/core/system_parameters/GPS_L1_CA.h index e961fed2a..ecb0fc753 100644 --- a/src/core/system_parameters/GPS_L1_CA.h +++ b/src/core/system_parameters/GPS_L1_CA.h @@ -1,11 +1,11 @@ /*! * \file GPS_L1_CA.h - * \brief Defines system parameters for GPS L1 C/A signal + * \brief Defines system parameters for GPS L1 C/A signal and NAV data * \author Javier Arribas, 2011. jarribas(at)cttc.es * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -32,38 +32,20 @@ #ifndef GNSS_SDR_GPS_L1_CA_H_ #define GNSS_SDR_GPS_L1_CA_H_ -#define NAVIGATION_SOLUTION_RATE_MS 1000 - - -const float GPS_C_m_s = 299792458.0; //!< The speed of light, [m/s] -const float GPS_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] - -const float GPS_STARTOFFSET_ms= 68.802; //[ms] Initial sign. travel time -const double GPS_PI = 3.1415926535898; //!< Pi used in the GPS coordinate system +// Physical constants +const float GPS_C_m_s = 299792458.0; //!< The speed of light, [m/s] +const float GPS_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double GPS_PI = 3.1415926535898; //!< Pi as defined in IS-GPS-200E +const double OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate, [rad/s] +const double GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] +const double F = -4.442807633e-10; //!< Constant, [s/(m)^(1/2)] // carrier and code frequencies -const float GPS_L1_FREQ_HZ = 1.57542e9; -const float GPS_L2_FREQ_HZ = 1.22760e9; -const float GPS_L1_CA_CODE_RATE_HZ = 1.023e6; -const float GPS_L1_CA_CODE_LENGTH_CHIPS = 1023.0; +const float GPS_L1_FREQ_HZ = 1.57542e9; //!< L1 [Hz] +const float GPS_L1_CA_CODE_RATE_HZ = 1.023e6; //!< GPS L1 C/A code rate [chips/s] +const float GPS_L1_CA_CODE_LENGTH_CHIPS = 1023.0; //!< GPS L1 C/A code length [chips] - -//-- Constants for satellite position calculation ------------------------- -const double OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate, [rad/s] -const double GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] -const double F = -4.442807633e-10; //!< Constant, [sec/(meter)^(1/2)] - - -// NAVIGATION MESSAGE DEMODULATION AND DECODING - -#define GPS_PREAMBLE {1, 0, 0, 0, 1, 0, 1, 1} -#define GPS_CA_PREAMBLE_LENGTH_BITS 8 -#define GPS_CA_TELEMETRY_RATE_BITS_SECOND 50 -#define GPS_WORD_LENGTH 4 // CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes -#define GPS_SUBFRAME_LENGTH 40 // GPS_WORD_LENGTH x 10 = 40 bytes -#define GPS_SUBFRAME_BITS 300 -#define GPS_WORD_BITS 30 /*! * \brief Maximum Time-Of-Arrival (TOA) difference between satellites for a receiver operated on Earth surface is 20 ms * @@ -74,6 +56,26 @@ const double F = -4.442807633e-10; //!< Constant, [sec/(meter)^(1 */ const double MAX_TOA_DELAY_MS=20; + + +#define NAVIGATION_SOLUTION_RATE_MS 1000 // this cannot go here +const float GPS_STARTOFFSET_ms= 68.802; //[ms] Initial sign. travel time (this cannot go here) + + +// NAVIGATION MESSAGE DEMODULATION AND DECODING + +#define GPS_PREAMBLE {1, 0, 0, 0, 1, 0, 1, 1} +#define GPS_CA_PREAMBLE_LENGTH_BITS 8 +#define GPS_CA_TELEMETRY_RATE_BITS_SECOND 50 //!< NAV message bit rate [bits/s] +#define GPS_WORD_LENGTH 4 // CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes +#define GPS_SUBFRAME_LENGTH 40 // GPS_WORD_LENGTH x 10 = 40 bytes +const int GPS_SUBFRAME_BITS=300; //!< Number of bits per subframe in the NAV message [bits] +const int GPS_WORD_BITS=30; //!< Number of bits per word in the NAV message [bits] + + + + + #define num_of_slices(x) sizeof(x)/sizeof(bits_slice) /*! diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index 339588150..439293770 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/core/system_parameters/gps_navigation_message.h b/src/core/system_parameters/gps_navigation_message.h index 75c7f8687..d05688ce8 100644 --- a/src/core/system_parameters/gps_navigation_message.h +++ b/src/core/system_parameters/gps_navigation_message.h @@ -5,7 +5,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -47,7 +47,7 @@ /*! - * \brief This class represents a GPS NAV Data as described in IS-GPS-200E + * \brief This class decodes a GPS NAV Data message as described in IS-GPS-200E * * See http://www.gps.gov/technical/icwg/IS-GPS-200E.pdf Appendix II */ @@ -59,7 +59,7 @@ private: signed long int read_navigation_signed(std::bitset bits, const bits_slice *slices, int num_of_slices); bool read_navigation_bool(std::bitset bits, const bits_slice *slices); - /*! + /* * Accounts for the beginning or end of week crossover * * See paragraph 20.3.3.3.3.1 (IS-GPS-200E) @@ -75,7 +75,7 @@ public: double d_IODE_SF3; double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] - double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] //broadcast orbit 2 double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] double d_e_eccentricity; //!< Eccentricity [dimensionless] @@ -98,10 +98,10 @@ public: double d_GPS_week; //!< GPS week number, aka WN [week] bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel //broadcast orbit 6 - double d_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + double d_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) double d_SV_health; - double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term for the benefit of "L1 only" or "L2 only" users [s] - double d_IODC; //!< Issue of Data, Clock + double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term for the benefit of "L1 only" or "L2 only" users [s] + double d_IODC; //!< Issue of Data, Clock //broadcast orbit 7 double d_fit_interval; @@ -127,7 +127,7 @@ public: bool b_integrity_status_flag; bool b_alert_flag; //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. - bool b_antispoofing_flag; //