floatbrake_gain;// gain used during conversion of vehicle's velocity to lean angle during braking (calculated from brake_rate)
int16_tbrake_roll;// target roll angle during braking periods
int16_tbrake_pitch;// target pitch angle during braking periods
floatbrake_roll;// target roll angle during braking periods
floatbrake_pitch;// target pitch angle during braking periods
int16_tbrake_timeout_roll;// number of cycles allowed for the braking to complete, this timeout will be updated at half-braking
int16_tbrake_timeout_pitch;// number of cycles allowed for the braking to complete, this timeout will be updated at half-braking
int16_tbrake_angle_max_roll;// maximum lean angle achieved during braking. Used to determine when the vehicle has begun to flatten out so that we can re-estimate the braking time
int16_tbrake_angle_max_pitch;// maximum lean angle achieved during braking Used to determine when the vehicle has begun to flatten out so that we can re-estimate the braking time
floatbrake_angle_max_roll;// maximum lean angle achieved during braking. Used to determine when the vehicle has begun to flatten out so that we can re-estimate the braking time
floatbrake_angle_max_pitch;// maximum lean angle achieved during braking Used to determine when the vehicle has begun to flatten out so that we can re-estimate the braking time
int16_tbrake_to_loiter_timer;// cycles to mix brake and loiter controls in POSHOLD_BRAKE_TO_LOITER
// loiter related variables
int16_tcontroller_to_pilot_timer_roll;// cycles to mix controller and pilot controls in POSHOLD_CONTROLLER_TO_PILOT
int16_tcontroller_to_pilot_timer_pitch;// cycles to mix controller and pilot controls in POSHOLD_CONTROLLER_TO_PILOT
int16_tcontroller_final_roll;// final roll angle from controller as we exit brake or loiter mode (used for mixing with pilot input)
int16_tcontroller_final_pitch;// final pitch angle from controller as we exit brake or loiter mode (used for mixing with pilot input)
floatcontroller_final_roll;// final roll angle from controller as we exit brake or loiter mode (used for mixing with pilot input)
floatcontroller_final_pitch;// final pitch angle from controller as we exit brake or loiter mode (used for mixing with pilot input)
// wind compensation related variables
Vector2fwind_comp_ef;// wind compensation in earth frame, filtered lean angles from position controller
int16_twind_comp_roll;// roll angle to compensate for wind
int16_twind_comp_pitch;// pitch angle to compensate for wind
floatwind_comp_roll;// roll angle to compensate for wind
floatwind_comp_pitch;// pitch angle to compensate for wind
uint16_twind_comp_start_timer;// counter to delay start of wind compensation for a short time after loiter is engaged
int8_twind_comp_timer;// counter to reduce wind comp roll/pitch lean angle calcs to 10hz
// final output
int16_troll;// final roll angle sent to attitude controller
int16_tpitch;// final pitch angle sent to attitude controller
floatroll;// final roll angle sent to attitude controller
floatpitch;// final pitch angle sent to attitude controller
// braking angle has started decreasing so re-estimate braking time
brake_timeout_roll=1+(uint16_t)(LOOP_RATE_FACTOR*15L*(int32_t)(abs(brake_roll))/(10L*(int32_t)g.poshold_brake_rate));// the 1.2 (12/10) factor has to be tuned in flight, here it means 120% of the "normal" time.
brake_timeout_roll=1+(uint16_t)(LOOP_RATE_FACTOR*15L*(int32_t)(fabsf(brake_roll))/(10L*(int32_t)g.poshold_brake_rate));// the 1.2 (12/10) factor has to be tuned in flight, here it means 120% of the "normal" time.
// braking angle has started decreasing so re-estimate braking time
brake_timeout_pitch=1+(uint16_t)(LOOP_RATE_FACTOR*15L*(int32_t)(abs(brake_pitch))/(10L*(int32_t)g.poshold_brake_rate));// the 1.2 (12/10) factor has to be tuned in flight, here it means 120% of the "normal" time.
brake_timeout_pitch=1+(uint16_t)(LOOP_RATE_FACTOR*15L*(int32_t)(fabsf(brake_pitch))/(10L*(int32_t)g.poshold_brake_rate));// the 1.2 (12/10) factor has to be tuned in flight, here it means 120% of the "normal" time.
// initialise pilot_roll to 0, wind_comp will be updated to compensate and poshold_update_pilot_lean_angle function shall not smooth this transition at next iteration. so 0 is the right value
pilot_roll=0;
pilot_roll=0.0f;
// store final controller output for mixing with pilot input
// initialise pilot_pitch to 0, wind_comp will be updated to compensate and update_pilot_lean_angle function shall not smooth this transition at next iteration. so 0 is the right value
pilot_pitch=0;
pilot_pitch=0.0f;
// store final loiter outputs for mixing with pilot input