0.5.1
Loading...
Searching...
No Matches
SinglePointPositioning.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#include <imgui.h>
11
14#include <fmt/core.h>
18
20
24
25#include "util/Logger.hpp"
27
41
46
48{
49 return "SinglePointPositioning - SPP";
50}
51
53{
54 return typeStatic();
55}
56
58{
59 return "Data Processor";
60}
61
63{
64 auto nSatColumnContent = [&](size_t pinIndex) -> bool {
65 if (auto gnssNavInfo = getInputValue<GnssNavInfo>(pinIndex))
66 {
67 size_t usedSatNum = 0;
68 std::string usedSats;
69 std::string allSats;
70
71 std::string filler = ", ";
72 for (const auto& satellite : gnssNavInfo->v->satellites())
73 {
74 if (_algorithm._obsFilter.isSatelliteAllowed(satellite.first))
75 {
76 usedSatNum++;
77 usedSats += (allSats.empty() ? "" : filler) + fmt::format("{}", satellite.first);
78 }
79 allSats += (allSats.empty() ? "" : filler) + fmt::format("{}", satellite.first);
80 }
81 ImGui::TextUnformatted(fmt::format("{} / {}", usedSatNum, gnssNavInfo->v->nSatellites()).c_str());
82 if (ImGui::IsItemHovered())
83 {
84 ImGui::SetTooltip("Used satellites: %s\n"
85 "Avail satellites: %s",
86 usedSats.c_str(), allSats.c_str());
87 }
88 }
89 return false;
90 };
91
92 if (_dynamicInputPins.ShowGuiWidgets(size_t(id), inputPins, this, { { .header = "# Sat", .content = nSatColumnContent } }))
93 {
95 }
96
97 ImGui::Separator();
98
99 // ###########################################################################################################
100
101 const float itemWidth = 280.0F * gui::NodeEditorApplication::windowFontRatio();
102 const float unitWidth = 100.0F * gui::NodeEditorApplication::windowFontRatio();
103
104 if (_algorithm.ShowGuiWidgets(nameId().c_str(), itemWidth, unitWidth))
105 {
107 }
108}
109
111{
112 LOG_TRACE("{}: called", nameId());
113
114 return {
115 { "dynamicInputPins", _dynamicInputPins },
116 { "algorithm", _algorithm },
117 };
118}
119
121{
122 LOG_TRACE("{}: called", nameId());
123
124 if (j.contains("dynamicInputPins")) { NAV::gui::widgets::from_json(j.at("dynamicInputPins"), _dynamicInputPins, this); }
125 if (j.contains("algorithm")) { j.at("algorithm").get_to(_algorithm); }
126}
127
129{
130 LOG_TRACE("{}: called", nameId());
131
132 if (std::all_of(inputPins.begin() + INPUT_PORT_INDEX_GNSS_NAV_INFO, inputPins.end(), [](const InputPin& inputPin) { return !inputPin.isPinLinked(); }))
133 {
134 LOG_ERROR("{}: You need to connect a GNSS NavigationInfo provider", nameId());
135 return false;
136 }
137
138 _algorithm.reset();
139
140 LOG_DEBUG("{}: initialized", nameId());
141
142 return true;
143}
144
146{
147 LOG_TRACE("{}: called", nameId());
148}
149
154
156{
157 node->DeleteInputPin(pinIdx);
158}
159
161{
162 // Collection of all connected navigation data providers
163 std::vector<InputPin::IncomingLink::ValueWrapper<GnssNavInfo>> gnssNavInfoWrappers;
164 std::vector<const GnssNavInfo*> gnssNavInfos;
165 for (size_t i = 0; i < _dynamicInputPins.getNumberOfDynamicPins(); i++)
166 {
168 {
169 gnssNavInfoWrappers.push_back(*gnssNavInfo);
170 gnssNavInfos.push_back(gnssNavInfo->v);
171 }
172 }
173 if (gnssNavInfos.empty()) { return; }
174
175 auto gnssObs = std::static_pointer_cast<const GnssObs>(queue.extract_front());
176 LOG_DATA("{}: [{}] Calculating SPP", nameId(), gnssObs->insTime.toYMDHMS(GPST));
177
178 if (auto sppSol = _algorithm.calcSppSolution(gnssObs, gnssNavInfos, nameId()))
179 {
181 }
182}
Single Point Positioning Algorithm.
Holds all Constants.
Save/Load the Nodes.
nlohmann::json json
json namespace
Navigation message information.
GNSS Observation messages.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
Definition Logger.hpp:67
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
Definition Logger.hpp:29
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
Definition Logger.hpp:73
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Definition Logger.hpp:65
Position and Velocity Storage Class.
Single Point Positioning (SPP) / Code Phase Positioning.
SPP Algorithm output.
Vector Utility functions.
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:151
Input pins of nodes.
Definition Pin.hpp:491
TsDeque< std::shared_ptr< const NAV::NodeData > > NodeDataQueue
Node data queue type.
Definition Pin.hpp:707
ImVec2 _guiConfigDefaultWindowSize
Definition Node.hpp:522
Node(std::string name)
Constructor.
Definition Node.cpp:29
std::optional< InputPin::IncomingLink::ValueWrapper< T > > getInputValue(size_t portIndex) const
Get Input Value connected on the pin. Only const data types.
Definition Node.hpp:290
std::vector< InputPin > inputPins
List of input pins.
Definition Node.hpp:509
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 DeleteInputPin(size_t pinIndex)
Deletes the input pin. Invalidates the pin reference given.
Definition Node.cpp:310
bool _hasConfig
Flag if the config window should be shown.
Definition Node.hpp:525
static void pinAddCallback(Node *node)
Function to call to add a new pin.
std::string type() const override
String representation of the Class Type.
void recvGnssObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Receive Function for the Gnss Observations.
static constexpr size_t OUTPUT_PORT_INDEX_SPPSOL
Flow (SppSol)
static std::string typeStatic()
String representation of the Class Type.
static void pinDeleteCallback(Node *node, size_t pinIdx)
Function to call to delete a pin.
static std::string category()
String representation of the Class Category.
SinglePointPositioning()
Default constructor.
void deinitialize() override
Deinitialize the node.
gui::widgets::DynamicInputPins _dynamicInputPins
Dynamic input pins.
~SinglePointPositioning() override
Destructor.
void restore(const json &j) override
Restores the node from a json object.
SPP::Algorithm _algorithm
SPP algorithm.
bool initialize() override
Initialize the node.
json save() const override
Saves the node into a json object.
static constexpr size_t INPUT_PORT_INDEX_GNSS_NAV_INFO
GnssNavInfo.
void guiConfig() override
ImGui config window which is shown on double click.
static std::string type()
Returns the type of the data class.
auto extract_front()
Returns a copy of the first element in the container and removes it from the container.
Definition TsDeque.hpp:494
static float windowFontRatio()
Ratio to multiply for GUI window elements.
ImGui extensions.
void ApplyChanges()
Signals that there have been changes to the flow.
void from_json(const json &j, DynamicInputPins &obj, Node *node)
Converts the provided json object into a node object.
@ GPST
GPS Time.
@ Flow
NodeData Trigger.
Definition Pin.hpp:52
@ Object
Generic Object.
Definition Pin.hpp:57