2015-05-29 23:12:49 -03:00
|
|
|
#include "Copter.h"
|
|
|
|
|
|
|
|
|
2015-01-06 11:51:51 -04:00
|
|
|
// Run landing gear controller at 10Hz
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::landinggear_update(){
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2015-01-06 11:51:51 -04:00
|
|
|
// If landing gear control is active, run update function.
|
2015-03-10 17:53:30 -03:00
|
|
|
if (check_if_auxsw_mode_used(AUXSW_LANDING_GEAR)){
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2015-01-06 11:51:51 -04:00
|
|
|
// last status (deployed or retracted) used to check for changes
|
|
|
|
static bool last_deploy_status;
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2015-01-06 15:53:01 -04:00
|
|
|
// if we are doing an automatic landing procedure, force the landing gear to deploy.
|
|
|
|
// To-Do: should we pause the auto-land procedure to give time for gear to come down?
|
2015-05-27 04:09:39 -03:00
|
|
|
if (control_mode == LAND ||
|
|
|
|
(control_mode==RTL && (rtl_state == RTL_LoiterAtHome || rtl_state == RTL_Land || rtl_state == RTL_FinalDescent)) ||
|
|
|
|
(control_mode == AUTO && auto_mode == Auto_Land) ||
|
|
|
|
(control_mode == AUTO && auto_mode == Auto_RTL && (rtl_state == RTL_LoiterAtHome || rtl_state == RTL_Land || rtl_state == RTL_FinalDescent))) {
|
2015-01-06 15:53:01 -04:00
|
|
|
landinggear.force_deploy(true);
|
2015-05-27 04:09:39 -03:00
|
|
|
}
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2015-01-06 11:51:51 -04:00
|
|
|
landinggear.update();
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2015-01-06 11:51:51 -04:00
|
|
|
// send event message to datalog if status has changed
|
|
|
|
if (landinggear.deployed() != last_deploy_status){
|
2015-01-06 22:51:06 -04:00
|
|
|
if (landinggear.deployed()) {
|
2015-01-06 11:51:51 -04:00
|
|
|
Log_Write_Event(DATA_LANDING_GEAR_DEPLOYED);
|
|
|
|
} else {
|
|
|
|
Log_Write_Event(DATA_LANDING_GEAR_RETRACTED);
|
|
|
|
}
|
|
|
|
}
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2015-01-06 11:51:51 -04:00
|
|
|
last_deploy_status = landinggear.deployed();
|
|
|
|
}
|
|
|
|
}
|