33 #include "generated/airframe.h"
43 #ifndef GUIDANCE_V_ADAPT_INITIAL_HOVER_THROTTLE
44 #ifdef GUIDANCE_V_NOMINAL_HOVER_THROTTLE
45 #define GUIDANCE_V_ADAPT_INITIAL_HOVER_THROTTLE GUIDANCE_V_NOMINAL_HOVER_THROTTLE
47 #define GUIDANCE_V_ADAPT_INITIAL_HOVER_THROTTLE 0.3
56 #ifndef GUIDANCE_V_ADAPT_MIN_HOVER_THROTTLE
57 #define GUIDANCE_V_ADAPT_MIN_HOVER_THROTTLE 0.2
65 #ifndef GUIDANCE_V_ADAPT_MAX_HOVER_THROTTLE
66 #define GUIDANCE_V_ADAPT_MAX_HOVER_THROTTLE 0.75
75 #ifndef GUIDANCE_V_ADAPT_NOISE_FACTOR
76 #define GUIDANCE_V_ADAPT_NOISE_FACTOR 1.0
83 #ifndef GUIDANCE_V_ADAPT_MAX_ACCEL
84 #define GUIDANCE_V_ADAPT_MAX_ACCEL 4.0
90 #ifndef GUIDANCE_V_ADAPT_MAX_CMD
91 #define GUIDANCE_V_ADAPT_MAX_CMD 0.9
93 #ifndef GUIDANCE_V_ADAPT_MIN_CMD
94 #define GUIDANCE_V_ADAPT_MIN_CMD 0.1
104 #ifndef GV_ADAPT_SYS_NOISE_F
105 #define GV_ADAPT_SYS_NOISE_F 0.00005
107 #define GV_ADAPT_SYS_NOISE BFP_OF_REAL(GV_ADAPT_SYS_NOISE_F, GV_ADAPT_P_FRAC)
110 #define GV_ADAPT_MEAS_NOISE_HOVER_F (50.0*GUIDANCE_V_ADAPT_NOISE_FACTOR)
111 #define GV_ADAPT_MEAS_NOISE_HOVER BFP_OF_REAL(GV_ADAPT_MEAS_NOISE_HOVER_F, GV_ADAPT_P_FRAC)
112 #define GV_ADAPT_MEAS_NOISE_OF_ZD (100.0*GUIDANCE_V_ADAPT_NOISE_FACTOR)
115 #define GV_ADAPT_P0_F 0.1
142 if (thrust_applied < gv_adapt_min_cmd || thrust_applied > gv_adapt_max_cmd
143 || zdd_meas < -gv_adapt_max_accel || zdd_meas > gv_adapt_max_accel) {
155 gv_adapt_Xmeas = (g_m_zdd + (thrust_applied >> 1)) / thrust_applied;
157 gv_adapt_Xmeas = (g_m_zdd - (thrust_applied >> 1)) / thrust_applied;
165 if (zd_ref < 0) { ref = -
ref; }
174 if (gv_adapt_P > gv_adapt_P0) {
179 gv_adapt_X = gv_adapt_X + ((((
int64_t)K * residual)) >>
K_FRAC);
190 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.