LP-500 HoTT Telemetry added device definitions
[librepilot.git] / flight / modules / PathFollower / inc / fixedwingautotakeoffcontroller.h
blob6930bd7db006457ce667b10bcac273764f4d5913
1 /**
2 ******************************************************************************
3 * @addtogroup LibrePilotModules LibrePilot Modules
4 * @{
5 * @addtogroup FixedWing CONTROL interface class
6 * @brief CONTROL interface class for pathfollower fixed wing fly controller
7 * @{
9 * @file fixedwingautotakeoffcontroller.h
10 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
11 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
12 * @brief Executes CONTROL for fixed wing fly objectives
14 * @see The GNU Public License (GPL) Version 3
16 *****************************************************************************/
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 * for more details.
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #ifndef FIXEDWINGAUTOTAKEOFFCONTROLLER_H
33 #define FIXEDWINGAUTOTAKEOFFCONTROLLER_H
34 #include "fixedwingflycontroller.h"
36 // AutoTakeoff state machine
37 typedef enum {
38 FW_AUTOTAKEOFF_STATE_INACTIVE = 0,
39 FW_AUTOTAKEOFF_STATE_LAUNCH,
40 FW_AUTOTAKEOFF_STATE_CLIMB,
41 FW_AUTOTAKEOFF_STATE_HOLD,
42 FW_AUTOTAKEOFF_STATE_ABORT,
43 FW_AUTOTAKEOFF_STATE_SIZE
44 } FixedWingAutoTakeoffControllerState_T;
46 class FixedWingAutoTakeoffController : public FixedWingFlyController {
47 protected:
48 static FixedWingAutoTakeoffController *p_inst;
50 public:
51 static FixedWingFlyController *instance()
53 if (!p_inst) {
54 p_inst = new FixedWingAutoTakeoffController();
56 return p_inst;
58 void Activate(void);
59 void UpdateAutoPilot(void);
61 private:
62 // variables
63 FixedWingAutoTakeoffControllerState_T state;
64 float initYaw;
65 float maxVelocity;
67 // functions
68 void setState(FixedWingAutoTakeoffControllerState_T setstate);
69 void setAttitude(bool unsafe);
70 float getAirspeed(void);
71 bool isUnsafe(void);
72 void run_inactive(void);
73 void run_launch(void);
74 void run_climb(void);
75 void run_hold(void);
76 void run_abort(void);
77 void init_inactive(void);
78 void init_launch(void);
79 void init_climb(void);
80 void init_hold(void);
81 void init_abort(void);
82 void(FixedWingAutoTakeoffController::*const runFunctionTable[FW_AUTOTAKEOFF_STATE_SIZE]) (void) = {
83 &FixedWingAutoTakeoffController::run_inactive,
84 &FixedWingAutoTakeoffController::run_launch,
85 &FixedWingAutoTakeoffController::run_climb,
86 &FixedWingAutoTakeoffController::run_hold,
87 &FixedWingAutoTakeoffController::run_abort
89 void(FixedWingAutoTakeoffController::*const initFunctionTable[FW_AUTOTAKEOFF_STATE_SIZE]) (void) = {
90 &FixedWingAutoTakeoffController::init_inactive,
91 &FixedWingAutoTakeoffController::init_launch,
92 &FixedWingAutoTakeoffController::init_climb,
93 &FixedWingAutoTakeoffController::init_hold,
94 &FixedWingAutoTakeoffController::init_abort
98 #endif // FIXEDWINGAUTOTAKEOFFCONTROLLER_H