-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathSUMData.cpp
220 lines (182 loc) · 4.93 KB
/
SUMData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*
* Copyright (c) 2015-2021 United States Government as represented by
* the National Aeronautics and Space Administration. No copyright
* is claimed in the United States under Title 17, U.S.Code. All Other
* Rights Reserved.
*/
#include "SUMData.h"
#include "Units.h"
#include "Util.h"
#include <string>
namespace larcfm {
SUMData::SUMData() {
s_err_ = 0.0;
v_err_ = 0.0;
s_EW_std_ = 0.0;
s_NS_std_ = 0.0;
s_EN_std_ = 0.0;
sz_std_ = 0.0;
v_EW_std_ = 0.0;
v_NS_std_ = 0.0;
v_EN_std_ = 0.0;
vz_std_ = 0.0;
}
SUMData::SUMData(const SUMData& sum) {
set(sum);
}
const SUMData& SUMData::EMPTY() {
static SUMData tmp;
return tmp;
}
double SUMData::get_s_EW_std() const {
return s_EW_std_;
}
double SUMData::get_s_EW_std(const std::string& u) const {
return Units::to(u,s_EW_std_);
}
double SUMData::get_s_NS_std() const {
return s_NS_std_;
}
double SUMData::get_s_NS_std(const std::string& u) const {
return Units::to(u,s_NS_std_);
}
double SUMData::get_s_EN_std() const {
return s_EN_std_;
}
double SUMData::get_s_EN_std(const std::string& u) const {
return Units::to(u,s_EN_std_);
}
double SUMData::get_sz_std() const {
return sz_std_;
}
double SUMData::get_sz_std(const std::string& u) const {
return Units::to(u,sz_std_);
}
double SUMData::get_v_EW_std() const {
return v_EW_std_;
}
double SUMData::get_v_EW_std(const std::string& u) const {
return Units::to(u,v_EW_std_);
}
double SUMData::get_v_NS_std() const {
return v_NS_std_;
}
double SUMData::get_v_NS_std(const std::string& u) const {
return Units::to(u,v_NS_std_);
}
double SUMData::get_v_EN_std() const {
return v_EN_std_;
}
double SUMData::get_v_EN_std(const std::string& u) const {
return Units::to(u,v_EN_std_);
}
double SUMData::get_vz_std() const {
return vz_std_;
}
double SUMData::get_vz_std(const std::string& u) const {
return Units::to(u,vz_std_);
}
void SUMData::set(const SUMData& sum) {
s_err_ = sum.s_err_;
v_err_ = sum.v_err_;
s_EW_std_ = sum.s_EW_std_;
s_NS_std_ = sum.s_NS_std_;
s_EN_std_ = sum.s_EN_std_;
sz_std_ = sum.sz_std_;
v_EW_std_ = sum.v_EW_std_;
v_NS_std_ = sum.v_NS_std_;
v_EN_std_ = sum.v_EN_std_;
vz_std_ = sum.vz_std_;
}
double SUMData::eigen_value_bound(double var1, double var2, double cov) {
double varAve = (var1 + var2)/2.0;
double det = var1*var2 - Util::sq(cov);
double temp1 = Util::sqrt_safe(varAve * varAve - det);
return varAve + temp1;
}
/**
* In PVS: covariance@h_pos_uncertainty and covariance@h_vel_uncertainty, but in Java they are not multiplied by the z-score yet.
*/
double SUMData::horizontal_uncertainty(double x_std, double y_std, double xy_std) {
return Util::sqrt_safe(eigen_value_bound(Util::sq(x_std),Util::sq(y_std),Util::sign(xy_std)*Util::sq(xy_std)));
}
/**
* s_EW_std: East/West position standard deviation in internal units
* s_NS_std: North/South position standard deviation in internal units
* s_EN_std: East/North position standard deviation in internal units
*/
void SUMData::setHorizontalPositionUncertainty(double s_EW_std, double s_NS_std, double s_EN_std) {
s_EW_std_ = s_EW_std;
s_NS_std_ = s_NS_std;
s_EN_std_ = s_EN_std;
s_err_ = horizontal_uncertainty(s_EW_std,s_NS_std,s_EN_std);
}
/**
* sz_std : Vertical position standard deviation in internal units
*/
void SUMData::setVerticalPositionUncertainty(double sz_std) {
sz_std_ = sz_std;
}
/**
* v_EW_std: East/West velocity standard deviation in internal units
* v_NS_std: North/South velocity standard deviation in internal units
* v_EN_std: East/North velocity standard deviation in internal units
*/
void SUMData::setHorizontalVelocityUncertainty(double v_EW_std, double v_NS_std, double v_EN_std) {
v_EW_std_ = v_EW_std;
v_NS_std_ = v_NS_std;
v_EN_std_ = v_EN_std;
v_err_ = horizontal_uncertainty(v_EW_std,v_NS_std,v_EN_std);
}
/**
* vz_std : Vertical speed standard deviation in internal units
*/
void SUMData::setVerticalSpeedUncertainty(double vz_std) {
vz_std_ = vz_std;
}
/**
* Set all uncertainties to 0
*/
void SUMData::resetUncertainty() {
s_err_ = 0.0;
v_err_ = 0.0;
s_EW_std_ = 0.0;
s_NS_std_ = 0.0;
s_EN_std_ = 0.0;
sz_std_ = 0.0;
v_EW_std_ = 0.0;
v_NS_std_ = 0.0;
v_EN_std_ = 0.0;
vz_std_ = 0.0;
}
/**
* @return Horizontal position rrror
*/
double SUMData::getHorizontalPositionError() const {
return s_err_;
}
/**
* @return vertical position error
*/
double SUMData::getVerticalPositionError() const {
return sz_std_;
}
/**
Set Horizontal speed error
*/
double SUMData::getHorizontalSpeedError() const {
return v_err_;
}
/**
* @return Vertical speed error
*/
double SUMData::getVerticalSpeedError() const {
return vz_std_;
}
/**
* Check if aircraft is using sensor uncertainty mitigation
*/
bool SUMData::is_SUM() const {
return s_err_ != 0.0 || sz_std_ != 0.0 || v_err_ != 0.0 || vz_std_ != 0.0;
}
}