0.2.0
Loading...
Searching...
No Matches
Functions.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
20
21namespace NAV
22{
38template<typename DerivedA, typename DerivedB>
39[[nodiscard]] Eigen::Vector3<typename DerivedA::Scalar> n_calcTransportRate(const Eigen::MatrixBase<DerivedA>& lla_position,
40 const Eigen::MatrixBase<DerivedB>& n_velocity,
41 const typename DerivedA::Scalar& R_N,
42 const typename DerivedA::Scalar& R_E)
43{
44 // 𝜙 Latitude in [rad]
45 const auto& latitude = lla_position(0);
46 // h Altitude in [m]
47 const auto& altitude = lla_position(2);
48
49 // Velocity North in [m/s]
50 const auto& v_N = n_velocity(0);
51 // Velocity East in [m/s]
52 const auto& v_E = n_velocity(1);
53
54 Eigen::Vector3<typename DerivedA::Scalar> n_omega_en__t1;
55 n_omega_en__t1(0) = v_E / (R_E + altitude);
56 n_omega_en__t1(1) = -v_N / (R_N + altitude);
57 n_omega_en__t1(2) = -n_omega_en__t1(0) * std::tan(latitude);
58
59 return n_omega_en__t1;
60}
61
71template<typename DerivedA, typename DerivedB = DerivedA>
72[[nodiscard]] Eigen::Vector3<typename DerivedA::Scalar> e_calcCentrifugalAcceleration(const Eigen::MatrixBase<DerivedA>& e_position,
73 const Eigen::MatrixBase<DerivedB>& e_omega_ie = InsConst<typename DerivedB::Scalar>::e_omega_ie)
74{
75 // ω_ie_e ⨯ [ω_ie_e ⨯ x_e]
76 return e_omega_ie.cross(e_omega_ie.cross(e_position));
77}
78
89template<typename DerivedA, typename DerivedB, typename DerivedC>
90[[nodiscard]] Eigen::Vector3<typename DerivedA::Scalar> n_calcCoriolisAcceleration(const Eigen::MatrixBase<DerivedA>& n_omega_ie,
91 const Eigen::MatrixBase<DerivedB>& n_omega_en,
92 const Eigen::MatrixBase<DerivedC>& n_velocity)
93{
94 return (2 * n_omega_ie + n_omega_en).cross(n_velocity);
95}
96
106template<typename DerivedA, typename DerivedB>
107[[nodiscard]] Eigen::Vector3<typename DerivedA::Scalar> e_calcCoriolisAcceleration(const Eigen::MatrixBase<DerivedA>& e_omega_ie, const Eigen::MatrixBase<DerivedB>& e_velocity)
108{
109 return (2 * e_omega_ie).cross(e_velocity);
110}
111
117template<typename Derived>
118[[nodiscard]] typename Derived::Scalar calcRollFromStaticAcceleration(const Eigen::MatrixBase<Derived>& b_accel)
119{
120 // See E.-H. Shin (2005) - Estimation Techniques for Low-Cost Inertial Navigation (Chapter 2.6 - eq. 2.72a)
121 return math::sgn(b_accel.z()) * std::asin(b_accel.y() / b_accel.norm());
122
123 // Another possible calculation would be:
124 // return std::atan2(b_accel.y(), b_accel.z());
125}
126
132template<typename Derived>
133[[nodiscard]] typename Derived::Scalar calcPitchFromStaticAcceleration(const Eigen::MatrixBase<Derived>& b_accel)
134{
135 // See E.-H. Shin (2005) - Estimation Techniques for Low-Cost Inertial Navigation (Chapter 2.6 - eq. 2.72b)
136 return -math::sgn(b_accel.z()) * std::asin(b_accel.x() / b_accel.norm());
137
138 // Another possible calculation would be:
139 // return std::atan2((-b_accel.x()), sqrt(std::pow(b_accel.y(), 2) + std::pow(b_accel.z(), 2)));
140}
141
152template<typename Derived>
153[[nodiscard]] typename Derived::Scalar calcYawFromVelocity(const Eigen::MatrixBase<Derived>& n_velocity)
154{
155 return std::atan2(n_velocity(1), n_velocity(0));
156}
157
168template<typename Derived>
169[[nodiscard]] typename Derived::Scalar calcPitchFromVelocity(const Eigen::MatrixBase<Derived>& n_velocity)
170{
171 return std::atan(-n_velocity(2) / std::sqrt(std::pow(n_velocity(0), 2) + std::pow(n_velocity(1), 2)));
172}
173
174} // namespace NAV
Holds all Constants.
Eigen::Vector3< typename DerivedA::Scalar > n_calcCoriolisAcceleration(const Eigen::MatrixBase< DerivedA > &n_omega_ie, const Eigen::MatrixBase< DerivedB > &n_omega_en, const Eigen::MatrixBase< DerivedC > &n_velocity)
Calculates the coriolis acceleration in [m/s^2] (acceleration due to motion in rotating reference fra...
Definition Functions.hpp:90
Eigen::Vector3< typename DerivedA::Scalar > e_calcCoriolisAcceleration(const Eigen::MatrixBase< DerivedA > &e_omega_ie, const Eigen::MatrixBase< DerivedB > &e_velocity)
Calculates the coriolis acceleration in [m/s^2] (acceleration due to motion in rotating reference fra...
Definition Functions.hpp:107
Derived::Scalar calcRollFromStaticAcceleration(const Eigen::MatrixBase< Derived > &b_accel)
Calculates the roll angle from a static acceleration measurement.
Definition Functions.hpp:118
Derived::Scalar calcPitchFromVelocity(const Eigen::MatrixBase< Derived > &n_velocity)
Calculates the Pitch angle from the trajectory defined by the given velocity.
Definition Functions.hpp:169
Derived::Scalar calcYawFromVelocity(const Eigen::MatrixBase< Derived > &n_velocity)
Calculates the Yaw angle from the trajectory defined by the given velocity.
Definition Functions.hpp:153
Eigen::Vector3< typename DerivedA::Scalar > e_calcCentrifugalAcceleration(const Eigen::MatrixBase< DerivedA > &e_position, const Eigen::MatrixBase< DerivedB > &e_omega_ie=InsConst< typename DerivedB::Scalar >::e_omega_ie)
Calculates the centrifugal acceleration in [m/s^2] (acceleration that makes a body follow a curved pa...
Definition Functions.hpp:72
Derived::Scalar calcPitchFromStaticAcceleration(const Eigen::MatrixBase< Derived > &b_accel)
Calculates the pitch angle from a static acceleration measurement.
Definition Functions.hpp:133
Eigen::Vector3< typename DerivedA::Scalar > n_calcTransportRate(const Eigen::MatrixBase< DerivedA > &lla_position, const Eigen::MatrixBase< DerivedB > &n_velocity, const typename DerivedA::Scalar &R_N, const typename DerivedA::Scalar &R_E)
Calculates the transport rate ω_en_n (rotation rate of the Earth frame relative to the navigation fra...
Definition Functions.hpp:39
Simple Math functions.
Constants.
Definition Constants.hpp:26