Skip to main content

Geodetic

Struct Geodetic 

Source
pub struct Geodetic { /* private fields */ }
Expand description

A position on the WGS84 ellipsoid: latitude, longitude, and height.

f64 throughout, where the rest of the crate is f32: at a latitude of 50° an f32 degree has a resolution of 4 × 10⁻⁶ °, which is 0.4 m on the ground. Positions relative to the origin are small, so everything after the conversion is f32 again.

Height is above the WGS84 ellipsoid for the conversion to be exact, which is what receivers compute (u-blox height, PX4 altitude_ellipsoid_m). Height above mean sea level works if used consistently, but it misplaces the ellipsoid by the local geoid undulation — up to 100 m — and so scales horizontal distance by up to 1.6 × 10⁻⁵: 1.6 cm per kilometer from the origin.

Implementations§

Source§

impl Geodetic

Source

pub fn from_degrees(latitude: f64, longitude: f64, height: f64) -> Self

Construct from latitude and longitude in degrees, and height in meters.

Current PX4 publishes exactly this, as float64: latitude_deg, longitude_deg and altitude_ellipsoid_m of SensorGps (msg/SensorGps.msg:8-11 at c4e4ef98) pass straight through, with no scaling.

Source

pub const fn from_radians(latitude: f64, longitude: f64, height: f64) -> Self

Construct from latitude and longitude in radians, and height in meters.

Source

pub fn from_degrees_e7(latitude: i32, longitude: i32, height_mm: i32) -> Self

Construct from the integer encoding u-blox NAV-PVT, MAVLink GPS_RAW_INT, and PX4’s older vehicle_gps_position all share: latitude and longitude in 10⁻⁷ degrees, height in millimeters.

ArduPilot’s Location shares the latitude and longitude but not the height, which is centimeters (int32_t alt; // in cm, libraries/AP_Common/Location.h:17 at 368dc0c4): passed here unconverted it is ten times too low. Multiply it by ten first.

Source

pub fn latitude_deg(self) -> f64

Latitude in degrees.

Source

pub fn longitude_deg(self) -> f64

Longitude in degrees.

Source

pub const fn latitude_rad(self) -> f64

Latitude in radians.

Source

pub const fn longitude_rad(self) -> f64

Longitude in radians.

Source

pub const fn height(self) -> f64

Height in meters, on the receiver’s datum.

Source

pub fn magnetic_declination(self) -> Option<Radians>

Available on crate feature magnetic-model only.

The magnetic declination here, east-positive, from the crate’s World Magnetic Model table (one epoch, 10° grid, bilinear): None for a coordinate that is not a number. Height is ignored.

The value Eskf applies itself where it places its origin, unless set_magnetic_declination has been called. A caller that knows its site before initializing hands the filter the site through set_origin instead, which reads this and leaves the model in charge; passing this to set_magnetic_declination fixes it for good. Behind the magnetic-model feature, on by default.

Source

pub fn normal_gravity(self) -> f32

WGS84 normal gravity here, m s⁻²: the value Config::gravity is configured with for a site.

Somigliana’s closed formula on the ellipsoid, NGA.STND.0036 v1.0.0 equation (4-1), carried to the height by the second-order series of (4-3), which the standard gives for small heights: it is within a few µm s⁻² of the exact (4-4) at the altitudes a vehicle navigates, against the 0.03 m s⁻² the latitude moves it. Not a number for a coordinate that is not one.

Trait Implementations§

Source§

impl Clone for Geodetic

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Geodetic

Source§

impl Debug for Geodetic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Geodetic

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Geodetic

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.