satellite-mobility-observer-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
27 #include "../model/satellite-constant-position-mobility-model.h"
28 #include "../model/satellite-mobility-observer.h"
29 #include "../model/satellite-propagation-delay-model.h"
30 #include "../model/satellite-utils.h"
31 #include "../utils/satellite-env-variables.h"
32 
33 #include "ns3/double.h"
34 #include "ns3/log.h"
35 #include "ns3/simulator.h"
36 #include "ns3/singleton.h"
37 #include "ns3/test.h"
38 
39 using namespace ns3;
40 
41 // definitions for reference elevation angle table, g_refElAngles
42 static const uint32_t g_latitudeCount = 19;
43 static const uint32_t g_longitudeCount = 37;
44 
45 static const double g_firstLatValue = -90.00;
46 static const double g_firstLonValue = -180.00;
47 
48 static const double g_latStep = 10.00;
49 static const double g_lonStep = 10.00;
50 
51 // reference test values, when sphere (radius 6378137 [m]) is used as reference ellipsoid
52 // satellite is at location latitude 0.00, longitude 33.00, altitude 35786000 [m]
53 // values in table are with altitude 0 [m]
54 //
55 // row = latitude from -90 ... 90 with 10 degrees step
56 // col = longitude from -180 ... 180 with 10 degrees step
57 //
59  {
60  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
61  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
62  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
63  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
64  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
65  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
66  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
67  -8.6018742e+00, -8.6018742e+00,
68  },
69 
70  {
71  -1.6704625e+01, -1.7493055e+01, -1.8012186e+01, -1.8246050e+01, -1.8187401e+01,
72  -1.7838061e+01, -1.7208826e+01, -1.6318974e+01, -1.5195434e+01, -1.3871747e+01,
73  -1.2386929e+01, -1.0784340e+01, -9.1106057e+00, -7.4145745e+00, -5.7462845e+00,
74  -4.1558514e+00, -2.6922153e+00, -1.4016983e+00, -3.2637365e-01, 4.9768367e-01,
75  1.0421305e+00, 1.2878816e+00, 1.2262239e+00, 8.5934923e-01, 2.0021921e-01,
76  -7.2821655e-01, -1.8943228e+00, -3.2594126e+00, -4.7795075e+00, -6.4070521e+00,
77  -8.0924743e+00, -9.7855486e+00, -1.1436585e+01, -1.2997501e+01, -1.4422852e+01,
78  -1.5670881e+01, -1.6704625e+01,
79  },
80 
81  {
82  -2.4576013e+01, -2.6154391e+01, -2.7198607e+01, -2.7670434e+01, -2.7552023e+01,
83  -2.6847888e+01, -2.5584395e+01, -2.3806912e+01, -2.1575549e+01, -1.8960673e+01,
84  -1.6039194e+01, -1.2892100e+01, -9.6032842e+00, -6.2593405e+00, -2.9498717e+00,
85  2.3226561e-01, 3.1913676e+00, 5.8305290e+00, 8.0550058e+00, 9.7774715e+00,
86  1.0924793e+01, 1.1445248e+01, 1.1314514e+01, 1.0538752e+01, 9.1538106e+00,
87  7.2208060e+00, 4.8194220e+00, 2.0406964e+00, -1.0192362e+00, -4.2636521e+00,
88  -7.5978706e+00, -1.0930338e+01, -1.4172702e+01, -1.7239467e+01, -2.0047834e+01,
89  -2.2518238e+01, -2.4576013e+01,
90  },
91 
92  {
93  -3.2150830e+01, -3.4559650e+01, -3.6169920e+01, -3.6902409e+01, -3.6718280e+01,
94  -3.5627470e+01, -3.3686477e+01, -3.0986701e+01, -2.7639000e+01, -2.3760356e+01,
95  -1.9465727e+01, -1.4865194e+01, -1.0065058e+01, -5.1713370e+00, -2.9441703e-01,
96  4.4461307e+00, 8.9176003e+00, 1.2972465e+01, 1.6450908e+01, 1.9189792e+01,
97  2.1039320e+01, 2.1885576e+01, 2.1672558e+01, 2.0414606e+01, 1.8193117e+01,
98  1.5139226e+01, 1.1410534e+01, 7.1704160e+00, 2.5744409e+00, -2.2357749e+00,
99  -7.1331465e+00, -1.2002325e+01, -1.6735261e+01, -2.1226341e+01, -2.5368068e+01,
100  -2.9048360e+01, -3.2150830e+01,
101  },
102 
103  {
104  -3.9340005e+01, -4.2663495e+01, -4.4926798e+01, -4.5969303e+01, -4.5706421e+01,
105  -4.4160181e+01, -4.1450862e+01, -3.7756269e+01, -3.3266805e+01, -2.8156901e+01,
106  -2.2575234e+01, -1.6647050e+01, -1.0482042e+01, -4.1841877e+00, 2.1377900e+00,
107  8.3595752e+00, 1.4330196e+01, 1.9861842e+01, 2.4723918e+01, 2.8648396e+01,
108  3.1356671e+01, 3.2613755e+01, 3.2296196e+01, 3.0436121e+01, 2.7209219e+01,
109  2.2875939e+01, 1.7715647e+01, 1.1983180e+01, 5.8918217e+00, -3.8641798e-01,
110  -6.7125435e+00, -1.2969801e+01, -1.9052647e+01, -2.4856049e+01, -3.0265212e+01,
111  -3.5146265e+01, -3.9340005e+01,
112  },
113 
114  {
115  -4.6006510e+01, -5.0377333e+01, -5.3449005e+01, -5.4896833e+01, -5.4529539e+01,
116  -5.2398361e+01, -4.8765619e+01, -4.3969265e+01, -3.8312737e+01, -3.2027268e+01,
117  -2.5278415e+01, -1.8185662e+01, -1.0841716e+01, -3.3289119e+00, 4.2661058e+00,
118  1.1837327e+01, 1.9241765e+01, 2.6277592e+01, 3.2658732e+01, 3.7994962e+01,
119  4.1806163e+01, 4.3619473e+01, 4.3158455e+01, 4.0497024e+01, 3.6015197e+01,
120  3.0207381e+01, 2.3523617e+01, 1.6311315e+01, 8.8197845e+00, 1.2243958e+00,
121  -6.3490162e+00, -1.3804110e+01, -2.1057702e+01, -2.8025122e+01, -3.4605077e+01,
122  -4.0662117e+01, -4.6006510e+01,
123  },
124 
125  {
126  -5.1930043e+01, -5.7520985e+01, -6.1664013e+01, -6.3706420e+01, -6.3181670e+01,
127  -6.0221250e+01, -5.5425332e+01, -4.9408454e+01, -4.2595155e+01, -3.5239767e+01,
128  -2.7490147e+01, -1.9435029e+01, -1.1133295e+01, -2.6328414e+00, 6.0148092e+00,
129  1.4739663e+01, 2.3433938e+01, 3.1922592e+01, 3.9915329e+01, 4.6932754e+01,
130  5.2230631e+01, 5.4870709e+01, 5.4190691e+01, 5.0376730e+01, 4.4284022e+01,
131  3.6803157e+01, 2.8567067e+01, 1.9969144e+01, 1.1246230e+01, 2.5419583e+00,
132  -6.0538155e+00, -1.4480449e+01, -2.2689549e+01, -3.0630706e+01, -3.8235778e+01,
133  -4.5396738e+01, -5.1930043e+01,
134  },
135 
136  {
137  -5.6763473e+01, -6.3721803e+01, -6.9350213e+01, -7.2406072e+01, -7.1595300e+01,
138  -6.7322356e+01, -6.1051957e+01, -5.3761638e+01, -4.5899432e+01, -3.7661064e+01,
139  -2.9133792e+01, -2.0356792e+01, -1.1348040e+01, -2.1185707e+00, 7.3174061e+00,
140  1.6932120e+01, 2.6669719e+01, 3.6421102e+01, 4.5972840e+01, 5.4890661e+01,
141  6.2253932e+01, 6.6299419e+01, 6.5223137e+01, 5.9587071e+01, 5.1443019e+01,
142  4.2196812e+01, 3.2529315e+01, 2.2765306e+01, 1.3067511e+01, 3.5195690e+00,
143  -5.8361176e+00, -1.4978614e+01, -2.3896132e+01, -3.2576186e+01, -4.0994468e+01,
144  -4.9096993e+01, -5.6763473e+01,
145  },
146 
147  {
148  -6.0018125e+01, -6.8243134e+01, -7.5780862e+01, -8.0930434e+01, -7.9407340e+01,
149  -7.2901185e+01, -6.5003558e+01, -5.6632347e+01, -4.8002623e+01, -3.9171269e+01,
150  -3.0147310e+01, -2.0921952e+01, -1.1479516e+01, -1.8030130e+00, 8.1215023e+00,
151  1.8300042e+01, 2.8723815e+01, 3.9357750e+01, 5.0116479e+01, 6.0796148e+01,
152  7.0799966e+01, 7.7720429e+01, 7.5667940e+01, 6.6957660e+01, 5.6556579e+01,
153  4.5806960e+01, 3.5082849e+01, 2.4526346e+01, 1.4198272e+01, 4.1213054e+00,
154  -5.7027141e+00, -1.5283649e+01, -2.4637188e+01, -3.3780337e+01, -4.2726850e+01,
155  -5.1480271e+01, -6.0018125e+01,
156  },
157 
158  {
159  -6.1181558e+01, -6.9969924e+01, -7.8698721e+01, -8.7394065e+01, -8.3918289e+01,
160  -7.5212668e+01, -6.6463206e+01, -5.7643574e+01, -4.8726780e+01, -3.9685056e+01,
161  -3.0489905e+01, -2.1112394e+01, -1.1523783e+01, -1.6966442e+00, 8.3934130e+00,
162  1.8765296e+01, 2.9429276e+01, 4.0383351e+01, 5.1609653e+01, 6.3071832e+01,
163  7.4714498e+01, 8.6465700e+01, 8.1757338e+01, 7.0040060e+01, 5.8461787e+01,
164  4.7088358e+01, 3.5967660e+01, 2.5128442e+01, 1.4581832e+01, 4.3244734e+00,
165  -5.6577772e+00, -1.5386361e+01, -2.4887136e+01, -3.4188224e+01, -4.3318546e+01,
166  -5.2306916e+01, -6.1181558e+01,
167  },
168 
169  {
170  -6.0018125e+01, -6.8243134e+01, -7.5780862e+01, -8.0930434e+01, -7.9407340e+01,
171  -7.2901185e+01, -6.5003558e+01, -5.6632347e+01, -4.8002623e+01, -3.9171269e+01,
172  -3.0147310e+01, -2.0921952e+01, -1.1479516e+01, -1.8030130e+00, 8.1215023e+00,
173  1.8300042e+01, 2.8723815e+01, 3.9357750e+01, 5.0116479e+01, 6.0796148e+01,
174  7.0799966e+01, 7.7720429e+01, 7.5667940e+01, 6.6957660e+01, 5.6556579e+01,
175  4.5806960e+01, 3.5082849e+01, 2.4526346e+01, 1.4198272e+01, 4.1213054e+00,
176  -5.7027141e+00, -1.5283649e+01, -2.4637188e+01, -3.3780337e+01, -4.2726850e+01,
177  -5.1480271e+01, -6.0018125e+01,
178  },
179 
180  {
181  -5.6763473e+01, -6.3721803e+01, -6.9350213e+01, -7.2406072e+01, -7.1595300e+01,
182  -6.7322356e+01, -6.1051957e+01, -5.3761638e+01, -4.5899432e+01, -3.7661064e+01,
183  -2.9133792e+01, -2.0356792e+01, -1.1348040e+01, -2.1185707e+00, 7.3174061e+00,
184  1.6932120e+01, 2.6669719e+01, 3.6421102e+01, 4.5972840e+01, 5.4890661e+01,
185  6.2253932e+01, 6.6299419e+01, 6.5223137e+01, 5.9587071e+01, 5.1443019e+01,
186  4.2196812e+01, 3.2529315e+01, 2.2765306e+01, 1.3067511e+01, 3.5195690e+00,
187  -5.8361176e+00, -1.4978614e+01, -2.3896132e+01, -3.2576186e+01, -4.0994468e+01,
188  -4.9096993e+01, -5.6763473e+01,
189  },
190 
191  {
192  -5.1930043e+01, -5.7520985e+01, -6.1664013e+01, -6.3706420e+01, -6.3181670e+01,
193  -6.0221250e+01, -5.5425332e+01, -4.9408454e+01, -4.2595155e+01, -3.5239767e+01,
194  -2.7490147e+01, -1.9435029e+01, -1.1133295e+01, -2.6328414e+00, 6.0148092e+00,
195  1.4739663e+01, 2.3433938e+01, 3.1922592e+01, 3.9915329e+01, 4.6932754e+01,
196  5.2230631e+01, 5.4870709e+01, 5.4190691e+01, 5.0376730e+01, 4.4284022e+01,
197  3.6803157e+01, 2.8567067e+01, 1.9969144e+01, 1.1246230e+01, 2.5419583e+00,
198  -6.0538155e+00, -1.4480449e+01, -2.2689549e+01, -3.0630706e+01, -3.8235778e+01,
199  -4.5396738e+01, -5.1930043e+01,
200  },
201 
202  {
203  -4.6006510e+01, -5.0377333e+01, -5.3449005e+01, -5.4896833e+01, -5.4529539e+01,
204  -5.2398361e+01, -4.8765619e+01, -4.3969265e+01, -3.8312737e+01, -3.2027268e+01,
205  -2.5278415e+01, -1.8185662e+01, -1.0841716e+01, -3.3289119e+00, 4.2661058e+00,
206  1.1837327e+01, 1.9241765e+01, 2.6277592e+01, 3.2658732e+01, 3.7994962e+01,
207  4.1806163e+01, 4.3619473e+01, 4.3158455e+01, 4.0497024e+01, 3.6015197e+01,
208  3.0207381e+01, 2.3523617e+01, 1.6311315e+01, 8.8197845e+00, 1.2243958e+00,
209  -6.3490162e+00, -1.3804110e+01, -2.1057702e+01, -2.8025122e+01, -3.4605077e+01,
210  -4.0662117e+01, -4.6006510e+01,
211  },
212 
213  {
214  -3.9340005e+01, -4.2663495e+01, -4.4926798e+01, -4.5969303e+01, -4.5706421e+01,
215  -4.4160181e+01, -4.1450862e+01, -3.7756269e+01, -3.3266805e+01, -2.8156901e+01,
216  -2.2575234e+01, -1.6647050e+01, -1.0482042e+01, -4.1841877e+00, 2.1377900e+00,
217  8.3595752e+00, 1.4330196e+01, 1.9861842e+01, 2.4723918e+01, 2.8648396e+01,
218  3.1356671e+01, 3.2613755e+01, 3.2296196e+01, 3.0436121e+01, 2.7209219e+01,
219  2.2875939e+01, 1.7715647e+01, 1.1983180e+01, 5.8918217e+00, -3.8641798e-01,
220  -6.7125435e+00, -1.2969801e+01, -1.9052647e+01, -2.4856049e+01, -3.0265212e+01,
221  -3.5146265e+01, -3.9340005e+01,
222  },
223 
224  {
225  -3.2150830e+01, -3.4559650e+01, -3.6169920e+01, -3.6902409e+01, -3.6718280e+01,
226  -3.5627470e+01, -3.3686477e+01, -3.0986701e+01, -2.7639000e+01, -2.3760356e+01,
227  -1.9465727e+01, -1.4865194e+01, -1.0065058e+01, -5.1713370e+00, -2.9441703e-01,
228  4.4461307e+00, 8.9176003e+00, 1.2972465e+01, 1.6450908e+01, 1.9189792e+01,
229  2.1039320e+01, 2.1885576e+01, 2.1672558e+01, 2.0414606e+01, 1.8193117e+01,
230  1.5139226e+01, 1.1410534e+01, 7.1704160e+00, 2.5744409e+00, -2.2357749e+00,
231  -7.1331465e+00, -1.2002325e+01, -1.6735261e+01, -2.1226341e+01, -2.5368068e+01,
232  -2.9048360e+01, -3.2150830e+01,
233  },
234 
235  {
236  -2.4576013e+01, -2.6154391e+01, -2.7198607e+01, -2.7670434e+01, -2.7552023e+01,
237  -2.6847888e+01, -2.5584395e+01, -2.3806912e+01, -2.1575549e+01, -1.8960673e+01,
238  -1.6039194e+01, -1.2892100e+01, -9.6032842e+00, -6.2593405e+00, -2.9498717e+00,
239  2.3226561e-01, 3.1913676e+00, 5.8305290e+00, 8.0550058e+00, 9.7774715e+00,
240  1.0924793e+01, 1.1445248e+01, 1.1314514e+01, 1.0538752e+01, 9.1538106e+00,
241  7.2208060e+00, 4.8194220e+00, 2.0406964e+00, -1.0192362e+00, -4.2636521e+00,
242  -7.5978706e+00, -1.0930338e+01, -1.4172702e+01, -1.7239467e+01, -2.0047834e+01,
243  -2.2518238e+01, -2.4576013e+01,
244  },
245 
246  {
247  -1.6704625e+01, -1.7493055e+01, -1.8012186e+01, -1.8246050e+01, -1.8187401e+01,
248  -1.7838061e+01, -1.7208826e+01, -1.6318974e+01, -1.5195434e+01, -1.3871747e+01,
249  -1.2386929e+01, -1.0784340e+01, -9.1106057e+00, -7.4145745e+00, -5.7462845e+00,
250  -4.1558514e+00, -2.6922153e+00, -1.4016983e+00, -3.2637365e-01, 4.9768367e-01,
251  1.0421305e+00, 1.2878816e+00, 1.2262239e+00, 8.5934923e-01, 2.0021921e-01,
252  -7.2821655e-01, -1.8943228e+00, -3.2594126e+00, -4.7795075e+00, -6.4070521e+00,
253  -8.0924743e+00, -9.7855486e+00, -1.1436585e+01, -1.2997501e+01, -1.4422852e+01,
254  -1.5670881e+01, -1.6704625e+01,
255  },
256 
257  {
258  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
259  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
260  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
261  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
262  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
263  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
264  -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00, -8.6018742e+00,
265  -8.6018742e+00, -8.6018742e+00,
266  }};
267 
294 class SatMobilityObserverTestCase : public TestCase
295 {
296  public:
298  virtual ~SatMobilityObserverTestCase();
299 
300  private:
301  virtual void DoRun(void);
302 };
303 
305  : TestCase("Test satellite mobility observer model.")
306 {
307 }
308 
310 {
311 }
312 
313 void
315 {
316  // Set simulation output details
317  Singleton<SatEnvVariables>::Get()->DoInitialize();
318  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-mobility-observer", "", true);
319 
320  // create mobilities
321  Ptr<SatConstantPositionMobilityModel> gwMob = CreateObject<SatConstantPositionMobilityModel>();
322  Ptr<SatConstantPositionMobilityModel> utMob = CreateObject<SatConstantPositionMobilityModel>();
323  Ptr<SatConstantPositionMobilityModel> satMob = CreateObject<SatConstantPositionMobilityModel>();
324 
325  // create propagation delays
326  Ptr<SatConstantPropagationDelayModel> gwProgDelay =
327  CreateObject<SatConstantPropagationDelayModel>();
328  Ptr<SatConstantPropagationDelayModel> utProgDelay =
329  CreateObject<SatConstantPropagationDelayModel>();
330 
331  // set propagation delays
332  gwProgDelay->SetDelay(Seconds(200));
333  utProgDelay->SetDelay(Seconds(300));
334 
335  // set satellite position, altitude is the Earth radius
336  double earthRadius =
337  CalculateDistance(GeoCoordinate(0.00, 0.00, 0.00).ToVector(), Vector(0, 0, 0));
338  GeoCoordinate satellitePosition = GeoCoordinate(0.00, 0.00, earthRadius);
339  satMob->SetGeoPosition(satellitePosition);
340 
341  // set some positions to UT and GW
342  gwMob->SetGeoPosition(GeoCoordinate(0.00, 0.00, 0.00));
343  utMob->SetGeoPosition(GeoCoordinate(0.00, 0.00, 0.00));
344 
345  // create mobility observers
346  Ptr<SatMobilityObserver> utObserver = CreateObject<SatMobilityObserver>(utMob, satMob);
347  Ptr<SatMobilityObserver> gwObserver = CreateObject<SatMobilityObserver>(gwMob, satMob);
348 
349  utObserver->ObserveTimingAdvance(utProgDelay, gwProgDelay, gwMob);
350  double timingAdvance = utObserver->GetTimingAdvance().GetSeconds();
351 
352  // check that we use correct earth radius
353  NS_TEST_ASSERT_MSG_EQ(earthRadius, 6378137, "Earth radius is not what expected");
354 
355  // check that timing advance is correct
356  NS_TEST_ASSERT_MSG_EQ(timingAdvance, 500, "Timing Advance incorrect");
357 
358  // Test that we get 0 degrees elevation angle at range points, where we stop seeing satellite
359  gwMob->SetGeoPosition(GeoCoordinate(60.00, 0.00, 0.00));
360  utMob->SetGeoPosition(GeoCoordinate(00.0, 60.00, 0.00));
361 
362  double utEl = utObserver->GetElevationAngle();
363  double gwEl = gwObserver->GetElevationAngle();
364 
365  NS_TEST_ASSERT_MSG_EQ(utEl, 0, "UT elevation angle incorrect");
366  NS_TEST_ASSERT_MSG_EQ(gwEl, 0, "GW elevation angle incorrect");
367 
368  gwMob->SetGeoPosition(GeoCoordinate(-60.0, 0.00, 0.00));
369  utMob->SetGeoPosition(GeoCoordinate(0.00, -60.00, 0.00));
370 
371  utEl = utObserver->GetElevationAngle();
372  gwEl = gwObserver->GetElevationAngle();
373 
374  NS_TEST_ASSERT_MSG_EQ(utEl, 0, "UT elevation angle incorrect");
375  NS_TEST_ASSERT_MSG_EQ(gwEl, 0, "GW elevation angle incorrect");
376 
377  gwMob->SetGeoPosition(GeoCoordinate(45.00, 45.00, 0.00));
378  utMob->SetGeoPosition(GeoCoordinate(-45.00, -45.00, 0.00));
379 
380  utEl = utObserver->GetElevationAngle();
381  gwEl = gwObserver->GetElevationAngle();
382 
383  NS_TEST_ASSERT_MSG_EQ(utEl, 0, "UT elevation angle incorrect");
384  NS_TEST_ASSERT_MSG_EQ(gwEl, 0, "GW elevation angle incorrect");
385 
386  gwMob->SetGeoPosition(GeoCoordinate(-45.00, 45.00, 0.00));
387  utMob->SetGeoPosition(GeoCoordinate(45.00, -45.00, 0.00));
388 
389  utEl = utObserver->GetElevationAngle();
390  gwEl = gwObserver->GetElevationAngle();
391 
392  NS_TEST_ASSERT_MSG_EQ(utEl, 0, "UT elevation angle incorrect");
393  NS_TEST_ASSERT_MSG_EQ(gwEl, 0, "GW elevation angle incorrect");
394 
395  // Test that we get valid elevation angle at points where we should see satellite
396 
397  gwMob->SetGeoPosition(GeoCoordinate(44.01, 45.00, 0.00));
398  utMob->SetGeoPosition(GeoCoordinate(45.00, -42.00, 0.00));
399 
400  utEl = utObserver->GetElevationAngle();
401  gwEl = gwObserver->GetElevationAngle();
402 
403  NS_TEST_ASSERT_MSG_EQ(std::isnan(utEl), false, "UT elevation angle incorrect");
404  NS_TEST_ASSERT_MSG_EQ(std::isnan(gwEl), false, "GW elevation angle incorrect");
405 
406  gwMob->SetGeoPosition(GeoCoordinate(10.0, 10.00, 0.00));
407  utMob->SetGeoPosition(GeoCoordinate(0.00, 0.00, 0.00));
408 
409  utEl = utObserver->GetElevationAngle();
410  gwEl = gwObserver->GetElevationAngle();
411 
412  NS_TEST_ASSERT_MSG_EQ(std::isnan(utEl), false, "UT elevation angle incorrect");
413  NS_TEST_ASSERT_MSG_EQ(std::isnan(gwEl), false, "GW elevation angle incorrect");
414 
415  // Test that we get invalid elevation angle at points where we shouldn't see satellite
416 
417  gwMob->SetGeoPosition(GeoCoordinate(45.01, 45.00, 0.00));
418  utMob->SetGeoPosition(GeoCoordinate(45.00, -45.01, 0.00));
419 
420  utEl = utObserver->GetElevationAngle();
421  gwEl = gwObserver->GetElevationAngle();
422 
423  NS_TEST_ASSERT_MSG_EQ(std::isnan(utEl), true, "UT elevation angle incorrect");
424  NS_TEST_ASSERT_MSG_EQ(std::isnan(gwEl), true, "GW elevation angle incorrect");
425 
426  gwMob->SetGeoPosition(GeoCoordinate(90.0, 0.00, 0.00));
427  utMob->SetGeoPosition(GeoCoordinate(0.00, 180.00, 0.00));
428 
429  utEl = utObserver->GetElevationAngle();
430  gwEl = gwObserver->GetElevationAngle();
431 
432  NS_TEST_ASSERT_MSG_EQ(std::isnan(utEl), true, "UT elevation angle incorrect");
433  NS_TEST_ASSERT_MSG_EQ(std::isnan(gwEl), true, "GW elevation angle incorrect");
434 
435  // Test that we get correct elevation angle with our reference satellite
436 
437  satellitePosition.SetLatitude(0.00);
438  satellitePosition.SetLongitude(33.00);
439  satellitePosition.SetAltitude(35786000.00);
440  satMob->SetGeoPosition(satellitePosition);
441 
442  Ptr<UniformRandomVariable> randAlt = CreateObject<UniformRandomVariable>();
443  randAlt->SetAttribute("Min", DoubleValue(-200.00));
444  randAlt->SetAttribute("Max", DoubleValue(600.00));
445 
446  gwObserver->SetAttribute("MinAltitude", DoubleValue(-200.00));
447  gwObserver->SetAttribute("MaxAltitude", DoubleValue(600.00));
448 
449  for (uint32_t i = 0; i < g_latitudeCount; i++)
450  {
451  for (uint32_t j = 0; j < g_longitudeCount; j++)
452  {
453  double lat = g_firstLatValue + (double)i * g_latStep;
454  double lon = g_firstLonValue + (double)j * g_lonStep;
455  double alt = randAlt->GetValue();
456 
457  gwMob->SetGeoPosition(GeoCoordinate(lat, lon, alt));
458  gwEl = gwObserver->GetElevationAngle();
459  double refValue = g_refElAngles[i][j];
460 
461  if (refValue < 0)
462  {
463  // NAN should be returned, because only points where we can see satellite is
464  // accepted
465  NS_TEST_ASSERT_MSG_EQ(std::isnan(gwEl),
466  true,
467  "UT elevation angle incorrect: lat-> " << lat << " lon-> "
468  << " alt->" << alt);
469  }
470  else
471  {
472  // valid values should be returned and it should be inside tolerance
473  NS_TEST_ASSERT_MSG_EQ(std::isnan(gwEl),
474  false,
475  "UT elevation angle incorrect (NAN): lat-> "
476  << lat << " lon-> "
477  << " alt" << alt);
478  NS_TEST_ASSERT_MSG_EQ_TOL(gwEl,
479  refValue,
480  0.00001,
481  "UT elevation angle incorrect: lat-> " << lat << " lon-> "
482  << " alt" << alt);
483  }
484  }
485  }
486 
487  Simulator::Destroy();
488 
489  Singleton<SatEnvVariables>::Get()->DoDispose();
490 }
491 
495 class SatMobilityObserverTestSuite : public TestSuite
496 {
497  public:
499 };
500 
502  : TestSuite("sat-mobility-observer-test", Type::UNIT)
503 {
504  AddTestCase(new SatMobilityObserverTestCase, TestCase::Duration::QUICK);
505 }
506 
507 // Do allocate an instance of this TestSuite
Test case to unit test Satellite Mobility Observer.
Test suite for Satellite mobility observer unit test cases.
GeoCoordinate class is used to store and operate with geodetic coordinates.
void SetAltitude(double altitude)
Sets altitude value of coordinate.
void SetLatitude(double latitude)
Sets latitude value of coordinate.
void SetLongitude(double longitude)
Sets longitude value of coordinate.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static const double g_firstLonValue
static const double g_firstLatValue
static const uint32_t g_longitudeCount
static const uint32_t g_latitudeCount
static const double g_lonStep
static const double g_refElAngles[g_latitudeCount][g_longitudeCount]
static SatMobilityObserverTestSuite satSatMobilityObserverTestSuite
static const double g_latStep