0.3.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 covPos;
90 covPos << std::pow(sdXYZ->x(), 2), *sdxy, -(*sdzx),
91 -(*sdxy), std::pow(sdXYZ->y(), 2), *sdyz,
92 *sdzx, -(*sdyz), std::pow(sdXYZ->z(), 2);
93 if (e_velocity && sdvXYZ && sdvxy && sdvzx && sdvyz)
94 {
95 Eigen::Matrix6d cov = Eigen::Matrix6d::Zero();
96 cov.topLeftCorner<3, 3>() = covPos;
97 cov.bottomRightCorner<3, 3>() << std::pow(sdvXYZ->x(), 2), *sdvxy, -(*sdvzx),
98 -(*sdvxy), std::pow(sdvXYZ->y(), 2), *sdvyz,
99 *sdvzx, -(*sdvyz), std::pow(sdvXYZ->z(), 2);
100
102 }
103 else
104 {
105 this->setPositionAndCov_e(*e_position, covPos);
106 }
107 }
108 else if (lla_position && sdNED && sdne && sddn && sded)
109 {
110 Eigen::Matrix3d covPos;
111 covPos << std::pow(sdNED->x(), 2), *sdne, -(*sddn),
112 -(*sdne), std::pow(sdNED->y(), 2), *sded,
113 *sddn, -(*sded), std::pow(sdNED->z(), 2);
114
115 if (n_velocity && sdvNED && sdvne && sdvdn && sdved)
116 {
117 Eigen::Matrix6d cov = Eigen::Matrix6d::Zero();
118 cov.topLeftCorner<3, 3>() = covPos;
119 cov.bottomRightCorner<3, 3>() << 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->setPosVelAndCov_n(*lla_position, *n_velocity, cov);
123 }
124 else
125 {
126 this->setPositionAndCov_n(*lla_position, covPos);
127 }
128 }
129 else if (e_position) { this->setPosition_e(*e_position); }
130 else if (lla_position) { this->setPosition_lla(*lla_position); }
131
132 else if (e_velocity) { this->setVelocity_e(*e_velocity); }
133 else if (n_velocity) { this->setVelocity_n(*n_velocity); }
134 }
135#endif
136
139 [[nodiscard]] static std::string type()
140 {
141 return "RtklibPosObs";
142 }
143
146 [[nodiscard]] std::string getType() const override { return type(); }
147
150 [[nodiscard]] static std::vector<std::string> parentTypes()
151 {
152 auto parent = PosVel::parentTypes();
153 parent.push_back(PosVel::type());
154 return parent;
155 }
156
158 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors()
159 {
161 desc.reserve(GetStaticDescriptorCount());
162 desc.emplace_back("Q [-]");
163 desc.emplace_back("ns [-]");
164 desc.emplace_back("age [s]");
165 desc.emplace_back("ratio [-]");
166
167 return desc;
168 }
169
171 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return PosVel::GetStaticDescriptorCount() + 4; }
172
174 [[nodiscard]] std::vector<std::string> staticDataDescriptors() const override { return GetStaticDataDescriptors(); }
175
177 [[nodiscard]] size_t staticDescriptorCount() const override { return GetStaticDescriptorCount(); }
178
182 [[nodiscard]] std::optional<double> getValueAt(size_t idx) const override
183 {
185 if (idx < PosVel::GetStaticDescriptorCount()) { return PosVel::getValueAt(idx); }
186 switch (idx)
187 {
188 case PosVel::GetStaticDescriptorCount() + 0: // Q [-]
189 return Q;
190 case PosVel::GetStaticDescriptorCount() + 1: // ns [-]
191 return ns;
192 case PosVel::GetStaticDescriptorCount() + 2: // age [s]
193 return age;
194 case PosVel::GetStaticDescriptorCount() + 3: // ratio [-]
195 return ratio;
196 default:
197 return std::nullopt;
198 }
199 return std::nullopt;
200 }
201
203 uint8_t Q = 0;
205 uint8_t ns = 0;
207 double age = std::nan("");
209 double ratio = std::nan("");
210};
211
212} // namespace NAV
#define INS_ASSERT(_EXPR)
Assert function wrapper.
Definition Assert.h:19
Vector space operations.
Matrix< double, 6, 6 > Matrix6d
Double 6x6 Eigen::Matrix.
Definition Eigen.hpp:37
Position and Velocity Storage Class.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:710
InsTime insTime
Time at which the message was received.
Definition NodeData.hpp:123
Position and Velocity Storage Class.
Definition PosVel.hpp:23
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition PosVel.hpp:73
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition PosVel.hpp:38
const Eigen::Vector3d & n_velocity() const
Returns the velocity in [m/s], in navigation coordinates.
Definition PosVel.hpp:211
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition PosVel.hpp:46
static std::string type()
Returns the type of the data class.
Definition PosVel.hpp:27
const Eigen::Vector3d & e_velocity() const
Returns the velocity in [m/s], in earth coordinates.
Definition PosVel.hpp:208
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition PosVel.hpp:84
void setPosVelAndCov_n(const Eigen::MatrixBase< DerivedP > &lla_position, const Eigen::MatrixBase< DerivedV > &n_velocity, const Eigen::MatrixBase< Derived > &n_covarianceMatrix)
Set the position, velocity and the covariance matrix.
Definition PosVel.hpp:293
void setVelocity_n(const Eigen::MatrixBase< Derived > &n_velocity)
Set the Velocity in the NED frame.
Definition PosVel.hpp:249
void setVelocity_e(const Eigen::MatrixBase< Derived > &e_velocity)
Set the Velocity in the earth frame.
Definition PosVel.hpp:240
void setPosVelAndCov_e(const Eigen::MatrixBase< DerivedP > &e_position, const Eigen::MatrixBase< DerivedV > &e_velocity, const Eigen::MatrixBase< Derived > &e_covarianceMatrix)
Set the position, velocity and the covariance matrix.
Definition PosVel.hpp:280
void setPositionAndCov_n(const Eigen::MatrixBase< DerivedP > &lla_position, const Eigen::MatrixBase< Derived > &n_covarianceMatrix)
Set the position and the covariance matrix.
Definition Pos.hpp:313
const Eigen::Vector3d & e_position() const
Returns the coordinates in [m].
Definition Pos.hpp:249
void setPositionAndCov_e(const Eigen::MatrixBase< DerivedP > &e_position, const Eigen::MatrixBase< Derived > &e_covarianceMatrix)
Set the position and the covariance matrix.
Definition Pos.hpp:303
void setPosition_e(const Eigen::MatrixBase< Derived > &e_position)
Set the Position in coordinates.
Definition Pos.hpp:284
const Eigen::Vector3d & lla_position() const
Returns the latitude 𝜙, longitude λ and altitude (height above ground) in [rad, rad,...
Definition Pos.hpp:237
void setPosition_lla(const Eigen::MatrixBase< Derived > &lla_position)
Set the Position lla object.
Definition Pos.hpp:293
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:203
double ratio
Ratio.
Definition RtklibPosObs.hpp:209
double age
Age [s].
Definition RtklibPosObs.hpp:207
std::string getType() const override
Returns the type of the data class.
Definition RtklibPosObs.hpp:146
static std::string type()
Returns the type of the data class.
Definition RtklibPosObs.hpp:139
uint8_t ns
Number of satellites.
Definition RtklibPosObs.hpp:205
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition RtklibPosObs.hpp:171
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition RtklibPosObs.hpp:158
size_t staticDescriptorCount() const override
Get the amount of descriptors.
Definition RtklibPosObs.hpp:177
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition RtklibPosObs.hpp:150
std::vector< std::string > staticDataDescriptors() const override
Returns a vector of data descriptors.
Definition RtklibPosObs.hpp:174
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition RtklibPosObs.hpp:182