0.3.0
Loading...
Searching...
No Matches
ProcessNoise.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
16#include <Eigen/Core>
17
22
23namespace NAV
24{
25
29Eigen::Matrix3d G_RandomWalk(const Eigen::Vector3d& sigma2);
30
35Eigen::Matrix3d G_GaussMarkov1(const Eigen::Vector3d& sigma2, const Eigen::Vector3d& beta);
36
41[[nodiscard]] Eigen::Vector3d psd2BiasGaussMarkov(const Eigen::Vector3d& sigma2_bd, const Eigen::Vector3d& tau_bd);
42
49[[nodiscard]] Eigen::Matrix3d Q_psi_psi(const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const double& tau_s);
50
58[[nodiscard]] Eigen::Matrix3d ien_Q_dv_psi(const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ien_F_21, const double& tau_s);
59
69[[nodiscard]] Eigen::Matrix3d ien_Q_dv_dv(const Eigen::Vector3d& S_ra, const Eigen::Vector3d& S_bad, const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ien_F_21, const double& tau_s);
70
78[[nodiscard]] Eigen::Matrix3d ien_Q_dv_domega(const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ien_F_21, const Eigen::Matrix3d& ien_Dcm_b, const double& tau_s);
79
88[[nodiscard]] Eigen::Matrix3d n_Q_dr_psi(const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& n_F_21, const Eigen::Matrix3d& T_rn_p, const double& tau_s);
89
97[[nodiscard]] Eigen::Matrix3d ie_Q_dr_psi(const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ie_F_21, const double& tau_s);
98
109[[nodiscard]] Eigen::Matrix3d n_Q_dr_dv(const Eigen::Vector3d& S_ra, const Eigen::Vector3d& S_bad, const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& n_F_21, const Eigen::Matrix3d& T_rn_p, const double& tau_s);
110
120[[nodiscard]] Eigen::Matrix3d ie_Q_dr_dv(const Eigen::Vector3d& S_ra, const Eigen::Vector3d& S_bad, const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ie_F_21, const double& tau_s);
121
132[[nodiscard]] Eigen::Matrix3d n_Q_dr_dr(const Eigen::Vector3d& S_ra, const Eigen::Vector3d& S_bad, const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& n_F_21, const Eigen::Matrix3d& T_rn_p, const double& tau_s);
133
143[[nodiscard]] Eigen::Matrix3d ie_Q_dr_dr(const Eigen::Vector3d& S_ra, const Eigen::Vector3d& S_bad, const Eigen::Vector3d& S_rg, const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ie_F_21, const double& tau_s);
144
152[[nodiscard]] Eigen::Matrix3d n_Q_dr_df(const Eigen::Vector3d& S_bad, const Eigen::Matrix3d& T_rn_p, const Eigen::Matrix3d& n_Dcm_b, const double& tau_s);
153
160[[nodiscard]] Eigen::Matrix3d ie_Q_dr_df(const Eigen::Vector3d& S_bad, const Eigen::Matrix3d& ie_Dcm_b, const double& tau_s);
161
170[[nodiscard]] Eigen::Matrix3d n_Q_dr_domega(const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& n_F_21, const Eigen::Matrix3d& T_rn_p, const Eigen::Matrix3d& n_Dcm_b, const double& tau_s);
171
179[[nodiscard]] Eigen::Matrix3d ie_Q_dr_domega(const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& ie_F_21, const Eigen::Matrix3d& ie_Dcm_b, const double& tau_s);
180
187[[nodiscard]] Eigen::Matrix3d Q_df_dv(const Eigen::Vector3d& S_bad, const Eigen::Matrix3d& b_Dcm_ien, const double& tau_s);
188
194[[nodiscard]] Eigen::Matrix3d Q_df_df(const Eigen::Vector3d& S_bad, const double& tau_s);
195
202[[nodiscard]] Eigen::Matrix3d Q_domega_psi(const Eigen::Vector3d& S_bgd, const Eigen::Matrix3d& b_Dcm_ien, const double& tau_s);
203
209[[nodiscard]] Eigen::Matrix3d Q_domega_domega(const Eigen::Vector3d& S_bgd, const double& tau_s);
210
216[[nodiscard]] Eigen::Matrix2d Q_gnss(const double& S_cPhi, const double& S_cf, const double& tau_s);
217
227template<typename KeyType, typename T>
228[[nodiscard]] KeyedMatrixX<T, KeyType, KeyType> e_noiseInput_G(const Eigen::Quaterniond& b_quat_p,
229 const Eigen::Quaternion<T>& e_quat_b,
230 bool accelBiases, bool gyroBiases,
231 bool accelScaleFactor, bool gyroScaleFactor,
232 bool accelMisalignment, bool gyroMisalignment)
233
234{
235 std::vector<KeyType> rowKeys;
236 rowKeys.reserve(3 + 3 + 4
237 + 3 * (static_cast<size_t>(accelBiases) + static_cast<size_t>(gyroBiases))
238 + 3 * (static_cast<size_t>(accelScaleFactor) + static_cast<size_t>(gyroScaleFactor))
239 + 4 * (static_cast<size_t>(accelMisalignment) + static_cast<size_t>(gyroMisalignment)));
240 std::vector<KeyType> colKeys;
241 colKeys.reserve(3 + 3 + 3
242 + 3 * (static_cast<size_t>(accelBiases) + static_cast<size_t>(gyroBiases))
243 + 3 * (static_cast<size_t>(accelScaleFactor) + static_cast<size_t>(gyroScaleFactor)));
244
245 constexpr std::array<KeyType, 3> AngleErrorKeys = { Keys::AttQ1, Keys::AttQ2, Keys::AttQ3 }; // 3 quaternion keys are used for the angle error
246
247 rowKeys.insert(rowKeys.end(), Keys::PosVelAtt<KeyType>.begin(), Keys::PosVelAtt<KeyType>.end());
248 colKeys.insert(colKeys.end(), Keys::PosVel<KeyType>.begin(), Keys::PosVel<KeyType>.end());
249 colKeys.insert(colKeys.end(), AngleErrorKeys.begin(), AngleErrorKeys.end());
250
251 if (accelBiases)
252 {
253 rowKeys.insert(rowKeys.end(), Keys::AccelBias<KeyType>.begin(), Keys::AccelBias<KeyType>.end());
254 colKeys.insert(colKeys.end(), Keys::AccelBias<KeyType>.begin(), Keys::AccelBias<KeyType>.end());
255 }
256 if (gyroBiases)
257 {
258 rowKeys.insert(rowKeys.end(), Keys::GyroBias<KeyType>.begin(), Keys::GyroBias<KeyType>.end());
259 colKeys.insert(colKeys.end(), Keys::GyroBias<KeyType>.begin(), Keys::GyroBias<KeyType>.end());
260 }
261 if (accelScaleFactor)
262 {
263 rowKeys.insert(rowKeys.end(), Keys::AccelScaleFactor<KeyType>.begin(), Keys::AccelScaleFactor<KeyType>.end());
264 colKeys.insert(colKeys.end(), Keys::AccelScaleFactor<KeyType>.begin(), Keys::AccelScaleFactor<KeyType>.end());
265 }
266 if (gyroScaleFactor)
267 {
268 rowKeys.insert(rowKeys.end(), Keys::GyroScaleFactor<KeyType>.begin(), Keys::GyroScaleFactor<KeyType>.end());
269 colKeys.insert(colKeys.end(), Keys::GyroScaleFactor<KeyType>.begin(), Keys::GyroScaleFactor<KeyType>.end());
270 }
271 if (accelMisalignment) { rowKeys.insert(rowKeys.end(), Keys::AccelMisalignment<KeyType>.begin(), Keys::AccelMisalignment<KeyType>.end()); }
272 if (gyroMisalignment) { rowKeys.insert(rowKeys.end(), Keys::GyroMisalignment<KeyType>.begin(), Keys::GyroMisalignment<KeyType>.end()); }
273
274 KeyedMatrixX<T, KeyType, KeyType> G(Eigen::MatrixX<T>::Zero(static_cast<int>(rowKeys.size()), static_cast<int>(colKeys.size())), rowKeys, colKeys);
275
276 Eigen::Quaternion<T> e_quat_p = e_quat_b * b_quat_p.cast<T>();
277 G(Keys::Vel<KeyType>, Keys::Vel<KeyType>) = e_quat_p.toRotationMatrix();
278 G(Keys::Att<KeyType>, AngleErrorKeys) = trafo::covRPY2quatJacobian(e_quat_p) * e_quat_p.toRotationMatrix();
279 if (accelBiases) { G(Keys::AccelBias<KeyType>, Keys::AccelBias<KeyType>).setIdentity(); }
280 if (gyroBiases) { G(Keys::GyroBias<KeyType>, Keys::GyroBias<KeyType>).setIdentity(); }
281 if (accelScaleFactor) { G(Keys::AccelScaleFactor<KeyType>, Keys::AccelScaleFactor<KeyType>).setIdentity(); }
282 if (gyroScaleFactor) { G(Keys::GyroScaleFactor<KeyType>, Keys::GyroScaleFactor<KeyType>).setIdentity(); }
283
284 return G;
285}
286
298template<typename KeyType, typename T>
299[[nodiscard]] KeyedMatrixX<T, KeyType, KeyType> e_noiseScale_W(const Eigen::Vector3d& sigma2_ra, const Eigen::Vector3d& sigma2_rg,
300 const Eigen::Vector3d& sigma2_bad, const Eigen::Vector3d& sigma2_bgd,
301 const Eigen::Vector3d& sigma2_sad, const Eigen::Vector3d& sigma2_sgd,
302 bool accelBiases, bool gyroBiases,
303 bool accelScaleFactor, bool gyroScaleFactor)
304
305{
306 std::vector<KeyType> keys;
307 keys.reserve(3 + 3 + 3
308 + 3 * (static_cast<size_t>(accelBiases) + static_cast<size_t>(gyroBiases))
309 + 3 * (static_cast<size_t>(accelScaleFactor) + static_cast<size_t>(gyroScaleFactor)));
310
311 constexpr std::array<KeyType, 3> AngleErrorKeys = { Keys::AttQ1, Keys::AttQ2, Keys::AttQ3 }; // 3 quaternion keys are used for the angle error
312 keys.insert(keys.end(), Keys::PosVel<KeyType>.begin(), Keys::PosVel<KeyType>.end());
313 keys.insert(keys.end(), AngleErrorKeys.begin(), AngleErrorKeys.end());
314
315 if (accelBiases) { keys.insert(keys.end(), Keys::AccelBias<KeyType>.begin(), Keys::AccelBias<KeyType>.end()); }
316 if (gyroBiases) { keys.insert(keys.end(), Keys::GyroBias<KeyType>.begin(), Keys::GyroBias<KeyType>.end()); }
317 if (accelScaleFactor) { keys.insert(keys.end(), Keys::AccelScaleFactor<KeyType>.begin(), Keys::AccelScaleFactor<KeyType>.end()); }
318 if (gyroScaleFactor) { keys.insert(keys.end(), Keys::GyroScaleFactor<KeyType>.begin(), Keys::GyroScaleFactor<KeyType>.end()); }
319
320 KeyedMatrixX<T, KeyType, KeyType> W(Eigen::MatrixX<T>::Zero(static_cast<int>(keys.size()), static_cast<int>(keys.size())), keys, keys);
321
322 W(Keys::Vel<KeyType>, Keys::Vel<KeyType>).diagonal() = sigma2_ra.cast<T>();
323 W(AngleErrorKeys, AngleErrorKeys).diagonal() = sigma2_rg.cast<T>();
324 if (accelBiases) { W(Keys::AccelBias<KeyType>, Keys::AccelBias<KeyType>).diagonal() = sigma2_bad.cast<T>(); }
325 if (gyroBiases) { W(Keys::GyroBias<KeyType>, Keys::GyroBias<KeyType>).diagonal() = sigma2_bgd.cast<T>(); }
326 if (accelScaleFactor) { W(Keys::AccelScaleFactor<KeyType>, Keys::AccelScaleFactor<KeyType>).diagonal() = sigma2_sad.cast<T>(); }
327 if (gyroScaleFactor) { W(Keys::GyroScaleFactor<KeyType>, Keys::GyroScaleFactor<KeyType>).diagonal() = sigma2_sgd.cast<T>(); }
328
329 return W;
330}
331
332} // namespace NAV
Transformation collection.
Eigen::Matrix< typename Derived::Scalar, 4, 3 > covRPY2quatJacobian(const Eigen::QuaternionBase< Derived > &n_quat_b)
Calculates the Jacobian to convert an attitude represented in Euler angels (roll, pitch,...
Definition CoordinateFrames.hpp:162
Inertial Navigation System Keys.
constexpr std::array< StateKeyType, 3 > GyroBias
All gyroscope bias keys.
Definition Keys.hpp:58
constexpr std::array< StateKeyType, 3 > AccelScaleFactor
All accelerometer scale factor keys.
Definition Keys.hpp:62
constexpr std::array< StateKeyType, 4 > AccelMisalignment
All accelerometer misalignment quaternion keys.
Definition Keys.hpp:69
constexpr std::array< StateKeyType, 4 > GyroMisalignment
All gyroscope misalignment quaternion keys.
Definition Keys.hpp:72
constexpr std::array< StateKeyType, 3 > GyroScaleFactor
All gyroscope scale factor keys.
Definition Keys.hpp:65
constexpr std::array< StateKeyType, 3 > AccelBias
All accelerometer bias keys.
Definition Keys.hpp:55
Motion System Model.
constexpr std::array< StateKeyType, 4 > Att
All attitude keys.
Definition MotionModel.hpp:62
@ AttQ3
z: Coefficient of k
Definition MotionModel.hpp:49
@ AttQ1
x: Coefficient of i
Definition MotionModel.hpp:47
@ AttQ2
y: Coefficient of j
Definition MotionModel.hpp:48
constexpr std::array< StateKeyType, 10 > PosVelAtt
Vector with all position velocity and attitude keys.
Definition MotionModel.hpp:70
constexpr std::array< StateKeyType, 6 > PosVel
Vector with all position and velocity keys.
Definition MotionModel.hpp:66
constexpr std::array< StateKeyType, 3 > Vel
All velocity keys.
Definition MotionModel.hpp:59
Eigen::Matrix3d ie_Q_dr_domega(const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ie_F_21, const Eigen::Matrix3d &ie_Dcm_b, const double &tau_s)
Submatrix 𝐐_35 of the system noise covariance matrix 𝐐
Eigen::Matrix3d G_GaussMarkov1(const Eigen::Vector3d &sigma2, const Eigen::Vector3d &beta)
Submatrix 𝐆_a of the noise input matrix 𝐆
Eigen::Matrix3d ie_Q_dr_df(const Eigen::Vector3d &S_bad, const Eigen::Matrix3d &ie_Dcm_b, const double &tau_s)
Submatrix 𝐐_34 of the system noise covariance matrix 𝐐
Eigen::Matrix3d Q_domega_psi(const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &b_Dcm_ien, const double &tau_s)
Submatrix 𝐐_51 of the system noise covariance matrix 𝐐
Eigen::Matrix3d Q_df_df(const Eigen::Vector3d &S_bad, const double &tau_s)
Submatrix 𝐐_44 of the system noise covariance matrix 𝐐
Eigen::Matrix3d ien_Q_dv_dv(const Eigen::Vector3d &S_ra, const Eigen::Vector3d &S_bad, const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ien_F_21, const double &tau_s)
Submatrix 𝐐_22 of the system noise covariance matrix 𝐐
Eigen::Matrix3d ie_Q_dr_psi(const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ie_F_21, const double &tau_s)
Submatrix 𝐐_31 of the system noise covariance matrix 𝐐
Eigen::Matrix3d G_RandomWalk(const Eigen::Vector3d &sigma2)
Random walk noise input matrix 𝐆
Eigen::Matrix3d n_Q_dr_dv(const Eigen::Vector3d &S_ra, const Eigen::Vector3d &S_bad, const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &n_F_21, const Eigen::Matrix3d &T_rn_p, const double &tau_s)
Submatrix 𝐐_32 of the system noise covariance matrix 𝐐
KeyedMatrixX< T, KeyType, KeyType > e_noiseInput_G(const Eigen::Quaterniond &b_quat_p, const Eigen::Quaternion< T > &e_quat_b, bool accelBiases, bool gyroBiases, bool accelScaleFactor, bool gyroScaleFactor, bool accelMisalignment, bool gyroMisalignment)
Calculate the noise input matrix in Earth frame coordinates.
Definition ProcessNoise.hpp:228
KeyedMatrixX< T, KeyType, KeyType > e_noiseScale_W(const Eigen::Vector3d &sigma2_ra, const Eigen::Vector3d &sigma2_rg, const Eigen::Vector3d &sigma2_bad, const Eigen::Vector3d &sigma2_bgd, const Eigen::Vector3d &sigma2_sad, const Eigen::Vector3d &sigma2_sgd, bool accelBiases, bool gyroBiases, bool accelScaleFactor, bool gyroScaleFactor)
Calculate the noise scale matrix in Earth frame coordinates.
Definition ProcessNoise.hpp:299
Eigen::Matrix3d Q_df_dv(const Eigen::Vector3d &S_bad, const Eigen::Matrix3d &b_Dcm_ien, const double &tau_s)
Submatrix 𝐐_42 of the system noise covariance matrix 𝐐
Eigen::Matrix3d Q_psi_psi(const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const double &tau_s)
Submatrix 𝐐_11 of the system noise covariance matrix 𝐐
Eigen::Matrix3d n_Q_dr_df(const Eigen::Vector3d &S_bad, const Eigen::Matrix3d &T_rn_p, const Eigen::Matrix3d &n_Dcm_b, const double &tau_s)
Submatrix 𝐐_34 of the system noise covariance matrix 𝐐
Eigen::Vector3d psd2BiasGaussMarkov(const Eigen::Vector3d &sigma2_bd, const Eigen::Vector3d &tau_bd)
u_bias^2 Power Spectral Density of the bias for a Gauss-Markov random process
Eigen::Matrix3d Q_domega_domega(const Eigen::Vector3d &S_bgd, const double &tau_s)
Submatrix 𝐐_55 of the system noise covariance matrix 𝐐
Eigen::Matrix3d n_Q_dr_psi(const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &n_F_21, const Eigen::Matrix3d &T_rn_p, const double &tau_s)
Submatrix 𝐐_31 of the system noise covariance matrix 𝐐
Eigen::Matrix2d Q_gnss(const double &S_cPhi, const double &S_cf, const double &tau_s)
Submatrix 𝐐_66 of the system noise covariance matrix 𝐐
Eigen::Matrix3d ie_Q_dr_dv(const Eigen::Vector3d &S_ra, const Eigen::Vector3d &S_bad, const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ie_F_21, const double &tau_s)
Submatrix 𝐐_32 of the system noise covariance matrix 𝐐
Eigen::Matrix3d n_Q_dr_domega(const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &n_F_21, const Eigen::Matrix3d &T_rn_p, const Eigen::Matrix3d &n_Dcm_b, const double &tau_s)
Submatrix 𝐐_35 of the system noise covariance matrix 𝐐
Eigen::Matrix3d ien_Q_dv_psi(const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ien_F_21, const double &tau_s)
Submatrix 𝐐_21 of the system noise covariance matrix 𝐐
Eigen::Matrix3d ie_Q_dr_dr(const Eigen::Vector3d &S_ra, const Eigen::Vector3d &S_bad, const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ie_F_21, const double &tau_s)
Submatrix 𝐐_33 of the system noise covariance matrix 𝐐
Eigen::Matrix3d n_Q_dr_dr(const Eigen::Vector3d &S_ra, const Eigen::Vector3d &S_bad, const Eigen::Vector3d &S_rg, const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &n_F_21, const Eigen::Matrix3d &T_rn_p, const double &tau_s)
Submatrix 𝐐_33 of the system noise covariance matrix 𝐐
Eigen::Matrix3d ien_Q_dv_domega(const Eigen::Vector3d &S_bgd, const Eigen::Matrix3d &ien_F_21, const Eigen::Matrix3d &ien_Dcm_b, const double &tau_s)
Submatrix 𝐐_25 of the system noise covariance matrix 𝐐
Matrix which can be accessed by keys.
KeyedMatrix< Scalar, RowKeyType, ColKeyType, Eigen::Dynamic, Eigen::Dynamic > KeyedMatrixX
Dynamic size KeyedMatrix.
Definition KeyedMatrix.hpp:2308