pub struct GPS {
    pub earth_r: f64,
    pub obs_model: Array2<f64>,
    pub covar: Array2<f64>,
    pub init_lat: f64,
    pub init_lon: f64,
}
Expand description

Represents a GPS sensor with specific parameters.

Fields§

§earth_r: f64

Earth radius constant for distance calculations.

§obs_model: Array2<f64>

Observation model matrix for the GPS sensor.

§covar: Array2<f64>

Covariance matrix for the GPS sensor.

§init_lat: f64

Initial latitude for position calculations.

§init_lon: f64

Initial longitude for position calculations.

Implementations§

source§

impl GPS

source

pub fn new(xy_idx: (usize, usize), dims: usize, var: f64) -> Self

Creates a new GPS instance with specified parameters.

§Arguments
  • xy_idx - Tuple representing the indices of X and Y coordinates in the observation model matrix.
  • dims - Number of dimensions for the observation model.
  • var - Variance for the covariance matrix.
§Returns

(GPS): A new GPS instance.

§Examples
use openpilot::common::ext_kal_fltr::GPS;

let xy_idx = (0, 1);
let dims = 2;
let var = 1e4;
let gps = GPS::new(xy_idx, dims, var);
source

pub fn init_pos(&mut self, latlon: &[f64])

Initializes the GPS sensor with the given latitude and longitude.

§Arguments
  • latlon - Array containing latitude and longitude values.
§Examples
use openpilot::common::ext_kal_fltr::GPS;

let mut gps = GPS::new((0, 1), 2, 1e4);
gps.init_pos(&[37.7749, -122.4194]);
source

pub fn _haversine(&self, lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> f64

Calculates the Haversine distance between two points on the Earth’s surface.

§Arguments
  • lat1 - Latitude of the first point.
  • lon1 - Longitude of the first point.
  • lat2 - Latitude of the second point.
  • lon2 - Longitude of the second point.
§Returns

(f64): Haversine distance between the two points.

§Examples
use openpilot::common::ext_kal_fltr::GPS;

let gps = GPS::new((0, 1), 2, 1e4);
let distance = gps._haversine(37.7749, -122.4194, 38.0000, -121.0000);
source

pub fn convert_deg2m(&self, lat: f64, lon: f64) -> (f64, f64)

Converts latitude and longitude coordinates to meters.

§Arguments
  • lat - Latitude coordinate.
  • lon - Longitude coordinate.
§Returns

((f64, f64)): Tuple containing converted X and Y coordinates in meters.

§Examples
use openpilot::common::ext_kal_fltr::GPS;

let gps = GPS::new((0, 1), 2, 1e4);
let (xs, ys) = gps.convert_deg2m(37.7749, -122.4194);
source

pub fn _convert_m2deg(&self, xs: f64, ys: f64) -> (f64, f64)

Converts X and Y coordinates in meters to latitude and longitude coordinates.

§Arguments
  • xs - X coordinate in meters.
  • ys - Y coordinate in meters.
§Returns

((f64, f64)): Tuple containing converted latitude and longitude coordinates.

§Examples
use openpilot::common::ext_kal_fltr::GPS;

let gps = GPS::new((0, 1), 2, 1e4);
let (lat, lon) = gps._convert_m2deg(100.0, 200.0);
source

pub fn read(&self, latlon: &[f64], accuracy: Option<f64>) -> SensorReading

Reads GPS data and returns a SensorReading instance.

§Arguments
  • latlon - Array containing latitude and longitude values.
  • accuracy - Optional accuracy value. If not provided, the default covariance of the sensor is used.
§Returns

(SensorReading): A new SensorReading instance based on GPS data and covariance.

§Examples
use openpilot::common::ext_kal_fltr::GPS;

let mut gps = GPS::new((0, 1), 2, 1e4);
gps.init_pos(&[37.7749, -122.4194]);
let sensor_reading = gps.read(&[37.7749, -122.4194], Some(10.0));

Trait Implementations§

source§

impl Debug for GPS

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for GPS

§

impl Send for GPS

§

impl Sync for GPS

§

impl Unpin for GPS

§

impl UnwindSafe for GPS

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.