Skip to content

Commit

Permalink
Fix: remove magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSprenger committed Jun 8, 2024
1 parent 3544a46 commit 86d9d2b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions boards/recovery/src/data_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pub struct DataManager {
pub imu: (Option<Imu1>, Option<Imu2>),
pub utc_time: Option<UtcTime>,
pub gps_vel: Option<GpsVel>,
pub historical_barometer_altitude: HistoryBuffer<(f32, u32), 8>,
pub historical_barometer_altitude: HistoryBuffer<(f32, u32), 8>, // RECOVERY_DATA_POINTS (issue
// when putting as const)
pub current_state: Option<RocketStates>,
// each tick represents a minute that passed
pub recovery_counter: u8,
Expand Down Expand Up @@ -69,7 +70,7 @@ impl DataManager {
return false;
}
_ => {
info!("avg: {}", avg_sum / 7.0);
info!("avg: {}", avg_sum / (RECOVERY_DATA_POINTS as f32 - 1.0));
}
}
}
Expand All @@ -86,7 +87,7 @@ impl DataManager {
}
}
pub fn is_landed(&mut self) -> bool {
if self.historical_barometer_altitude.len() < 8 {
if self.historical_barometer_altitude.len() < RECOVERY_DATA_POINTS {
return false;
}
let mut buf = self.historical_barometer_altitude.oldest_ordered();

Check failure on line 93 in boards/recovery/src/data_manager.rs

View workflow job for this annotation

GitHub Actions / All

mismatched types

Check failure on line 93 in boards/recovery/src/data_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

mismatched types

error[E0308]: mismatched types --> boards/recovery/src/data_manager.rs:93:55 | 93 | if self.historical_barometer_altitude.len() < RECOVERY_DATA_POINTS { | ---------------------------------------- ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `u8` | | | expected because this is `usize` | help: you can convert a `u8` to a `usize` | 93 | if self.historical_barometer_altitude.len() < RECOVERY_DATA_POINTS.into() { | +++++++
Expand All @@ -102,7 +103,7 @@ impl DataManager {
avg_sum += (i.0 - prev.0) / time_diff;
prev = i;
}
match avg_sum / 7.0 {
match avg_sum / (RECOVERY_DATA_POINTS as f32 - 1.0) {
// inclusive range
x if (-0.25..=0.25).contains(&x) => {
if self.recovery_counter >= RECOVERY_TIMER_TIMEOUT {
Expand Down

0 comments on commit 86d9d2b

Please sign in to comment.