0.5.1
Loading...
Searching...
No Matches
UbloxGnssObsConverter.cpp
Go to the documentation of this file.
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
10
11#include <map>
12
13#include "util/Logger.hpp"
14
16
19
30
35
37{
38 return "UbloxGnssObsConverter";
39}
40
42{
43 return typeStatic();
44}
45
47{
48 return "Converter";
49}
50
52{
53 LOG_TRACE("{}: called", nameId());
54
55 _lastEpochObs.clear();
56
57 return true;
58}
59
61{
62 auto ubloxObs = std::static_pointer_cast<const UbloxObs>(queue.extract_front());
63
64 namespace ubx = vendor::ublox;
65
66 if (ubloxObs->msgClass == ubx::UBX_CLASS_RXM)
67 {
68 if (static_cast<ubx::UbxRxmMessages>(ubloxObs->msgId) == ubx::UbxRxmMessages::UBX_RXM_RAWX)
69 {
70 LOG_DATA("{}: Converting message at [{}]", nameId(), ubloxObs->insTime.toYMDHMS(GPST));
71 auto gnssObs = std::make_shared<GnssObs>();
72 gnssObs->insTime = ubloxObs->insTime;
73
74 const auto& ubxRxmRawx = std::get<ubx::UbxRxmRawx>(ubloxObs->data);
75
76 for (const auto& satSys : SatelliteSystem::GetAll())
77 {
78 std::map<SatSigId, GnssObs::ObservationData> sortedObsData;
79 for (const auto& data : ubxRxmRawx.data)
80 {
81 if (ubx::getSatSys(data.gnssId) != satSys) { continue; }
82
83 SatSigId satSigId(ubx::getCode(data.gnssId, data.sigId), data.svId);
84 LOG_DATA("{}: [{}][{}], prValid {}, cpValid {}, halfCycValid {}, subHalfSubtractedFromPhase {}, trkStat {}, observedLastEpoch {}",
85 nameId(), ubloxObs->insTime.toYMDHMS(GPST), satSigId, data.prValid(), data.cpValid(), data.halfCycValid(), data.subHalfSubtractedFromPhase(), data.trkStat,
86 _lastEpochObs.contains(satSigId));
87 GnssObs::ObservationData obsData(satSigId);
88 if (data.prValid())
89 {
90 if (data.prMes > 100'000'000) { return; } // Sometimes at the start of the ublox receiver, it reports absurd high numbers
92 .value = data.prMes,
93 .SSI = 0,
94 };
95 }
96 if (data.cpValid())
97 {
98 std::bitset<4> LLI;
99 LLI[0] = !_lastEpochObs.contains(satSigId);
100 LLI[1] = !data.halfCycValid();
102 .value = data.cpMes,
103 .SSI = 0,
104 .LLI = static_cast<uint8_t>(LLI.to_ulong()),
105 };
106 }
107 obsData.doppler = data.doMes;
108 obsData.CN0 = data.cno;
109
110 sortedObsData.insert(std::make_pair(satSigId, obsData));
111 gnssObs->satData(satSigId.toSatId()).frequencies |= satSigId.freq();
112 }
113 std::erase_if(_lastEpochObs, [&](const SatSigId& satSigId) { return satSigId.freq().getSatSys() == satSys; });
114 for (const auto& obsData : sortedObsData)
115 {
116 // LOG_DATA("{}: Adding [{}]", nameId(), obsData.second.satSigId);
117 gnssObs->data.push_back(obsData.second);
118 if (obsData.second.carrierPhase)
119 {
120 _lastEpochObs.insert(obsData.first);
121 }
122 }
123 }
124 if (gnssObs->data.empty()) { return; }
126 }
127 }
128}
Save/Load the Nodes.
GNSS Observation messages.
Utility class for logging to console and file.
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
Definition Logger.hpp:29
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Definition Logger.hpp:65
Convert UbloxObs into GnssObs.
ublox Observation Class
SatelliteSystem getSatSys() const
Get the satellite system for which this frequency is defined.
static std::string type()
Returns the type of the data class.
Definition GnssObs.hpp:151
TsDeque< std::shared_ptr< const NAV::NodeData > > NodeDataQueue
Node data queue type.
Definition Pin.hpp:707
Node(std::string name)
Constructor.
Definition Node.cpp:29
OutputPin * CreateOutputPin(const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier, OutputPin::PinData data=static_cast< void * >(nullptr), int idx=-1)
Create an Output Pin object.
Definition Node.cpp:278
std::string nameId() const
Node name and id.
Definition Node.cpp:323
std::string name
Name of the Node.
Definition Node.hpp:507
InputPin * CreateInputPin(const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier={}, InputPin::Callback callback=static_cast< InputPin::FlowFirableCallbackFunc >(nullptr), InputPin::FlowFirableCheckFunc firable=nullptr, int priority=0, int idx=-1)
Create an Input Pin object.
Definition Node.cpp:252
void invokeCallbacks(size_t portIndex, const std::shared_ptr< const NodeData > &data)
Calls all registered callbacks on the specified output port.
Definition Node.cpp:179
bool _hasConfig
Flag if the config window should be shown.
Definition Node.hpp:525
auto extract_front()
Returns a copy of the first element in the container and removes it from the container.
Definition TsDeque.hpp:494
void receiveObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Data receive function.
static constexpr size_t OUTPUT_PORT_INDEX_GNSS_OBS
Flow.
bool initialize() override
Initialize the node.
static std::string category()
String representation of the Class Category.
~UbloxGnssObsConverter() override
Destructor.
UbloxGnssObsConverter()
Default constructor.
static std::string typeStatic()
String representation of the Class Type.
std::string type() const override
String representation of the Class Type.
std::unordered_set< SatSigId > _lastEpochObs
List of signals of the last epoch. To set the LLI flag.
static std::string type()
Returns the type of the data class.
Definition UbloxObs.hpp:30
Code getCode(uint8_t gnssId, uint8_t sigId)
Get the GNSS code from gnssId and sigId.
SatelliteSystem getSatSys(uint8_t gnssId)
Get the GNSS Satellite System from gnssId.
@ UBX_CLASS_RXM
Receiver Manager Messages: Satellite Status, RTC Status.
UbxRxmMessages
The available RXM Messages.
@ GPST
GPS Time.
Stores the satellites observations.
Definition GnssObs.hpp:47
std::optional< Pseudorange > pseudorange
Pseudorange measurement [m].
Definition GnssObs.hpp:122
std::optional< CarrierPhase > carrierPhase
Carrier phase measurement [cycles].
Definition GnssObs.hpp:123
std::optional< double > CN0
Carrier-to-Noise density [dBHz].
Definition GnssObs.hpp:125
std::optional< double > doppler
Doppler measurement [Hz].
Definition GnssObs.hpp:124
@ Flow
NodeData Trigger.
Definition Pin.hpp:52
Identifies a satellite signal (satellite frequency and number)
Frequency freq() const
Returns the frequency of the satellite signal.
SatId toSatId() const
Returns a satellite identifier for the satellite signal.
static std::vector< SatelliteSystem > GetAll()
Returns a list with all possible satellite systems.