2015-01-06 00:24:05 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include "AP_LandingGear.h"
|
|
|
|
#include <AP_Relay/AP_Relay.h>
|
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <RC_Channel/RC_Channel.h>
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
2015-10-25 14:03:46 -03:00
|
|
|
const AP_Param::GroupInfo AP_LandingGear::var_info[] = {
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
// @Param: SERVO_RTRACT
|
|
|
|
// @DisplayName: Landing Gear Servo Retracted PWM Value
|
|
|
|
// @Description: Servo PWM value when landing gear is retracted
|
|
|
|
// @Range: 1000 2000
|
|
|
|
// @Units: pwm
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
2015-01-06 11:25:43 -04:00
|
|
|
AP_GROUPINFO("SERVO_RTRACT", 0, AP_LandingGear, _servo_retract_pwm, AP_LANDINGGEAR_SERVO_RETRACT_PWM_DEFAULT),
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
// @Param: SERVO_DEPLOY
|
|
|
|
// @DisplayName: Landing Gear Servo Deployed PWM Value
|
|
|
|
// @Description: Servo PWM value when landing gear is deployed
|
|
|
|
// @Range: 1000 2000
|
|
|
|
// @Units: pwm
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
2015-01-06 11:25:43 -04:00
|
|
|
AP_GROUPINFO("SERVO_DEPLOY", 1, AP_LandingGear, _servo_deploy_pwm, AP_LANDINGGEAR_SERVO_DEPLOY_PWM_DEFAULT),
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
AP_GROUPEND
|
|
|
|
};
|
|
|
|
|
|
|
|
/// enable - enable or disable land gear retraction
|
|
|
|
void AP_LandingGear::enable(bool on_off)
|
|
|
|
{
|
|
|
|
_retract_enabled = on_off;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// deploy - deploy landing gear
|
|
|
|
void AP_LandingGear::deploy()
|
2015-01-06 11:25:43 -04:00
|
|
|
{
|
|
|
|
// set servo PWM to deployed position
|
|
|
|
RC_Channel_aux::set_radio(RC_Channel_aux::k_landing_gear_control, _servo_deploy_pwm);
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
// set deployed flag
|
|
|
|
_deployed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// retract - retract landing gear
|
|
|
|
void AP_LandingGear::retract()
|
|
|
|
{
|
2015-01-06 11:25:43 -04:00
|
|
|
// set servo PWM to retracted position
|
|
|
|
RC_Channel_aux::set_radio(RC_Channel_aux::k_landing_gear_control, _servo_retract_pwm);
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
// reset deployed flag
|
|
|
|
_deployed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// update - should be called at 10hz
|
|
|
|
void AP_LandingGear::update()
|
2015-01-06 15:52:16 -04:00
|
|
|
{
|
|
|
|
// if there is a force deploy active, disable retraction, then reset force deploy to consume it
|
|
|
|
// gear will be deployed automatically because _retract_enabled is false.
|
|
|
|
// this will disable retract switch until it is cycled through deploy position
|
|
|
|
if ( _force_deploy){
|
|
|
|
enable(false);
|
|
|
|
force_deploy(false);
|
|
|
|
}
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
if (!_retract_enabled) {
|
|
|
|
// force deployment if retract is not enabled
|
|
|
|
deploy();
|
|
|
|
// retract is disabled until switch is placed into deploy position to prevent accidental retraction on bootup if switch was left in retract position
|
2015-01-06 22:52:59 -04:00
|
|
|
enable(_command_mode == LandingGear_Deploy);
|
2015-01-06 00:24:05 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-06 22:52:59 -04:00
|
|
|
if (_command_mode == LandingGear_Deploy){
|
2015-01-06 00:24:05 -04:00
|
|
|
deploy();
|
|
|
|
}
|
2015-01-06 22:52:59 -04:00
|
|
|
|
|
|
|
if (_command_mode == LandingGear_Retract){
|
2015-01-06 00:24:05 -04:00
|
|
|
retract();
|
|
|
|
}
|
|
|
|
}
|