MAV'RIC
state.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file state.h
34  *
35  * \author MAV'RIC Team
36  * \author Nicolas Dousse
37  *
38  * \brief Holds the current status of the MAV
39  *
40  ******************************************************************************/
41 
42 
43 #ifndef STATE_H_
44 #define STATE_H_
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #include "stdint.h"
51 #include "mav_modes.h"
52 #include "analog_monitor.h"
53 #include <stdbool.h>
54 
58 typedef enum
59 {
60  CLIMB_TO_SAFE_ALT,
61  FLY_TO_HOME_WP,
62  CRITICAL_LAND
63 } critical_behavior_enum;
64 
68 typedef enum
69 {
70  DESCENT_TO_SMALL_ALTITUDE,
71  DESCENT_TO_GND
72 } auto_landing_behavior_t;
73 
74 typedef enum MAV_MODE_FLAG mav_flag_t;
75 
79 typedef struct
80 {
82  mav_state_t mav_state;
83 
84  mav_mode_custom_t mav_mode_custom;
85 
86  int32_t simulation_mode;
87 
88  uint8_t autopilot_type;
89  uint8_t autopilot_name;
90 
91  uint16_t sensor_present;
92  uint16_t sensor_enabled;
93  uint16_t sensor_health;
94 
96  bool in_the_air;
98 
99  uint32_t remote_active;
101 
103 } state_t;
104 
105 
115 bool state_init(state_t *state, state_t* state_config, const analog_monitor_t* analog_monitor);
116 
123 void state_switch_to_active_mode(state_t* state,mav_state_t* mav_state);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif //STATE_H_
uint8_t autopilot_name
The name of the autopilot (MAV_AUTOPILOT enum in common.h)
Definition: state.h:89
uint8_t autopilot_type
The type of the autopilot (MAV_TYPE enum in common.h)
Definition: state.h:88
uint16_t sensor_present
The type of sensors that are present on the autopilot (Value of 0: not present. Value of 1: present...
Definition: state.h:91
bool nav_plan_active
Flag to tell that a flight plan (min 1 waypoint) is active.
Definition: state.h:95
mav_mode_custom_t mav_mode_custom
The value of the custom_mode.
Definition: state.h:84
mav_state_t mav_state
The value of the MAV state.
Definition: state.h:82
bool reset_position
Flag to enable the reset of the position estimation.
Definition: state.h:97
Analog monitor structure.
Definition: analog_monitor.h:90
The state structure.
Definition: state.h:79
uint32_t remote_active
Flag to tell whether the remote is active or not.
Definition: state.h:99
mav_mode_t mav_mode
The value of the MAV mode.
Definition: state.h:81
bool in_the_air
Flag to tell whether the vehicle is airborne or not.
Definition: state.h:96
uint16_t sensor_health
The health of sensors present on the autopilot (Value of 0: not enabled. Value of 1: enabled...
Definition: state.h:93
Definition: mav_modes.h:147
int32_t simulation_mode
The value of the simulation_mode (0: real, 1: simulation)
Definition: state.h:86
uint16_t sensor_enabled
The sensors enabled on the autopilot (Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control)
Definition: state.h:92
uint32_t use_mode_from_remote
Flag to tell whether the modes are coming from the remote or not.
Definition: state.h:100
const analog_monitor_t * analog_monitor
The pointer to the analog monitor structure.
Definition: state.h:102