Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
mission_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
30 #ifndef MISSION_COMMON_H
31 #define MISSION_COMMON_H
32 
33 #include "std.h"
35 #include "math/pprz_geodetic_int.h"
36 
38  MissionWP = 1,
43 };
44 
51 };
52 
54  MissionRun = 0,
57 };
58 
59 struct _mission_wp {
60  union {
61  struct EnuCoor_f wp_f;
62  struct EnuCoor_i wp_i;
63  } wp;
64 };
65 
67  union {
68  struct EnuCoor_f center_f;
69  struct EnuCoor_i center_i;
70  } center;
71 
72  float radius;
73 };
74 
76  union {
77  struct EnuCoor_f from_f;
78  struct EnuCoor_i from_i;
79  } from;
80 
81  union {
82  struct EnuCoor_f to_f;
83  struct EnuCoor_i to_i;
84  } to;
85 };
86 
87 #define MISSION_PATH_NB 5
88 struct _mission_path {
89  union {
90  struct EnuCoor_f path_f[MISSION_PATH_NB];
91  struct EnuCoor_i path_i[MISSION_PATH_NB];
92  } path;
93 
96 };
97 
98 #define MISSION_CUSTOM_MAX 12 // maximum number of parameters
99 #define MISSION_TYPE_SIZE 6
100 
107 typedef bool (*mission_custom_cb)(uint8_t nb, float *params, enum MissionRunFlag flag);
108 
112 };
113 
118 };
119 
122  union {
123  struct _mission_wp mission_wp;
124  struct _mission_circle mission_circle;
125  struct _mission_segment mission_segment;
126  struct _mission_path mission_path;
127  struct _mission_custom mission_custom;
128  } element;
129 
130  float duration;
132 };
133 
137 #ifndef MISSION_ELEMENT_NB
138 #define MISSION_ELEMENT_NB 20
139 #endif
140 
144 #ifndef MISSION_REGISTER_NB
145 #define MISSION_REGISTER_NB 6
146 #endif
147 
148 struct _mission {
151  float element_time;
154 };
155 
156 extern struct _mission mission;
157 
160 extern void mission_init(void);
161 
167 extern bool mission_insert(enum MissionInsertMode insert, struct _mission_element *element);
168 
174 extern bool mission_register(mission_custom_cb cb, char *type);
175 
180 extern bool mission_element_convert(struct _mission_element *el);
181 
185 extern struct _mission_element *mission_get(void);
186 
191 
198 extern bool mission_point_of_lla(struct EnuCoor_f *point, struct LlaCoor_i *lla);
199 
209 extern int mission_run(void);
210 
215 extern void mission_status_report(void);
216 
219 extern int mission_parse_GOTO_WP(uint8_t *buf);
220 extern int mission_parse_GOTO_WP_LLA(uint8_t *buf);
221 extern int mission_parse_CIRCLE(uint8_t *buf);
222 extern int mission_parse_CIRCLE_LLA(uint8_t *buf);
223 extern int mission_parse_SEGMENT(uint8_t *buf);
224 extern int mission_parse_SEGMENT_LLA(uint8_t *buf);
225 extern int mission_parse_PATH(uint8_t *buf);
226 extern int mission_parse_PATH_LLA(uint8_t *buf);
227 extern int mission_parse_CUSTOM(uint8_t *buf);
228 extern int mission_parse_UPDATE(uint8_t *buf);
229 extern int mission_parse_GOTO_MISSION(uint8_t *buf);
230 extern int mission_parse_NEXT_MISSION(uint8_t *buf);
231 extern int mission_parse_END_MISSION(uint8_t *buf);
232 
233 #endif // MISSION_COMMON_H
234 
_mission_element::type
enum MissionType type
Definition: mission_common.h:121
ReplaceAll
@ ReplaceAll
remove all elements and add the new one
Definition: mission_common.h:49
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
mission_point_of_lla
bool mission_point_of_lla(struct EnuCoor_f *point, struct LlaCoor_i *lla)
Get the ENU component of LLA mission point This function is firmware specific.
Definition: mission_fw_nav.c:38
MISSION_PATH_NB
#define MISSION_PATH_NB
Definition: mission_common.h:87
MissionCircle
@ MissionCircle
Definition: mission_common.h:39
_mission::current_idx
uint8_t current_idx
current mission element index
Definition: mission_common.h:153
mission_parse_GOTO_WP_LLA
int mission_parse_GOTO_WP_LLA(uint8_t *buf)
Definition: mission_common.c:214
MISSION_TYPE_SIZE
#define MISSION_TYPE_SIZE
Definition: mission_common.h:99
mission_get_from_index
struct _mission_element * mission_get_from_index(uint8_t index)
Get mission element by index.
Definition: mission_common.c:142
_mission_element
Definition: mission_common.h:120
_mission_segment::to
union _mission_segment::@286 to
MissionInit
@ MissionInit
first exec
Definition: mission_common.h:55
_mission_custom
Definition: mission_common.h:114
mission_register
bool mission_register(mission_custom_cb cb, char *type)
Register a new navigation or action callback function.
Definition: mission_common.c:115
pprz_geodetic_int.h
Paparazzi fixed point math for geodetic calculations.
ReplaceCurrent
@ ReplaceCurrent
replace current element
Definition: mission_common.h:48
MissionCustom
@ MissionCustom
Definition: mission_common.h:42
_mission::elements
struct _mission_element elements[MISSION_ELEMENT_NB]
Definition: mission_common.h:149
ReplaceNexts
@ ReplaceNexts
replace the next element and remove all the others
Definition: mission_common.h:50
mission_parse_END_MISSION
int mission_parse_END_MISSION(uint8_t *buf)
Definition: mission_common.c:473
point
Definition: common_nav.h:39
mission_parse_NEXT_MISSION
int mission_parse_NEXT_MISSION(uint8_t *buf)
Definition: mission_common.c:460
MISSION_CUSTOM_MAX
#define MISSION_CUSTOM_MAX
Definition: mission_common.h:98
mission_init
void mission_init(void)
Init mission structure.
Definition: mission_common.c:42
Prepend
@ Prepend
add before the current element
Definition: mission_common.h:47
MissionWP
@ MissionWP
Definition: mission_common.h:38
std.h
pprz_geodetic_float.h
Paparazzi floating point math for geodetic calculations.
mission_parse_PATH_LLA
int mission_parse_PATH_LLA(uint8_t *buf)
Definition: mission_common.c:352
_mission::insert_idx
uint8_t insert_idx
inserstion index
Definition: mission_common.h:152
_mission_circle::radius
float radius
Definition: mission_common.h:72
mission_parse_CIRCLE_LLA
int mission_parse_CIRCLE_LLA(uint8_t *buf)
Definition: mission_common.c:253
mission_parse_SEGMENT_LLA
int mission_parse_SEGMENT_LLA(uint8_t *buf)
Definition: mission_common.c:295
_mission_path::path
union _mission_path::@287 path
Append
@ Append
add at the last position
Definition: mission_common.h:46
_mission_circle::center
union _mission_circle::@284 center
_mission_wp
Definition: mission_common.h:59
mission_custom_cb
bool(* mission_custom_cb)(uint8_t nb, float *params, enum MissionRunFlag flag)
custom mission element callback
Definition: mission_common.h:107
mission_element_convert
bool mission_element_convert(struct _mission_element *el)
Convert mission element's points format if needed.
Definition: mission_common.c:158
mission_parse_CIRCLE
int mission_parse_CIRCLE(uint8_t *buf)
Definition: mission_common.c:235
MissionRun
@ MissionRun
normal run
Definition: mission_common.h:54
_mission_element::element
union _mission_element::@288 element
EnuCoor_f
vector in East North Up coordinates Units: meters
Definition: pprz_geodetic_float.h:72
mission_get
struct _mission_element * mission_get(void)
Get current mission element.
Definition: mission_common.c:162
_mission::registered
struct _mission_registered registered[MISSION_REGISTER_NB]
Definition: mission_common.h:150
mission_parse_SEGMENT
int mission_parse_SEGMENT(uint8_t *buf)
Definition: mission_common.c:275
_mission_registered::cb
mission_custom_cb cb
navigation/action function callback
Definition: mission_common.h:110
mission_parse_CUSTOM
int mission_parse_CUSTOM(uint8_t *buf)
Definition: mission_common.c:391
MissionInsertMode
MissionInsertMode
Definition: mission_common.h:45
_mission_registered
Definition: mission_common.h:109
_mission_custom::reg
struct _mission_registered * reg
pointer to a registered custom mission element
Definition: mission_common.h:115
MISSION_ELEMENT_NB
#define MISSION_ELEMENT_NB
Max number of elements in the tasks' list can be redefined.
Definition: mission_common.h:138
mission_insert
bool mission_insert(enum MissionInsertMode insert, struct _mission_element *element)
Insert a mission element according to the insertion mode.
Definition: mission_common.c:60
_mission_segment::from
union _mission_segment::@285 from
_mission_registered::type
char type[MISSION_TYPE_SIZE]
mission element identifier (5 char max + 1 \0)
Definition: mission_common.h:111
_mission_custom::params
float params[MISSION_CUSTOM_MAX]
list of parameters
Definition: mission_common.h:116
mission_parse_PATH
int mission_parse_PATH(uint8_t *buf)
Definition: mission_common.c:320
_mission_wp::wp
union _mission_wp::@283 wp
MISSION_REGISTER_NB
#define MISSION_REGISTER_NB
Max number of registered nav/action callbacks can be redefined.
Definition: mission_common.h:145
mission_parse_GOTO_MISSION
int mission_parse_GOTO_MISSION(uint8_t *buf)
Definition: mission_common.c:445
_mission_segment
Definition: mission_common.h:75
LlaCoor_i
vector in Latitude, Longitude and Altitude
Definition: pprz_geodetic_int.h:59
_mission_path
Definition: mission_common.h:88
_mission_element::index
uint8_t index
index of mission element
Definition: mission_common.h:131
MissionUpdate
@ MissionUpdate
param update
Definition: mission_common.h:56
mission_parse_UPDATE
int mission_parse_UPDATE(uint8_t *buf)
Definition: mission_common.c:413
mission
struct _mission mission
Definition: mission_common.c:40
mission_parse_GOTO_WP
int mission_parse_GOTO_WP(uint8_t *buf)
Parsing functions called when a mission message is received.
Definition: mission_common.c:197
mission_status_report
void mission_status_report(void)
Report mission status.
Definition: mission_common.c:172
type
timer subsystem type(config options) --------------------------------------------(advanced timers using RCC_APB1) TIM1 adc(if USE_AD_TIM1) radio_control/ppm(if USE_PPM_TIM1
_mission_path::nb
uint8_t nb
Definition: mission_common.h:95
mission_run
int mission_run(void)
Run mission.
Definition: mission_fw_nav.c:181
MissionPath
@ MissionPath
Definition: mission_common.h:41
_mission_custom::nb
uint8_t nb
number of parameters
Definition: mission_common.h:117
_mission_element::duration
float duration
time to spend in the element (<= 0 to disable)
Definition: mission_common.h:130
_mission
Definition: mission_common.h:148
_mission_circle
Definition: mission_common.h:66
MissionSegment
@ MissionSegment
Definition: mission_common.h:40
MissionRunFlag
MissionRunFlag
Definition: mission_common.h:53
_mission_path::path_idx
uint8_t path_idx
Definition: mission_common.h:94
EnuCoor_i
vector in East North Up coordinates
Definition: pprz_geodetic_int.h:77
_mission::element_time
float element_time
time in second spend in the current element
Definition: mission_common.h:151
MissionType
MissionType
Definition: mission_common.h:37