Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
formation.h
Go to the documentation of this file.
1 
7 #ifndef FORMATION_H
8 #define FORMATION_H
9 
12 
13 #define FORM_MODE_GLOBAL 0
14 #define FORM_MODE_COURSE 1
15 
17 extern float form_prox;
18 extern int form_mode;
19 extern uint8_t leader_id;
20 
22 
23 struct slot_ {
25  float east;
26  float north;
27  float alt;
28 };
29 
30 extern struct slot_ formation[NB_ACS];
31 
32 extern int formation_init(void);
33 
34 extern int add_slot(uint8_t _id, float slot_e, float slot_n, float slot_a);
35 
36 #define UpdateSlot(_id, _se, _sn, _sa) { \
37  formation[the_acs_id[_id]].east = _se; \
38  formation[the_acs_id[_id]].north = _sn; \
39  formation[the_acs_id[_id]].alt = _sa; \
40 }
41 
42 #define UpdateFormationStatus(_id,_status) { formation[the_acs_id[_id]].status = _status; }
43 
44 #define ParseFormationStatus() { \
45  uint8_t ac_id = DL_FORMATION_STATUS_ac_id(dl_buffer); \
46  uint8_t leader = DL_FORMATION_STATUS_leader_id(dl_buffer); \
47  uint8_t status = DL_FORMATION_STATUS_status(dl_buffer); \
48  if (ac_id == AC_ID) leader_id = leader; \
49  else if (leader == leader_id) { UpdateFormationStatus(ac_id,status); } \
50  else { UpdateFormationStatus(ac_id,UNSET); } \
51 }
52 
53 #define ParseFormationSlot() { \
54  uint8_t ac_id = DL_FORMATION_SLOT_ac_id(dl_buffer); \
55  uint8_t mode = DL_FORMATION_SLOT_mode(dl_buffer); \
56  float slot_east = DL_FORMATION_SLOT_slot_east(dl_buffer); \
57  float slot_north = DL_FORMATION_SLOT_slot_north(dl_buffer); \
58  float slot_alt = DL_FORMATION_SLOT_slot_alt(dl_buffer); \
59  UpdateSlot(ac_id, slot_east, slot_north, slot_alt); \
60  if (ac_id == leader_id) form_mode = mode; \
61 }
62 
63 extern int start_formation(void);
64 
65 extern int stop_formation(void);
66 
67 extern int formation_flight(void);
68 
69 extern void formation_pre_call(void);
70 
71 #endif /* FORMATION_H */
float coef_form_speed
Definition: formation.c:29
float north
Definition: formation.h:26
float form_prox
Definition: formation.c:27
enum slot_status status
Definition: formation.h:24
int formation_init(void)
Definition: formation.c:66
uint8_t leader_id
Definition: formation.c:33
int stop_formation(void)
Definition: formation.c:107
struct slot_ formation[NB_ACS]
Definition: formation.c:36
int form_mode
Definition: formation.c:32
int add_slot(uint8_t _id, float slot_e, float slot_n, float slot_a)
Definition: formation.c:83
float coef_form_course
Definition: formation.c:30
float east
Definition: formation.h:25
Definition: formation.h:21
Definition: formation.h:21
float alt
Definition: formation.h:27
#define NB_ACS
Definition: traffic_info.h:33
unsigned char uint8_t
Definition: types.h:14
slot_status
Definition: formation.h:21
float coef_form_alt
Definition: formation.c:31
void formation_pre_call(void)
Definition: formation.c:247
Information relative to the other aircrafts.
int start_formation(void)
Definition: formation.c:93
float coef_form_pos
Definition: formation.c:28
int formation_flight(void)
Definition: formation.c:124