Struct TestDataRecord

Source
pub struct TestDataRecord {
Show 31 fields pub time: DateTime<Utc>, pub bearing_accuracy: f64, pub speed_accuracy: f64, pub vertical_accuracy: f64, pub horizontal_accuracy: f64, pub speed: f64, pub bearing: f64, pub altitude: f64, pub longitude: f64, pub latitude: f64, pub qz: f64, pub qy: f64, pub qx: f64, pub qw: f64, pub roll: f64, pub pitch: f64, pub yaw: f64, pub acc_z: f64, pub acc_y: f64, pub acc_x: f64, pub gyro_z: f64, pub gyro_y: f64, pub gyro_x: f64, pub mag_z: f64, pub mag_y: f64, pub mag_x: f64, pub relative_altitude: f64, pub pressure: f64, pub grav_z: f64, pub grav_y: f64, pub grav_x: f64,
}
Expand description

Struct representing a single row of test data from the CSV file.

Fields correspond to columns in the CSV, with appropriate renaming for Rust style. This struct is setup to capture the data recorded from the Sensor Logger app. Primarily, this represents IMU data as (relative to the device) and GPS data.

Fields§

§time: DateTime<Utc>

Date-time string: YYYY-MM-DD hh:mm:ss+UTCTZ

§bearing_accuracy: f64

accuracy of the bearing (magnetic heading) in degrees

§speed_accuracy: f64

accuracy of the speed in m/s

§vertical_accuracy: f64

accuracy of the altitude in meters

§horizontal_accuracy: f64

accuracy of the horizontal position in meters

§speed: f64

Speed in m/s

§bearing: f64

Bearing in degrees

§altitude: f64

Altitude in meters

§longitude: f64

Longitude in degrees

§latitude: f64

Latitude in degrees

§qz: f64

Quaternion component representing the rotation around the z-axis

§qy: f64

Quaternion component representing the rotation around the y-axis

§qx: f64

Quaternion component representing the rotation around the x-axis

§qw: f64

Quaternion component representing the rotation around the w-axis

§roll: f64

Roll angle in radians

§pitch: f64

Pitch angle in radians

§yaw: f64

Yaw angle in radians

§acc_z: f64

Z-acceleration in m/s^2

§acc_y: f64

Y-acceleration in m/s^2

§acc_x: f64

X-acceleration in m/s^2

§gyro_z: f64

Rotation rate around the z-axis in radians/s

§gyro_y: f64

Rotation rate around the y-axis in radians/s

§gyro_x: f64

Rotation rate around the x-axis in radians/s

§mag_z: f64

Magnetic field strength in the z-direction in microteslas

§mag_y: f64

Magnetic field strength in the y-direction in microteslas

§mag_x: f64

Magnetic field strength in the x-direction in microteslas

§relative_altitude: f64

Change in altitude in meters

§pressure: f64

pressure in millibars

§grav_z: f64

Acceleration due to gravity in the z-direction in m/s^2

§grav_y: f64

Acceleration due to gravity in the y-direction in m/s^2

§grav_x: f64

Acceleration due to gravity in the x-direction in m/s^2

Implementations§

Source§

impl TestDataRecord

Source

pub fn from_csv<P: AsRef<Path>>(path: P) -> Result<Vec<Self>, Box<dyn Error>>

Reads a CSV file and returns a vector of TestDataRecord structs.

§Arguments
  • path - Path to the CSV file to read.
§Returns
  • Ok(Vec<TestDataRecord>) if successful.
  • Err if the file cannot be read or parsed.
§Example
use strapdown::sim::TestDataRecord;
use std::path::Path;

let record = TestDataRecord {
    time: chrono::Utc::now(),
    bearing_accuracy: 0.1,
    speed_accuracy: 0.1,
    vertical_accuracy: 0.1,
    horizontal_accuracy: 0.1,
    speed: 1.0,
    bearing: 90.0,
    altitude: 100.0,
    longitude: -122.0,
    latitude: 37.0,
    qz: 0.0,
    qy: 0.0,
    qx: 0.0,
    qw: 1.0,
    roll: 0.0,
    pitch: 0.0,
    yaw: 0.0,
    acc_z: 9.81,
    acc_y: 0.0,
    acc_x: 0.0,
    gyro_z: 0.01,
    gyro_y: 0.01,
    gyro_x: 0.01,
    mag_z: 50.0,
    mag_y: -30.0,
    mag_x: -20.0,
    relative_altitude: 0.0,
    pressure: 1013.25,
    grav_z: 9.81,
    grav_y: 0.0,
    grav_x: 0.0,
};
let records = vec![record];
TestDataRecord::to_csv(&records, "data.csv")
   .expect("Failed to write test data to CSV");
let read_records = TestDataRecord::from_csv("data.csv")
  .expect("Failed to read test data from CSV");
// doctest cleanup
std::fs::remove_file("data.csv").unwrap();
Source

pub fn to_csv<P: AsRef<Path>>(records: &[Self], path: P) -> Result<()>

Writes a vector of TestDataRecord structs to a CSV file.

§Arguments
  • records - Vector of TestDataRecord structs to write
  • path - Path where the CSV file will be saved
§Returns
  • io::Result<()> - Ok if successful, Err otherwise
§Example
use strapdown::sim::TestDataRecord;
use std::path::Path;

let record = TestDataRecord {
    time: chrono::Utc::now(),
    bearing_accuracy: 0.1,
    speed_accuracy: 0.1,
    vertical_accuracy: 0.1,
    horizontal_accuracy: 0.1,
    speed: 1.0,
    bearing: 90.0,
    altitude: 100.0,
    longitude: -122.0,
    latitude: 37.0,
    qz: 0.0,
    qy: 0.0,
    qx: 0.0,
    qw: 1.0,
    roll: 0.0,
    pitch: 0.0,
    yaw: 0.0,
    acc_z: 9.81,
    acc_y: 0.0,
    acc_x: 0.0,
    gyro_z: 0.01,
    gyro_y: 0.01,
    gyro_x: 0.01,
    mag_z: 50.0,
    mag_y: -30.0,
    mag_x: -20.0,
    relative_altitude: 0.0,
    pressure: 1013.25,
    grav_z: 9.81,
    grav_y: 0.0,
    grav_x: 0.0,
};
let records = vec![record];
TestDataRecord::to_csv(&records, "data.csv")
   .expect("Failed to write test data to CSV");
// doctest cleanup
std::fs::remove_file("data.csv").unwrap();

Trait Implementations§

Source§

impl Clone for TestDataRecord

Source§

fn clone(&self) -> TestDataRecord

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TestDataRecord

Source§

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

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

impl<'de> Deserialize<'de> for TestDataRecord

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for TestDataRecord

Source§

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

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

impl Serialize for TestDataRecord

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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<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<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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,