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
|
2017-06-10 01:11:00 -03:00
|
|
|
void Copter::landinggear_update()
|
|
|
|
{
|
2017-08-04 03:40:55 -03:00
|
|
|
// exit immediately if no landing gear output has been enabled
|
|
|
|
if (!SRV_Channels::function_assigned(SRV_Channel::k_landing_gear_control)) {
|
2017-08-04 03:04:18 -03:00
|
|
|
return;
|
|
|
|
}
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2017-08-04 03:04:18 -03:00
|
|
|
// last status (deployed or retracted) used to check for changes, initialised to startup state of landing gear
|
|
|
|
static bool last_deploy_status = landinggear.deployed();
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2017-08-04 03:04:18 -03: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?
|
2017-12-06 07:18:34 -04:00
|
|
|
if (flightmode->landing_gear_should_be_deployed()) {
|
2018-08-02 22:25:58 -03:00
|
|
|
landinggear.set_position(AP_LandingGear::LandingGear_Deploy);
|
2017-08-04 03:04:18 -03:00
|
|
|
}
|
2015-01-06 22:51:06 -04:00
|
|
|
|
2017-08-04 03:04:18 -03:00
|
|
|
// send event message to datalog if status has changed
|
|
|
|
if (landinggear.deployed() != last_deploy_status) {
|
|
|
|
if (landinggear.deployed()) {
|
|
|
|
Log_Write_Event(DATA_LANDING_GEAR_DEPLOYED);
|
|
|
|
} else {
|
|
|
|
Log_Write_Event(DATA_LANDING_GEAR_RETRACTED);
|
2015-01-06 11:51:51 -04:00
|
|
|
}
|
|
|
|
}
|
2017-08-04 03:04:18 -03:00
|
|
|
|
|
|
|
last_deploy_status = landinggear.deployed();
|
2015-01-06 11:51:51 -04:00
|
|
|
}
|