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
impl TestDataRecord
Sourcepub fn from_csv<P: AsRef<Path>>(path: P) -> Result<Vec<Self>, Box<dyn Error>>
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();
Sourcepub fn to_csv<P: AsRef<Path>>(records: &[Self], path: P) -> Result<()>
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 writepath
- 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
impl Clone for TestDataRecord
Source§fn clone(&self) -> TestDataRecord
fn clone(&self) -> TestDataRecord
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TestDataRecord
impl Debug for TestDataRecord
Source§impl<'de> Deserialize<'de> for TestDataRecord
impl<'de> Deserialize<'de> for TestDataRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for TestDataRecord
impl Display for TestDataRecord
Auto Trait Implementations§
impl Freeze for TestDataRecord
impl RefUnwindSafe for TestDataRecord
impl Send for TestDataRecord
impl Sync for TestDataRecord
impl Unpin for TestDataRecord
impl UnwindSafe for TestDataRecord
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.