0.2.0
Loading...
Searching...
No Matches
ErrorModel.hpp
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
13
14#pragma once
15
17
22
24
25#include "util/Eigen.hpp"
26#include <random>
27#include <map>
28
29namespace NAV
30{
32class ErrorModel : public Node
33{
34 public:
38 ~ErrorModel() override;
40 ErrorModel(const ErrorModel&) = delete;
44 ErrorModel& operator=(const ErrorModel&) = delete;
47
49 [[nodiscard]] static std::string typeStatic();
50
52 [[nodiscard]] std::string type() const override;
53
55 [[nodiscard]] static std::string category();
56
59 void guiConfig() override;
60
62 [[nodiscard]] json save() const override;
63
66 void restore(const json& j) override;
67
68 private:
69 constexpr static size_t OUTPUT_PORT_INDEX_FLOW = 0;
70 constexpr static size_t INPUT_PORT_INDEX_FLOW = 0;
71
73 enum class InputType
74 {
75 None,
76 ImuObs,
78 PosVelAtt,
79 GnssObs,
80 };
81
83 InputType _inputType = InputType::None;
84
86 bool resetNode() override;
87
91 void afterCreateLink(OutputPin& startPin, InputPin& endPin) override;
92
96 void afterDeleteLink(OutputPin& startPin, InputPin& endPin) override;
97
101 void receiveObs(InputPin::NodeDataQueue& queue, size_t pinIdx);
102
105 [[nodiscard]] std::shared_ptr<ImuObs> receiveImuObs(const std::shared_ptr<ImuObs>& imuObs);
106
109 [[nodiscard]] std::shared_ptr<ImuObsWDelta> receiveImuObsWDelta(const std::shared_ptr<ImuObsWDelta>& imuObs);
110
113 [[nodiscard]] std::shared_ptr<PosVelAtt> receivePosVelAtt(const std::shared_ptr<PosVelAtt>& posVelAtt);
114
117 [[nodiscard]] std::shared_ptr<GnssObs> receiveGnssObs(const std::shared_ptr<GnssObs>& gnssObs);
118
120 InsTime _lastObservationTime;
122 double _messageFrequency{};
123
124 // #########################################################################################################################################
125 // ImuObs
126 // #########################################################################################################################################
127 //
129 Eigen::Vector3d RandomWalkAccelerometer = Eigen::Vector3d::Zero();
130
132 Eigen::Vector3d RandomWalkGyroscope = Eigen::Vector3d::Zero();
133
135 Eigen::Vector3d IntegratedRandomWalkGyro = Eigen::Vector3d::Zero();
136
138 Eigen::Vector3d IntegratedRandomWalkAccelerometer_velocity = Eigen::Vector3d::Zero();
139
141 Eigen::Vector3d IntegratedRandomWalkAccelerometer = Eigen::Vector3d::Zero();
142
144 Eigen::Vector3d IntegratedRandomWalkGyroscope_velocity = Eigen::Vector3d::Zero();
145
147 Eigen::Vector3d IntegratedRandomWalkGyroscope = Eigen::Vector3d::Zero();
148
149 // --------------------------------------------------------------- Offset ------------------------------------------------------------------
150
152 enum class ImuAccelerometerBiasUnits
153 {
154 m_s2,
155 };
157 ImuAccelerometerBiasUnits _imuAccelerometerBiasUnit = ImuAccelerometerBiasUnits::m_s2;
159 Eigen::Vector3d _imuAccelerometerBias_p = Eigen::Vector3d::Zero();
160
162 enum class ImuGyroscopeBiasUnits
163 {
164 rad_s,
165 deg_s,
166 };
168 ImuGyroscopeBiasUnits _imuGyroscopeBiasUnit = ImuGyroscopeBiasUnits::rad_s;
170 Eigen::Vector3d _imuGyroscopeBias_p = Eigen::Vector3d::Zero();
171
172 // ---------------------------------------------------------------- Noise ------------------------------------------------------------------
173
175 enum class ImuAccelerometerNoiseUnits
176 {
177 m_s2,
178 m2_s4,
179 };
181 ImuAccelerometerNoiseUnits _imuAccelerometerNoiseUnit = ImuAccelerometerNoiseUnits::m_s2;
183 Eigen::Vector3d _imuAccelerometerNoise = Eigen::Vector3d::Zero();
185 RandomNumberGenerator _imuAccelerometerRng;
186
188 enum class ImuGyroscopeNoiseUnits
189 {
190 rad_s,
191 deg_s,
192 rad2_s2,
193 deg2_s2,
194 };
196 ImuGyroscopeNoiseUnits _imuGyroscopeNoiseUnit = ImuGyroscopeNoiseUnits::rad_s;
198 Eigen::Vector3d _imuGyroscopeNoise = Eigen::Vector3d::Zero();
200 RandomNumberGenerator _imuGyroscopeRng;
201
203 enum class ImuAccelerometerRWUnits
204 {
205 m_s2_sqrts,
206 m_s2_sqrth,
207 };
209 enum class ImuGyroscopeRWUnits
210 {
211 rad_s_sqrts,
212 rad_s_sqrth,
213 deg_s_sqrts,
214 deg_s_sqrth,
215 };
216
218 enum class ImuAccelerometerIRWUnits
219 {
220 m_s3_sqrts,
221 m_s3_sqrth,
222 };
224 enum class ImuGyroscopeIRWUnits
225 {
226 rad_s2_sqrts,
227 rad_s2_sqrth,
228 deg_s2_sqrts,
229 deg_s2_sqrth,
230 };
231
233 ImuAccelerometerRWUnits _imuAccelerometerRWUnit = ImuAccelerometerRWUnits::m_s2_sqrts;
235 Eigen::Vector3d _imuAccelerometerRW = Eigen::Vector3d::Zero();
237 RandomNumberGenerator _imuAccelerometerRWRng;
238
240 ImuGyroscopeRWUnits _imuGyroscopeRWUnit = ImuGyroscopeRWUnits::rad_s_sqrts;
242 Eigen::Vector3d _imuGyroscopeRW = Eigen::Vector3d::Zero();
244 RandomNumberGenerator _imuGyroscopeRWRng;
245
247 ImuAccelerometerIRWUnits _imuAccelerometerIRWUnit = ImuAccelerometerIRWUnits::m_s3_sqrts;
249 Eigen::Vector3d _imuAccelerometerIRW = Eigen::Vector3d::Zero();
251 RandomNumberGenerator _imuAccelerometerIRWRng;
252
254 ImuGyroscopeIRWUnits _imuGyroscopeIRWUnit = ImuGyroscopeIRWUnits::rad_s2_sqrts;
256 Eigen::Vector3d _imuGyroscopeIRW = Eigen::Vector3d::Zero();
258 RandomNumberGenerator _imuGyroscopeIRWRng;
259
261 double _imuObsWDeltaAverageWindow = 10;
262
263 // #########################################################################################################################################
264 // PosVelAtt
265 // #########################################################################################################################################
266
267 // --------------------------------------------------------------- Offset ------------------------------------------------------------------
268
270 enum class PositionBiasUnits
271 {
272 meter,
273 rad_rad_m,
274 deg_deg_m,
275 };
277 PositionBiasUnits _positionBiasUnit = PositionBiasUnits::meter;
279 Eigen::Vector3d _positionBias = Eigen::Vector3d::Zero();
280
282 enum class VelocityBiasUnits
283 {
284 m_s,
285 };
287 VelocityBiasUnits _velocityBiasUnit = VelocityBiasUnits::m_s;
289 Eigen::Vector3d _velocityBias = Eigen::Vector3d::Zero();
290
292 enum class AttitudeBiasUnits
293 {
294 rad,
295 deg,
296 };
298 AttitudeBiasUnits _attitudeBiasUnit = AttitudeBiasUnits::deg;
300 Eigen::Vector3d _attitudeBias = Eigen::Vector3d::Zero();
301
302 // ---------------------------------------------------------------- Noise ------------------------------------------------------------------
303
305 enum class PositionNoiseUnits
306 {
307 meter,
308 rad_rad_m,
309 deg_deg_m,
310 meter2,
311 rad2_rad2_m2,
312 deg2_deg2_m2,
313 };
314
316 PositionNoiseUnits _positionNoiseUnit = PositionNoiseUnits::meter;
318 Eigen::Vector3d _positionNoise = Eigen::Vector3d::Zero();
320 RandomNumberGenerator _positionRng;
322 enum class VelocityNoiseUnits
323 {
324 m_s,
325 m2_s2,
326 };
328 VelocityNoiseUnits _velocityNoiseUnit = VelocityNoiseUnits::m_s;
330 Eigen::Vector3d _velocityNoise = Eigen::Vector3d::Zero();
332 RandomNumberGenerator _velocityRng;
333
335 enum class AttitudeNoiseUnits
336 {
337 rad,
338 deg,
339 rad2,
340 deg2,
341 };
343 AttitudeNoiseUnits _attitudeNoiseUnit = AttitudeNoiseUnits::deg;
345 Eigen::Vector3d _attitudeNoise = Eigen::Vector3d::Zero();
347 RandomNumberGenerator _attitudeRng;
348
349 // #########################################################################################################################################
350 // GnssObs
351 // #########################################################################################################################################
352
353 // ---------------------------------------------------------------- Noise ------------------------------------------------------------------
354
356 enum class PseudorangeNoiseUnits
357 {
358 meter,
359 };
361 PseudorangeNoiseUnits _gui_pseudorangeNoiseUnit = PseudorangeNoiseUnits::meter;
363 double _gui_pseudorangeNoise{ 0.3 };
365 RandomNumberGenerator _pseudorangeRng;
366
368 enum class CarrierPhaseNoiseUnits
369 {
370 meter,
371 };
373 CarrierPhaseNoiseUnits _gui_carrierPhaseNoiseUnit = CarrierPhaseNoiseUnits::meter;
375 double _gui_carrierPhaseNoise{ 0.003 };
377 RandomNumberGenerator _carrierPhaseRng;
378
380 enum class DopplerNoiseUnits
381 {
382 m_s,
383 };
385 DopplerNoiseUnits _gui_dopplerNoiseUnit = DopplerNoiseUnits::m_s;
387 double _gui_dopplerNoise{ 0.05 };
389 RandomNumberGenerator _dopplerRng;
390
391 // -------------------------------------------------------------- Ambiguity ----------------------------------------------------------------
392
394 std::array<int, 2> _gui_ambiguityLimits = { { -20, 20 } };
396 RandomNumberGenerator _ambiguityRng;
398 std::map<SatSigId, std::vector<std::pair<InsTime, int>>> _ambiguities;
399
400 // ------------------------------------------------------------- Cycle-slip ----------------------------------------------------------------
401
403 enum class CycleSlipFrequencyUnits
404 {
405 per_day,
406 per_hour,
407 per_minute,
408 };
410 CycleSlipFrequencyUnits _gui_cycleSlipFrequencyUnit = CycleSlipFrequencyUnits::per_hour;
412 double _gui_cycleSlipFrequency{ 0.0 };
414 int _gui_cycleSlipRange = 20;
416 InsTime _cycleSlipWindowStartTime;
417
419 enum class CycleSlipDetectionProbabilityUnits
420 {
421 percent,
422 };
424 CycleSlipDetectionProbabilityUnits _gui_cycleSlipDetectionProbabilityUnit = CycleSlipDetectionProbabilityUnits::percent;
426 double _gui_cycleSlipDetectionProbability{ 100.0 };
427
429 RandomNumberGenerator _cycleSlipRng;
430
432 struct CycleSlipInfo
433 {
434 InsTime time;
435 SatSigId satSigId;
436 bool LLI;
437 };
439 std::vector<CycleSlipInfo> _cycleSlips;
440
442 Frequency _filterFreq = G01;
444 Code _filterCode = Code_Default;
445};
446
447} // namespace NAV
const Code Code_Default
Default selection for codes.
Definition Code.hpp:654
Vector space operations.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
@ G01
GPS L1 (1575.42 MHz).
Definition Frequency.hpp:28
@ None
None.
Definition GlobalActions.hpp:19
GNSS Observation messages.
Data storage class for one VectorNavImu observation.
Parent Class for all IMU Observations.
Node Class.
Position, Velocity and Attitude Storage Class.
Random Number Generator.
Adds errors (biases and noise) to measurements.
Definition ErrorModel.hpp:33
~ErrorModel() override
Destructor.
void restore(const json &j) override
Restores the node from a json object.
ErrorModel(const ErrorModel &)=delete
Copy constructor.
json save() const override
Saves the node into a json object.
std::string type() const override
String representation of the Class Type.
ErrorModel & operator=(const ErrorModel &)=delete
Copy assignment operator.
static std::string typeStatic()
String representation of the Class Type.
static std::string category()
String representation of the Class Category.
ErrorModel(ErrorModel &&)=delete
Move constructor.
void guiConfig() override
ImGui config window which is shown on double click.
ErrorModel()
Default constructor.
ErrorModel & operator=(ErrorModel &&)=delete
Move assignment operator.
GNSS Observation message information.
Definition GnssObs.hpp:32
VectorNav Observation storage Class.
Definition ImuObsWDelta.hpp:22
IMU Observation storage class.
Definition ImuObs.hpp:25
Input pins of nodes.
Definition Pin.hpp:491
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
Abstract parent class for all nodes.
Definition Node.hpp:86
Output pins of nodes.
Definition Pin.hpp:338
Position, Velocity and Attitude Storage Class.
Definition PosVelAtt.hpp:25