Paparazzi UAS  v5.18.0_stable
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 "subsystems/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_ {
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); }
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 */
traffic_info.h
add_slot
int add_slot(uint8_t _id, float slot_e, float slot_n, float slot_a)
Definition: formation.c:80
formation_init
int formation_init(void)
Definition: formation.c:62
stop_formation
int stop_formation(void)
Definition: formation.c:106
coef_form_speed
float coef_form_speed
Definition: formation.h:17
slot_::status
enum slot_status status
Definition: formation.h:25
status
uint8_t status
Definition: nps_radio_control_spektrum.c:101
updateFormationStatus
static void updateFormationStatus(uint8_t id, uint8_t status)
Definition: formation.h:44
updateSlot
static void updateSlot(uint8_t id, float se, float sn, float sa)
Definition: formation.h:37
parseFormationSlot
static void parseFormationSlot(uint8_t *buf)
Definition: formation.h:56
start_formation
int start_formation(void)
Definition: formation.c:91
coef_form_pos
float coef_form_pos
Definition: formation.h:17
slot_::east
float east
Definition: formation.h:26
formation
struct slot_ formation[]
Definition: formation.c:32
ACTIVE
@ ACTIVE
Definition: formation.h:22
slot_
Definition: formation.h:24
slot_::alt
float alt
Definition: formation.h:28
form_mode
uint8_t form_mode
Definition: formation.c:28
formation_flight
int formation_flight(void)
Definition: formation.c:124
uint8_t
unsigned char uint8_t
Definition: types.h:14
slot_::north
float north
Definition: formation.h:27
coef_form_course
float coef_form_course
Definition: formation.h:17
parseFormationStatus
static void parseFormationStatus(uint8_t *buf)
Definition: formation.h:46
leader_id
uint8_t leader_id
Definition: formation.c:29
slot_status
slot_status
Definition: formation.h:22
formation_pre_call
void formation_pre_call(void)
Definition: formation.c:254
mode
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:69
coef_form_alt
float coef_form_alt
Definition: formation.c:27
ac_id
uint8_t ac_id
Definition: sim_ap.c:48
UNSET
@ UNSET
Definition: formation.h:22
IDLE
@ IDLE
Definition: formation.h:22
ti_acs_id
uint8_t ti_acs_id[NB_ACS_ID]
Definition: traffic_info.c:43
form_prox
float form_prox
Definition: formation.c:23
LOST
@ LOST
Definition: formation.h:22