0.2.0
Loading...
Searching...
No Matches
InertialIntegrator.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 <functional>
17#include <optional>
18#include <memory>
19
22
27
29#include "util/Eigen.hpp"
30#include "util/Json.hpp"
31
32namespace NAV
33{
34
37{
38 public:
52
55 {
56 double dt = 0.0;
57 Eigen::Vector3d p_acceleration;
58 Eigen::Vector3d p_angularRate;
59
60 Eigen::Vector3d p_biasAcceleration = Eigen::Vector3d::Zero();
61 Eigen::Vector3d p_biasAngularRate = Eigen::Vector3d::Zero();
62 };
63
65 void reset();
66
68 [[nodiscard]] bool hasInitialPosition() const;
69
72 void setInitialState(const PosVelAtt& state);
73
76 void setState(const PosVelAtt& state);
77
81 void setTotalSensorBiases(const Eigen::Vector3d& p_biasAcceleration, const Eigen::Vector3d& p_biasAngularRate);
82
86 void applySensorBiasesIncrements(const Eigen::Vector3d& p_deltaBiasAcceleration, const Eigen::Vector3d& p_deltaBiasAngularRate);
87
92 void applyStateErrors_n(const Eigen::Vector3d& lla_positionError, const Eigen::Vector3d& n_velocityError, const Eigen::Vector3d& n_attitudeError_b);
93
98 void applyStateErrors_e(const Eigen::Vector3d& e_positionError, const Eigen::Vector3d& e_velocityError, const Eigen::Vector3d& e_attitudeError_b);
99
101 [[nodiscard]] const ScrollingBuffer<Measurement>& getMeasurements() const;
102
104 [[nodiscard]] std::optional<std::reference_wrapper<const PosVelAtt>> getLatestState() const;
105
107 [[nodiscard]] const Eigen::Vector3d& p_getLastAccelerationBias() const;
108
110 [[nodiscard]] const Eigen::Vector3d& p_getLastAngularRateBias() const;
111
113 enum class IntegrationFrame : int
114 {
115 ECEF,
116 NED,
117 };
118
121
123 [[nodiscard]] std::optional<Eigen::Vector3d> p_calcCurrentAcceleration() const;
124
126 [[nodiscard]] std::optional<Eigen::Vector3d> p_calcCurrentAngularRate() const;
127
134 std::shared_ptr<PosVelAtt> calcInertialSolution(const InsTime& obsTime, const Eigen::Vector3d& p_acceleration, const Eigen::Vector3d& p_angularRate, const ImuPos& imuPos);
135
145 std::shared_ptr<PosVelAtt> calcInertialSolutionDelta(const InsTime& obsTime, const double& dt, Eigen::Vector3d p_deltaVelocity, Eigen::Vector3d p_deltaTheta,
146 Eigen::Vector3d p_acceleration, Eigen::Vector3d p_angularRate, const ImuPos& imuPos);
147
148 private:
152 std::shared_ptr<PosVelAtt> calcInertialSolutionFromMeasurementBuffer(const ImuPos& imuPos);
153
155 void setBufferSizes();
156
161
162 Eigen::Vector3d p_lastBiasAcceleration = Eigen::Vector3d::Zero();
163 Eigen::Vector3d p_lastBiasAngularRate = Eigen::Vector3d::Zero();
164
165 // #########################################################################################################################################
166
168 IntegrationFrame _integrationFrame = IntegrationFrame::NED;
169
172
173 // #########################################################################################################################################
174
176 PosVelAttDerivativeConstants<double> _posVelAttDerivativeConstants;
177
178 friend bool InertialIntegratorGui(const char* label, InertialIntegrator& integrator, float width);
179 friend void to_json(json& j, const InertialIntegrator& data);
180 friend void from_json(const json& j, InertialIntegrator& data);
181};
182
187bool InertialIntegratorGui(const char* label, InertialIntegrator& integrator, float width = 250.0F);
188
192void to_json(json& j, const InertialIntegrator& data);
196void from_json(const json& j, InertialIntegrator& data);
197
202
203} // namespace NAV
Vector space operations.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Different Gravity Models.
Imu Position Data.
bool InertialIntegratorGui(const char *label, InertialIntegrator &integrator, float width=250.0F)
Shows a GUI for advanced configuration of the InertialIntegrator.
The class is responsible for all time-related tasks.
Defines how to save certain datatypes to json.
Inertial Navigation Mechanization Functions.
Provides Numerical integration methods.
Position, Velocity and Attitude Storage Class.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
A buffer which is overwriting itself from the start when full.
IMU Position.
Definition ImuPos.hpp:26
Inertial Measurement Integrator.
Definition InertialIntegrator.hpp:37
void applyStateErrors_e(const Eigen::Vector3d &e_positionError, const Eigen::Vector3d &e_velocityError, const Eigen::Vector3d &e_attitudeError_b)
Apply the errors to the latest state.
std::optional< Eigen::Vector3d > p_calcCurrentAcceleration() const
Calculate the current acceleration, if measurements area available.
bool hasInitialPosition() const
Checks if an initial position is set.
IntegrationFrame getIntegrationFrame() const
Returns the selected integration frame.
void setState(const PosVelAtt &state)
Pushes the state to the list of states.
std::optional< Eigen::Vector3d > p_calcCurrentAngularRate() const
Calculate the current angular rate, if measurements area available.
friend void to_json(json &j, const InertialIntegrator &data)
Write info to a json object.
std::optional< std::reference_wrapper< const PosVelAtt > > getLatestState() const
Get the latest state if it exists.
void applyStateErrors_n(const Eigen::Vector3d &lla_positionError, const Eigen::Vector3d &n_velocityError, const Eigen::Vector3d &n_attitudeError_b)
Apply the errors to the latest state.
void setTotalSensorBiases(const Eigen::Vector3d &p_biasAcceleration, const Eigen::Vector3d &p_biasAngularRate)
Sets the sensor biases total values.
const Eigen::Vector3d & p_getLastAccelerationBias() const
Return the last acceleration bias in platform frame coordinates in [m/s^2].
friend void from_json(const json &j, InertialIntegrator &data)
Read info from a json object.
IntegrationFrame
Available Integration Frames.
Definition InertialIntegrator.hpp:114
@ NED
Local North-East-Down frame.
@ ECEF
Earth-Centered Earth-Fixed frame.
std::shared_ptr< PosVelAtt > calcInertialSolution(const InsTime &obsTime, const Eigen::Vector3d &p_acceleration, const Eigen::Vector3d &p_angularRate, const ImuPos &imuPos)
Calculates the inertial navigation solution.
std::shared_ptr< PosVelAtt > calcInertialSolutionDelta(const InsTime &obsTime, const double &dt, Eigen::Vector3d p_deltaVelocity, Eigen::Vector3d p_deltaTheta, Eigen::Vector3d p_acceleration, Eigen::Vector3d p_angularRate, const ImuPos &imuPos)
Calculates the inertial navigation solution.
IntegrationAlgorithm
Available Integration Algorithms.
Definition InertialIntegrator.hpp:41
@ SingleStepRungeKutta4
Runge-Kutta 4th order (explicit)
@ MultiStepRK4
Multistep Runge-Kutta 4th order (explicit) (taking 2 old epochs into account)
@ SingleStepHeun2
Heun's method (2nd order) (explicit)
@ COUNT
Amount of available integration algorithms.
@ MultiStepRK3
Multistep Runge-Kutta 3rd order (explicit) / Simpson's rule (taking 2 old epochs into account)
@ SingleStepRungeKutta3
Runge-Kutta 3rd order (explicit) / Simpson's rule.
@ SingleStepRungeKutta2
Runge-Kutta 2nd order (explicit) / Explicit midpoint method.
@ SingleStepHeun3
Heun's method (3nd order) (explicit)
@ SingleStepRungeKutta1
Runge-Kutta 1st order (explicit) / (Forward) Euler method.
void setInitialState(const PosVelAtt &state)
Sets the initial state.
void reset()
Clears all internal data.
friend bool InertialIntegratorGui(const char *label, InertialIntegrator &integrator, float width)
Shows a GUI for advanced configuration of the InertialIntegrator.
const ScrollingBuffer< Measurement > & getMeasurements() const
Get the measurements buffer.
const Eigen::Vector3d & p_getLastAngularRateBias() const
Return the last angular rate bias in platform frame coordinates in [rad/s].
void applySensorBiasesIncrements(const Eigen::Vector3d &p_deltaBiasAcceleration, const Eigen::Vector3d &p_deltaBiasAngularRate)
Sets the sensor biases increment.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
Position, Velocity and Attitude Storage Class.
Definition PosVelAtt.hpp:25
A buffer which is overwriting itself from the start when full.
Definition ScrollingBuffer.hpp:29
Inertial Measurement.
Definition InertialIntegrator.hpp:55
Eigen::Vector3d p_biasAngularRate
Angular rate bias in platform frame coordinates in [rad/s].
Definition InertialIntegrator.hpp:61
Eigen::Vector3d p_angularRate
Angular rate in platform frame coordinates in [rad/s].
Definition InertialIntegrator.hpp:58
Eigen::Vector3d p_biasAcceleration
Acceleration bias in platform frame coordinates in [m/s^2].
Definition InertialIntegrator.hpp:60
Eigen::Vector3d p_acceleration
Acceleration in platform frame coordinates in [m/s^2].
Definition InertialIntegrator.hpp:57
double dt
Time since previous observation.
Definition InertialIntegrator.hpp:56
Values needed to calculate the PosVelAttDerivative for the local-navigation frame.
Definition Mechanization.hpp:27