Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions firmware/src/sensors/baro_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ static void baro_thread_fn(void *p1, void *p2, void *p3)
.nis = measurement_1.nis,
.faults = health_1.fault_count,
.healthy = health_1.healthy},
.altitude = st.ground_calibrated ? kf.h : 0.0f,
.altitude = kf.h,
.altitude_agl = st.ground_calibrated ? kf.h - st.ground_altitude : 0.0f,
.alt_variance = kf.P00,
.velocity = st.ground_calibrated ? kf.v : 0.0f,
.velocity = kf.v,
.vel_variance = kf.P11,
.timestamp = now_ms};

Expand Down
1 change: 1 addition & 0 deletions firmware/src/state_machine/state_machine_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define STATE_MACHINE_CONFIG_H

// Standby baseline
#define GROUND_WARMUP_MS 2000 // Ignore baro samples for first 2s to let KF converge
#define GROUND_AVERAGE_SAMPLES 50 // At 50Hz = 1 second of data

// Ascent detection
Expand Down
3 changes: 3 additions & 0 deletions firmware/src/state_machine/states/standby.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ LOG_MODULE_REGISTER(state_standby, LOG_LEVEL_DBG);
static flight_state_id_t update_standby(struct flight_sm *sm, const state_sample_t *sample)
{
if (!sm->ground_ready) {
if ((sample->timestamp_ms - sm->ground_warmup_start_ms) < GROUND_WARMUP_MS) {
return FLIGHT_STATE_STANDBY;
}
sm->ground_sum_m += sample->altitude_m;
sm->ground_samples++;
LOG_DBG("Ground calibration: %d/%d samples, current_alt=%.2f m, avg=%.2f m",
Expand Down
Loading