32 if (j.contains(
"useGuiInputs")) { j.at(
"useGuiInputs").get_to(
_useGuiInputs); }
40 std::scoped_lock lk(
_mutex);
47 std::scoped_lock lk(
_mutex);
53 std::scoped_lock lk(
_mutex);
57 if (std::ranges::all_of(
_wantsInit, [](
bool val) {
return val; }))
59 LOG_DEBUG(
"Resetting common log variables.");
72 if (std::scoped_lock lk(
_mutex);
78 return static_cast<double>((insTime -
_startTime).count());
84 std::scoped_lock lk(
_mutex);
87 if (lla_position.hasNaN())
89 LOG_WARN(
"Not setting common log origin to {}, {}, {} [deg, deg, m]",
90 rad2deg(lla_position.x()),
rad2deg(lla_position.y()), lla_position.z());
96 LOG_DEBUG(
"Common log setting position of origin to {}, {}, {} [deg, deg, m]",
97 rad2deg(lla_position.x()),
rad2deg(lla_position.y()), lla_position.z());
112 return { .northSouth = northSouth, .eastWest = eastWest };
117 bool changed =
false;
118 if (ImGui::Checkbox(fmt::format(
"Override position origin (for all common logging)##{}",
id).c_str(), &
_useGuiInputs))
127 std::scoped_lock lk(
_mutex);
Common logging variables like time into run and local positions.
Functions concerning the ellipsoid model.
nlohmann::json json
json namespace
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_WARN
Error occurred, but a fallback option exists and program continues to work normally.
static bool ShowOriginInput(const char *id)
Shows a GUI to input a origin location.
static void restore(const json &j)
Read info from a json object.
static std::mutex _mutex
Mutex to lock before writing.
CommonLog()
Default constructor.
size_t _index
Index which common log node this is.
void initialize() const
Initialize the common log variables.
static json save()
Returns a json object of the common log.
static std::optional< gui::widgets::PositionWithFrame > _originPosition
Origin for calculation of relative position.
static double calcTimeIntoRun(const InsTime &insTime)
Calculates the relative time into he run.
static bool _useGuiInputs
Use GUI inputs.
static LocalPosition calcLocalPosition(const Eigen::Vector3d &lla_position)
Calculate the local position offset from a reference point.
static InsTime _startTime
Start Time for calculation of relative time.
static std::vector< bool > _wantsInit
Vector on which nodes want to initialize.
virtual ~CommonLog()
Destructor.
The class is responsible for all time-related tasks.
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.
Scalar calcGeographicalDistance(Scalar lat1, Scalar lon1, Scalar lat2, Scalar lon2)
Measure the distance between two points over an ellipsoidal-surface.
constexpr auto rad2deg(const T &rad)
Convert Radians to Degree.
Local position offset from a reference point.