QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSProtocolMath.h File Reference
#include <cmath>
#include <cstdint>
#include <ctime>
#include <limits>
#include <numbers>
#include <optional>
#include <QtCore/QByteArray>
#include "GPSReceiverConfig.h"
+ Include dependency graph for GPSProtocolMath.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GPSProtocolMath::Ecef
 

Namespaces

namespace  GPSProtocolMath
 Unit conversions and geodesy shared by receiver families and their callers.
 

Functions

constexpr double GPSProtocolMath::degreesFromE7 (int32_t value)
 Degrees of a coordinate in 1e-7 degree units, as u-blox and MAVLink send them.
 
constexpr double GPSProtocolMath::metersFromMillimeters (int32_t value)
 
double GPSProtocolMath::roundedToMillimeters (double meters)
 meters rounded to whole millimetres.
 
std::optional< uint32_t > GPSProtocolMath::tenthMillimeters (double meters)
 meters in 0.1 mm, truncated toward zero. Empty when not finite, negative or beyond a 32-bit unsigned field.
 
Ecef GPSProtocolMath::toEcef (const GPSEllipsoidPosition &position)
 
GPSEllipsoidPosition GPSProtocolMath::fromEcef (const Ecef &position)
 
double GPSProtocolMath::distance (const Ecef &left, const Ecef &right)
 Straight-line distance between left and right, in metres.
 
bool GPSProtocolMath::nearEarthSurface (const Ecef &position)
 
uint64_t GPSProtocolMath::utcMicroseconds (int year, int month, int day, int hour, int minute, int second, int32_t nsec)
 
QByteArray gpsFixedDecimal (double value, int decimals)
 

Variables

constexpr double GPSProtocolMath::DEG_TO_RAD = std::numbers::pi / 180.0
 
constexpr double GPSProtocolMath::RAD_TO_DEG = 180.0 / std::numbers::pi
 
constexpr time_t GPSProtocolMath::UTC_PLAUSIBILITY_FLOOR_SECS = static_cast<time_t>(1234567890ULL)
 Receiver dates before this instant (2009-02-13) are implausible and reported as unknown.
 

Function Documentation

◆ gpsFixedDecimal()

QByteArray gpsFixedDecimal ( double  value,
int  decimals 
)

Formats value as printf's "%.<decimals>f" does in the C locale: exact binary ties round to even and a negative zero keeps its sign. QByteArray::number() does neither, and would change the command bytes for such values.

Definition at line 65 of file GPSProtocolMath.cc.

Referenced by SBF::Plan::base(), Femto::Plan::fixedBase(), Unicore::Plan::fixedBase(), Ashtech::Plan::fixedPosition(), and Quectel::Plan::writeBase().