0.4.1
Loading...
Searching...
No Matches
CommonLog.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
9/// @file CommonLog.hpp
10/// @brief Common logging variables like time into run and local positions
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2022-06-23
13
14#pragma once
15
16#include <mutex>
17#include <vector>
18#include <optional>
19
20#include <nlohmann/json.hpp>
21using json = nlohmann::json; ///< json namespace
22
23#include "util/Eigen.hpp"
26
27namespace NAV
28{
29/// Common logging variables like time into run and local positions
31{
32 public:
33 /// @brief Destructor
34 virtual ~CommonLog();
35 /// @brief Copy constructor
36 CommonLog(const CommonLog&) = delete;
37 /// @brief Move constructor
38 CommonLog(CommonLog&&) = delete;
39 /// @brief Copy assignment operator
40 CommonLog& operator=(const CommonLog&) = delete;
41 /// @brief Move assignment operator
43
44 /// @brief Initialize the common log variables
45 void initialize() const;
46
47 /// @brief Calculates the relative time into he run
48 /// @param[in] insTime Absolute Time
49 /// @return Relative
50 static double calcTimeIntoRun(const InsTime& insTime);
51
52 /// Local position offset from a reference point
54 {
55 double northSouth = 0.0; ///< North/South deviation from the reference point [m]
56 double eastWest = 0.0; ///< East/West deviation from the reference point [m]
57 };
58
59 /// @brief Calculate the local position offset from a reference point
60 /// @param[in] lla_position [𝜙, λ, h] Latitude, Longitude, Altitude in [rad, rad, m]
61 /// @return Local positions in north/south and east/west directions in [m]
62 static LocalPosition calcLocalPosition(const Eigen::Vector3d& lla_position);
63
64 /// @brief Shows a GUI to input a origin location
65 /// @param[in] id Unique id for ImGui
66 /// @return True if something was changed
67 static bool ShowOriginInput(const char* id);
68
69 /// @brief Returns a json object of the common log
70 [[nodiscard]] static json save();
71 /// @brief Read info from a json object
72 /// @param[in] j Json variable to read info from
73 static void restore(const json& j);
74
75 protected:
76 /// @brief Default constructor
77 CommonLog();
78
79 /// Start Time for calculation of relative time
80 static inline InsTime _startTime;
81 /// Origin for calculation of relative position
82 static inline std::optional<gui::widgets::PositionWithFrame> _originPosition;
83 /// Use GUI inputs
84 static inline bool _useGuiInputs = false;
85
86 private:
87 /// Mutex to lock before writing
88 static inline std::mutex _mutex;
89 /// Vector on which nodes want to initialize
90 static inline std::vector<bool> _wantsInit;
91 /// Index which common log node this is
92 size_t _index = 0;
93};
94
95} // namespace NAV
Vector space operations.
nlohmann::json json
json namespace
The class is responsible for all time-related tasks.
Position Input GUI widgets.
CommonLog & operator=(const CommonLog &)=delete
Copy assignment operator.
static bool ShowOriginInput(const char *id)
Shows a GUI to input a origin location.
CommonLog(CommonLog &&)=delete
Move constructor.
static void restore(const json &j)
Read info from a json object.
Definition CommonLog.cpp:30
static std::mutex _mutex
Mutex to lock before writing.
Definition CommonLog.hpp:88
CommonLog()
Default constructor.
Definition CommonLog.cpp:38
size_t _index
Index which common log node this is.
Definition CommonLog.hpp:92
CommonLog(const CommonLog &)=delete
Copy constructor.
void initialize() const
Initialize the common log variables.
Definition CommonLog.cpp:51
static json save()
Returns a json object of the common log.
Definition CommonLog.cpp:21
static std::optional< gui::widgets::PositionWithFrame > _originPosition
Origin for calculation of relative position.
Definition CommonLog.hpp:82
static double calcTimeIntoRun(const InsTime &insTime)
Calculates the relative time into he run.
Definition CommonLog.cpp:70
static bool _useGuiInputs
Use GUI inputs.
Definition CommonLog.hpp:84
static LocalPosition calcLocalPosition(const Eigen::Vector3d &lla_position)
Calculate the local position offset from a reference point.
Definition CommonLog.cpp:81
CommonLog & operator=(CommonLog &&)=delete
Move assignment operator.
static InsTime _startTime
Start Time for calculation of relative time.
Definition CommonLog.hpp:80
static std::vector< bool > _wantsInit
Vector on which nodes want to initialize.
Definition CommonLog.hpp:90
virtual ~CommonLog()
Destructor.
Definition CommonLog.cpp:45
The class is responsible for all time-related tasks.
Definition InsTime.hpp:710
Local position offset from a reference point.
Definition CommonLog.hpp:54
double northSouth
North/South deviation from the reference point [m].
Definition CommonLog.hpp:55
double eastWest
East/West deviation from the reference point [m].
Definition CommonLog.hpp:56