Paparazzi UAS  v7.0_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,
42  MissionCustom = 5
43 };
44 
51 };
52 
54  MissionRun = 0,
56  MissionUpdate = 2
57 };
58 
59 struct _mission_wp {
60  struct EnuCoor_f wp;
61 };
62 
64  struct EnuCoor_f center;
65  float radius;
66 };
67 
69  struct EnuCoor_f from;
70  struct EnuCoor_f to;
71 };
72 
73 #define MISSION_PATH_NB 5
74 struct _mission_path {
78 };
79 
80 #define MISSION_CUSTOM_MAX 12 // maximum number of parameters
81 #define MISSION_TYPE_SIZE 6
82 
89 typedef bool (*mission_custom_cb)(uint8_t nb, float *params, enum MissionRunFlag flag);
90 
94 };
95 
100 };
101 
103  enum MissionType type;
104  union {
105  struct _mission_wp mission_wp;
106  struct _mission_circle mission_circle;
107  struct _mission_segment mission_segment;
108  struct _mission_path mission_path;
109  struct _mission_custom mission_custom;
111 
112  float duration;
114 };
115 
119 #ifndef MISSION_ELEMENT_NB
120 #define MISSION_ELEMENT_NB 20
121 #endif
122 
126 #ifndef MISSION_REGISTER_NB
127 #define MISSION_REGISTER_NB 6
128 #endif
129 
130 struct _mission {
133  float element_time;
136 };
137 
138 extern struct _mission mission;
139 
142 extern void mission_init(void);
143 
149 extern bool mission_insert(enum MissionInsertMode insert, struct _mission_element *element);
150 
156 extern bool mission_register(mission_custom_cb cb, char *type);
157 
161 extern struct _mission_element *mission_get(void);
162 
167 
174 extern bool mission_point_of_lla(struct EnuCoor_f *point, struct LlaCoor_i *lla);
175 
185 extern int mission_run(void);
186 
191 extern void mission_status_report(void);
192 
195 extern int mission_parse_GOTO_WP(uint8_t *buf);
196 extern int mission_parse_GOTO_WP_LLA(uint8_t *buf);
197 extern int mission_parse_CIRCLE(uint8_t *buf);
198 extern int mission_parse_CIRCLE_LLA(uint8_t *buf);
199 extern int mission_parse_SEGMENT(uint8_t *buf);
200 extern int mission_parse_SEGMENT_LLA(uint8_t *buf);
201 extern int mission_parse_PATH(uint8_t *buf);
202 extern int mission_parse_PATH_LLA(uint8_t *buf);
203 extern int mission_parse_CUSTOM(uint8_t *buf);
204 extern int mission_parse_UPDATE(uint8_t *buf);
205 extern int mission_parse_GOTO_MISSION(uint8_t *buf);
206 extern int mission_parse_NEXT_MISSION(uint8_t *buf);
208 
209 #endif // MISSION_COMMON_H
210 
vector in Latitude, Longitude and Altitude
float params[MISSION_CUSTOM_MAX]
list of parameters
#define MISSION_TYPE_SIZE
struct _mission mission
int mission_parse_END_MISSION(uint8_t *buf)
union _mission_element::@299 element
int mission_parse_GOTO_WP_LLA(uint8_t *buf)
int mission_parse_CUSTOM(uint8_t *buf)
bool(* mission_custom_cb)(uint8_t nb, float *params, enum MissionRunFlag flag)
custom mission element callback
void mission_init(void)
Init mission structure.
struct EnuCoor_f wp
int mission_parse_NEXT_MISSION(uint8_t *buf)
int mission_parse_PATH_LLA(uint8_t *buf)
int mission_run(void)
Run mission.
bool mission_insert(enum MissionInsertMode insert, struct _mission_element *element)
Insert a mission element according to the insertion mode.
void mission_status_report(void)
Report mission status.
struct _mission_registered * reg
pointer to a registered custom mission element
int mission_parse_SEGMENT_LLA(uint8_t *buf)
char type[MISSION_TYPE_SIZE]
mission element identifier (5 char max + 1 \0)
mission_custom_cb cb
navigation/action function callback
struct EnuCoor_f to
uint8_t nb
number of parameters
MissionType
@ MissionCustom
@ MissionCircle
@ MissionWP
@ MissionSegment
@ MissionPath
struct _mission_registered registered[MISSION_REGISTER_NB]
int mission_parse_GOTO_WP(uint8_t *buf)
Parsing functions called when a mission message is received.
int mission_parse_CIRCLE(uint8_t *buf)
MissionRunFlag
@ MissionInit
first exec
@ MissionRun
normal run
@ MissionUpdate
param update
struct _mission_element elements[MISSION_ELEMENT_NB]
float element_time
time in second spend in the current element
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.
struct EnuCoor_f from
int mission_parse_UPDATE(uint8_t *buf)
struct _mission_element * mission_get_from_index(uint8_t index)
Get mission element by index.
int mission_parse_SEGMENT(uint8_t *buf)
enum MissionType type
uint8_t index
index of mission element
int mission_parse_GOTO_MISSION(uint8_t *buf)
#define MISSION_PATH_NB
#define MISSION_REGISTER_NB
Max number of registered nav/action callbacks can be redefined.
#define MISSION_ELEMENT_NB
Max number of elements in the tasks' list can be redefined.
bool mission_register(mission_custom_cb cb, char *type)
Register a new navigation or action callback function.
struct EnuCoor_f center
uint8_t insert_idx
inserstion index
uint8_t path_idx
struct EnuCoor_f path[MISSION_PATH_NB]
struct _mission_element * mission_get(void)
Get current mission element.
MissionInsertMode
@ ReplaceCurrent
replace current element
@ Append
add at the last position
@ ReplaceNexts
replace the next element and remove all the others
@ ReplaceAll
remove all elements and add the new one
@ Prepend
add before the current element
float duration
time to spend in the element (<= 0 to disable)
int mission_parse_PATH(uint8_t *buf)
#define MISSION_CUSTOM_MAX
uint8_t current_idx
current mission element index
int mission_parse_CIRCLE_LLA(uint8_t *buf)
Paparazzi floating point math for geodetic calculations.
vector in East North Up coordinates Units: meters
Paparazzi fixed point math for geodetic calculations.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98