2015-01-06 00:24:05 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
/// @file AP_LandingGear.h
|
|
|
|
/// @brief Landing gear control library
|
2016-02-17 21:25:32 -04:00
|
|
|
#pragma once
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <AP_Common/AP_Common.h>
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
#define AP_LANDINGGEAR_SERVO_RETRACT_PWM_DEFAULT 1250 // default PWM value to move servo to when landing gear is up
|
|
|
|
#define AP_LANDINGGEAR_SERVO_DEPLOY_PWM_DEFAULT 1750 // default PWM value to move servo to when landing gear is down
|
|
|
|
|
2015-01-06 22:52:59 -04:00
|
|
|
// Gear command modes
|
|
|
|
enum LandingGearCommandMode {
|
|
|
|
LandingGear_Deploy,
|
|
|
|
LandingGear_Auto,
|
|
|
|
LandingGear_Retract
|
|
|
|
};
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
/// @class AP_LandingGear
|
|
|
|
/// @brief Class managing the control of landing gear
|
|
|
|
class AP_LandingGear {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Constructor
|
2015-01-06 11:25:43 -04:00
|
|
|
AP_LandingGear() :
|
2015-01-06 22:52:59 -04:00
|
|
|
_retract_enabled(false),
|
2015-01-06 00:24:05 -04:00
|
|
|
_deployed(false),
|
2015-01-06 22:52:59 -04:00
|
|
|
_force_deploy(false),
|
|
|
|
_command_mode(LandingGear_Deploy)
|
2015-01-06 00:24:05 -04:00
|
|
|
{
|
|
|
|
// setup parameter defaults
|
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// enabled - returns true if landing gear retract is enabled
|
|
|
|
bool enabled() const { return _retract_enabled; }
|
2015-01-06 22:52:59 -04:00
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
/// deployed - returns true if the landing gear is deployed
|
|
|
|
bool deployed() const { return _deployed; }
|
|
|
|
|
|
|
|
/// update - should be called at 10hz
|
|
|
|
void update();
|
2015-01-06 22:52:59 -04:00
|
|
|
|
|
|
|
/// set_cmd_mode - set command mode to deploy, auto or retract
|
|
|
|
void set_cmd_mode(LandingGearCommandMode cmd) { _command_mode = cmd; }
|
|
|
|
|
|
|
|
/// force_deploy - set to true to force gear to deploy
|
2015-01-06 15:52:16 -04:00
|
|
|
void force_deploy(bool force) { _force_deploy = force;}
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
bool _retract_enabled; // true if landing gear retraction is enabled
|
|
|
|
|
|
|
|
// Parameters
|
|
|
|
AP_Int16 _servo_retract_pwm; // PWM value to move servo to when gear is retracted
|
|
|
|
AP_Int16 _servo_deploy_pwm; // PWM value to move servo to when gear is deployed
|
|
|
|
|
|
|
|
// internal variables
|
|
|
|
bool _deployed; // true if the landing gear has been deployed, initialized false
|
2015-01-06 15:52:16 -04:00
|
|
|
bool _force_deploy; // used by main code to force landing gear to deploy, such as in Land mode
|
2015-01-06 22:52:59 -04:00
|
|
|
LandingGearCommandMode _command_mode; // pilots commanded control mode: Manual Deploy, Auto, or Manual Retract
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
/// enable - enable landing gear retraction
|
|
|
|
void enable(bool on_off);
|
|
|
|
|
|
|
|
/// retract - retract landing gear
|
|
|
|
void retract();
|
|
|
|
|
|
|
|
/// deploy - deploy the landing gear
|
|
|
|
void deploy();
|
|
|
|
};
|