diff --git a/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_gps_sdr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_gps_sdr_acquisition_cc.cc index 050c4c350..724e08d48 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_gps_sdr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_gps_sdr_acquisition_cc.cc @@ -292,7 +292,7 @@ void gps_l1_ca_gps_sdr_acquisition_cc::calculate_magnitudes( d_ifft->execute(); // inverse FFT of the result = convolution in time x86_gr_complex_mag(d_ifft->get_outbuf(), d_fft_size); // d_ifft->get_outbuf()=|abs(·)|^2 - x86_float_max((float*)d_ifft->get_outbuf(), &indext, &magt, d_fft_size); // find max of |abs(·)|^2 -> index and magt + x86_float_max((float*)d_ifft->get_outbuf(), &indext, &magt, d_fft_size); // find max of |abs(á)|^2 -> index and magt if (magt > d_mag) { // if the magnitude is > threshold @@ -306,7 +306,7 @@ void gps_l1_ca_gps_sdr_acquisition_cc::calculate_magnitudes( memcpy(d_best_magnitudes, d_ifft->get_outbuf(), sizeof(float) * d_fft_size); - // Remove the maximum and its neighbours to calculate the mean + // Remove the maximum and its neighbors to calculate the mean ((float*)d_ifft->get_outbuf())[indext] = 0.0; if (indext != 0) { diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index a40218a85..dfb8fbdd6 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -86,6 +86,7 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel, connected_ = false; message_ = 0; + gnss_satellite_ = Gnss_Satellite(); } @@ -96,6 +97,7 @@ Channel::~Channel() delete trk_; delete nav_; delete pass_through_; + //delete gnss_satellite_; } @@ -166,12 +168,12 @@ gr_basic_block_sptr Channel::get_right_block() -void Channel::set_satellite(unsigned int satellite) +void Channel::set_satellite(Gnss_Satellite satellite) { - satellite_ = satellite; - acq_->set_satellite(satellite); - trk_->set_satellite(satellite); - nav_->set_satellite(satellite); + gnss_satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + acq_->set_satellite(satellite.get_PRN()); + trk_->set_satellite(satellite.get_PRN()); + nav_->set_satellite(satellite.get_PRN()); } @@ -236,14 +238,14 @@ void Channel::process_channel_messages() case 1: LOG_AT_LEVEL(INFO) << "Channel " << channel_ - << " ACQ SUCCESS satellite " << satellite_; + << " ACQ SUCCESS satellite " << gnss_satellite_; channel_fsm_.Event_gps_valid_acquisition(); break; case 2: LOG_AT_LEVEL(INFO) << "Channel " << channel_ - << " ACQ FAILED satellite " << satellite_; + << " ACQ FAILED satellite " << gnss_satellite_; if (repeat_ == true) { channel_fsm_.Event_gps_failed_acquisition_repeat(); @@ -256,7 +258,7 @@ void Channel::process_channel_messages() case 3: LOG_AT_LEVEL(INFO) << "Channel " << channel_ - << " TRACKING FAILED satellite " << satellite_ + << " TRACKING FAILED satellite " << gnss_satellite_ << ", reacquisition."; channel_fsm_.Event_gps_failed_tracking(); break; diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index 0a70afdc3..393cf288e 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -42,6 +42,7 @@ #include "control_message_factory.h" #include "concurrent_queue.h" + class ConfigurationInterface; class AcquisitionInterface; class TrackingInterface; @@ -77,7 +78,7 @@ public: size_t item_size(){ return 0; } - unsigned int satellite(){ return satellite_; } + Gnss_Satellite satellite() const { return gnss_satellite_; } AcquisitionInterface* acquisition(){ return acq_; } @@ -86,7 +87,7 @@ public: TelemetryDecoderInterface* telemetry(){ return nav_; } void start_acquisition(); - void set_satellite(unsigned int satellite); + void set_satellite(Gnss_Satellite satellite); void start(); /*! @@ -106,7 +107,7 @@ private: std::string implementation_; unsigned int channel_; - unsigned int satellite_; + Gnss_Satellite gnss_satellite_; bool connected_; bool stop_; int message_; diff --git a/src/core/interfaces/channel_interface.h b/src/core/interfaces/channel_interface.h index e9868c5da..a955ccd9a 100644 --- a/src/core/interfaces/channel_interface.h +++ b/src/core/interfaces/channel_interface.h @@ -38,6 +38,7 @@ #define GNSS_SDR_CHANNEL_INTERFACE_H_ #include "gnss_block_interface.h" +#include "gnss_satellite.h" /*! * \brief This abstract class represents an interface to a channel GNSS block. @@ -52,9 +53,9 @@ class ChannelInterface: public GNSSBlockInterface public: - virtual unsigned int satellite() = 0; + virtual Gnss_Satellite satellite() const = 0; virtual void start_acquisition() = 0; - virtual void set_satellite(unsigned int) = 0; + virtual void set_satellite(Gnss_Satellite) = 0; virtual void start() = 0; virtual void stop() = 0; }; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index ff18fddec..bf2f0a235 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -38,11 +38,13 @@ #include #include #include +#include #include "configuration_interface.h" #include "gnss_block_interface.h" #include "channel_interface.h" #include "gnss_block_factory.h" + using google::LogMessage; GNSSFlowgraph::GNSSFlowgraph(ConfigurationInterface *configuration, @@ -54,7 +56,7 @@ GNSSFlowgraph::GNSSFlowgraph(ConfigurationInterface *configuration, blocks_ = new std::vector(); block_factory_ = new GNSSBlockFactory(); queue_ = queue; - available_GPS_satellites_IDs_ = new std::list(); + available_GPS_satellites_IDs_ = new std::list(); init(); } @@ -449,26 +451,43 @@ void GNSSFlowgraph::set_satellites_list() * \TODO Describe GNSS satellites more nicely, with RINEX notation * See http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf (page 5) */ - for (unsigned int id = 1; id < 33; id++) + std::set available_gps_prn = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23 , 25, 26, 27, 28, 29, 30, + 31, 32}; + + + std::set::iterator available_gps_prn_iter; + + for (available_gps_prn_iter = available_gps_prn.begin(); + available_gps_prn_iter != available_gps_prn.end(); + available_gps_prn_iter++) { - available_GPS_satellites_IDs_->push_back(id); + sv = Gnss_Satellite(std::string("GPS"), *available_gps_prn_iter); + std::cout << *available_gps_prn_iter << std::endl; + available_GPS_satellites_IDs_->push_back(sv); } - std::list::iterator it = + // for (unsigned int id = 1; id < 33; id++) + // { + // available_GPS_satellites_IDs_->push_back(id); + // } + + std::list::iterator it = available_GPS_satellites_IDs_->begin(); for (unsigned int i = 0; i < channels_count_; i++) { - unsigned int sat = configuration_->property("Acquisition" - + boost::lexical_cast(i) + ".satellite", 0); - if ((sat == 0) || (sat==*it)) // 0 = not PRN in configuration file + unsigned int sat = configuration_->property("Acquisition" + boost::lexical_cast(i) + ".satellite", 0); + if ((sat == 0) || (sat == it->get_PRN())) // 0 = not PRN in configuration file { it++; } else { - available_GPS_satellites_IDs_->remove(sat); - available_GPS_satellites_IDs_->insert(it, sat); + sv = Gnss_Satellite(std::string("GPS"), it->get_PRN()); + available_GPS_satellites_IDs_->remove(sv); + available_GPS_satellites_IDs_->insert(it, sv); } } diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 3abf591db..cb45db7dd 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -41,6 +41,7 @@ #include #include #include "GPS_L1_CA.h" +#include "gnss_satellite.h" class GNSSBlockInterface; class ChannelInterface; @@ -133,8 +134,10 @@ private: gr_top_block_sptr top_block_; gr_msg_queue_sptr queue_; - std::list* available_GPS_satellites_IDs_; + std::list* available_GPS_satellites_IDs_; std::queue* available_Galileo_satellites_IDs_; + + Gnss_Satellite sv; }; #endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/ diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index f1a51a303..02b6c9f4a 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -27,6 +27,7 @@ * * ------------------------------------------------------------------------- */ + #include "gnss_satellite.h" #include #include @@ -65,10 +66,31 @@ void Gnss_Satellite::reset() PRN = 0; system = std::string(""); block = std::string(""); + rf_link = 0; } +std::ostream& operator<<(std::ostream &out, const Gnss_Satellite &sat) // output +{ + //std::string psystem = sat::get_system() + out << sat.get_system() << " PRN " << sat.get_PRN() << " (Block " << sat.get_block() << ")"; + return out; +} + + +bool operator== (const Gnss_Satellite &sat1, const Gnss_Satellite &sat2) +{ + bool equal = false; + if (sat1.get_system().compare(sat2.get_system()) == 0) + { + if (sat1.get_PRN() == (sat2.get_PRN())) + { + equal = true; + } + } + return equal; +} void Gnss_Satellite::set_system(std::string system_) @@ -158,7 +180,7 @@ void Gnss_Satellite::set_PRN(unsigned int PRN_) -unsigned int Gnss_Satellite::get_PRN() +unsigned int Gnss_Satellite::get_PRN() const { // Get satellite's PRN unsigned int PRN_; @@ -171,7 +193,7 @@ unsigned int Gnss_Satellite::get_PRN() -std::string Gnss_Satellite::get_system() +std::string Gnss_Satellite::get_system() const { // Get the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"} std::string system_; @@ -183,7 +205,7 @@ std::string Gnss_Satellite::get_system() -std::string Gnss_Satellite::get_block() +std::string Gnss_Satellite::get_block() const { // Get the satellite block std::string block_; @@ -312,78 +334,103 @@ void Gnss_Satellite::set_block(std::string system_, unsigned int PRN_ ) switch ( PRN_ ) { // info from http://www.sdcm.ru/smglo/grupglo?version=eng&site=extern + // See also http://www.glonass-center.ru/en/GLONASS/ case 1 : block = std::string("1"); //Plane 1 + rf_link = 1; break; case 2 : block = std::string("-4"); //Plane 1 + rf_link = -4; break; case 3 : block = std::string("5"); //Plane 1 + rf_link = 5; break; case 4 : block = std::string("6"); //Plane 1 + rf_link = 6; break; case 5 : block = std::string("1"); //Plane 1 + rf_link = 1; break; case 6 : block = std::string("-4"); //Plane 1 + rf_link = -4; break; case 7 : block = std::string("5"); //Plane 1 + rf_link = 5; break; case 8 : block = std::string("6"); //Plane 1 + rf_link = 6; break; case 9 : block = std::string("-2"); //Plane 2 + rf_link = -2; break; case 10 : block = std::string("-7"); //Plane 2 + rf_link = -7; break; case 11 : block = std::string("0"); //Plane 2 + rf_link = 0; break; case 12 : block = std::string("-1"); //Plane 2 + rf_link = -1; break; case 13 : block = std::string("-2"); //Plane 2 + rf_link = -2; break; case 14 : block = std::string("-7"); //Plane 2 + rf_link = -7; break; case 15 : block = std::string("0"); //Plane 2 + rf_link = 0; break; case 16 : block = std::string("-1"); //Plane 2 + rf_link = -1; break; case 17 : block = std::string("4"); //Plane 3 + rf_link = 4; break; case 18 : block = std::string("-3"); //Plane 3 + rf_link = -3; break; case 19 : block = std::string("3"); //Plane 3 + rf_link = 3; break; case 20 : block = std::string("2"); //Plane 3 + rf_link = 2; break; case 21 : block = std::string("4"); //Plane 3 + rf_link = 4; break; case 22 : block = std::string("-3"); //Plane 3 + rf_link = -3; break; case 23 : block = std::string("3"); //Plane 3 + rf_link = 3; break; case 24 : block = std::string("2"); //Plane 3 + rf_link = 2; break; default : block = std::string("Unknown"); @@ -416,8 +463,10 @@ void Gnss_Satellite::set_block(std::string system_, unsigned int PRN_ ) switch ( PRN_ ) { case 11 : - block = std::string("IOV"); // Launched from French Guiana at 10:30 GMT on October 21, 2011 + block = std::string("IOV"); // PFM, the ProtoFlight Model (GSAT0101), launched from French Guiana at 10:30 GMT on October 21, 2011 break; + case 12 : + block =std::string("IOV"); // Galileo In-Orbit Validation (IOV) satellite FM2 (Flight Model 2) also known as GSAT0102, launched the same day default: block = std::string("Unknown"); } diff --git a/src/core/system_parameters/gnss_satellite.h b/src/core/system_parameters/gnss_satellite.h index 0499704f1..fc3510bc4 100644 --- a/src/core/system_parameters/gnss_satellite.h +++ b/src/core/system_parameters/gnss_satellite.h @@ -34,6 +34,7 @@ #include #include +#include /* * \brief This class represents a GNSS satellite. @@ -47,18 +48,21 @@ public: Gnss_Satellite(); //!< Default Constructor. Gnss_Satellite(std::string system_, unsigned int PRN_); //!< Concrete GNSS satellite Constructor. ~Gnss_Satellite(); //!< Default Destructor. - unsigned int get_PRN(); //!< Gets satellite's PRN - std::string get_system(); //!< Gets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"} - std::string get_block(); //!< Gets the satellite block. If GPS, returns {"IIA", "IIR", "IIR-M", "IIF"} - + unsigned int get_PRN() const; //!< Gets satellite's PRN + std::string get_system() const; //!< Gets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"} + std::string get_block() const; //!< Gets the satellite block. If GPS, returns {"IIA", "IIR", "IIR-M", "IIF"} + friend bool operator== (const Gnss_Satellite &, const Gnss_Satellite &); // operator== for comparison + friend std::ostream& operator<<(std::ostream &, const Gnss_Satellite &); // operator<< for pretty printing private: unsigned int PRN; std::string system; std::string block; + signed int rf_link; void set_system(std::string system); // Sets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"}. Returns 1 if success. void set_PRN(unsigned int PRN); // Sets satellite's PRN void set_block(std::string system_, unsigned int PRN_ ); std::set system_set; // = {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"}; void reset(); + }; #endif