[rotorcraft] from Ewoud: change feedback gain scale in vertical control for better resolution

The bit shifts are reduced by 5 (increasing the gain by factor 32), GUIDANCE_V_GAIN_SCALER (48) removed
So to get the same gains as before, multiply them by 1.5

Maybe also adjust the GUIDANCE_V_MAX_SUM_ERR, which should really have a sensible default anyway!!!!
On the other hand the max sum error was not adjusted in any airframe file when the GAIN_SCALER was added by Bart 2012-04-03.
So now it's nearly back to the same level as we had then, which was probably good?
This commit is contained in:
Felix Ruess
2013-02-07 17:45:49 +01:00
parent 9bb86e28c8
commit fd36199f34
@@ -52,8 +52,6 @@
#warning "GUIDANCE_V_INV_M has been removed. If you don't want to use adaptive hover, please define GUIDANCE_V_NOMINAL_HOVER_THROTTLE"
#endif
#define GUIDANCE_V_GAIN_SCALER 48
uint8_t guidance_v_mode;
int32_t guidance_v_ff_cmd;
int32_t guidance_v_fb_cmd;
@@ -298,11 +296,11 @@ __attribute__ ((always_inline)) static inline void run_hover_loop(bool_t in_flig
/* our error feed back command */
/* z-axis pointing down -> positive error means we need less thrust */
guidance_v_fb_cmd = ((-guidance_v_kp * err_z) >> 12) +
((-guidance_v_kd * err_zd) >> 21) +
((-guidance_v_ki * guidance_v_z_sum_err) >> 21);
guidance_v_fb_cmd = ((-guidance_v_kp * err_z) >> 7) +
((-guidance_v_kd * err_zd) >> 16) +
((-guidance_v_ki * guidance_v_z_sum_err) >> 16);
guidance_v_delta_t = guidance_v_ff_cmd + (guidance_v_fb_cmd * GUIDANCE_V_GAIN_SCALER);
guidance_v_delta_t = guidance_v_ff_cmd + guidance_v_fb_cmd;
/* bound the result */
Bound(guidance_v_delta_t, 0, MAX_PPRZ);