33 #include "generated/airframe.h"
42 #ifndef GUIDANCE_V_ADAPT_INITIAL_HOVER_THROTTLE
43 #define GUIDANCE_V_ADAPT_INITIAL_HOVER_THROTTLE 0.3
51 #ifndef GUIDANCE_V_ADAPT_MIN_HOVER_THROTTLE
52 #define GUIDANCE_V_ADAPT_MIN_HOVER_THROTTLE 0.2
60 #ifndef GUIDANCE_V_ADAPT_MAX_HOVER_THROTTLE
61 #define GUIDANCE_V_ADAPT_MAX_HOVER_THROTTLE 0.75
70 #ifndef GUIDANCE_V_ADAPT_NOISE_FACTOR
71 #define GUIDANCE_V_ADAPT_NOISE_FACTOR 1.0
78 #ifndef GUIDANCE_V_ADAPT_MAX_ACCEL
79 #define GUIDANCE_V_ADAPT_MAX_ACCEL 4.0
85 #ifndef GUIDANCE_V_ADAPT_MAX_CMD
86 #define GUIDANCE_V_ADAPT_MAX_CMD 0.9
88 #ifndef GUIDANCE_V_ADAPT_MIN_CMD
89 #define GUIDANCE_V_ADAPT_MIN_CMD 0.1
99 #ifndef GV_ADAPT_SYS_NOISE_F
100 #define GV_ADAPT_SYS_NOISE_F 0.00005
102 #define GV_ADAPT_SYS_NOISE BFP_OF_REAL(GV_ADAPT_SYS_NOISE_F, GV_ADAPT_P_FRAC)
105 #define GV_ADAPT_MEAS_NOISE_HOVER_F (50.0*GUIDANCE_V_ADAPT_NOISE_FACTOR)
106 #define GV_ADAPT_MEAS_NOISE_HOVER BFP_OF_REAL(GV_ADAPT_MEAS_NOISE_HOVER_F, GV_ADAPT_P_FRAC)
107 #define GV_ADAPT_MEAS_NOISE_OF_ZD (100.0*GUIDANCE_V_ADAPT_NOISE_FACTOR)
110 #define GV_ADAPT_P0_F 0.1
137 if (thrust_applied < gv_adapt_min_cmd || thrust_applied > gv_adapt_max_cmd
138 || zdd_meas < -gv_adapt_max_accel || zdd_meas > gv_adapt_max_accel) {
150 gv_adapt_Xmeas = (g_m_zdd + (thrust_applied >> 1)) / thrust_applied;
152 gv_adapt_Xmeas = (g_m_zdd - (thrust_applied >> 1)) / thrust_applied;
160 if (zd_ref < 0) { ref = -
ref; }
169 if (gv_adapt_P > gv_adapt_P0) {
174 gv_adapt_X = gv_adapt_X + ((((
int64_t)K * residual)) >>
K_FRAC);
185 Bound(gv_adapt_X, min_out, max_out);
Adaptation block of the vertical guidance.
#define GV_ADAPT_SYS_NOISE
#define GUIDANCE_V_ADAPT_MAX_CMD
Filter is not fed if command values are out of a % of 0/MAX_PPRZ.
#define GV_ADAPT_MEAS_NOISE_HOVER
#define GUIDANCE_V_ADAPT_MAX_HOVER_THROTTLE
Maximum hover throttle as factor of MAX_PPRZ.
#define BFP_OF_REAL(_vr, _frac)
#define GUIDANCE_V_ADAPT_MIN_CMD
static const int32_t gv_adapt_P0
#define GV_ADAPT_MEAS_NOISE_OF_ZD
static const int32_t gv_adapt_X0
void gv_adapt_run(int32_t zdd_meas, int32_t thrust_applied, int32_t zd_ref)
Adaptation function.
int32_t gv_adapt_P
Covariance.
int32_t gv_adapt_Xmeas
Measurement.
#define GUIDANCE_V_ADAPT_MIN_HOVER_THROTTLE
Minimum hover throttle as factor of MAX_PPRZ.
#define ACCEL_BFP_OF_REAL(_af)
#define GUIDANCE_V_ADAPT_INITIAL_HOVER_THROTTLE
Initial hover throttle as factor of MAX_PPRZ.
int32_t gv_adapt_X
State of the estimator.
#define GUIDANCE_V_ADAPT_MAX_ACCEL
Filter is not fed if accel values are more than +/- MAX_ACCEL.
Paparazzi fixed point algebra.