| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This file is part of INSTINCT, the INS Toolkit for Integrated | ||
| 2 | // Navigation Concepts and Training by the Institute of Navigation of | ||
| 3 | // the University of Stuttgart, Germany. | ||
| 4 | // | ||
| 5 | // This Source Code Form is subject to the terms of the Mozilla Public | ||
| 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| 7 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| 8 | |||
| 9 | /// @file UbloxGnssOrbitCollector.hpp | ||
| 10 | /// @brief Collects UBX-RXM-SFRBX messages and provides the Orbit information | ||
| 11 | /// @author T. Topp (topp@ins.uni-stuttgart.de) | ||
| 12 | /// @date 2024-02-05 | ||
| 13 | |||
| 14 | #pragma once | ||
| 15 | |||
| 16 | #include <mutex> | ||
| 17 | #include <bitset> | ||
| 18 | #include <memory> | ||
| 19 | #include <unordered_map> | ||
| 20 | #include <set> | ||
| 21 | |||
| 22 | #include "internal/Node/Node.hpp" | ||
| 23 | #include "NodeData/GNSS/GnssNavInfo.hpp" | ||
| 24 | #include "NodeData/GNSS/UbloxObs.hpp" | ||
| 25 | |||
| 26 | #include "Navigation/GNSS/Satellite/internal/SatNavData.hpp" | ||
| 27 | |||
| 28 | namespace ubx = NAV::vendor::ublox; | ||
| 29 | |||
| 30 | namespace NAV | ||
| 31 | { | ||
| 32 | /// Collects UBX-RXM-SFRBX messages and provides the Orbit information | ||
| 33 | class UbloxGnssOrbitCollector : public Node | ||
| 34 | { | ||
| 35 | public: | ||
| 36 | /// @brief Default constructor | ||
| 37 | UbloxGnssOrbitCollector(); | ||
| 38 | /// @brief Destructor | ||
| 39 | ~UbloxGnssOrbitCollector() override; | ||
| 40 | /// @brief Copy constructor | ||
| 41 | UbloxGnssOrbitCollector(const UbloxGnssOrbitCollector&) = delete; | ||
| 42 | /// @brief Move constructor | ||
| 43 | UbloxGnssOrbitCollector(UbloxGnssOrbitCollector&&) = delete; | ||
| 44 | /// @brief Copy assignment operator | ||
| 45 | UbloxGnssOrbitCollector& operator=(const UbloxGnssOrbitCollector&) = delete; | ||
| 46 | /// @brief Move assignment operator | ||
| 47 | UbloxGnssOrbitCollector& operator=(UbloxGnssOrbitCollector&&) = delete; | ||
| 48 | |||
| 49 | /// @brief String representation of the Class Type | ||
| 50 | [[nodiscard]] static std::string typeStatic(); | ||
| 51 | |||
| 52 | /// @brief String representation of the Class Type | ||
| 53 | [[nodiscard]] std::string type() const override; | ||
| 54 | |||
| 55 | /// @brief String representation of the Class Category | ||
| 56 | [[nodiscard]] static std::string category(); | ||
| 57 | |||
| 58 | /// @brief ImGui config window which is shown on double click | ||
| 59 | /// @attention Don't forget to set _hasConfig to true in the constructor of the node | ||
| 60 | void guiConfig() override; | ||
| 61 | |||
| 62 | private: | ||
| 63 | constexpr static size_t INPUT_PORT_INDEX_UBLOX_OBS = 0; ///< @brief Flow (UbloxObs) | ||
| 64 | constexpr static size_t OUTPUT_PORT_INDEX_GNSS_NAV_INFO = 0; ///< @brief Object | ||
| 65 | |||
| 66 | /// @brief Initialize the node | ||
| 67 | bool initialize() override; | ||
| 68 | |||
| 69 | /// @brief Called when a link is to be deleted | ||
| 70 | /// @param[in] startPin Pin where the link starts | ||
| 71 | /// @param[in] endPin Pin where the link ends | ||
| 72 | void onDeleteLink(OutputPin& startPin, InputPin& endPin) override; | ||
| 73 | |||
| 74 | /// @brief Data object to share over the output pin | ||
| 75 | GnssNavInfo _gnssNavInfo; | ||
| 76 | |||
| 77 | /// Mutex to lock if the connected ublox obs provider is a file reader | ||
| 78 | std::optional<std::unique_lock<std::mutex>> _postProcessingLock; | ||
| 79 | |||
| 80 | /// @brief Ephemeris builder to store unfinished ephemeris data till all subframes are collected | ||
| 81 | struct EphemerisBuilder | ||
| 82 | { | ||
| 83 | /// @brief Constructor | ||
| 84 | /// @param[in] satId Satellite identifier | ||
| 85 | /// @param[in] navData Nav data to store | ||
| 86 | 47 | EphemerisBuilder(const SatId& satId, std::shared_ptr<SatNavData> navData) | |
| 87 | 47 | : satId(satId), navData(std::move(navData)) | |
| 88 | { | ||
| 89 | 47 | subframes.reset(); | |
| 90 | 47 | } | |
| 91 | |||
| 92 | SatId satId; ///< Satellite Identifier | ||
| 93 | std::shared_ptr<SatNavData> navData; ///< Navigation data pointer | ||
| 94 | std::bitset<5> subframes; ///< Flags for which subframes were received already. e.g. Subframes 1, 2, 3 for GPS | ||
| 95 | }; | ||
| 96 | |||
| 97 | /// @brief Map of ephemeris build helper for each satellite | ||
| 98 | std::vector<EphemerisBuilder> _ephemerisBuilder; | ||
| 99 | |||
| 100 | /// @brief List of IOD for each satellite | ||
| 101 | std::unordered_map<SatId, size_t> _lastAccessedBuilder; | ||
| 102 | |||
| 103 | /// List of satellite systems to emit warnings because conversion is not implemented yet | ||
| 104 | std::set<SatelliteSystem> _warningsNotImplemented; | ||
| 105 | |||
| 106 | /// @brief Searches the ephemeris builder for the given satellite and time. If nothing found returns a new instance. | ||
| 107 | /// @param[in] satId Satellite identifier | ||
| 108 | /// @param[in] insTime Time to search for (either time of ephemeris or time of clock) | ||
| 109 | /// @param[in] IOD Issue of Data (Ephemeris, Nav, ...) | ||
| 110 | /// @return Reference to the ephemeris builder | ||
| 111 | EphemerisBuilder& getEphemerisBuilder(const SatId& satId, const InsTime& insTime, size_t IOD = 0); | ||
| 112 | |||
| 113 | /// @brief Searches the ephemeris builder for the given Issue of Data Ephemeris | ||
| 114 | /// @param[in] satId Satellite Identifier | ||
| 115 | /// @param[in] IOD Issue of Data (Ephemeris, Nav, ...) | ||
| 116 | /// @return Reference to the ephemeris builder if it was found | ||
| 117 | std::optional<std::reference_wrapper<EphemerisBuilder>> getEphemerisBuilder(const SatId& satId, size_t IOD); | ||
| 118 | |||
| 119 | /// @brief Searches the most recent ephemeris builder for the given satellite | ||
| 120 | /// @param[in] satId Satellite identifier | ||
| 121 | /// @return Reference to the ephemeris builder if it was found | ||
| 122 | std::optional<std::reference_wrapper<EphemerisBuilder>> getLastEphemerisBuilder(const SatId& satId); | ||
| 123 | |||
| 124 | /// @brief Data receive function | ||
| 125 | /// @param[in] queue Queue with all the received data messages | ||
| 126 | /// @param[in] pinIdx Index of the pin the data is received on | ||
| 127 | void receiveObs(InputPin::NodeDataQueue& queue, size_t pinIdx); | ||
| 128 | |||
| 129 | /// @brief Decrypt the GPS SFRBX message | ||
| 130 | /// @param[in] satId Satellite Identifier | ||
| 131 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 132 | /// @param[in] insTime Time of the message | ||
| 133 | void decryptGPS(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 134 | |||
| 135 | /// @brief Decrypt the Galileo SFRBX message | ||
| 136 | /// @param[in] satId Satellite Identifier | ||
| 137 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 138 | /// @param[in] insTime Time of the message | ||
| 139 | void decryptGalileo(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 140 | |||
| 141 | /// @brief Decrypt the GLONASS SFRBX message | ||
| 142 | /// @param[in] satId Satellite Identifier | ||
| 143 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 144 | /// @param[in] insTime Time of the message | ||
| 145 | void decryptGLONASS(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 146 | |||
| 147 | /// @brief Decrypt the BeiDou SFRBX message | ||
| 148 | /// @param[in] satId Satellite Identifier | ||
| 149 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 150 | /// @param[in] insTime Time of the message | ||
| 151 | void decryptBeiDou(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 152 | |||
| 153 | /// @brief Decrypt the QZSS SFRBX message | ||
| 154 | /// @param[in] satId Satellite Identifier | ||
| 155 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 156 | /// @param[in] insTime Time of the message | ||
| 157 | void decryptQZSS(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 158 | |||
| 159 | /// @brief Decrypt the IRNSS SFRBX message | ||
| 160 | /// @param[in] satId Satellite Identifier | ||
| 161 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 162 | /// @param[in] insTime Time of the message | ||
| 163 | void decryptIRNSS(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 164 | |||
| 165 | /// @brief Decrypt the SBAS SFRBX message | ||
| 166 | /// @param[in] satId Satellite Identifier | ||
| 167 | /// @param[in] sfrbx RAWX-SFRBX message | ||
| 168 | /// @param[in] insTime Time of the message | ||
| 169 | void decryptSBAS(const SatId& satId, const ubx::UbxRxmSfrbx& sfrbx, const InsTime& insTime); | ||
| 170 | }; | ||
| 171 | |||
| 172 | } // namespace NAV | ||
| 173 |