Apogee Filter¶
A Kalman filter for apogee detection. The filter tracks a 2-element state vector (altitude and vertical velocity) and provides an apogee detection function.
-
int filter_init(struct filter *filter)¶
Initialize the filter.
Zeroes state, sets initial covariance, and loads process/measurement noise from Kconfig (scaled by FILTER_SCALE_DIVISOR).
- Parameters:
filter – Pointer to filter structure.
- Return values:
0 – on success.
-EINVAL – if
filteris NULL.
-
int filter_predict(struct filter *filter, int64_t dt)¶
Perform the filter prediction step.
Propagates state and covariance forward in time using a constant-velocity model.
- Parameters:
filter – Pointer to filter structure.
dt – Elapsed time in nanoseconds since last prediction.
- Return values:
0 – on success.
-EINVAL – if
filteris NULL ordt<= 0.
-
int filter_update(struct filter *filter, float z)¶
Perform the filter measurement update step.
Computes Kalman gain and corrects the state estimate using a barometric altitude measurement.
- Parameters:
filter – Pointer to filter structure.
z – Measured altitude in meters.
- Return values:
0 – on success.
-EINVAL – if
filteris NULL.
-
int filter_detect_apogee(struct filter *filter)¶
Detect apogee from the filter’s velocity estimate.
Returns 1 when the estimated vertical velocity crosses zero from positive to non-positive, indicating apogee.
- Parameters:
filter – Pointer to filter structure.
- Return values:
1 – if apogee detected.
0 – if apogee not detected.
-EINVAL – if
filteris NULL.
-
FILTER_SCALE_DIVISOR¶
Divisor applied to Kconfig milliscale noise parameters.
-
struct filter¶
- #include <filter.h>
2-state Kalman filter structure for rocket apogee detection.
State vector: x[0] = altitude (m) x[1] = vertical velocity (m/s)
The filter assumes a constant-velocity model and uses barometric altitude as the measurement input.