Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: lib: Change the sensor readings axes to navigator's standard #37

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,12 @@ impl Navigator {
/// ```
pub fn read_mag(&mut self) -> AxisData {
let (x, y, z) = self.mag.read().unwrap();
AxisData { x, y, z }
// Change the axes to navigator's standard. Right-handed, Z-axis down (aeronautical frame, NED).
AxisData {
x: y,
y: x * -1.0,
z,
}
}

/// Reads the temperature using BMP280 of [`Navigator`].
Expand Down Expand Up @@ -878,10 +883,13 @@ impl Navigator {
/// ```
pub fn read_accel(&mut self) -> AxisData {
let reading: [f32; 3] = self.imu.get_scaled_accel().unwrap();
// Change the axes to navigator's standard. Right-handed, Z-axis down (aeronautical frame, NED).
// Obs.: ICM20602 sensor is measuring with inverted directions, not following data-sheet.
// Thus, with IC's placement only Z needs to be inverted.
AxisData {
x: reading[0],
y: reading[1],
z: reading[2],
z: reading[2] * -1.0,
}
}

Expand All @@ -907,9 +915,10 @@ impl Navigator {
/// ```
pub fn read_gyro(&mut self) -> AxisData {
let reading: [f32; 3] = self.imu.get_scaled_gyro().unwrap();
// Change the axes to navigator's standard. Right-handed, Z-axis down (aeronautical frame, NED).
AxisData {
x: reading[0],
y: reading[1],
x: reading[0] * -1.0,
y: reading[1] * -1.0,
z: reading[2],
}
}
Expand Down
Loading