0.4.1
Loading...
Searching...
No Matches
PositionInput.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 PositionInput.hpp
10/// @brief Position Input GUI widgets
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2023-08-14
13
14#pragma once
15
16#include <cstdint>
17#include <Eigen/Core>
18#include <nlohmann/json.hpp>
19using json = nlohmann::json; ///< json namespace
20
23
24namespace NAV
25{
26namespace gui::widgets
27{
28
29/// Position with Reference frame, used for GUI input
31{
32 /// Reference frames
33 enum class ReferenceFrame : uint8_t
34 {
35 ECEF, ///< Earth-centered Earth-fixed
36 LLA, ///< Latitude, Longitude, Altitude
37 COUNT, ///< Amount of items in the enum
38 };
39
40 /// Reference frame used for the input, not for the storage of values
42 /// Position in ECEF coordinates in [m]
43 Eigen::Vector3d e_position = trafo::lla2ecef_WGS84(Eigen::Vector3d::Zero());
44
45 /// Latitude in [rad]
46 [[nodiscard]] double latitude() const { return trafo::ecef2lla_WGS84(e_position)(0); }
47 /// Longitude in [rad]
48 [[nodiscard]] double longitude() const { return trafo::ecef2lla_WGS84(e_position)(1); }
49 /// Altitude in [m]
50 [[nodiscard]] double altitude() const { return trafo::ecef2lla_WGS84(e_position)(2); }
51 /// Latitude in [deg]
52 [[nodiscard]] double latitude_deg() const { return trafo::ecef2lla_WGS84(e_position)(0); }
53 /// Longitude in [deg]
54 [[nodiscard]] double longitude_deg() const { return trafo::ecef2lla_WGS84(e_position)(1); }
55
56 /// Latitude in [rad, rad, m]
57 [[nodiscard]] Eigen::Vector3d latLonAlt() const { return trafo::ecef2lla_WGS84(e_position); }
58 /// Latitude in [deg, deg, m]
59 [[nodiscard]] Eigen::Vector3d latLonAlt_deg() const
60 {
62 return { rad2deg(lla(0)), rad2deg(lla(1)), lla(2) };
63 }
64};
65
66/// @brief Converts the provided Object into a json object
67/// @param[out] j Return Json object
68/// @param[in] refFrame Object to convert
69void to_json(json& j, const PositionWithFrame::ReferenceFrame& refFrame);
70/// @brief Converts the provided json object
71/// @param[in] j Json object with the time system
72/// @param[out] refFrame Object to return
73void from_json(const json& j, PositionWithFrame::ReferenceFrame& refFrame);
74/// @brief Converts the provided Object into a json object
75/// @param[out] j Return Json object
76/// @param[in] position Object to convert
77void to_json(json& j, const PositionWithFrame& position);
78/// @brief Converts the provided json object
79/// @param[in] j Json object with the time system
80/// @param[out] position Object to return
81void from_json(const json& j, PositionWithFrame& position);
82
83/// Layout options for the Position input
84enum class PositionInputLayout : uint8_t
85{
86 SINGLE_COLUMN, ///< All elements in a single column
87 SINGLE_ROW, ///< All elements in a single row
88 TWO_ROWS, ///< 2 rows
89};
90
91/// @brief Inputs to edit an Position object
92/// @param[in] str Text to display near the Frame selection (Unique id for the ImGui elements)
93/// @param[in, out] position Position and reference frame object to modify
94/// @param[in] layout Layout to use
95/// @param[in] itemWidth Width of the widget items
96/// @return True if changes were made to the object
97bool PositionInput(const char* str, PositionWithFrame& position, PositionInputLayout layout = PositionInputLayout::SINGLE_COLUMN, float itemWidth = 140.0F);
98
99} // namespace gui::widgets
100
101/// @brief Converts the enum to a string
102/// @param[in] refFrame Enum value to convert into text
103/// @return String representation of the enum
105
106} // namespace NAV
Transformation collection.
nlohmann::json json
json namespace
void from_json(const json &j, DynamicInputPins &obj, Node *node)
Converts the provided json object into a node object.
bool PositionInput(const char *str, PositionWithFrame &position, PositionInputLayout layout=PositionInputLayout::SINGLE_COLUMN, float itemWidth=140.0F)
Inputs to edit an Position object.
void to_json(json &j, const DynamicInputPins &obj)
Converts the provided object into json.
PositionInputLayout
Layout options for the Position input.
@ SINGLE_ROW
All elements in a single row.
@ SINGLE_COLUMN
All elements in a single column.
Eigen::Vector3< typename Derived::Scalar > ecef2lla_WGS84(const Eigen::MatrixBase< Derived > &e_position)
Converts Earth-centered-Earth-fixed coordinates into latitude, longitude and altitude using WGS84.
Eigen::Vector3< typename Derived::Scalar > lla2ecef_WGS84(const Eigen::MatrixBase< Derived > &lla_position)
Converts latitude, longitude and altitude into Earth-centered-Earth-fixed coordinates using WGS84.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
constexpr auto rad2deg(const T &rad)
Convert Radians to Degree.
Definition Units.hpp:39
Position with Reference frame, used for GUI input.
double latitude() const
Latitude in [rad].
double latitude_deg() const
Latitude in [deg].
Eigen::Vector3d latLonAlt_deg() const
Latitude in [deg, deg, m].
double longitude_deg() const
Longitude in [deg].
Eigen::Vector3d latLonAlt() const
Latitude in [rad, rad, m].
double longitude() const
Longitude in [rad].
Eigen::Vector3d e_position
Position in ECEF coordinates in [m].
double altitude() const
Altitude in [m].
ReferenceFrame frame
Reference frame used for the input, not for the storage of values.