uint8_tbraking_time_updated_roll:1;// true once we have re-estimated the braking time. This is done once as the vehicle begins to flatten out after braking
uint8_tbraking_time_updated_pitch:1;// true once we have re-estimated the braking time. This is done once as the vehicle begins to flatten out after braking
// pilot input related variables
floatpilot_roll;// pilot requested roll angle (filtered to slow returns to zero)
floatpilot_pitch;// pilot requested roll angle (filtered to slow returns to zero)
// braking related variables
floatbrake_gain;// gain used during conversion of vehicle's velocity to lean angle during braking (calculated from brake_rate)
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
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
struct{
uint8_ttime_updated_roll:1;// true once we have re-estimated the braking time. This is done once as the vehicle begins to flatten out after braking
uint8_ttime_updated_pitch:1;// true once we have re-estimated the braking time. This is done once as the vehicle begins to flatten out after braking
floatgain;// gain used during conversion of vehicle's velocity to lean angle during braking (calculated from rate)
floatroll;// target roll angle during braking periods
floatpitch;// target pitch angle during braking periods
int16_ttimeout_roll;// number of cycles allowed for the braking to complete, this timeout will be updated at half-braking
int16_ttimeout_pitch;// number of cycles allowed for the braking to complete, this timeout will be updated at half-braking
floatangle_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
floatangle_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_tto_loiter_timer;// cycles to mix brake and loiter controls in POSHOLD_TO_LOITER
}brake;
// loiter related variables
int16_tcontroller_to_pilot_timer_roll;// cycles to mix controller and pilot controls in POSHOLD_CONTROLLER_TO_PILOT
// braking angle has started decreasing so re-estimate braking 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_time_updated_roll=true;
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.
brake.time_updated_roll=true;
}
}
// if velocity is very low reduce braking time to 0.5seconds
// braking angle has started decreasing so re-estimate braking 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.
braking_time_updated_pitch=true;
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.
brake.time_updated_pitch=true;
}
}
// if velocity is very low reduce braking time to 0.5seconds