diff --git a/include/gnss_utils/ublox_raw.h b/include/gnss_utils/ublox_raw.h index e204b52c38a1645424f40d36dd46a4bdef14caf6..46e21c321efd8ea7983d0b248532b036eeb15ec6 100644 --- a/include/gnss_utils/ublox_raw.h +++ b/include/gnss_utils/ublox_raw.h @@ -14,8 +14,11 @@ class UBloxRaw int addDataStream(const std::vector<u_int8_t>& data_stream); - const Observations& getObservations() const; - const Navigation& getNavigation() const; + Observations getObservations(); + Navigation getNavigation(); + + inline bool newObsData(){return new_obs_;}; + inline bool newNavData(){return new_nav_;}; private: raw_t raw_data_; @@ -23,6 +26,9 @@ class UBloxRaw Observations obs_; Navigation nav_; + bool new_obs_; + bool new_nav_; + void updateObservations(); }; diff --git a/src/ublox_raw.cpp b/src/ublox_raw.cpp index 5a1f463aa99323287f86856dcc0dc5d7e2be6673..ff396324c4c8bb3df491c6e683ce144615081661 100644 --- a/src/ublox_raw.cpp +++ b/src/ublox_raw.cpp @@ -9,6 +9,9 @@ UBloxRaw::UBloxRaw() assert("Failed when allocating memory for raw_t"); return; } + + new_obs_ = false; + new_nav_ = false; }; UBloxRaw::~UBloxRaw(){}; @@ -26,6 +29,7 @@ int UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream) { case 1: updateObservations(); + new_obs_ = true; break; case 2: // Ephemeris @@ -35,6 +39,7 @@ int UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream) nav_.addEphemeris(*(raw_data_.nav.eph)); nav_.addGLONASSEphemeris(*(raw_data_.nav.geph)); nav_.addSBASEphemeris(*(raw_data_.nav.seph)); + new_nav_ = true; break; case 3: // SBAS @@ -45,19 +50,30 @@ int UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream) nav_.addGLONASSEphemeris(*(raw_data_.nav.geph)); nav_.addSBASEphemeris(*(raw_data_.nav.seph)); updateObservations(); + new_obs_ = true; + new_nav_ = true; break; case 9: // Almanac nav_.clearAlmanac(); nav_.addAlmanac(*(raw_data_.nav.alm)); + new_nav_ = true; break; } return update_type; } -const Observations& UBloxRaw::getObservations() const {return obs_;} -const Navigation& UBloxRaw::getNavigation() const {return nav_;} +Observations UBloxRaw::getObservations() +{ + new_obs_ = false; + return obs_; +} +Navigation UBloxRaw::getNavigation() +{ + new_nav_ = false; + return nav_; +} void UBloxRaw::updateObservations() {