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

create recovery timer mechanism #101

Merged
merged 12 commits into from
Jun 8, 2024
Prev Previous commit
Next Next commit
Fix: remove magic number
  • Loading branch information
NoahSprenger committed Jun 8, 2024
commit 86d9d2bc69d0c1dd3634fa371d5ad023be1dc8aa
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 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,
NoahSprenger marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -69,7 +70,7 @@
return false;
}
_ => {
info!("avg: {}", avg_sum / 7.0);
info!("avg: {}", avg_sum / (RECOVERY_DATA_POINTS as f32 - 1.0));
}
}
}
Expand All @@ -86,10 +87,10 @@
}
}
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() { | +++++++
match buf.next() {
Some(last) => {
let mut avg_sum: f32 = 0.0;
Expand All @@ -102,7 +103,7 @@
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
Loading