Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
formation.h
Go to the documentation of this file.
1 
7 #ifndef FORMATION_H
8 #define FORMATION_H
9 
10 #include "modules/datalink/datalink.h" // dl_buffer
11 #include "generated/airframe.h" // AC_ID
13 
14 #define FORM_MODE_GLOBAL 0
15 #define FORM_MODE_COURSE 1
16 
18 extern float form_prox;
19 extern uint8_t form_mode;
20 extern uint8_t leader_id;
21 
23 
24 struct slot_ {
25  enum slot_status status;
26  float east;
27  float north;
28  float alt;
29 };
30 
31 extern struct slot_ formation[];
32 
33 extern int formation_init(void);
34 
35 extern int add_slot(uint8_t _id, float slot_e, float slot_n, float slot_a);
36 
37 static inline void updateSlot(uint8_t id, float se, float sn, float sa)
38 {
39  formation[ti_acs_id[id]].east = se;
40  formation[ti_acs_id[id]].north = sn;
41  formation[ti_acs_id[id]].alt = sa;
42 }
43 
45 
46 static inline void parseFormationStatus(uint8_t *buf)
47 {
48  uint8_t ac_id = DL_FORMATION_STATUS_ac_id(buf);
49  uint8_t leader = DL_FORMATION_STATUS_leader_id(buf);
50  uint8_t status = DL_FORMATION_STATUS_status(buf);
51  if (ac_id == AC_ID) { leader_id = leader; }
52  else if (leader == leader_id) { updateFormationStatus(ac_id, status); }
53  else { updateFormationStatus(ac_id, UNSET); }
54 }
55 
56 static inline void parseFormationSlot(uint8_t *buf)
57 {
58  uint8_t ac_id = DL_FORMATION_SLOT_ac_id(buf);
59  uint8_t mode = DL_FORMATION_SLOT_mode(buf);
60  float slot_east = DL_FORMATION_SLOT_slot_east(buf);
61  float slot_north = DL_FORMATION_SLOT_slot_north(buf);
62  float slot_alt = DL_FORMATION_SLOT_slot_alt(buf);
63  updateSlot(ac_id, slot_east, slot_north, slot_alt);
64  if (ac_id == leader_id) { form_mode = mode; }
65 }
66 
67 extern int start_formation(void);
68 extern int stop_formation(void);
69 extern int formation_flight(void);
70 extern void formation_pre_call(void);
71 
72 #endif /* FORMATION_H */
static void parseFormationSlot(uint8_t *buf)
Definition: formation.h:56
enum slot_status status
Definition: formation.h:25
struct slot_ formation[]
Definition: formation.c:32
int formation_flight(void)
Definition: formation.c:124
slot_status
Definition: formation.h:22
@ LOST
Definition: formation.h:22
@ ACTIVE
Definition: formation.h:22
@ UNSET
Definition: formation.h:22
@ IDLE
Definition: formation.h:22
float alt
Definition: formation.h:28
float coef_form_pos
Definition: formation.h:17
float coef_form_course
Definition: formation.h:17
float east
Definition: formation.h:26
uint8_t leader_id
Definition: formation.c:29
static void updateSlot(uint8_t id, float se, float sn, float sa)
Definition: formation.h:37
int add_slot(uint8_t _id, float slot_e, float slot_n, float slot_a)
Definition: formation.c:80
int start_formation(void)
Definition: formation.c:91
uint8_t form_mode
Definition: formation.c:28
float north
Definition: formation.h:27
static void updateFormationStatus(uint8_t id, uint8_t status)
Definition: formation.h:44
float coef_form_speed
Definition: formation.h:17
static void parseFormationStatus(uint8_t *buf)
Definition: formation.h:46
float form_prox
Definition: formation.c:23
float coef_form_alt
Definition: formation.c:27
int formation_init(void)
Definition: formation.c:62
void formation_pre_call(void)
Definition: formation.c:254
int stop_formation(void)
Definition: formation.c:106
uint8_t ti_acs_id[NB_ACS_ID]
Definition: traffic_info.c:43
uint8_t status
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
Definition: sonar_bebop.c:65
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98