State machine rewritten, compiles, WIP

This commit is contained in:
Anton Babushkin
2013-07-28 23:12:16 +04:00
parent 7c1693a877
commit 8c1067a017
5 changed files with 944 additions and 1183 deletions
+29 -26
View File
@@ -58,29 +58,28 @@
* @addtogroup topics @{
*/
/* State Machine */
/* main state machine */
typedef enum {
NAVIGATION_STATE_INIT = 0,
NAVIGATION_STATE_MANUAL_STANDBY,
NAVIGATION_STATE_MANUAL,
NAVIGATION_STATE_ASSISTED_STANDBY,
NAVIGATION_STATE_ASSISTED_SEATBELT,
NAVIGATION_STATE_ASSISTED_SIMPLE,
NAVIGATION_STATE_ASSISTED_DESCENT,
NAVIGATION_STATE_AUTO_STANDBY,
NAVIGATION_STATE_AUTO_READY,
NAVIGATION_STATE_AUTO_TAKEOFF,
NAVIGATION_STATE_AUTO_LOITER,
NAVIGATION_STATE_AUTO_MISSION,
NAVIGATION_STATE_AUTO_RTL,
NAVIGATION_STATE_AUTO_LAND
} navigation_state_t;
MAIN_STATE_MANUAL = 0,
MAIN_STATE_SEATBELT,
MAIN_STATE_EASY,
MAIN_STATE_AUTO,
} main_state_t;
/* navigation state machine */
typedef enum {
MANUAL_STANDBY = 0,
MANUAL_READY,
MANUAL_IN_AIR
} manual_state_t;
NAVIGATION_STATE_STANDBY = 0, // standby state, disarmed
NAVIGATION_STATE_DIRECT, // true manual control, no any stabilization
NAVIGATION_STATE_STABILIZE, // attitude stabilization
NAVIGATION_STATE_ALTHOLD, // attitude + altitude stabilization
NAVIGATION_STATE_VECTOR, // attitude + altitude + position stabilization
NAVIGATION_STATE_AUTO_READY, // AUTO, landed, reeady for takeoff
NAVIGATION_STATE_AUTO_TAKEOFF, // detect takeoff using land detector and switch to desired AUTO mode
NAVIGATION_STATE_AUTO_LOITER, // pause mission
NAVIGATION_STATE_AUTO_MISSION, // fly mission
NAVIGATION_STATE_AUTO_RTL, // Return To Launch, when home position switch to LAND
NAVIGATION_STATE_AUTO_LAND // land and switch to AUTO_READY when landed (detect using land detector)
} navigation_state_t;
typedef enum {
ARMING_STATE_INIT = 0,
@@ -103,16 +102,16 @@ typedef enum {
MODE_SWITCH_AUTO
} mode_switch_pos_t;
typedef enum {
ASSISTED_SWITCH_SEATBELT = 0,
ASSISTED_SWITCH_EASY
} assisted_switch_pos_t;
typedef enum {
RETURN_SWITCH_NONE = 0,
RETURN_SWITCH_RETURN
} return_switch_pos_t;
typedef enum {
ASSISTED_SWITCH_SEATBELT = 0,
ASSISTED_SWITCH_SIMPLE
} assisted_switch_pos_t;
typedef enum {
MISSION_SWITCH_NONE = 0,
MISSION_SWITCH_MISSION
@@ -175,7 +174,8 @@ struct vehicle_status_s
uint64_t failsave_lowlevel_start_time; /**< time when the lowlevel failsafe flag was set */
// uint64_t failsave_highlevel_begin; TO BE COMPLETED
navigation_state_t navigation_state; /**< current system state */
main_state_t main_state; /**< main state machine */
navigation_state_t navigation_state; /**< navigation state machine */
arming_state_t arming_state; /**< current arming state */
hil_state_t hil_state; /**< current hil state */
@@ -183,6 +183,8 @@ struct vehicle_status_s
int32_t system_id; /**< system id, inspired by MAVLink's system ID field */
int32_t component_id; /**< subsystem / component id, inspired by MAVLink's component ID field */
bool is_rotary_wing;
mode_switch_pos_t mode_switch;
return_switch_pos_t return_switch;
assisted_switch_pos_t assisted_switch;
@@ -198,6 +200,7 @@ struct vehicle_status_s
bool condition_home_position_valid; /**< indicates a valid home position (a valid home position is not always a valid launch) */
bool condition_local_position_valid;
bool condition_airspeed_valid; /**< set to true by the commander app if there is a valid airspeed measurement available */
bool condition_landed; /**< true if vehicle is landed, always true if disarmed */
bool rc_signal_found_once;
bool rc_signal_lost; /**< true if RC reception is terminally lost */