0.2.0
Loading...
Searching...
No Matches
RtklibPosObs.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#include "util/Eigen.hpp"
18#include "Navigation/Transformations/Units.hpp"
19
20namespace NAV
21{
23class RtklibPosObs : public PosVel
24{
25 public:
26#ifdef TESTING
28 RtklibPosObs() = default;
29
57 std::optional<Eigen::Vector3d> e_position,
58 std::optional<Eigen::Vector3d> lla_position,
59 std::optional<Eigen::Vector3d> e_velocity,
60 std::optional<Eigen::Vector3d> n_velocity,
61 uint8_t Q,
62 uint8_t ns,
63 std::optional<Eigen::Vector3d> sdXYZ,
64 std::optional<Eigen::Vector3d> sdNED,
65 std::optional<double> sdxy,
66 std::optional<double> sdyz,
67 std::optional<double> sdzx,
68 std::optional<double> sdne,
69 std::optional<double> sded,
70 std::optional<double> sddn,
71 double age,
72 double ratio,
73 std::optional<Eigen::Vector3d> sdvNED,
74 std::optional<double> sdvne,
75 std::optional<double> sdved,
76 std::optional<double> sdvdn,
77 std::optional<Eigen::Vector3d> sdvXYZ,
78 std::optional<double> sdvxy,
79 std::optional<double> sdvyz,
80 std::optional<double> sdvzx)
81 : Q(Q), ns(ns), age(age), ratio(ratio)
82 {
83 this->insTime = insTime;
84
85 if (lla_position) { lla_position->head<2>() = deg2rad(lla_position->head<2>()); }
86
87 if (e_position && sdXYZ && sdxy && sdzx && sdyz)
88 {
89 Eigen::Matrix3d cov;
90 cov << std::pow(sdXYZ->x(), 2), *sdxy, -(*sdzx),
91 -(*sdxy), std::pow(sdXYZ->y(), 2), *sdyz,
92 *sdzx, -(*sdyz), std::pow(sdXYZ->z(), 2);
93 this->setPositionAndStdDev_e(*e_position, cov);
94 this->setPosCovarianceMatrix_e(cov);
95 }
96 else if (lla_position && sdNED && sdne && sddn && sded)
97 {
98 Eigen::Matrix3d cov;
99 cov << std::pow(sdNED->x(), 2), *sdne, -(*sddn),
100 -(*sdne), std::pow(sdNED->y(), 2), *sded,
101 *sddn, -(*sded), std::pow(sdNED->z(), 2);
102 this->setPositionAndStdDev_lla(*lla_position, cov);
103 this->setPosCovarianceMatrix_n(cov);
104 }
105 else if (e_position) { this->setPosition_e(*e_position); }
106 else if (lla_position) { this->setPosition_lla(*lla_position); }
107
108 if (e_velocity && sdvXYZ && sdvxy && sdvzx && sdvyz)
109 {
110 Eigen::Matrix3d cov;
111 cov << std::pow(sdvXYZ->x(), 2), *sdvxy, -(*sdvzx),
112 -(*sdvxy), std::pow(sdvXYZ->y(), 2), *sdvyz,
113 *sdvzx, -(*sdvyz), std::pow(sdvXYZ->z(), 2);
114 this->setVelocityAndStdDev_e(*e_velocity, cov);
115 }
116 else if (n_velocity && sdvNED && sdvne && sdvdn && sdved)
117 {
118 Eigen::Matrix3d cov;
119 cov << std::pow(sdvNED->x(), 2), *sdvne, -(*sdvdn),
120 -(*sdvne), std::pow(sdvNED->y(), 2), *sdved,
121 *sdvdn, -(*sdved), std::pow(sdvNED->z(), 2);
122 this->setVelocityAndStdDev_n(*n_velocity, cov);
123 }
124 else if (e_velocity) { this->setVelocity_e(*e_velocity); }
125 else if (n_velocity) { this->setVelocity_n(*n_velocity); }
126 }
127#endif
128
131 [[nodiscard]] static std::string type()
132 {
133 return "RtklibPosObs";
134 }
135
138 [[nodiscard]] static std::vector<std::string> parentTypes()
139 {
140 auto parent = PosVel::parentTypes();
141 parent.push_back(PosVel::type());
142 return parent;
143 }
144
146 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors()
147 {
149 desc.reserve(GetStaticDescriptorCount());
150 desc.emplace_back("Q [-]");
151 desc.emplace_back("ns [-]");
152 desc.emplace_back("age [s]");
153 desc.emplace_back("ratio [-]");
154
155 return desc;
156 }
157
159 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return 43; }
160
162 [[nodiscard]] std::vector<std::string> staticDataDescriptors() const override { return GetStaticDataDescriptors(); }
163
165 [[nodiscard]] size_t staticDescriptorCount() const override { return GetStaticDescriptorCount(); }
166
170 [[nodiscard]] std::optional<double> getValueAt(size_t idx) const override
171 {
173 switch (idx)
174 {
175 case 0: // Latitude [deg]
176 case 1: // Longitude [deg]
177 case 2: // Altitude [m]
178 case 3: // North/South [m]
179 case 4: // East/West [m]
180 case 5: // X-ECEF [m]
181 case 6: // Y-ECEF [m]
182 case 7: // Z-ECEF [m]
183 case 8: // X-ECEF StDev [m]
184 case 9: // Y-ECEF StDev [m]
185 case 10: // Z-ECEF StDev [m]
186 case 11: // XY-ECEF StDev [m]
187 case 12: // XZ-ECEF StDev [m]
188 case 13: // YZ-ECEF StDev [m]
189 case 14: // North StDev [m]
190 case 15: // East StDev [m]
191 case 16: // Down StDev [m]
192 case 17: // NE StDev [m]
193 case 18: // ND StDev [m]
194 case 19: // ED StDev [m]
195 case 20: // Velocity norm [m/s]
196 case 21: // X velocity ECEF [m/s]
197 case 22: // Y velocity ECEF [m/s]
198 case 23: // Z velocity ECEF [m/s]
199 case 24: // North velocity [m/s]
200 case 25: // East velocity [m/s]
201 case 26: // Down velocity [m/s]
202 case 27: // X velocity ECEF StDev [m/s]
203 case 28: // Y velocity ECEF StDev [m/s]
204 case 29: // Z velocity ECEF StDev [m/s]
205 case 30: // XY velocity StDev [m]
206 case 31: // XZ velocity StDev [m]
207 case 32: // YZ velocity StDev [m]
208 case 33: // North velocity StDev [m/s]
209 case 34: // East velocity StDev [m/s]
210 case 35: // Down velocity StDev [m/s]
211 case 36: // NE velocity StDev [m]
212 case 37: // ND velocity StDev [m]
213 case 38: // ED velocity StDev [m]
214 return PosVel::getValueAt(idx);
215 case 39: // Q [-]
216 return Q;
217 case 40: // ns [-]
218 return ns;
219 case 41: // age [s]
220 return age;
221 case 42: // ratio [-]
222 return ratio;
223 default:
224 return std::nullopt;
225 }
226 return std::nullopt;
227 }
228
230 uint8_t Q = 0;
232 uint8_t ns = 0;
234 double age = std::nan("");
236 double ratio = std::nan("");
237};
238
239} // namespace NAV
#define INS_ASSERT(_EXPR)
Assert function wrapper.
Definition Assert.h:19
Vector space operations.
Position, Velocity and Attitude Storage Class.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
InsTime insTime
Time at which the message was received.
Definition NodeData.hpp:89
Position, Velocity and Attitude Storage Class.
Definition PosVel.hpp:23
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition PosVel.hpp:34
void setVelocityAndStdDev_e(const Eigen::Vector3d &e_velocity, const Eigen::Matrix3d &e_velocityCovarianceMatrix)
Set the Velocity in ECEF coordinates and its standard deviation.
Definition PosVel.hpp:233
const Eigen::Vector3d & n_velocity() const
Returns the velocity in [m/s], in navigation coordinates.
Definition PosVel.hpp:196
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition PosVel.hpp:42
void setVelocity_e(const Eigen::Vector3d &e_velocity)
Set the Velocity in the earth frame.
Definition PosVel.hpp:216
static std::string type()
Returns the type of the data class.
Definition PosVel.hpp:27
void setVelocity_n(const Eigen::Vector3d &n_velocity)
Set the Velocity in the NED frame.
Definition PosVel.hpp:224
const Eigen::Vector3d & e_velocity() const
Returns the velocity in [m/s], in earth coordinates.
Definition PosVel.hpp:193
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition PosVel.hpp:80
void setVelocityAndStdDev_n(const Eigen::Vector3d &n_velocity, const Eigen::Matrix3d &n_velocityCovarianceMatrix)
Set the Velocity in NED coordinates and its standard deviation.
Definition PosVel.hpp:243
void setPositionAndStdDev_e(const Eigen::Vector3d &e_position, const Eigen::Matrix3d &e_positionCovarianceMatrix)
Set the Position in ECEF coordinates and its standard deviation.
Definition Pos.hpp:237
void setPosCovarianceMatrix_n(const Eigen::MatrixBase< Derived > &n_covarianceMatrix)
Set the Covariance matrix in ECEF coordinates.
Definition Pos.hpp:277
void setPositionAndStdDev_lla(const Eigen::Vector3d &lla_position, const Eigen::Matrix3d &n_positionCovarianceMatrix)
Set the Position in LLA coordinates and its standard deviation.
Definition Pos.hpp:247
const Eigen::Vector3d & e_position() const
Returns the coordinates in [m].
Definition Pos.hpp:200
const Eigen::Vector3d & lla_position() const
Returns the latitude 𝜙, longitude λ and altitude (height above ground) in [rad, rad,...
Definition Pos.hpp:188
void setPosition_e(const Eigen::Vector3d &e_position)
Set the Position in coordinates.
Definition Pos.hpp:220
void setPosition_lla(const Eigen::Vector3d &lla_position)
Set the Position lla object.
Definition Pos.hpp:228
void setPosCovarianceMatrix_e(const Eigen::MatrixBase< Derived > &e_covarianceMatrix)
Set the Covariance matrix in ECEF coordinates.
Definition Pos.hpp:258
RTKLIB Observation Class.
Definition RtklibPosObs.hpp:24
uint8_t Q
1:fix, 2:float, 3:sbas, 4:dgps, 5:single, 6:ppp
Definition RtklibPosObs.hpp:230
double ratio
Ratio.
Definition RtklibPosObs.hpp:236
double age
Age [s].
Definition RtklibPosObs.hpp:234
static std::string type()
Returns the type of the data class.
Definition RtklibPosObs.hpp:131
uint8_t ns
Number of satellites.
Definition RtklibPosObs.hpp:232
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition RtklibPosObs.hpp:159
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition RtklibPosObs.hpp:146
size_t staticDescriptorCount() const override
Get the amount of descriptors.
Definition RtklibPosObs.hpp:165
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition RtklibPosObs.hpp:138
std::vector< std::string > staticDataDescriptors() const override
Returns a vector of data descriptors.
Definition RtklibPosObs.hpp:162
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition RtklibPosObs.hpp:170