0.3.0
Loading...
Searching...
No Matches
NodeRegistry.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
9#include "NodeRegistry.hpp"
10
11#include "util/Logger.hpp"
12
14#include "NodeData/NodeData.hpp"
15
16#include <string>
17
18/* -------------------------------------------------------------------------------------------------------- */
19/* Private Members */
20/* -------------------------------------------------------------------------------------------------------- */
21
22namespace NAV::NodeRegistry
23{
24namespace
25{
26
27/// List of all registered nodes.
28/// Key: category, Value: Nodes
29std::map<std::string, std::vector<NodeInfo>> _registeredNodes;
30
31/// List of all registered node data types.
32/// Key: NodeData.type(), Value: parentTypes()
33std::map<std::string, std::vector<std::string>> _registeredNodeDataTypes;
34
35/* -------------------------------------------------------------------------------------------------------- */
36/* Private Function Declarations */
37/* -------------------------------------------------------------------------------------------------------- */
38
39/// @brief Registers a Node with the NodeManager
40/// @tparam T Node Class to register
41template<std::derived_from<Node> T>
42void registerNodeType()
43{
44 NodeInfo info;
45 info.constructor = []() { return new T(); }; // NOLINT(cppcoreguidelines-owning-memory)
46 info.type = T::typeStatic();
47
48 T obj;
49 for (const InputPin& pin : obj.inputPins)
50 {
51 info.pinInfoList.emplace_back(pin.kind, pin.type, pin.dataIdentifier);
52 }
53 for (const OutputPin& pin : obj.outputPins)
54 {
55 info.pinInfoList.emplace_back(pin.kind, pin.type, pin.dataIdentifier);
56 }
57
58 _registeredNodes[T::category()].push_back(info);
59}
60
61/// @brief Register a NodeData with the NodeManager
62/// @tparam T NodeData Class to register
63template<std::derived_from<NodeData> T>
64void registerNodeDataType()
65{
66 _registeredNodeDataTypes[T::type()] = T::parentTypes();
67}
68
69} // namespace
70} // namespace NAV::NodeRegistry
71
72/* -------------------------------------------------------------------------------------------------------- */
73/* Function Definitions */
74/* -------------------------------------------------------------------------------------------------------- */
75
77{
78 if (pin == nullptr)
79 {
80 return true;
81 }
82
84 for (const auto& pinInfo : this->pinInfoList)
85 {
86 const std::vector<std::string>& startPinDataIdentifier = pin->kind == Pin::Kind::Input ? pinInfo.dataIdentifier : pin->dataIdentifier;
87 const std::vector<std::string>& endPinDataIdentifier = pin->kind == Pin::Kind::Input ? pin->dataIdentifier : pinInfo.dataIdentifier;
88 const std::string& startPinParentNodeType = pin->kind == Pin::Kind::Input ? this->type : pin->parentNode->type();
89
90 if (pinInfo.kind == searchPinKind && pinInfo.type == pin->type)
91 {
92 if ((pinInfo.type == Pin::Type::Flow
93 && NAV::NodeRegistry::NodeDataTypeAnyIsChildOf(startPinDataIdentifier, endPinDataIdentifier))
94 || (pinInfo.type == Pin::Type::Delegate
95 && std::ranges::find(endPinDataIdentifier, startPinParentNodeType) != endPinDataIdentifier.end())
96 || ((pinInfo.type == Pin::Type::Object || pinInfo.type == Pin::Type::Matrix) // NOLINT(misc-redundant-expression) - false positive warning
97 && Pin::dataIdentifierHaveCommon(startPinDataIdentifier, endPinDataIdentifier))
98 || pinInfo.type == Pin::Type::Bool || pinInfo.type == Pin::Type::Int || pinInfo.type == Pin::Type::Float || pinInfo.type == Pin::Type::String)
99 {
100 return true;
101 }
102 }
103 }
104
105 return false;
106}
107
108const std::map<std::string, std::vector<NAV::NodeRegistry::NodeInfo>>& NAV::NodeRegistry::RegisteredNodes()
109{
110 return _registeredNodes;
111}
112
113bool NAV::NodeRegistry::NodeDataTypeAnyIsChildOf(const std::vector<std::string>& childTypes, const std::vector<std::string>& parentTypes)
114{
115 for (const auto& childType : childTypes)
116 {
117 for (const auto& parentType : parentTypes)
118 {
119 if (childType == parentType)
120 {
121 return true;
122 }
123 for (const auto& [dataType, parentTypes] : _registeredNodeDataTypes)
124 {
125 if (dataType == childType)
126 {
127 for (const auto& parentTypeOfChild : parentTypes)
128 {
129 if (NodeDataTypeAnyIsChildOf({ parentTypeOfChild }, { parentType }))
130 {
131 return true;
132 }
133 }
134 }
135 }
136 }
137 }
138
139 return false;
140}
141
142std::vector<std::string> NAV::NodeRegistry::GetParentNodeDataTypes(const std::string& type)
143{
144 std::vector<std::string> returnTypes;
145 if (_registeredNodeDataTypes.contains(type))
146 {
147 const auto& parentTypes = _registeredNodeDataTypes.at(type);
148
149 // Add all the immediate parents
150 if (!parentTypes.empty())
151 {
152 returnTypes.insert(returnTypes.end(), parentTypes.begin(), parentTypes.end());
153 }
154
155 // Add parents of parents
156 for (const auto& parentType : parentTypes)
157 {
158 auto parentParentTypes = GetParentNodeDataTypes(parentType);
159 if (!parentParentTypes.empty())
160 {
161 returnTypes.insert(returnTypes.end(), parentParentTypes.begin(), parentParentTypes.end());
162 }
163 }
164 }
165
166 return returnTypes;
167}
168
169// Utility
171#include "Nodes/Utility/Demo.hpp"
176// Converter
182// Data Link
183#if __linux__ || __APPLE__
185#endif
188// Data Logger
196// Data Processor
207// Data Provider
229// Data Simulator
232// Plotting
234// State
236// Experimental
240
242{
243 LOG_TRACE("called");
244
246
247 // Utility
248 registerNodeType<Combiner>();
249 registerNodeType<Demo>();
250 registerNodeType<GroupBox>();
251 registerNodeType<Merger>();
252 registerNodeType<Terminator>();
253 registerNodeType<TimeWindow>();
254 // Converter
255 registerNodeType<RtklibPosConverter>();
256 registerNodeType<UartPacketConverter>();
257 registerNodeType<UbloxGnssObsConverter>();
258 registerNodeType<UbloxGnssOrbitCollector>();
259 registerNodeType<VectorNavBinaryConverter>();
260 // Data Link
261#if __linux__ || __APPLE__
262 registerNodeType<MavlinkSend>();
263#endif
264 registerNodeType<UdpSend>();
265 registerNodeType<UdpRecv>();
266 // Data Logger
267 registerNodeType<CsvLogger>();
268 registerNodeType<KmlLogger>();
269 registerNodeType<MatrixLogger>();
270 registerNodeType<RinexObsLogger>();
271 registerNodeType<UartDataLogger>();
272 registerNodeType<VectorNavDataLogger>();
273 registerNodeType<WiFiObsLogger>();
274 // Data Processor
275 registerNodeType<AllanDeviation>();
276 registerNodeType<ErrorModel>();
277 registerNodeType<GnssAnalyzer>();
278 registerNodeType<SinglePointPositioning>();
279 registerNodeType<ImuIntegrator>();
280 registerNodeType<LooselyCoupledKF>();
281 registerNodeType<LowPassFilter>();
282 registerNodeType<PressToHgt>();
283 registerNodeType<ImuFusion>();
284 registerNodeType<WiFiPositioning>();
285 // Data Provider
286 registerNodeType<CsvFile>();
287 registerNodeType<RinexNavFile>();
288 registerNodeType<RinexObsFile>();
289 registerNodeType<EmlidFile>();
290 registerNodeType<RtklibPosFile>();
291 registerNodeType<NmeaFile>();
292 registerNodeType<UbloxFile>();
293 registerNodeType<EmlidSensor>();
294 registerNodeType<UbloxSensor>();
295 registerNodeType<ImuFile>();
296 registerNodeType<KvhFile>();
297 registerNodeType<VectorNavFile>();
298 registerNodeType<KvhSensor>();
299 registerNodeType<Navio2Sensor>();
300 registerNodeType<VectorNavSensor>();
301 registerNodeType<UlogFile>();
302 registerNodeType<PosVelAttFile>();
303 registerNodeType<MultiImuFile>();
304 registerNodeType<EspressifSensor>();
305 registerNodeType<ArubaSensor>();
306 registerNodeType<WiFiObsFile>();
307 // Data Simulator
308 registerNodeType<ImuSimulator>();
309 registerNodeType<BaroSimulator>();
310 // Experimental
311 // registerNodeType<NAV::experimental::ARMA>();
312 // registerNodeType<NAV::experimental::SkydelNetworkStream>();
313 // registerNodeType<NAV::experimental::Delay>();
314 // Plotting
315 registerNodeType<Plot>();
316 // State
317 registerNodeType<PosVelAttInitializer>();
318
320}
321
337#include "NodeData/State/Pos.hpp"
342
345
347{
348 registerNodeDataType<NodeData>();
349 // General
350 registerNodeDataType<DynamicData>();
351 registerNodeDataType<StringObs>();
352 // GNSS
353 registerNodeDataType<EmlidObs>();
354 registerNodeDataType<GnssCombination>();
355 registerNodeDataType<GnssObs>();
356 registerNodeDataType<RtklibPosObs>();
357 registerNodeDataType<SppSolution>();
358 registerNodeDataType<UbloxObs>();
359 // IMU
360 registerNodeDataType<ImuObs>();
361 registerNodeDataType<ImuObsSimulated>();
362 registerNodeDataType<ImuObsWDelta>();
363 registerNodeDataType<KvhObs>();
364 registerNodeDataType<VectorNavBinaryOutput>();
365 // State
366 registerNodeDataType<InsGnssLCKFSolution>();
367 registerNodeDataType<Pos>();
368 registerNodeDataType<PosVel>();
369 registerNodeDataType<PosVelAtt>();
370 // WiFi
371 registerNodeDataType<WiFiObs>();
372 registerNodeDataType<WiFiPositioningSolution>();
373 // Barometer
374 registerNodeDataType<BaroPressObs>();
375 registerNodeDataType<BaroHgt>();
376}
377
378std::vector<std::string> NAV::NodeRegistry::GetStaticDataDescriptors(const std::vector<std::string>& dataIdentifier)
379{
380 // ATTENTION: Entries need to be in correct inheritance order (deepest inheritance first)
381
382 // NodeData
391 // Pos
400 // ImuObs
405 // Barometer
408
409 return {};
410}
411
412bool NAV::NodeRegistry::TypeHasDynamicData(const std::string& type)
413{
414 return type == DynamicData::type()
415 || type == GnssCombination::type()
416 || type == GnssObs::type()
417 || type == SppSolution::type()
418 || type == VectorNavBinaryOutput::type();
419}
420
421std::shared_ptr<NAV::NodeData> NAV::NodeRegistry::CopyNodeData(const std::shared_ptr<const NodeData>& nodeData)
422{
423 if (nodeData == nullptr) { return nullptr; }
424
425 // General
426 if (nodeData->getType() == DynamicData::type()) { return std::make_shared<DynamicData>(*std::static_pointer_cast<const DynamicData>(nodeData)); }
427 if (nodeData->getType() == StringObs::type()) { return std::make_shared<StringObs>(*std::static_pointer_cast<const StringObs>(nodeData)); }
428 // GNSS
429 if (nodeData->getType() == EmlidObs::type()) { return std::make_shared<EmlidObs>(*std::static_pointer_cast<const EmlidObs>(nodeData)); }
430 if (nodeData->getType() == GnssCombination::type()) { return std::make_shared<GnssCombination>(*std::static_pointer_cast<const GnssCombination>(nodeData)); }
431 if (nodeData->getType() == GnssObs::type()) { return std::make_shared<GnssObs>(*std::static_pointer_cast<const GnssObs>(nodeData)); }
432 if (nodeData->getType() == RtklibPosObs::type()) { return std::make_shared<RtklibPosObs>(*std::static_pointer_cast<const RtklibPosObs>(nodeData)); }
433 if (nodeData->getType() == SppSolution::type()) { return std::make_shared<SppSolution>(*std::static_pointer_cast<const SppSolution>(nodeData)); }
434 if (nodeData->getType() == UbloxObs::type()) { return std::make_shared<UbloxObs>(*std::static_pointer_cast<const UbloxObs>(nodeData)); }
435 // IMU
436 if (nodeData->getType() == ImuObs::type()) { return std::make_shared<ImuObs>(*std::static_pointer_cast<const ImuObs>(nodeData)); }
437 if (nodeData->getType() == ImuObsSimulated::type()) { return std::make_shared<ImuObsSimulated>(*std::static_pointer_cast<const ImuObsSimulated>(nodeData)); }
438 if (nodeData->getType() == ImuObsWDelta::type()) { return std::make_shared<ImuObsWDelta>(*std::static_pointer_cast<const ImuObsWDelta>(nodeData)); }
439 if (nodeData->getType() == KvhObs::type()) { return std::make_shared<KvhObs>(*std::static_pointer_cast<const KvhObs>(nodeData)); }
440 if (nodeData->getType() == VectorNavBinaryOutput::type()) { return std::make_shared<VectorNavBinaryOutput>(*std::static_pointer_cast<const VectorNavBinaryOutput>(nodeData)); }
441 // State
442 if (nodeData->getType() == InsGnssLCKFSolution::type()) { return std::make_shared<InsGnssLCKFSolution>(*std::static_pointer_cast<const InsGnssLCKFSolution>(nodeData)); }
443 if (nodeData->getType() == InsGnssTCKFSolution::type()) { return std::make_shared<InsGnssTCKFSolution>(*std::static_pointer_cast<const InsGnssTCKFSolution>(nodeData)); }
444 if (nodeData->getType() == Pos::type()) { return std::make_shared<Pos>(*std::static_pointer_cast<const Pos>(nodeData)); }
445 if (nodeData->getType() == PosVel::type()) { return std::make_shared<PosVel>(*std::static_pointer_cast<const PosVel>(nodeData)); }
446 if (nodeData->getType() == PosVelAtt::type()) { return std::make_shared<PosVelAtt>(*std::static_pointer_cast<const PosVelAtt>(nodeData)); }
447 // WiFi
448 if (nodeData->getType() == WiFiObs::type()) { return std::make_shared<WiFiObs>(*std::static_pointer_cast<const WiFiObs>(nodeData)); }
449 if (nodeData->getType() == WiFiPositioningSolution::type()) { return std::make_shared<WiFiPositioningSolution>(*std::static_pointer_cast<const WiFiPositioningSolution>(nodeData)); }
450 // Barometer
451 if (nodeData->getType() == BaroPressObs::type()) { return std::make_shared<BaroPressObs>(*std::static_pointer_cast<const BaroPressObs>(nodeData)); }
452 if (nodeData->getType() == BaroHgt::type()) { return std::make_shared<BaroHgt>(*std::static_pointer_cast<const BaroHgt>(nodeData)); }
453
454 return nullptr;
455}
ARMA Node.
Computes Allan Deviation.
Aruba Sensor Class.
Barometric Height Storage Class.
Barometric Pressure Storage Class.
Barometer observation simulator.
Calculates differences between signals.
CSV File reader.
Data Logger for CSV files.
Delay Node.
Demo Node which demonstrates all capabilities.
Dynamic Data container.
File Reader for Emlid log files.
Emlid Observation Class.
Emlid Sensor Class.
Adds errors (biases and noise) to measurements.
Espressif Sensor Class.
Allows creation of GNSS measurement combinations.
GNSS measurement combinations.
GNSS Observation messages.
Group Box.
File Reader for Imu log files.
Combines signals of sensors that provide the same signal-type to one signal.
Integrates ImuObs Data.
Data storage class for simulated IMU observations.
Data storage class for one VectorNavImu observation.
Parent Class for all IMU Observations.
Imu Observation Simulator.
Loosely-coupled Kalman Filter INS/GNSS errors.
Tightly-coupled Kalman Filter INS/GNSS errors.
Data Logger for Pos data as KML (Keyhole Markup Language) files (input for Google Earth)
File Reader for Kvh log files.
Data storage class for one KVH Imu observation.
KVH Sensors.
Utility class for logging to console and file.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Definition Logger.hpp:65
Kalman Filter class for the loosely coupled INS/GNSS integration.
Filters incoming data.
Data Logger for matrices.
Merger Node.
File reader for Multi-IMU data log files.
Navio2 Sensors.
File Reader for NMEA files.
Abstract NodeData Class.
Utility class which specifies available nodes.
Node Class.
Plots data into ImPlot Windows.
PosVelAtt File Reader.
Position, Velocity, Attitude Initializer from GPS and IMU data.
Position, Velocity and Attitude Storage Class.
Position and Velocity Storage Class.
Position Storage Class.
Pressure to height converter.
File reader for RINEX Navigation messages.
File reader for RINEX Observation messages.
Logger for GnssObs to RINEX observation files.
Convert RTKLib pos files into PosVel.
File Reader for RTKLIB Pos files.
RTKLIB Pos Observation Class.
Single Point Positioning (SPP) / Code Phase Positioning.
Node receiving UDP packages from the Skydel GNSS simulator Instinct plugin.
SPP Algorithm output.
Wrapper for String Messages.
Terminator for open signals. Mainly used for test flows.
Limits measurement data from any source to a user-defined timewindow.
Data Logger for Uart packets.
Decrypts Uart packets.
File Reader for ubx files.
Convert UbloxObs into GnssObs.
Collects UBX-RXM-SFRBX messages and provides the Orbit information.
ublox Observation Class
Ublox Sensor Class.
File Reader for ULog files.
Converts VectorNavBinaryOutput.
Binary Outputs from VectorNav Sensors.
Data Logger for VectorNav observations.
File Reader for Vector Nav log files.
Vector Nav Sensors.
WiFiObs File Reader.
Data Logger for WiFi observations.
Espressif Observation Class.
WiFi Positioning Algorithm output.
WiFi Positioning.
static std::string type()
Returns the type of the data class.
Definition BaroHgt.hpp:28
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition BaroHgt.hpp:45
static std::string type()
Returns the type of the data class.
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
static std::string type()
Returns the type of the data class.
Definition EmlidObs.hpp:30
static std::string type()
Returns the type of the data class.
static std::string type()
Returns the type of the data class.
Definition GnssObs.hpp:150
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
static std::string type()
Returns the type of the data class.
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
Definition ImuObs.hpp:33
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition ImuObs.hpp:50
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
static std::string type()
Returns the type of the data class.
Definition KvhObs.hpp:39
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition KvhObs.hpp:56
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition NodeData.hpp:56
static bool _autostartWorker
Flag which prevents the worker to be autostarted if false.
Definition Node.hpp:451
virtual std::string type() const =0
String representation of the Class Type.
Pins in the GUI for information exchange.
Definition Pin.hpp:43
Node * parentNode
Reference to the parent node.
Definition Pin.hpp:307
std::vector< std::string > dataIdentifier
One or multiple Data Identifiers (Unique name which is used for data flows)
Definition Pin.hpp:305
Type type
Type of the Pin.
Definition Pin.hpp:301
static bool dataIdentifierHaveCommon(const std::vector< std::string > &a, const std::vector< std::string > &b)
Checks if the first list of data identifiers has a common entry with the second.
Definition Pin.cpp:59
Kind kind
Kind of the Pin (Input/Output)
Definition Pin.hpp:303
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition PosVelAtt.hpp:48
static std::string type()
Returns the type of the data class.
Definition PosVelAtt.hpp:29
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition PosVel.hpp:46
static std::string type()
Returns the type of the data class.
Definition PosVel.hpp:27
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition Pos.hpp:53
static std::string type()
Returns the type of the data class.
Definition Pos.hpp:36
static std::string type()
Returns the type of the data class.
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
Definition StringObs.hpp:33
static std::string type()
Returns the type of the data class.
Definition UbloxObs.hpp:30
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
static std::string type()
Returns the type of the data class.
Definition WiFiObs.hpp:27
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
static std::string type()
Returns the type of the data class.
Sends a navigation solution via the MAVLink protocol.
bool NodeDataTypeAnyIsChildOf(const std::vector< std::string > &childTypes, const std::vector< std::string > &parentTypes)
Checks if any of the provided child types is a child of any of the provided parent types.
const std::map< std::string, std::vector< NodeInfo > > & RegisteredNodes()
Reference to List of all registered Nodes.
std::vector< std::string > GetParentNodeDataTypes(const std::string &type)
Get the Parent Node Data Types of the specified Node Data Type.
void RegisterNodeDataTypes()
Register all available NodeData types for the program.
bool TypeHasDynamicData(const std::string &type)
Wether the specified Node Data Type can have dynamic data.
void RegisterNodeTypes()
Register all available Node types for the program.
std::vector< std::string > GetStaticDataDescriptors(const std::vector< std::string > &dataIdentifier)
Returns a vector of data descriptors for the pin data identifiers.
std::shared_ptr< NodeData > CopyNodeData(const std::shared_ptr< const NodeData > &nodeData)
Creates a copy of the data.
Holds information for registered nodes.
std::function< Node *()> constructor
Constructor.
std::string type
Class Type of the node.
bool hasCompatiblePin(const Pin *pin) const
Checks if the node has a pin which can be linked.
std::vector< PinInfo > pinInfoList
List of port data types.
Kind of the Pin (Input/Output)
Definition Pin.hpp:165
@ Input
Input Pin.
Definition Pin.hpp:171
@ Output
Output Pin.
Definition Pin.hpp:170
@ Delegate
Reference to the Node object.
Definition Pin.hpp:59
@ Matrix
Matrix Object.
Definition Pin.hpp:58
@ Int
Integer Number.
Definition Pin.hpp:54
@ Float
Floating Point Number.
Definition Pin.hpp:55
@ String
std::string
Definition Pin.hpp:56
@ Flow
NodeData Trigger.
Definition Pin.hpp:52
@ Bool
Boolean.
Definition Pin.hpp:53
@ Object
Generic Object.
Definition Pin.hpp:57
Asynchronous data link - receiver node.
Asynchronous data link - sender node.