2 * \file control_states.h
3 * \brief Control states declaration for control loop & ihm display
4 * \author Sylvain Gaeremynck <sylvain.gaeremynck@parrot.com>
8 #ifndef _CONTROL_STATES_H_
9 #define _CONTROL_STATES_H_
11 #ifdef CTRL_STATES_STRING
12 typedef char ctrl_string_t[32];
15 // Macros to customize preprocessing
16 // If this CTRL_STATES_STRING is not defined, this file declare several enumeration
17 // If user defines CTRL_STATES_STRING, this file will define several array of strings.
18 // Each string being equivalent to an enumeration entry
20 #ifdef CTRL_STATES_STRING
21 #define CVAR(a) #a /* Using # causes the first argument after the # to be returned as a string in quotes */
24 #define CVARZ(a) a = 0
30 * \brief control loop thread states.
31 * \brief this defines major states
33 #ifndef DO_NOT_INCLUDE_MAJOR_CTRL_STATES
34 #ifdef CTRL_STATES_STRING
35 static ctrl_string_t ctrl_states[] = {
39 CVARZ( CTRL_DEFAULT ),
43 CVAR( CTRL_HOVERING ),
45 CVAR( CTRL_TRANS_TAKEOFF ),
46 CVAR( CTRL_TRANS_GOTOFIX ),
47 CVAR( CTRL_TRANS_LANDING ),
48 #ifndef CTRL_STATES_STRING
58 * \brief flying states.
59 * \brief this is one of the minor state
61 #ifndef DO_NOT_INCLUDE_MINOR_CTRL_STATES
62 #ifdef CTRL_STATES_STRING
63 static ctrl_string_t flying_states[] = {
68 CVAR( FLYING_LOST_ALT ),
69 CVAR( FLYING_LOST_ALT_GO_DOWN ),
70 CVAR( FLYING_ALT_OUT_ZONE ),
71 CVAR( FLYING_COMBINED_YAW )
72 #ifndef CTRL_STATES_STRING
80 * \enum HOVERING_STATES
81 * \brief flying states.
82 * \brief this is one of the minor state
84 #ifndef DO_NOT_INCLUDE_MINOR_CTRL_STATES
85 #ifdef CTRL_STATES_STRING
86 static ctrl_string_t hovering_states[] = {
92 CVAR( HOVERING_YAW_LOST_ALT),
93 CVAR( HOVERING_YAW_LOST_ALT_GO_DOWN),
94 CVAR( HOVERING_ALT_OUT_ZONE),
95 CVAR( HOVERING_YAW_ALT_OUT_ZONE),
96 CVAR( HOVERING_LOST_ALT ),
97 CVAR( HOVERING_LOST_ALT_GO_DOWN ),
98 CVAR( HOVERING_LOST_COM ),
99 CVAR( LOST_COM_LOST_ALT ),
100 CVAR( LOST_COM_LOST_ALT_TOO_LONG ),
101 CVAR( LOST_COM_ALT_OK )
102 #ifndef CTRL_STATES_STRING
110 * \enum TAKEOFF_TRANS_STATES
111 * \brief take off states.
112 * \brief this is one of the minor state
114 #ifndef DO_NOT_INCLUDE_MINOR_CTRL_STATES
115 #ifdef CTRL_STATES_STRING
116 static ctrl_string_t takeoff_trans_states[] = {
120 CVARZ( TAKEOFF_GROUND ),
121 CVAR( TAKEOFF_AUTO ),
122 #ifndef CTRL_STATES_STRING
123 } TAKEOFF_TRANS_STATES;
130 * \enum GOTOFIX_TRANS_STATES
131 * \brief gotofix substates.
132 * \brief this is one of the minor state
134 #ifndef DO_NOT_INCLUDE_MINOR_CTRL_STATES
135 #ifdef CTRL_STATES_STRING
136 static ctrl_string_t gotofix_trans_states[] = {
141 CVAR( GOTOFIX_LOST_ALT ),
143 #ifndef CTRL_STATES_STRING
144 } GOTOFIX_TRANS_STATES;
151 * \enum LANDING_TRANS_STATES
152 * \brief landing states.
153 * \brief this is one of the minor state
155 #ifndef DO_NOT_INCLUDE_MINOR_CTRL_STATES
156 #ifdef CTRL_STATES_STRING
157 static ctrl_string_t landing_trans_states[] = {
161 CVARZ( LANDING_CLOSED_LOOP ),
162 CVAR( LANDING_OPEN_LOOP ),
163 CVAR( LANDING_OPEN_LOOP_FAST )
164 #ifndef CTRL_STATES_STRING
165 } LANDING_TRANS_STATES;
171 #ifdef CTRL_STATES_STRING
172 #ifndef DO_NOT_INCLUDE_CTRL_STATES_LINK
175 * \brief This array is used to link minor states & major state's strings
177 static ctrl_string_t* control_states_link[] = {
184 takeoff_trans_states,
185 gotofix_trans_states,
191 #endif // _CONTROL_STATES_H_