0.4.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
PosVelAttInitializer.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
9/// @file PosVelAttInitializer.hpp
10/// @brief Position, Velocity, Attitude Initializer from GPS and IMU data
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2021-02-03
13
14#pragma once
15
17
19
24
27
28#include <limits>
29
30namespace NAV
31{
32/// Position, Velocity, Attitude Initializer from GPS and IMU data
34{
35 public:
36 /// @brief Default constructor
38 /// @brief Destructor
39 ~PosVelAttInitializer() override;
40 /// @brief Copy constructor
42 /// @brief Move constructor
44 /// @brief Copy assignment operator
46 /// @brief Move assignment operator
48
49 /// @brief String representation of the Class Type
50 [[nodiscard]] static std::string typeStatic();
51
52 /// @brief String representation of the Class Type
53 [[nodiscard]] std::string type() const override;
54
55 /// @brief String representation of the Class Category
56 [[nodiscard]] static std::string category();
57
58 /// @brief ImGui config window which is shown on double click
59 /// @attention Don't forget to set _hasConfig to true in the constructor of the node
60 void guiConfig() override;
61
62 /// @brief Saves the node into a json object
63 [[nodiscard]] json save() const override;
64
65 /// @brief Restores the node from a json object
66 /// @param[in] j Json object with the node state
67 void restore(const json& j) override;
68
69 private:
70 constexpr static size_t OUTPUT_PORT_INDEX_POS_VEL_ATT = 0; ///< @brief Flow (PosVelAtt)
71
72 /// Index of the input pin for IMU observations
74 /// Index of the input pin for GNSS observations
76
77 /// @brief Initialize the node
78 bool initialize() override;
79
80 /// @brief Deinitialize the node
81 void deinitialize() override;
82
83 /// Add or removes input pins depending on the settings and modifies the output pin
84 void updatePins();
85
86 /// Checks whether all Flags are set and writes logs messages
87 void finalizeInit();
88
89 /// @brief Receive Imu Observations
90 /// @param[in] queue Queue with all the received data messages
91 /// @param[in] pinIdx Index of the pin the data is received on
92 void receiveImuObs(InputPin::NodeDataQueue& queue, size_t pinIdx);
93
94 /// @brief Receive Gnss Observations
95 /// @param[in] queue Queue with all the received data messages
96 /// @param[in] pinIdx Index of the pin the data is received on
97 void receiveGnssObs(InputPin::NodeDataQueue& queue, size_t pinIdx);
98
99 /// @brief Receive Ublox Observations
100 /// @param[in] obs Ublox Data
101 void receiveUbloxObs(const std::shared_ptr<const UbloxObs>& obs);
102
103 /// @brief Receive Pos Observations
104 /// @param[in] obs Pos Data
105 void receivePosObs(const std::shared_ptr<const Pos>& obs);
106
107 /// @brief Receive PosVel Observations
108 /// @param[in] obs PosVel Data
109 void receivePosVelObs(const std::shared_ptr<const PosVel>& obs);
110
111 /// @brief Receive PosVelAtt Observations
112 /// @param[in] obs PosVelAtt Data
113 void receivePosVelAttObs(const std::shared_ptr<const PosVelAtt>& obs);
114
115 /// @brief Polls the PVA solution if all is set in the GUI
116 /// @return The PVA solution
117 [[nodiscard]] std::shared_ptr<const NodeData> pollPVASolution();
118
119 /// Time in [s] to initialize the state
120 double _initDuration = 5.0;
121
122 /// Start time of the averaging process
124
125 /// Initialization source for attitude
126 enum class AttitudeMode : uint8_t
127 {
128 BOTH, ///< Use IMU and GNSS Observations for attitude initialization
129 IMU, ///< Use IMU Observations for attitude initialization
130 GNSS, ///< Use GNSS Observations for attitude initialization
131 COUNT, ///< Amount of items in the enum
132 };
133
134 /// @brief Converts the enum to a string
135 /// @param[in] attitudeMode Enum value to convert into text
136 /// @return String representation of the enum
137 friend constexpr const char* to_string(AttitudeMode attitudeMode);
138
139 /// GUI option to pecify the initialization source for attitude
141
142 /// Whether the GNSS values should be used or we want to override the values manually
143 bool _overridePosition = false;
144 /// Values to override the Position in ECEF coordinates in [m]
146
147 /// Position Accuracy to achieve in [cm]
149 /// Last position accuracy in [cm] for XYZ or NED
150 std::array<double, 3> _lastPositionAccuracy = { std::numeric_limits<double>::infinity(),
151 std::numeric_limits<double>::infinity(),
152 std::numeric_limits<double>::infinity() };
153
154 /// Override options for Position
155 enum class VelocityOverride : uint8_t
156 {
157 OFF, ///< Do not override the values
158 ECEF, ///< Override with ECEF values
159 NED, ///< Override with NED values
160 COUNT, ///< Amount of items in the enum
161 };
162
163 /// @brief Converts the enum to a string
164 /// @param[in] velOverride Enum value to convert into text
165 /// @return String representation of the enum
166 friend constexpr const char* to_string(VelocityOverride velOverride);
167
168 /// Whether the GNSS values should be used or we want to override the values manually
170 /// Values to override the Velocity in [m/s]
171 Eigen::Vector3d _overrideVelocityValues = Eigen::Vector3d::Zero();
172 /// Velocity Accuracy to achieve in [cm/s]
174 /// Last velocity accuracy in [cm/s] for XYZ or NED
175 std::array<double, 3> _lastVelocityAccuracy = { std::numeric_limits<double>::infinity(),
176 std::numeric_limits<double>::infinity(),
177 std::numeric_limits<double>::infinity() };
178
179 /// Count of received attitude measurements
181 /// Averaged Attitude (roll, pitch, yaw) in [rad]
182 std::array<double, 3> _averagedAttitude = { 0.0, 0.0, 0.0 };
183 /// Whether the IMU values should be used or we want to override the values manually
184 std::array<bool, 3> _overrideRollPitchYaw = { false, false, false };
185 /// Values to override Roll, Pitch and Yaw with in [deg]
186 std::array<double, 3> _overrideRollPitchYawValues = {};
187
188 /// Whether the states are initialized (pos, vel, att, messages send)
189 std::array<bool, 4> _posVelAttInitialized = { false, false, false, false };
190
191 /// Time Format to input the init time with
193
194 /// Initialization time
196 /// Initialized Quaternion body to navigation frame (roll, pitch, yaw)
197 Eigen::Quaterniond _n_Quat_b_init;
198 /// Position in ECEF coordinates
199 Eigen::Vector3d _e_initPosition;
200 /// Velocity in navigation coordinates
201 Eigen::Vector3d _n_initVelocity;
202};
203
204/// @brief Converts the enum to a string
205/// @param[in] attitudeMode Enum value to convert into text
206/// @return String representation of the enum
207constexpr const char* to_string(PosVelAttInitializer::AttitudeMode attitudeMode)
208{
209 switch (attitudeMode)
210 {
212 return "Both";
214 return "IMU";
216 return "GNSS";
218 return "";
219 }
220 return "";
221}
222
223/// @brief Converts the enum to a string
224/// @param[in] velOverride Enum value to convert into text
225/// @return String representation of the enum
226constexpr const char* to_string(PosVelAttInitializer::VelocityOverride velOverride)
227{
228 switch (velOverride)
229 {
231 return "OFF";
233 return "ECEF";
235 return "NED";
237 return "";
238 }
239 return "";
240}
241
242} // namespace NAV
nlohmann::json json
json namespace
Parent Class for all IMU Observations.
The class is responsible for all time-related tasks.
Node Class.
Position, Velocity and Attitude Storage Class.
Position Input GUI widgets.
RTKLIB Pos Observation Class.
Widget to modify time point values.
ublox Observation Class
TsDeque< std::shared_ptr< const NAV::NodeData > > NodeDataQueue
Node data queue type.
Definition Pin.hpp:707
The class is responsible for all time-related tasks.
Definition InsTime.hpp:710
Node(std::string name)
Constructor.
Definition Node.cpp:30
int _inputPinIdxGNSS
Index of the input pin for GNSS observations.
std::array< double, 3 > _overrideRollPitchYawValues
Values to override Roll, Pitch and Yaw with in [deg].
VelocityOverride
Override options for Position.
bool _overridePosition
Whether the GNSS values should be used or we want to override the values manually.
void receivePosObs(const std::shared_ptr< const Pos > &obs)
Receive Pos Observations.
void deinitialize() override
Deinitialize the node.
std::array< bool, 4 > _posVelAttInitialized
Whether the states are initialized (pos, vel, att, messages send)
gui::widgets::TimeEditFormat _initTimeEditFormat
Time Format to input the init time with.
PosVelAttInitializer & operator=(PosVelAttInitializer &&)=delete
Move assignment operator.
std::array< double, 3 > _averagedAttitude
Averaged Attitude (roll, pitch, yaw) in [rad].
std::array< double, 3 > _lastPositionAccuracy
Last position accuracy in [cm] for XYZ or NED.
static constexpr size_t OUTPUT_PORT_INDEX_POS_VEL_ATT
Flow (PosVelAtt)
static std::string typeStatic()
String representation of the Class Type.
AttitudeMode
Initialization source for attitude.
@ BOTH
Use IMU and GNSS Observations for attitude initialization.
@ IMU
Use IMU Observations for attitude initialization.
@ GNSS
Use GNSS Observations for attitude initialization.
Eigen::Vector3d _overrideVelocityValues
Values to override the Velocity in [m/s].
void receiveGnssObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Receive Gnss Observations.
AttitudeMode _attitudeMode
GUI option to pecify the initialization source for attitude.
Eigen::Vector3d _e_initPosition
Position in ECEF coordinates.
void receivePosVelObs(const std::shared_ptr< const PosVel > &obs)
Receive PosVel Observations.
friend constexpr const char * to_string(AttitudeMode attitudeMode)
Converts the enum to a string.
std::string type() const override
String representation of the Class Type.
Eigen::Quaterniond _n_Quat_b_init
Initialized Quaternion body to navigation frame (roll, pitch, yaw)
PosVelAttInitializer(PosVelAttInitializer &&)=delete
Move constructor.
void guiConfig() override
ImGui config window which is shown on double click.
void updatePins()
Add or removes input pins depending on the settings and modifies the output pin.
int _inputPinIdxIMU
Index of the input pin for IMU observations.
double _velocityAccuracyThreshold
Velocity Accuracy to achieve in [cm/s].
double _initDuration
Time in [s] to initialize the state.
void restore(const json &j) override
Restores the node from a json object.
~PosVelAttInitializer() override
Destructor.
PosVelAttInitializer()
Default constructor.
bool initialize() override
Initialize the node.
Eigen::Vector3d _n_initVelocity
Velocity in navigation coordinates.
std::array< bool, 3 > _overrideRollPitchYaw
Whether the IMU values should be used or we want to override the values manually.
std::shared_ptr< const NodeData > pollPVASolution()
Polls the PVA solution if all is set in the GUI.
json save() const override
Saves the node into a json object.
PosVelAttInitializer & operator=(const PosVelAttInitializer &)=delete
Copy assignment operator.
void finalizeInit()
Checks whether all Flags are set and writes logs messages.
InsTime _startTime
Start time of the averaging process.
InsTime _initTime
Initialization time.
double _positionAccuracyThreshold
Position Accuracy to achieve in [cm].
static std::string category()
String representation of the Class Category.
void receivePosVelAttObs(const std::shared_ptr< const PosVelAtt > &obs)
Receive PosVelAtt Observations.
void receiveImuObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Receive Imu Observations.
gui::widgets::PositionWithFrame _overridePositionValue
Values to override the Position in ECEF coordinates in [m].
PosVelAttInitializer(const PosVelAttInitializer &)=delete
Copy constructor.
double _countAveragedAttitude
Count of received attitude measurements.
VelocityOverride _overrideVelocity
Whether the GNSS values should be used or we want to override the values manually.
std::array< double, 3 > _lastVelocityAccuracy
Last velocity accuracy in [cm/s] for XYZ or NED.
void receiveUbloxObs(const std::shared_ptr< const UbloxObs > &obs)
Receive Ublox Observations.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
GPS week and time of week in GPS standard time [GPST].
Definition InsTime.hpp:369
Position with Reference frame, used for GUI input.
Time Edit format and system.
Definition TimeEdit.hpp:29