Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
traffic_info.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) Pascal Brisset, Antoine Drouin (2008), Kirk Scheper (2016)
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
28 
29 #include "generated/airframe.h" // AC_ID
30 #include "generated/flight_plan.h" // NAV_MSL0
31 
33 #include "pprzlink/dl_protocol.h" // datalink messages
34 #include "pprzlink/messages.h" // telemetry messages
35 
36 #include "state.h"
37 #include "math/pprz_geodetic_utm.h"
39 
40 /* number of ac being tracked */
42 /* index of ac in the list of traffic info aircraft (ti_acs) */
44 /* container for available traffic info */
46 
47 /* Geoid height (msl) over ellipsoid [mm] */
49 
51 {
52  memset(ti_acs_id, 0, NB_ACS_ID);
53 
54  ti_acs_id[0] = 0; // ground station
55  ti_acs_id[AC_ID] = 1;
56  ti_acs[ti_acs_id[AC_ID]].ac_id = AC_ID;
57  ti_acs_idx = 2;
58 
59  geoid_height = NAV_MSL0;
60 }
61 
66 static void update_geoid_height(void) {
68  {
70  } else if(bit_is_set(gps.valid_fields, GPS_VALID_POS_LLA_BIT))
71  {
73  } /* default is just keep last available height */
74 }
75 
76 bool parse_acinfo_dl(void)
77 {
78  uint8_t sender_id = SenderIdOfPprzMsg(dl_buffer);
79  uint8_t msg_id = IdOfPprzMsg(dl_buffer);
80 
81  /* handle telemetry message */
82  if (sender_id > 0) {
83  switch (msg_id) {
84  case DL_GPS_SMALL: {
85  uint32_t multiplex_speed = DL_GPS_SMALL_multiplex_speed(dl_buffer);
86 
87  // decode compressed values
88  int16_t course = (int16_t)((multiplex_speed >> 21) & 0x7FF); // bits 31-21 course in decideg
89  if (course & 0x400) {
90  course |= 0xF800; // fix for twos complements
91  }
92  course *= 2; // scale course by resolution
93  int16_t gspeed = (int16_t)((multiplex_speed >> 10) & 0x7FF); // bits 20-10 ground speed cm/s
94  if (gspeed & 0x400) {
95  gspeed |= 0xF800; // fix for twos complements
96  }
97  int16_t climb = (int16_t)(multiplex_speed & 0x3FF); // bits 9-0 z climb speed in cm/s
98  if (climb & 0x200) {
99  climb |= 0xFC00; // fix for twos complements
100  }
101 
102  set_ac_info_lla(sender_id,
103  DL_GPS_SMALL_lat(dl_buffer),
104  DL_GPS_SMALL_lon(dl_buffer),
105  (int32_t)DL_GPS_SMALL_alt(dl_buffer) * 10,
106  course,
107  gspeed,
108  climb,
110  }
111  break;
112  case DL_GPS: {
113  set_ac_info_utm(sender_id,
114  DL_GPS_utm_east(dl_buffer),
115  DL_GPS_utm_north(dl_buffer),
116  DL_GPS_alt(dl_buffer),
117  DL_GPS_utm_zone(dl_buffer),
118  DL_GPS_course(dl_buffer),
119  DL_GPS_speed(dl_buffer),
120  DL_GPS_climb(dl_buffer),
121  DL_GPS_itow(dl_buffer));
122  }
123  break;
124  case DL_GPS_LLA: {
125  set_ac_info_lla(sender_id,
126  DL_GPS_LLA_lat(dl_buffer),
127  DL_GPS_LLA_lon(dl_buffer),
128  DL_GPS_LLA_alt(dl_buffer),
129  DL_GPS_LLA_course(dl_buffer),
130  DL_GPS_LLA_speed(dl_buffer),
131  DL_GPS_LLA_climb(dl_buffer),
132  DL_GPS_LLA_itow(dl_buffer));
133  }
134  break;
135  default:
136  return FALSE;
137  }
138  /* handle datalink message */
139  } else {
140  switch (msg_id) {
141  case DL_ACINFO: {
142  set_ac_info_utm(DL_ACINFO_ac_id(dl_buffer),
143  DL_ACINFO_utm_east(dl_buffer),
144  DL_ACINFO_utm_north(dl_buffer),
145  DL_ACINFO_alt(dl_buffer) * 10,
146  DL_ACINFO_utm_zone(dl_buffer),
147  DL_ACINFO_course(dl_buffer),
148  DL_ACINFO_speed(dl_buffer),
149  DL_ACINFO_climb(dl_buffer),
150  DL_ACINFO_itow(dl_buffer));
151  }
152  break;
153  case DL_ACINFO_LLA: {
154  set_ac_info_lla(DL_ACINFO_LLA_ac_id(dl_buffer),
155  DL_ACINFO_LLA_lat(dl_buffer),
156  DL_ACINFO_LLA_lon(dl_buffer),
157  DL_ACINFO_LLA_alt(dl_buffer) * 10,
158  DL_ACINFO_LLA_course(dl_buffer),
159  DL_ACINFO_LLA_speed(dl_buffer),
160  DL_ACINFO_LLA_climb(dl_buffer),
161  DL_ACINFO_LLA_itow(dl_buffer));
162  }
163  break;
164  default:
165  return FALSE;
166  }
167  }
168  return TRUE;
169 }
170 
171 
172 void set_ac_info_utm(uint8_t id, uint32_t utm_east, uint32_t utm_north, uint32_t alt, uint8_t utm_zone, uint16_t course,
174 {
175  if (ti_acs_idx < NB_ACS) {
176  if (id > 0 && ti_acs_id[id] == 0) { // new aircraft id
177  ti_acs_id[id] = ti_acs_idx++;
178  ti_acs[ti_acs_id[id]].ac_id = id;
179  }
180 
181  ti_acs[ti_acs_id[id]].status = 0;
182 
183  uint16_t my_zone = state.utm_origin_f.zone;
184  if (utm_zone == my_zone) {
185  ti_acs[ti_acs_id[id]].utm_pos_i.east = utm_east;
186  ti_acs[ti_acs_id[id]].utm_pos_i.north = utm_north;
187  ti_acs[ti_acs_id[id]].utm_pos_i.alt = alt;
188  ti_acs[ti_acs_id[id]].utm_pos_i.zone = utm_zone;
190 
191  } else { // store other uav in utm extended zone
192  struct UtmCoor_i utm = {.east = utm_east, .north = utm_north, .alt = alt, .zone = utm_zone};
193  struct LlaCoor_i lla;
194  lla_of_utm_i(&lla, &utm);
195  LLA_COPY(ti_acs[ti_acs_id[id]].lla_pos_i, lla);
197 
198  utm.zone = my_zone;
199  utm_of_lla_i(&utm, &lla);
200 
201  UTM_COPY(ti_acs[ti_acs_id[id]].utm_pos_i, utm);
202  SetBit(ti_acs[ti_acs_id[id]].status, AC_INFO_POS_UTM_I);
203  }
204 
205  ti_acs[ti_acs_id[id]].course = RadOfDeciDeg(course);
206  ti_acs[ti_acs_id[id]].gspeed = MOfCm(gspeed);
207  ti_acs[ti_acs_id[id]].climb = MOfCm(climb);
209 
210  ti_acs[ti_acs_id[id]].itow = itow;
211  }
212 }
213 
215  int16_t course, uint16_t gspeed, int16_t climb, uint32_t itow)
216 {
217  if (ti_acs_idx < NB_ACS) {
218  if (id > 0 && ti_acs_id[id] == 0) {
219  ti_acs_id[id] = ti_acs_idx++;
220  ti_acs[ti_acs_id[id]].ac_id = id;
221  }
222 
223  ti_acs[ti_acs_id[id]].status = 0;
224 
225  struct LlaCoor_i lla = {.lat = lat, .lon = lon, .alt = alt};
226  LLA_COPY(ti_acs[ti_acs_id[id]].lla_pos_i, lla);
228 
229  ti_acs[ti_acs_id[id]].course = RadOfDeciDeg(course);
230  ti_acs[ti_acs_id[id]].gspeed = MOfCm(gspeed);
231  ti_acs[ti_acs_id[id]].climb = MOfCm(climb);
232  SetBit(ti_acs[ti_acs_id[id]].status, AC_INFO_VEL_LOCAL_F);
233 
234  ti_acs[ti_acs_id[id]].itow = itow;
235  }
236 }
237 
238 /* Conversion funcitons for computing ac position in requested reference frame from
239  * any other available reference frame
240  */
241 
242 /* compute UTM position of aircraft with ac_id (int) */
244 {
245  uint8_t ac_nr = ti_acs_id[ac_id];
246  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I))
247  {
248  return;
249  }
250 
251  /* LLA_i -> UTM_i is more accurate than from UTM_f */
252  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I))
253  {
254  // use my zone as reference, i.e zone extend
256  utm_of_lla_i(&ti_acs[ac_nr].utm_pos_i, &ti_acs[ac_nr].lla_pos_i);
258  ti_acs[ac_nr].utm_pos_i.alt -= geoid_height;
259  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F))
260  {
261  UTM_BFP_OF_REAL(ti_acs[ac_nr].utm_pos_i, ti_acs[ac_nr].utm_pos_f);
262  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F))
263  {
264  // use my zone as reference, i.e zone extend
266  utm_of_lla_f(&ti_acs[ac_nr].utm_pos_f, &ti_acs[ac_nr].lla_pos_f);
268  ti_acs[ac_nr].utm_pos_f.alt -= geoid_height/1000.;
269  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F);
270  UTM_BFP_OF_REAL(ti_acs[ac_nr].utm_pos_i, ti_acs[ac_nr].utm_pos_f);
271  }
272  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I);
273 }
274 
275 /* compute LLA position of aircraft with ac_id (int) */
277 {
278  uint8_t ac_nr = ti_acs_id[ac_id];
279  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I))
280  {
281  return;
282  }
283 
284  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F))
285  {
286  LLA_BFP_OF_REAL(ti_acs[ac_nr].lla_pos_i, ti_acs[ac_nr].lla_pos_f);
287  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I))
288  {
289  lla_of_utm_i(&ti_acs[ac_nr].lla_pos_i, &ti_acs[ac_nr].utm_pos_i);
291  ti_acs[ac_nr].lla_pos_i.alt += geoid_height;
292  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F))
293  {
294  lla_of_utm_f(&ti_acs[ac_nr].lla_pos_f, &ti_acs[ac_nr].utm_pos_f);
296  ti_acs[ac_nr].lla_pos_f.alt += geoid_height/1000.;
297  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F);
298  LLA_BFP_OF_REAL(ti_acs[ac_nr].lla_pos_i, ti_acs[ac_nr].lla_pos_f);
299  }
300  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I);
301 }
302 
303 /* compute ENU position of aircraft with ac_id (int) */
305 {
306  uint8_t ac_nr = ti_acs_id[ac_id];
307  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_ENU_I))
308  {
309  return;
310  }
311 
312  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_ENU_F))
313  {
314  ENU_BFP_OF_REAL(ti_acs[ac_nr].enu_pos_i, ti_acs[ac_nr].enu_pos_f);
315  }
316  else if (state.ned_initialized_i)
317  {
318  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I) || bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I))
319  {
321  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F) || bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F))
322  {
324  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_ENU_F);
325  ENU_BFP_OF_REAL(ti_acs[ac_nr].enu_pos_i, ti_acs[ac_nr].enu_pos_f)
326  }
327  } else if (state.utm_initialized_f)
328  {
329  /* if utm origin is initialized we use the ENU = UTM - UTM_ORIGIN as in state to facilitate comparison */
330  ENU_OF_UTM_DIFF(ti_acs[ac_nr].enu_pos_f, *acInfoGetPositionUtm_f(ac_id), state.utm_origin_f);
331  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_ENU_F);
332  ENU_BFP_OF_REAL(ti_acs[ac_nr].enu_pos_i, ti_acs[ac_nr].enu_pos_f);
333  }
334  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_ENU_I);
335 }
336 
337 /* compute UTM position of aircraft with ac_id (float) */
339 {
340  uint8_t ac_nr = ti_acs_id[ac_id];
341  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F))
342  {
343  return;
344  }
345 
346  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I))
347  {
348  UTM_FLOAT_OF_BFP(ti_acs[ac_nr].utm_pos_f, ti_acs[ac_nr].utm_pos_i);
349  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I))
350  {
351  // use my zone as reference, i.e zone extend
353  utm_of_lla_i(&ti_acs[ac_nr].utm_pos_i, &ti_acs[ac_nr].lla_pos_i);
355  ti_acs[ac_nr].utm_pos_i.alt -= geoid_height;
356  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I);
357  UTM_FLOAT_OF_BFP(ti_acs[ac_nr].utm_pos_f, ti_acs[ac_nr].utm_pos_i);
358  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F))
359  {
360  /* not very accurate with float ~5cm */
362  utm_of_lla_f(&ti_acs[ac_nr].utm_pos_f, &ti_acs[ac_nr].lla_pos_f);
364  ti_acs[ac_nr].utm_pos_f.alt -= geoid_height/1000.;
365  }
366  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F);
367 }
368 
369 /* compute LLA position of aircraft with ac_id (float) */
371 {
372  uint8_t ac_nr = ti_acs_id[ac_id];
373  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F))
374  {
375  return;
376  }
377 
378  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I))
379  {
380  LLA_FLOAT_OF_BFP(ti_acs[ac_nr].lla_pos_f, ti_acs[ac_nr].lla_pos_i);
381  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I))
382  {
383  lla_of_utm_i(&ti_acs[ac_nr].lla_pos_i, &ti_acs[ac_nr].utm_pos_i);
385  ti_acs[ac_nr].lla_pos_i.alt += geoid_height;
386  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I);
387  LLA_FLOAT_OF_BFP(ti_acs[ac_nr].lla_pos_f, ti_acs[ac_nr].lla_pos_i);
388  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F))
389  {
390  lla_of_utm_f(&ti_acs[ac_nr].lla_pos_f, &ti_acs[ac_nr].utm_pos_f);
392  ti_acs[ac_nr].lla_pos_f.alt += geoid_height/1000.;
393  }
394  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F);
395 }
396 
397 /* compute ENU position of aircraft with ac_id (float) */
399 {
400  uint8_t ac_nr = ti_acs_id[ac_id];
401  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_ENU_F))
402  {
403  return;
404  }
405 
406  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_ENU_I))
407  {
408  ENU_FLOAT_OF_BFP(ti_acs[ac_nr].enu_pos_f, ti_acs[ac_nr].enu_pos_i);
409  }
410  else if (state.ned_initialized_i)
411  {
412  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_F) || bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_F))
413  {
415  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_LLA_I) || bit_is_set(ti_acs[ac_nr].status, AC_INFO_POS_UTM_I))
416  {
418  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_ENU_I);
419  ENU_FLOAT_OF_BFP(ti_acs[ac_nr].enu_pos_f, ti_acs[ac_nr].enu_pos_i);
420  }
421  } else if (state.utm_initialized_f)
422  {
423  /* if utm origin is initialized we use the ENU = UTM - UTM_ORIGIN as in state to facilitate comparison */
424  ENU_OF_UTM_DIFF(ti_acs[ac_nr].enu_pos_f, *acInfoGetPositionUtm_f(ac_id), state.utm_origin_f);
425  }
426  SetBit(ti_acs[ac_nr].status, AC_INFO_POS_ENU_F);
427 }
428 
429 /* compute ENU velocity of aircraft with ac_id (int) */
431 {
432  uint8_t ac_nr = ti_acs_id[ac_id];
433  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_I))
434  {
435  return;
436  }
437 
438  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_F))
439  {
440  SPEEDS_BFP_OF_REAL(ti_acs[ac_nr].enu_vel_i, ti_acs[ac_nr].enu_vel_f);
441  } else {
442  ti_acs[ac_nr].enu_vel_f.x = ti_acs[ac_nr].gspeed * sinf(ti_acs[ac_nr].course);
443  ti_acs[ac_nr].enu_vel_f.y = ti_acs[ac_nr].gspeed * cosf(ti_acs[ac_nr].course);
444  ti_acs[ac_nr].enu_vel_f.z = ti_acs[ac_nr].climb;
445  SetBit(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_F);
446  SPEEDS_BFP_OF_REAL(ti_acs[ac_nr].enu_vel_i, ti_acs[ac_nr].enu_vel_f);
447  }
448  SetBit(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_I);
449 }
450 
451 /* compute ENU position of aircraft with ac_id (float) */
453 {
454  uint8_t ac_nr = ti_acs_id[ac_id];
455  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_F))
456  {
457  return;
458  }
459 
460  if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_I))
461  {
462  SPEEDS_FLOAT_OF_BFP(ti_acs[ac_nr].enu_vel_f, ti_acs[ac_nr].enu_vel_i);
463  } else if (bit_is_set(ti_acs[ac_nr].status, AC_INFO_VEL_LOCAL_F)) {
464  ti_acs[ac_nr].enu_vel_f.x = ti_acs[ac_nr].gspeed * sinf(ti_acs[ac_nr].course);
465  ti_acs[ac_nr].enu_vel_f.y = ti_acs[ac_nr].gspeed * cosf(ti_acs[ac_nr].course);
466  ti_acs[ac_nr].enu_vel_f.z = ti_acs[ac_nr].climb;
467  }
468  SetBit(ti_acs[ac_nr].status, AC_INFO_VEL_ENU_F);
469 }
static struct UtmCoor_f * acInfoGetPositionUtm_f(uint8_t ac_id)
Get position from UTM coordinates (float).
Definition: traffic_info.h:361
unsigned short uint16_t
Definition: types.h:16
uint8_t ac_id
Definition: sim_ap.c:46
#define SPEEDS_BFP_OF_REAL(_ef, _ei)
Definition: pprz_algebra.h:722
status
Definition: anemotaxis.c:10
int32_t north
in centimeters
bool utm_initialized_f
True if utm origin (float) coordinate frame is initialsed.
Definition: state.h:236
void acInfoCalcPositionUtm_f(uint8_t ac_id)
Definition: traffic_info.c:338
struct LlaCoor_i lla_pos_i
Position in Latitude, Longitude and Altitude.
Definition: traffic_info.h:78
int32_t geoid_height
Definition: traffic_info.c:48
struct EnuCoor_f enu_vel_f
speed in North East Down coordinates
Definition: traffic_info.h:114
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
void set_ac_info_lla(uint8_t id, int32_t lat, int32_t lon, int32_t alt, int16_t course, uint16_t gspeed, int16_t climb, uint32_t itow)
Set Aircraft info.
Definition: traffic_info.c:214
void acInfoCalcVelocityEnu_f(uint8_t ac_id)
Definition: traffic_info.c:452
void acInfoCalcVelocityEnu_i(uint8_t ac_id)
Definition: traffic_info.c:430
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
Definition: gps.h:82
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
Definition: state.h:220
float climb
m/s
Definition: traffic_info.h:118
uint32_t itow
ms
Definition: traffic_info.h:119
void acInfoCalcPositionUtm_i(uint8_t ac_id)
Definition: traffic_info.c:243
void acInfoCalcPositionLla_i(uint8_t ac_id)
Definition: traffic_info.c:276
struct UtmCoor_f utm_pos_f
Position in UTM coordinates.
Definition: traffic_info.h:97
#define AC_INFO_POS_LLA_I
Definition: traffic_info.h:48
float gspeed
m/s
Definition: traffic_info.h:117
#define AC_INFO_POS_UTM_F
Definition: traffic_info.h:50
bool parse_acinfo_dl(void)
Parse all datalink or telemetry messages that contain global position of other acs Messages currently...
Definition: traffic_info.c:76
#define UTM_FLOAT_OF_BFP(_o, _i)
#define AC_INFO_VEL_ENU_I
Definition: traffic_info.h:53
int32_t east
in centimeters
void enu_of_lla_point_f(struct EnuCoor_f *enu, struct LtpDef_f *def, struct LlaCoor_f *lla)
#define SPEEDS_FLOAT_OF_BFP(_ef, _ei)
Definition: pprz_algebra.h:716
vector in Latitude, Longitude and Altitude
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
Definition: sys_time.h:74
uint16_t status
Holds the status bits for all acinfo position and velocity representations.
Definition: traffic_info.h:64
#define NB_ACS_ID
Definition: rssi.c:35
uint8_t ac_id
Definition: traffic_info.h:58
#define FALSE
Definition: std.h:5
int32_t alt
in millimeters above WGS84 reference ellipsoid
WGS-84 Geoid Heights.
void set_ac_info_utm(uint8_t id, uint32_t utm_east, uint32_t utm_north, uint32_t alt, uint8_t utm_zone, uint16_t course, uint16_t gspeed, uint16_t climb, uint32_t itow)
Set Aircraft info.
Definition: traffic_info.c:172
uint8_t zone
UTM zone number.
#define UTM_BFP_OF_REAL(_o, _i)
#define TRUE
Definition: std.h:4
int32_t hmsl
height above mean sea level (MSL) in mm
Definition: gps.h:88
void acInfoCalcPositionEnu_i(uint8_t ac_id)
Definition: traffic_info.c:304
float x
in meters
struct UtmCoor_i utm_pos_i
Position in UTM coordinates.
Definition: traffic_info.h:71
#define NB_ACS
Definition: rssi.c:38
static void update_geoid_height(void)
Update estimate of the geoid height Requires an available hsml and/or lla measurement, if not available value isn't updated.
Definition: traffic_info.c:66
void lla_of_utm_i(struct LlaCoor_i *lla, struct UtmCoor_i *utm)
Convert a UTM to LLA.
void lla_of_utm_f(struct LlaCoor_f *lla, struct UtmCoor_f *utm)
unsigned long uint32_t
Definition: types.h:18
signed short int16_t
Definition: types.h:17
#define ENU_FLOAT_OF_BFP(_o, _i)
#define GPS_VALID_HMSL_BIT
Definition: gps.h:53
int32_t lon
in degrees*1e7
#define AC_INFO_POS_ENU_I
Definition: traffic_info.h:49
static struct LlaCoor_f * acInfoGetPositionLla_f(uint8_t ac_id)
Get position from LLA coordinates (float).
Definition: traffic_info.h:372
void utm_of_lla_i(struct UtmCoor_i *utm, struct LlaCoor_i *lla)
Convert a LLA to UTM.
uint8_t zone
UTM zone number.
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
Definition: state.h:233
#define LLA_COPY(_pos1, _pos2)
Definition: pprz_geodetic.h:53
signed long int32_t
Definition: types.h:19
bool ned_initialized_i
true if local int coordinate frame is initialsed
Definition: state.h:171
#define AC_INFO_POS_ENU_F
Definition: traffic_info.h:52
void traffic_info_init(void)
Definition: traffic_info.c:50
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
Definition: state.h:166
float alt
in meters (normally above WGS84 reference ellipsoid)
Constants UTM (Mercator) projections.
void acInfoCalcPositionEnu_f(uint8_t ac_id)
Definition: traffic_info.c:398
int32_t alt
in millimeters (above WGS84 reference ellipsoid or above MSL)
struct LlaCoor_f lla_pos_f
Position in Latitude, Longitude and Altitude.
Definition: traffic_info.h:104
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
float z
in meters
#define AC_INFO_VEL_LOCAL_F
Definition: traffic_info.h:55
static int16_t course[3]
Definition: airspeed_uADC.c:57
struct acInfo ti_acs[NB_ACS]
Definition: traffic_info.c:45
#define LLA_BFP_OF_REAL(_o, _i)
uint8_t dl_buffer[MSG_SIZE]
Definition: main_demo5.c:64
#define GPS_VALID_POS_LLA_BIT
Definition: gps.h:49
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
Definition: gps.c:288
#define ENU_BFP_OF_REAL(_o, _i)
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition: gps.h:86
#define AC_INFO_POS_UTM_I
Definition: traffic_info.h:47
float course
rad
Definition: traffic_info.h:116
void enu_of_lla_point_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct LlaCoor_i *lla)
Convert a point from LLA to local ENU.
int32_t lat
in degrees*1e7
void acInfoCalcPositionLla_f(uint8_t ac_id)
Definition: traffic_info.c:370
static struct LlaCoor_i * acInfoGetPositionLla_i(uint8_t ac_id)
Get position from LLA coordinates (int).
Definition: traffic_info.h:339
uint8_t ti_acs_idx
Definition: traffic_info.c:41
float y
in meters
#define ENU_OF_UTM_DIFF(_pos, _utm1, _utm2)
Definition: pprz_geodetic.h:73
struct GpsState gps
global GPS state
Definition: gps.c:75
#define AC_INFO_POS_LLA_F
Definition: traffic_info.h:51
#define LLA_FLOAT_OF_BFP(_o, _i)
static int32_t wgs84_ellipsoid_to_geoid_i(int32_t lat, int32_t lon)
Get WGS84 ellipsoid/geoid separation.
struct State state
Definition: state.c:36
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)
#define AC_INFO_VEL_ENU_F
Definition: traffic_info.h:54
position in UTM coordinates
uint8_t ti_acs_id[NB_ACS_ID]
Definition: traffic_info.c:43
#define UTM_COPY(_u1, _u2)
Definition: pprz_geodetic.h:66