0.3.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
23
25
26#include "util/Eigen.hpp"
27#include <random>
28#include <map>
29
30namespace NAV
31{
33class ErrorModel : public Node
34{
35 public:
39 ~ErrorModel() override;
41 ErrorModel(const ErrorModel&) = delete;
45 ErrorModel& operator=(const ErrorModel&) = delete;
48
50 [[nodiscard]] static std::string typeStatic();
51
53 [[nodiscard]] std::string type() const override;
54
56 [[nodiscard]] static std::string category();
57
60 void guiConfig() override;
61
63 [[nodiscard]] json save() const override;
64
67 void restore(const json& j) override;
68
69 private:
70 constexpr static size_t OUTPUT_PORT_INDEX_FLOW = 0;
71 constexpr static size_t INPUT_PORT_INDEX_FLOW = 0;
72
74 enum class InputType : uint8_t
75 {
76 None,
77 ImuObs,
79 PosVelAtt,
80 GnssObs,
81 };
82
85
87 bool resetNode() override;
88
92 void afterCreateLink(OutputPin& startPin, InputPin& endPin) override;
93
97 void afterDeleteLink(OutputPin& startPin, InputPin& endPin) override;
98
102 void receiveObs(InputPin::NodeDataQueue& queue, size_t pinIdx);
103
110 std::shared_ptr<ImuObs> receiveImuObs(const std::shared_ptr<ImuObs>& imuObs,
111 const Eigen::Vector3d& accelerometerBias_p,
112 const Eigen::Vector3d& gyroscopeBias_p,
113 const Eigen::Vector3d& accelerometerNoiseStd,
114 const Eigen::Vector3d& gyroscopeNoiseStd);
115
122 [[nodiscard]] std::shared_ptr<ImuObsWDelta> receiveImuObsWDelta(const std::shared_ptr<ImuObsWDelta>& imuObs,
123 const Eigen::Vector3d& accelerometerBias_p,
124 const Eigen::Vector3d& gyroscopeBias_p,
125 const Eigen::Vector3d& accelerometerNoiseStd,
126 const Eigen::Vector3d& gyroscopeNoiseStd);
127
130 [[nodiscard]] std::shared_ptr<PosVelAtt> receivePosVelAtt(const std::shared_ptr<PosVelAtt>& posVelAtt);
131
134 [[nodiscard]] std::shared_ptr<GnssObs> receiveGnssObs(const std::shared_ptr<GnssObs>& gnssObs);
135
139 double _dt = 0.0;
140
141 // #########################################################################################################################################
142 // ImuObs
143 // #########################################################################################################################################
144 //
146 Eigen::Vector3d _randomWalkAccelerometer = Eigen::Vector3d::Zero();
147
149 Eigen::Vector3d _randomWalkGyroscope = Eigen::Vector3d::Zero();
150
152 Eigen::Vector3d _integratedRandomWalkAccelerometer_velocity = Eigen::Vector3d::Zero();
153
155 Eigen::Vector3d _integratedRandomWalkAccelerometer = Eigen::Vector3d::Zero();
156
158 Eigen::Vector3d _integratedRandomWalkGyroscope_velocity = Eigen::Vector3d::Zero();
159
161 Eigen::Vector3d _integratedRandomWalkGyroscope = Eigen::Vector3d::Zero();
162
163 // --------------------------------------------------------------- Offset ------------------------------------------------------------------
164
166 Units::ImuAccelerometerUnits _imuAccelerometerBiasUnit = Units::ImuAccelerometerUnits::m_s2;
168 Eigen::Vector3d _imuAccelerometerBias_p = Eigen::Vector3d::Zero();
169
171 Units::ImuGyroscopeUnits _imuGyroscopeBiasUnit = Units::ImuGyroscopeUnits::rad_s;
173 Eigen::Vector3d _imuGyroscopeBias_p = Eigen::Vector3d::Zero();
174
175 // ---------------------------------------------------------------- Noise ------------------------------------------------------------------
176
178 Units::ImuAccelerometerNoiseUnits _imuAccelerometerNoiseUnit = Units::ImuAccelerometerNoiseUnits::m_s2_sqrts;
180 Eigen::Vector3d _imuAccelerometerNoise = Eigen::Vector3d::Zero();
183
185 Units::ImuGyroscopeNoiseUnits _imuGyroscopeNoiseUnit = Units::ImuGyroscopeNoiseUnits::rad_s_sqrts;
187 Eigen::Vector3d _imuGyroscopeNoise = Eigen::Vector3d::Zero();
190
192 Units::ImuAccelerometerNoiseUnits _imuAccelerometerRWUnit = Units::ImuAccelerometerNoiseUnits::m_s2_sqrts;
194 Eigen::Vector3d _imuAccelerometerRW = Eigen::Vector3d::Zero();
197
199 Units::ImuGyroscopeNoiseUnits _imuGyroscopeRWUnit = Units::ImuGyroscopeNoiseUnits::rad_s_sqrts;
201 Eigen::Vector3d _imuGyroscopeRW = Eigen::Vector3d::Zero();
204
206 Units::ImuAccelerometerIRWUnits _imuAccelerometerIRWUnit = Units::ImuAccelerometerIRWUnits::m_s3_sqrts;
208 Eigen::Vector3d _imuAccelerometerIRW = Eigen::Vector3d::Zero();
211
213 Units::ImuGyroscopeIRWUnits _imuGyroscopeIRWUnit = Units::ImuGyroscopeIRWUnits::rad_s2_sqrts;
215 Eigen::Vector3d _imuGyroscopeIRW = Eigen::Vector3d::Zero();
218
219 // #########################################################################################################################################
220 // PosVelAtt
221 // #########################################################################################################################################
222
223 // --------------------------------------------------------------- Offset ------------------------------------------------------------------
224
226 enum class PositionBiasUnits : uint8_t
227 {
228 meter,
229 };
233 Eigen::Vector3d _positionBias = Eigen::Vector3d::Zero();
234
236 enum class VelocityBiasUnits : uint8_t
237 {
238 m_s,
239 };
243 Eigen::Vector3d _velocityBias = Eigen::Vector3d::Zero();
244
246 enum class AttitudeBiasUnits : uint8_t
247 {
248 rad,
249 deg,
250 };
254 Eigen::Vector3d _attitudeBias = Eigen::Vector3d::Zero();
255
256 // ---------------------------------------------------------------- Noise ------------------------------------------------------------------
257
259 enum class PositionNoiseUnits : uint8_t
260 {
261 meter,
262 meter2,
263 };
264
268 Eigen::Vector3d _positionNoise = Eigen::Vector3d::Zero();
272 enum class VelocityNoiseUnits : uint8_t
273 {
274 m_s,
275 m2_s2,
276 };
280 Eigen::Vector3d _velocityNoise = Eigen::Vector3d::Zero();
283
285 enum class AttitudeNoiseUnits : uint8_t
286 {
287 rad,
288 deg,
289 rad2,
290 deg2,
291 };
295 Eigen::Vector3d _attitudeNoise = Eigen::Vector3d::Zero();
298
299 // #########################################################################################################################################
300 // GnssObs
301 // #########################################################################################################################################
302
303 // ---------------------------------------------------------------- Noise ------------------------------------------------------------------
304
306 enum class PseudorangeNoiseUnits : uint8_t
307 {
308 meter,
309 };
316
318 enum class CarrierPhaseNoiseUnits : uint8_t
319 {
320 meter,
321 };
325 double _gui_carrierPhaseNoise{ 0.003 };
328
330 enum class DopplerNoiseUnits : uint8_t
331 {
332 m_s,
333 };
337 double _gui_dopplerNoise{ 0.05 };
340
341 // -------------------------------------------------------------- Ambiguity ----------------------------------------------------------------
342
344 std::array<int, 2> _gui_ambiguityLimits = { { -20, 20 } };
348 std::map<SatSigId, std::vector<std::pair<InsTime, int>>> _ambiguities;
349
350 // ------------------------------------------------------------- Cycle-slip ----------------------------------------------------------------
351
353 enum class CycleSlipFrequencyUnits : uint8_t
354 {
355 per_day,
356 per_hour,
357 per_minute,
358 };
367
370 {
371 percent,
372 };
377
380
389 std::vector<CycleSlipInfo> _cycleSlips;
390
395};
396
397} // namespace NAV
const Code Code_Default
Default selection for codes.
Definition Code.hpp:655
Vector space operations.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
@ G01
GPS L1 (1575.42 MHz).
Definition Frequency.hpp:28
GNSS Observation messages.
Units used by INS.
ImuGyroscopeUnits
Possible units to specify an gyroscope bias with.
Definition Units.hpp:38
ImuAccelerometerIRWUnits
Possible units to specify an accelerometer IRW.
Definition Units.hpp:64
ImuAccelerometerNoiseUnits
Possible units to specify an accelerometer noise.
Definition Units.hpp:46
ImuGyroscopeIRWUnits
Possible units to specify an gyro RW.
Definition Units.hpp:72
ImuGyroscopeNoiseUnits
Possible units to specify an gyro noise.
Definition Units.hpp:54
ImuAccelerometerUnits
Possible units to specify an accelerometer with.
Definition Units.hpp:31
Data storage class for one VectorNavImu observation.
Parent Class for all IMU Observations.
Node Class.
Position, Velocity and Attitude Storage Class.
Random Number Generator.
Enumerate for GNSS Codes.
Definition Code.hpp:89
Adds errors (biases and noise) to measurements.
Definition ErrorModel.hpp:34
Frequency _filterFreq
Frequencies used for calculation (GUI filter)
Definition ErrorModel.hpp:392
RandomNumberGenerator _imuAccelerometerRng
Random number generator for the accelerometer noise.
Definition ErrorModel.hpp:182
VelocityBiasUnits
Possible units to specify an velocity bias with.
Definition ErrorModel.hpp:237
PositionBiasUnits
Possible units to specify a position bias with.
Definition ErrorModel.hpp:227
int _gui_cycleSlipRange
Ambiguity limits cycle-slip.
Definition ErrorModel.hpp:364
RandomNumberGenerator _carrierPhaseRng
Random number generator for the carrier-phase noise.
Definition ErrorModel.hpp:327
Units::ImuAccelerometerUnits _imuAccelerometerBiasUnit
Selected unit for the accelerometer bias in the GUI.
Definition ErrorModel.hpp:166
VelocityBiasUnits _velocityBiasUnit
Selected unit for the velocity bias in the GUI.
Definition ErrorModel.hpp:241
std::array< int, 2 > _gui_ambiguityLimits
Ambiguity limits.
Definition ErrorModel.hpp:344
CarrierPhaseNoiseUnits _gui_carrierPhaseNoiseUnit
Selected unit for the carrier-phase noise in the GUI.
Definition ErrorModel.hpp:323
std::shared_ptr< PosVelAtt > receivePosVelAtt(const std::shared_ptr< PosVelAtt > &posVelAtt)
Callback when receiving an ImuObs.
RandomNumberGenerator _imuGyroscopeRng
Random number generator for the gyroscope noise.
Definition ErrorModel.hpp:189
RandomNumberGenerator _imuAccelerometerIRWRng
Random number generator for the accelerometer IRW noise.
Definition ErrorModel.hpp:210
Units::ImuGyroscopeIRWUnits _imuGyroscopeIRWUnit
Selected unit for the accelerometer IRW noise in the GUI.
Definition ErrorModel.hpp:213
RandomNumberGenerator _imuGyroscopeRWRng
Random number generator for the accelerometer RW noise.
Definition ErrorModel.hpp:203
RandomNumberGenerator _imuAccelerometerRWRng
Random number generator for the accelerometer RW noise.
Definition ErrorModel.hpp:196
~ErrorModel() override
Destructor.
PositionNoiseUnits _positionNoiseUnit
Selected unit for the position noise in the GUI.
Definition ErrorModel.hpp:266
Eigen::Vector3d _positionNoise
Noise of the position (Unit as selected)
Definition ErrorModel.hpp:268
Units::ImuGyroscopeUnits _imuGyroscopeBiasUnit
Selected unit for the gyroscope bias in the GUI.
Definition ErrorModel.hpp:171
Eigen::Vector3d _imuAccelerometerNoise
Noise of the accelerometer (Unit as selected)
Definition ErrorModel.hpp:180
static constexpr size_t OUTPUT_PORT_INDEX_FLOW
Flow.
Definition ErrorModel.hpp:70
CycleSlipDetectionProbabilityUnits
Possible units to specify the cycle-slip detection probability with.
Definition ErrorModel.hpp:370
VelocityNoiseUnits _velocityNoiseUnit
Selected unit for the velocity noise in the GUI.
Definition ErrorModel.hpp:278
void restore(const json &j) override
Restores the node from a json object.
void afterDeleteLink(OutputPin &startPin, InputPin &endPin) override
Called when a link was deleted.
Eigen::Vector3d _integratedRandomWalkGyroscope
3D array which allow to accumulate IRW for gyro
Definition ErrorModel.hpp:161
Units::ImuAccelerometerNoiseUnits _imuAccelerometerNoiseUnit
Selected unit for the accelerometer noise in the GUI.
Definition ErrorModel.hpp:178
CycleSlipFrequencyUnits
Possible units to specify the cycle-slip rate with.
Definition ErrorModel.hpp:354
ErrorModel(const ErrorModel &)=delete
Copy constructor.
RandomNumberGenerator _attitudeRng
Random number generator for the attitude noise.
Definition ErrorModel.hpp:297
AttitudeBiasUnits _attitudeBiasUnit
Selected unit for the attitude bias in the GUI.
Definition ErrorModel.hpp:252
AttitudeNoiseUnits
Possible units to specify a attitude noise with.
Definition ErrorModel.hpp:286
@ deg
[deg] (Standard deviation)
json save() const override
Saves the node into a json object.
InputType
Input type.
Definition ErrorModel.hpp:75
@ ImuObsWDelta
ImuObsWDelta.
std::string type() const override
String representation of the Class Type.
RandomNumberGenerator _imuGyroscopeIRWRng
Random number generator for the accelerometer RW noise.
Definition ErrorModel.hpp:217
Eigen::Vector3d _velocityBias
Bias of the velocity (Unit as selected)
Definition ErrorModel.hpp:243
std::shared_ptr< ImuObs > receiveImuObs(const std::shared_ptr< ImuObs > &imuObs, const Eigen::Vector3d &accelerometerBias_p, const Eigen::Vector3d &gyroscopeBias_p, const Eigen::Vector3d &accelerometerNoiseStd, const Eigen::Vector3d &gyroscopeNoiseStd)
Callback when receiving an ImuObs.
ErrorModel & operator=(const ErrorModel &)=delete
Copy assignment operator.
InsTime _lastObservationTime
Last observation time.
Definition ErrorModel.hpp:137
RandomNumberGenerator _cycleSlipRng
Random number generator for the cycle-slip.
Definition ErrorModel.hpp:379
double _gui_cycleSlipDetectionProbability
The chance to detect a cycle slip and set the Loss-of-Lock indicator.
Definition ErrorModel.hpp:376
Eigen::Vector3d _integratedRandomWalkGyroscope_velocity
3D array which allow to accumulate IRW veloctiy noise for gyro
Definition ErrorModel.hpp:158
CycleSlipDetectionProbabilityUnits _gui_cycleSlipDetectionProbabilityUnit
Selected unit for the cycle-slip detection probability in the GUI.
Definition ErrorModel.hpp:374
Eigen::Vector3d _velocityNoise
Noise of the velocity (Unit as selected)
Definition ErrorModel.hpp:280
CycleSlipFrequencyUnits _gui_cycleSlipFrequencyUnit
Selected unit for the cycle-slip frequency in the GUI.
Definition ErrorModel.hpp:360
Eigen::Vector3d _imuAccelerometerRW
RW noise of the accelerometer (Unit as selected)
Definition ErrorModel.hpp:194
double _gui_pseudorangeNoise
Noise of the pseudorange (Unit as selected)
Definition ErrorModel.hpp:313
double _gui_carrierPhaseNoise
Noise of the carrier-phase (Unit as selected)
Definition ErrorModel.hpp:325
double _dt
Time interval of the messages [s].
Definition ErrorModel.hpp:139
RandomNumberGenerator _pseudorangeRng
Random number generator for the pseudorange noise.
Definition ErrorModel.hpp:315
Eigen::Vector3d _integratedRandomWalkAccelerometer
3D array which allow to accumulate IRW for accelerometer
Definition ErrorModel.hpp:155
Units::ImuGyroscopeNoiseUnits _imuGyroscopeRWUnit
Selected unit for the accelerometer RW noise in the GUI.
Definition ErrorModel.hpp:199
PositionNoiseUnits
Possible units to specify a position noise with.
Definition ErrorModel.hpp:260
@ meter2
NED [m^2 m^2 m^2] (Variance)
@ meter
NED [m m m] (Standard deviation)
DopplerNoiseUnits _gui_dopplerNoiseUnit
Selected unit for the range-rate noise in the GUI.
Definition ErrorModel.hpp:335
RandomNumberGenerator _ambiguityRng
Random number generator for the ambiguity.
Definition ErrorModel.hpp:346
DopplerNoiseUnits
Possible units to specify a range-rate noise with.
Definition ErrorModel.hpp:331
@ m_s
[m/s] (Standard deviation)
Eigen::Vector3d _imuAccelerometerBias_p
Bias of the accelerometer in platform coordinates (Unit as selected)
Definition ErrorModel.hpp:168
RandomNumberGenerator _positionRng
Random number generator for the position noise.
Definition ErrorModel.hpp:270
Eigen::Vector3d _imuGyroscopeBias_p
Bias of the gyroscope in platform coordinates (Unit as selected)
Definition ErrorModel.hpp:173
InputType _inputType
Input type.
Definition ErrorModel.hpp:84
Code _filterCode
Codes used for calculation (GUI filter)
Definition ErrorModel.hpp:394
double _gui_dopplerNoise
Noise of the range-rate (Unit as selected)
Definition ErrorModel.hpp:337
void receiveObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Callback when receiving data on a port.
Units::ImuAccelerometerNoiseUnits _imuAccelerometerRWUnit
Selected unit for the accelerometer RW noise in the GUI.
Definition ErrorModel.hpp:192
Eigen::Vector3d _imuGyroscopeNoise
Noise of the gyroscope (Unit as selected)
Definition ErrorModel.hpp:187
std::shared_ptr< ImuObsWDelta > receiveImuObsWDelta(const std::shared_ptr< ImuObsWDelta > &imuObs, const Eigen::Vector3d &accelerometerBias_p, const Eigen::Vector3d &gyroscopeBias_p, const Eigen::Vector3d &accelerometerNoiseStd, const Eigen::Vector3d &gyroscopeNoiseStd)
Callback when receiving an ImuObsWDelta.
Eigen::Vector3d _positionBias
Bias of the position (Unit as selected)
Definition ErrorModel.hpp:233
void afterCreateLink(OutputPin &startPin, InputPin &endPin) override
Called when a new link was established.
PseudorangeNoiseUnits
Possible units to specify a pseudorange noise with.
Definition ErrorModel.hpp:307
@ meter
[m] (Standard deviation)
Eigen::Vector3d _imuGyroscopeIRW
RW noise of the accelerometer (Unit as selected)
Definition ErrorModel.hpp:215
static std::string typeStatic()
String representation of the Class Type.
static std::string category()
String representation of the Class Category.
CarrierPhaseNoiseUnits
Possible units to specify a carrier-phase noise with.
Definition ErrorModel.hpp:319
@ meter
[m] (Standard deviation)
Units::ImuAccelerometerIRWUnits _imuAccelerometerIRWUnit
Selected unit for the accelerometer IRW noise in the GUI.
Definition ErrorModel.hpp:206
ErrorModel(ErrorModel &&)=delete
Move constructor.
Eigen::Vector3d _randomWalkGyroscope
3D array which allow to accumulate RW noise for gyro
Definition ErrorModel.hpp:149
Eigen::Vector3d _attitudeBias
Bias of the attitude (Unit as selected)
Definition ErrorModel.hpp:254
void guiConfig() override
ImGui config window which is shown on double click.
Eigen::Vector3d _imuAccelerometerIRW
IRW noise of the accelerometer (Unit as selected)
Definition ErrorModel.hpp:208
PositionBiasUnits _positionBiasUnit
Selected unit for the position bias in the GUI.
Definition ErrorModel.hpp:231
Eigen::Vector3d _imuGyroscopeRW
RW noise of the accelerometer (Unit as selected)
Definition ErrorModel.hpp:201
AttitudeNoiseUnits _attitudeNoiseUnit
Selected unit for the attitude noise in the GUI.
Definition ErrorModel.hpp:293
static constexpr size_t INPUT_PORT_INDEX_FLOW
Flow.
Definition ErrorModel.hpp:71
ErrorModel()
Default constructor.
std::shared_ptr< GnssObs > receiveGnssObs(const std::shared_ptr< GnssObs > &gnssObs)
Callback when receiving an GnssObs.
Eigen::Vector3d _randomWalkAccelerometer
3D array which allow to accumulate RW noise for accelerometer
Definition ErrorModel.hpp:146
VelocityNoiseUnits
Possible units to specify an velocity noise with.
Definition ErrorModel.hpp:273
@ m_s
[m/s] (Standard deviation)
Eigen::Vector3d _integratedRandomWalkAccelerometer_velocity
3D array which allow to accumulate IRW veloctiy noise for accelerometer
Definition ErrorModel.hpp:152
InsTime _cycleSlipWindowStartTime
The time frame which is considered for a cycle slip.
Definition ErrorModel.hpp:366
double _gui_cycleSlipFrequency
The cycle-slip frequency (Unit as selected)
Definition ErrorModel.hpp:362
RandomNumberGenerator _velocityRng
Random number generator for the velocity noise.
Definition ErrorModel.hpp:282
std::vector< CycleSlipInfo > _cycleSlips
List of produced cycle-slips.
Definition ErrorModel.hpp:389
RandomNumberGenerator _dopplerRng
Random number generator for the range-rate noise.
Definition ErrorModel.hpp:339
Units::ImuGyroscopeNoiseUnits _imuGyroscopeNoiseUnit
Selected unit for the gyroscope noise in the GUI.
Definition ErrorModel.hpp:185
ErrorModel & operator=(ErrorModel &&)=delete
Move assignment operator.
Eigen::Vector3d _attitudeNoise
Noise of the attitude (Unit as selected)
Definition ErrorModel.hpp:295
std::map< SatSigId, std::vector< std::pair< InsTime, int > > > _ambiguities
Ambiguity map.
Definition ErrorModel.hpp:348
AttitudeBiasUnits
Possible units to specify a attitude bias with.
Definition ErrorModel.hpp:247
bool resetNode() override
Resets the node. It is guaranteed that the node is initialized when this is called.
PseudorangeNoiseUnits _gui_pseudorangeNoiseUnit
Selected unit for the pseudorange noise in the GUI.
Definition ErrorModel.hpp:311
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
Input pins of nodes.
Definition Pin.hpp:491
The class is responsible for all time-related tasks.
Definition InsTime.hpp:668
Abstract parent class for all nodes.
Definition Node.hpp:86
Output pins of nodes.
Definition Pin.hpp:338
Manages a thread which calls a specified function at a specified interval.
Definition RandomNumberGenerator.hpp:29
Cycle-slip information.
Definition ErrorModel.hpp:383
InsTime time
Time of the cycle-slip.
Definition ErrorModel.hpp:384
SatSigId satSigId
Satellite Signal identifier.
Definition ErrorModel.hpp:385
bool LLI
Whether the LLI was set.
Definition ErrorModel.hpp:386
Identifies a satellite signal (satellite frequency and number)
Definition SatelliteIdentifier.hpp:67