Program Listing for File global-coordinate-tools.h

Return to documentation for file (common/maplab-common/include/maplab-common/global-coordinate-tools.h)

#ifndef MAPLAB_COMMON_GLOBAL_COORDINATE_TOOLS_H_
#define MAPLAB_COMMON_GLOBAL_COORDINATE_TOOLS_H_

#include <string>

#include <Eigen/Core>
#include <glog/logging.h>

#include <aslam/common/memory.h>

namespace common {

constexpr double kWGS84EarthGravitationalConstant = 3.986005e14;
constexpr double kWGS84EarthRotationRate = 7.2921151467e-5;
// Parameters of the WGS84 ellipsoid:
constexpr double kWGS84A = 6378137.0;

constexpr double kWGS84InverseFlattening = 298.257223563;

constexpr double kWGS84Flattening = 1.0 / kWGS84InverseFlattening;

constexpr double kWGS84B = kWGS84A * (1.0 - kWGS84Flattening);

const double kWGS84Eccentricity =
    sqrt(2.0 * kWGS84Flattening - kWGS84Flattening * kWGS84Flattening);

void llhToEcef(const Eigen::Vector3d& latitude_longitude_height,
               Eigen::Vector3d* earth_centered_earth_fixed);

void ecefToLlh(const Eigen::Vector3d& earth_centered_fixed,
               Eigen::Vector3d* latitude_longitude_height);

void ecefToLlhIterative(const Eigen::Vector3d& earth_centered_earth_fixed,
                        Eigen::Vector3d* latitude_longitude_height);

void ecefToNed(const Eigen::Vector3d& earth_centered_earth_fixed,
               const Eigen::Vector3d& origin_earth_centered_earth_fixed,
               Eigen::Vector3d* north_east_down);

void nedToEcef(const Eigen::Vector3d& north_east_down,
               const Eigen::Vector3d& origin_earth_centered_earth_fixed,
               Eigen::Vector3d* earth_centered_earth_fixed);

void getRotationMatrixEcefToNed(double lat_rad, double lon_rad,
                                Eigen::Matrix3d* R_NED_ECEF);

void getRotationMatrixNedToEcef(double lat_rad, double lon_rad,
                                Eigen::Matrix3d* R_ECEF_NED);

void writeGlobalCoordinatesToKml(
    const Aligned<std::vector, Eigen::Vector3d>& latitude_longitude_height,
    const std::string& filename);

constexpr double degreeToRadian(double degree);

constexpr double radianToDegree(double radian);
}  // namespace common

#endif  // MAPLAB_COMMON_GLOBAL_COORDINATE_TOOLS_H_