-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_vinti6.c
231 lines (191 loc) · 6.11 KB
/
test_vinti6.c
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
221
222
223
224
225
226
227
228
229
230
231
#include "Unity/src/unity.h"
#include "Vinti6.h"
#include "sofa.h"
#include "sofam.h"
#include "stdio.h"
#include "coord_conversion.h"
void setUp(void)
{
}
void tearDown(void)
{
}
static void test_output_state_vect_for_leo(void)
{
// Earth
double planet[4] = {6378.137, 398600.5, 1082.62999e-6, -2.53215e-6};
// Initial time
double t0 = 0;
// Initial state vector
double x0[6] = {2328.96594, -5995.21600, 1719.97894,
2.91110113, -0.98164053, -7.09049922};
// Final time
double t1 = 10000;
// Output state vector
double x1[6];
// V_mean
double vmean[6];
// Propagate state vector with Vinti6
Vinti6(planet, t0, x0, t1, x1, vmean);
// Verify ECI state vector for x
TEST_ASSERT_EQUAL_FLOAT(-485.5222682586, x1[0]);
// Verify ECI state vector for y
TEST_ASSERT_EQUAL_FLOAT(-3123.5190458862, x1[1]);
// Verify ECI state vector for z
TEST_ASSERT_EQUAL_FLOAT(5796.3841118105, x1[2]);
// Verify ECI state vector for xd
TEST_ASSERT_EQUAL_FLOAT(3.9097618929, x1[3]);
// Verify ECI state vector for yd
TEST_ASSERT_EQUAL_FLOAT(-6.0846992371, x1[4]);
// Verify ECI state vector for zd
TEST_ASSERT_EQUAL_FLOAT(-2.8777002798, x1[5]);
}
static void test_output_state_vect_for_heo(void)
{
// Earth
double planet[4] = { 6378.137, 398600.5, 1082.62999e-6, -2.53215e-6 };
// Initial time
double t0 = 0;
// Initial state vector
double x0[6] = { -7401.6349600000, 1385.6790200000, 2315.3263700000,
-0.3163486652, -6.4974499606, 2.8772974990 };
// Final time
double t1 = 10000;
// Output state vector
double x1[6];
// V_mean
double vmean[6];
// Propagate state vector with Vinti6
Vinti6(planet, t0, x0, t1, x1, vmean);
// Verify ECI state vector for x
TEST_ASSERT_EQUAL_FLOAT(6712.0609670032, x1[0]);
// Verify ECI state vector for y
TEST_ASSERT_EQUAL_FLOAT(-3985.3574556188, x1[1]);
// Verify ECI state vector for z
TEST_ASSERT_EQUAL_FLOAT(-981.3263536512, x1[2]);
// Verify ECI state vector for xd
TEST_ASSERT_EQUAL_FLOAT(2.7986992752, x1[3]);
// Verify ECI state vector for yd
TEST_ASSERT_EQUAL_FLOAT(5.5685271110, x1[4]);
// Verify ECI state vector for zd
TEST_ASSERT_EQUAL_FLOAT(-3.4494924891, x1[5]);
}
void test_ITRS_to_GCRS(void)
{
double itrs[3], gcrs[3];
/* UTC. */
int iy, im, id, ih, min;
double sec;
iy = 2023;
im = 3;
id = 10;
ih = 12;
min = 0;
sec = 0.0;
double it2rc[3][3];
ecef_to_eci(iy, im, id, ih, min, sec, it2rc);
/* Test Transofrmation Matrix*/
itrs[0] = 4072000;
itrs[1] = 0;
itrs[2] = 5111000;
iauRxp(it2rc, itrs, gcrs); // itrs * transform matrix (it2rc)
// Compared with MATLAB output of ECEF to ECI:
// itrs = [4072000, 0, 5111000]
// utc = ([2023 3 10 12 0 0])
// GCRS = ecef2eci(utc,itrs)
// Verify GCRS (ECI) vector for x
TEST_ASSERT_FLOAT_WITHIN(9.5, 3988588.14831142, gcrs[0]);
// Verify GCRS (ECI) vector for y
TEST_ASSERT_FLOAT_WITHIN(9.5, -873464.380671477, gcrs[1]);
// Verify GCRS (ECI) vector for z
TEST_ASSERT_FLOAT_WITHIN(9.5, 5102129.90415257, gcrs[2]);
}
//static void test_LLA_to_ITRS_state_vect(void)
//{
// double lat_i = 51.64;
// double lon_i = 0;
// double alt_i = 170 * 10^3;
// double
//}
//
static void test_LLA_to_GCRS_state_vect(void)
{
// // Recieve first and last gps pings. i.e., (lat_i lon_i alt_i), (lat_f lon_f alt_f)
// // Where _i denotes initial gps ping, _f denotes final gps ping during one duty cycle
//
// // Convert initial and final lat lon alt to ECI => (xi yi zi), (xf yf zf)
// // Compute midpoint position. e.g., x0 = average(xi,xf)
double lla_i[3] = {51.64, 0, 170 * pow(10,3)};
double lla_f[3] = {51.4, 0.3, 170.01 * pow(10,3)};
double deltaT = 5;
int iy, im, id, ih, min;
double sec;
iy = 2023;
im = 3;
id = 10;
ih = 12;
min = 0;
sec = 0.0;
double StateVector[6] = {0,0,0,0,0,0};
StateVectorCalc(lla_i, lla_f, deltaT, iy, im, id, ih, min, sec, StateVector);
// Compared with MATLAB output of LLA to ECI:
// lla = [51.64, 0, 170 * 10^3]
// eci = lla2eci(lla,utc)
// Verify GCRS (ECI) State vector for x
TEST_ASSERT_FLOAT_WITHIN(9.5, 4001274.85988405, StateVector[0]);
// Verify GCRS (ECI) vector for y
TEST_ASSERT_FLOAT_WITHIN(9.5, -865283.469878299, StateVector[1]);
// Verify GCRS (ECI) vector for z
TEST_ASSERT_FLOAT_WITHIN(9.5, 5093921.692695, StateVector[2]);
// Verify GCRS (ECI) vector for dxdt
TEST_ASSERT_FLOAT_WITHIN(9.5, -5094.43509554826, StateVector[3]);
// Verify GCRS (ECI) vector for dydt
TEST_ASSERT_FLOAT_WITHIN(9.5, -3267.95358198741, StateVector[4]);
// Verify GCRS (ECI) vector for dzdt
TEST_ASSERT_FLOAT_WITHIN(9.5, 3421.56636752933, StateVector[5]);
//
// // Compute average velocity xd yd zd. e.g., xd0 = (xf-xi)/delta_t
//
// // Note: Average velocity is approximated to occur at the same time as the midpoint position
// // Verify ECI state vector for x i
// TEST_ASSERT_EQUAL_FLOAT(eci_i[0], 3854.79365731171)
//
// // Verify ECI state vector for y i
// TEST_ASSERT_EQUAL_FLOAT(eci_i[1], -1344.88376807795);
//
// // Verify ECI state vector for z i
// TEST_ASSERT_EQUAL_FLOAT(eci_i[2], 5102.79072122665);
//
// // Verify ECI state vector for x f
// TEST_ASSERT_EQUAL_FLOAT(eci_f[0], 3859.88218343259);
//
// // Verify ECI state vector for y f
// TEST_ASSERT_EQUAL_FLOAT(eci_f[1], -1335.71733537663);
//
// // Verify ECI state vector for z f
// TEST_ASSERT_EQUAL_FLOAT(eci_f[2], 5101.36097196698);
//
// // Values compared to MATLAB function's "lla2eci" output
}
//static void test_avg_veloc_calc(void)
//{
// // Compute average velocity xd yd zd. e.g., xd0 = (xf-xi)/delta_t
//
// // Verify ECI state vector for xd
// TEST_ASSERT_EQUAL_FLOAT(xd0, );
//
// // Verify ECI state vector for yd
// TEST_ASSERT_EQUAL_FLOAT(yd0, );
//
// // Verify ECI state vector for zd
// TEST_ASSERT_EQUAL_FLOAT(zd0, );
//}
int main(void)
{
UnityBegin("test_vinti6.c");
RUN_TEST(test_output_state_vect_for_leo);
RUN_TEST(test_output_state_vect_for_heo);
RUN_TEST(test_ITRS_to_GCRS);
RUN_TEST(test_LLA_to_GCRS_state_vect);
return UnityEnd();
}