mars_lib 0.1.0.2abe2576fe7f
Modular and Robust Sensor-Fusion
Loading...
Searching...
No Matches
gps_conversion.h
Go to the documentation of this file.
1// Copyright (C) 2021 Christian Brommer, Control of Networked Systems, University of Klagenfurt, Austria.
2//
3// All rights reserved.
4//
5// This software is licensed under the terms of the BSD-2-Clause-License with
6// no commercial use allowed, the full terms of which are made available
7// in the LICENSE file. No license in patents is granted.
8//
9// You can contact the author at <christian.brommer@ieee.org>
10
11#ifndef GPS_CONVERSION_H
12#define GPS_CONVERSION_H
13
14#include <Eigen/Dense>
15
16namespace mars
17{
22{
23 GpsCoordinates() = default;
24 GpsCoordinates(double latitude, double longitude, double altitude)
25 : latitude_(latitude), longitude_(longitude), altitude_(altitude)
26 {
27 }
28 double latitude_{ 0 };
29 double longitude_{ 0 };
30 double altitude_{ 0 };
31
32 friend std::ostream& operator<<(std::ostream& out, const GpsCoordinates& coordinates);
33
34 inline GpsCoordinates operator+(const GpsCoordinates& coordinates)
35 {
36 return { latitude_ + coordinates.latitude_, longitude_ + coordinates.longitude_,
37 altitude_ + coordinates.altitude_ };
38 }
39
40 inline void operator+=(const GpsCoordinates& coordinates)
41 {
42 latitude_ += coordinates.latitude_;
43 longitude_ += coordinates.longitude_;
44 altitude_ += coordinates.altitude_;
45 }
46
47 inline void operator/=(const double& n)
48 {
49 if (n == 0)
50 {
51 throw std::overflow_error("Divide by zero exception");
52 }
53
54 latitude_ /= n;
55 longitude_ /= n;
56 altitude_ /= n;
57 }
58};
59
66{
67public:
69 GpsConversion() = default;
70
76 Eigen::Matrix<double, 3, 1> get_enu(mars::GpsCoordinates coordinates);
77
83
89
90private:
92 Eigen::Matrix3d ecef_ref_orientation_;
93 Eigen::Matrix<double, 3, 1> ecef_ref_point_;
94 bool reference_is_set{ false };
100 double deg2rad(const double& deg);
101
107 Eigen::Matrix<double, 3, 1> WGS84ToECEF(const mars::GpsCoordinates& coordinates);
108
114 Eigen::Matrix<double, 3, 1> ECEFToENU(const Eigen::Matrix<double, 3, 1>& ecef);
115
122 Eigen::Matrix<double, 3, 1> WGS84ToENU(const mars::GpsCoordinates& coordinates);
123};
124} // namespace mars
125#endif // GPS_CONVERSION_H
The GpsConversion class.
Definition gps_conversion.h:66
GpsCoordinates reference_
GPS reference coordinates.
Definition gps_conversion.h:91
void set_gps_reference(mars::GpsCoordinates coordinates)
set_gps_reference
Eigen::Matrix< double, 3, 1 > WGS84ToECEF(const mars::GpsCoordinates &coordinates)
WGS84ToECEF World Geodetic System 1984 model (WGS-84) to Earth-Centered-Earth-Fixed (ECEF)
mars::GpsCoordinates get_gps_reference()
get_gps_reference
bool reference_is_set
Definition gps_conversion.h:94
GpsConversion()=default
Eigen::Matrix3d ecef_ref_orientation_
Definition gps_conversion.h:92
Eigen::Matrix< double, 3, 1 > get_enu(mars::GpsCoordinates coordinates)
get_enu get current GPS reference coordinates
Eigen::Matrix< double, 3, 1 > ecef_ref_point_
Definition gps_conversion.h:93
GpsConversion(mars::GpsCoordinates coordinates)
Eigen::Matrix< double, 3, 1 > WGS84ToENU(const mars::GpsCoordinates &coordinates)
WGS84ToENU World Geodetic System 1984 model (WGS-84) to East-North-Up (ENU) based on given reference ...
Eigen::Matrix< double, 3, 1 > ECEFToENU(const Eigen::Matrix< double, 3, 1 > &ecef)
ECEFToENU Earth-Centered-Earth-Fixed (ECEF) to East-North-Up (ENU)
double deg2rad(const double &deg)
deg2rad
Definition buffer.h:27
The GpsCoordinates struct.
Definition gps_conversion.h:22
friend std::ostream & operator<<(std::ostream &out, const GpsCoordinates &coordinates)
double longitude_
Definition gps_conversion.h:29
GpsCoordinates()=default
double altitude_
Definition gps_conversion.h:30
double latitude_
Definition gps_conversion.h:28
GpsCoordinates(double latitude, double longitude, double altitude)
Definition gps_conversion.h:24
void operator+=(const GpsCoordinates &coordinates)
Definition gps_conversion.h:40
GpsCoordinates operator+(const GpsCoordinates &coordinates)
Definition gps_conversion.h:34
void operator/=(const double &n)
Definition gps_conversion.h:47