2015-08-11 03:28:44 -03:00
|
|
|
#include "AP_LandingGear.h"
|
|
|
|
#include <AP_Relay/AP_Relay.h>
|
|
|
|
#include <AP_Math/AP_Math.h>
|
2017-01-06 21:06:40 -04:00
|
|
|
#include <SRV_Channel/SRV_Channel.h>
|
2015-08-11 03:28:44 -03:00
|
|
|
#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
|
2017-05-15 20:21:16 -03:00
|
|
|
// @Description: Servo PWM value in microseconds when landing gear is retracted
|
2015-01-06 00:24:05 -04:00
|
|
|
// @Range: 1000 2000
|
2017-05-02 10:45:24 -03:00
|
|
|
// @Units: PWM
|
2015-01-06 00:24:05 -04:00
|
|
|
// @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
|
2017-05-15 20:21:16 -03:00
|
|
|
// @Description: Servo PWM value in microseconds when landing gear is deployed
|
2015-01-06 00:24:05 -04:00
|
|
|
// @Range: 1000 2000
|
2017-05-02 10:45:24 -03:00
|
|
|
// @Units: PWM
|
2015-01-06 00:24:05 -04:00
|
|
|
// @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
|
|
|
|
2017-08-04 03:28:33 -03:00
|
|
|
// @Param: STARTUP
|
|
|
|
// @DisplayName: Landing Gear Startup position
|
|
|
|
// @Description: Landing Gear Startup behaviour control
|
|
|
|
// @Values: 0:WaitForPilotInput, 1:Retract, 2:Deploy
|
|
|
|
// @User: Standard
|
|
|
|
AP_GROUPINFO("STARTUP", 2, AP_LandingGear, _startup_behaviour, (uint8_t)AP_LandingGear::LandingGear_Startup_WaitForPilotInput),
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
AP_GROUPEND
|
|
|
|
};
|
|
|
|
|
2017-08-04 03:28:33 -03:00
|
|
|
/// initialise state of landing gear
|
|
|
|
void AP_LandingGear::init()
|
|
|
|
{
|
|
|
|
switch ((enum LandingGearStartupBehaviour)_startup_behaviour.get()) {
|
|
|
|
default:
|
|
|
|
case LandingGear_Startup_WaitForPilotInput:
|
|
|
|
// do nothing
|
|
|
|
break;
|
|
|
|
case LandingGear_Startup_Retract:
|
|
|
|
retract();
|
|
|
|
break;
|
|
|
|
case LandingGear_Startup_Deploy:
|
|
|
|
deploy();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-10 01:07:38 -03:00
|
|
|
/// set landing gear position to retract, deploy or deploy-and-keep-deployed
|
|
|
|
void AP_LandingGear::set_position(LandingGearCommand cmd)
|
2015-01-06 00:24:05 -04:00
|
|
|
{
|
2017-06-10 01:07:38 -03:00
|
|
|
switch (cmd) {
|
|
|
|
case LandingGear_Retract:
|
2018-08-31 10:41:52 -03:00
|
|
|
retract();
|
2017-06-10 01:07:38 -03:00
|
|
|
break;
|
|
|
|
case LandingGear_Deploy:
|
|
|
|
deploy();
|
|
|
|
break;
|
|
|
|
}
|
2015-01-06 00:24:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// deploy - deploy landing gear
|
|
|
|
void AP_LandingGear::deploy()
|
2015-01-06 11:25:43 -04:00
|
|
|
{
|
|
|
|
// set servo PWM to deployed position
|
2017-01-06 21:06:40 -04:00
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_landing_gear_control, _servo_deploy_pwm);
|
2015-01-06 11:25:43 -04:00
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
// set deployed flag
|
2017-06-10 01:07:38 -03:00
|
|
|
_deployed = true;
|
2015-01-06 00:24:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// retract - retract landing gear
|
|
|
|
void AP_LandingGear::retract()
|
2017-06-10 01:07:38 -03:00
|
|
|
{
|
2015-01-06 11:25:43 -04:00
|
|
|
// set servo PWM to retracted position
|
2017-01-06 21:06:40 -04:00
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_landing_gear_control, _servo_retract_pwm);
|
2015-01-06 11:25:43 -04:00
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
// reset deployed flag
|
2017-06-10 01:07:38 -03:00
|
|
|
_deployed = false;
|
2015-01-06 00:24:05 -04:00
|
|
|
}
|