2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
5 * @addtogroup PathFollower FSM Brake
6 * @brief Executes brake seqeuence
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
11 * @brief Executes brake sequence fsm
13 * @see The GNU Public License (GPL) Version 3
15 *****************************************************************************/
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef VTOLBRAKEFSM_H
32 #define VTOLBRAKEFSM_H
34 #include "pathfollowerfsm.h"
36 // Brakeing state machine
38 BRAKE_STATE_INACTIVE
= 0, // Inactive state is the initialised state on startup
39 BRAKE_STATE_BRAKE
, // Initiate altitude hold before starting descent
40 BRAKE_STATE_HOLD
, // Waiting for attainment of landing descent rate
42 } PathFollowerFSM_BrakeState_T
;
45 FSMBRAKESTATUS_STATEEXITREASON_NONE
= 0
46 } VtolBrakeFSMStatusStateExitReasonOptions
;
48 class VtolBrakeFSM
: public PathFollowerFSM
{
50 static VtolBrakeFSM
*p_inst
;
54 static VtolBrakeFSM
*instance()
57 p_inst
= new VtolBrakeFSM();
61 int32_t Initialize(VtolPathFollowerSettingsData
*vtolPathFollowerSettings
,
62 PathDesiredData
*pathDesired
,
63 FlightStatusData
*flightStatus
,
64 PathStatusData
*ptr_pathStatus
);
68 PathFollowerFSMState_T
GetCurrentState(void);
69 uint8_t PositionHoldState(void);
73 // FSM instance data type
75 PathFollowerFSM_BrakeState_T currentState
;
76 uint32_t stateRunCount
;
77 uint32_t stateTimeoutCount
;
80 uint8_t observationCount
;
81 uint8_t observation2Count
;
84 // FSM state structure
86 void(VtolBrakeFSM::*setup
) (void); // Called to initialise the state
87 void(VtolBrakeFSM::*run
) (uint8_t); // Run the event detection code for a state
88 } PathFollowerFSM_BrakeStateHandler_T
;
91 VtolBrakeFSMData_T
*mBrakeData
;
92 VtolPathFollowerSettingsData
*vtolPathFollowerSettings
;
93 PathDesiredData
*pathDesired
;
94 PathStatusData
*pathStatus
;
95 FlightStatusData
*flightStatus
;
97 void setup_brake(void);
98 void run_brake(uint8_t);
100 void setState(PathFollowerFSM_BrakeState_T newState
, VtolBrakeFSMStatusStateExitReasonOptions reason
);
102 // void updateVtolBrakeFSMStatus();
104 void setStateTimeout(int32_t count
);
106 static PathFollowerFSM_BrakeStateHandler_T sBrakeStateTable
[BRAKE_STATE_SIZE
];
109 #endif // VTOLBRAKEFSM_H