CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ADSB/sagetech-sdk/target.h
Views: 1799
1
/**
2
* @copyright Copyright (c) 2020 Sagetech, Inc. All rights reserved.
3
*
4
* @File: target.h
5
* @Author: jim billmeyer
6
*
7
* @date December 11, 2020, 12:49 AM
8
*/
9
10
#ifndef TARGET_H
11
#define TARGET_H
12
13
#include <string.h>
14
#include <stdbool.h>
15
#include <stdint.h>
16
17
#define XPNDR_ADSB_TARGETS 400 // change this to the max number of
18
// target supported in the system.
19
20
typedef enum
21
{
22
trafLevel,
23
trafClimb,
24
trafDescend
25
} targetclimb_t;
26
27
typedef enum
28
{
29
trafTraffic,
30
trafAdvisory,
31
trafResolution
32
} targetalert_t;
33
34
// bit 0 - target found flag.
35
// bit 1 - target slot in use.
36
// bits 2-7 - the strike counter.
37
#define TARGET_FLAG_FOUND 0x01
38
#define TARGET_FLAG_USED 0x02
39
#define TARGET_FLAG_STRIKE_MASK 0xFC
40
41
typedef struct __attribute__((packed))
42
{
43
uint32_t icao;
44
bool airborne;
45
float bearing;
46
uint8_t distance;
47
int8_t altDiff;
48
int16_t nvel;
49
int16_t evel;
50
targetclimb_t climb;
51
targetalert_t alert;
52
#ifdef TARGET_SVR
53
msg_svr_t svr;
54
#endif
55
uint8_t flag; // used internally to purge stale targets.
56
} target_t;
57
58
typedef struct
59
{
60
uint32_t icao;
61
bool airborne;
62
float lat;
63
float lon;
64
int32_t alt;
65
int16_t heading;
66
uint16_t speed;
67
} ownship_t;
68
69
/**
70
* Gets the target list.
71
*
72
* @return The array of traffic targets.
73
*/
74
target_t *targetList(void);
75
76
/**
77
* Gets the ownship target information.
78
*
79
* @return The ownship target info.
80
*/
81
ownship_t *targetOwnship(void);
82
83
/**
84
* Find a target based on its icao number.
85
*
86
* @param icao The target's icao number
87
*
88
* @return A pointer to the target element or null if not found.
89
*/
90
target_t *targetFind(uint32_t icao);
91
92
/**
93
* Purge the traffic target list of stale traffic.
94
*
95
* The traffic gets purged if a find has not been done based
96
* on a strike counter.
97
*/
98
void targetPurge(void);
99
100
/**
101
* Adds a target to the traffic target list.
102
*
103
* @param target The target to add.
104
*/
105
void targetAdd(target_t *target);
106
107
/**
108
* Gets the target climb flag based on the vertical rate.
109
*
110
* @param vrate The current vertical rate of climb for the target.
111
*
112
* @return The level, climb or descend flag.
113
*/
114
targetclimb_t targetClimb(int16_t vrate);
115
116
/**
117
* Gets the traffic alert flag.
118
*
119
* @param dist The distance of the target to the ownship.
120
* @param alt The altitude difference between the target and ownship.
121
* @param nvel The NS speed vector of the target.
122
* @param evel The EW speed vector of the target.
123
*
124
* @return The traffic flag based on the parameters.
125
*/
126
targetalert_t targetAlert(double dist,
127
uint16_t alt,
128
int16_t nvel,
129
int16_t evel);
130
131
#endif /* TARGET_H */
132
133