1 // radio.cxx -- implementation of FGRadio
2 // Class to manage radio propagation using the ITM model
3 // Written by Adrian Musceac, started August 2011.
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #include <simgear/scene/material/mat.hxx>
30 #include <Scenery/scenery.hxx>
32 #define WITH_POINT_TO_POINT 1
38 /** radio parameters (which should probably be set for each radio) */
40 _receiver_sensitivity = -110.0; // typical AM receiver sensitivity seems to be 0.8 microVolt at 12dB SINAD
42 /** AM transmitter power in dBm.
43 * Note this value is calculated from the typical final transistor stage output
44 * small aircraft have portable transmitters which operate at 36 dBm output (4 Watts) others operate in the range 10-20 W
45 * later possibly store this value in aircraft description
46 * ATC comms usually operate high power equipment, thus making the link asymetrical; this is taken care of in propagation routines
47 * Typical output powers for ATC ground equipment, VHF-UHF:
48 * 40 dBm - 10 W (ground, clearance)
49 * 44 dBm - 20 W (tower)
50 * 47 dBm - 50 W (center, sectors)
51 * 50 dBm - 100 W (center, sectors)
52 * 53 dBm - 200 W (sectors, on directional arrays)
54 _transmitter_power = 43.0;
56 /** pilot plane's antenna gain + AI aircraft antenna gain
57 * real-life gain for conventional monopole/dipole antenna
60 _propagation_model = 2; // choose between models via option: realistic radio on/off
69 double FGRadio::getFrequency(int radio) {
73 freq = fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
76 freq = fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz");
79 freq = fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
85 /*** TODO: receive multiplayer chat message and voice
87 void FGRadio::receiveChat(SGGeod tx_pos, double freq, string text, int ground_to_air) {
91 /*** TODO: receive navaid
93 double FGRadio::receiveNav(SGGeod tx_pos, double freq, int transmission_type) {
95 // typical VOR/LOC transmitter power appears to be 200 Watt ~ 53 dBm
96 // vor/loc typical sensitivity between -107 and -101 dBm
97 // glideslope sensitivity between -85 and -81 dBm
98 if ( _propagation_model == 1) {
99 return LOS_calculate_attenuation(tx_pos, freq, 1);
101 else if ( _propagation_model == 2) {
102 return ITM_calculate_attenuation(tx_pos, freq, 1);
109 /*** Receive ATC radio communication as text
111 void FGRadio::receiveATC(SGGeod tx_pos, double freq, string text, int ground_to_air) {
114 double comm1 = getFrequency(1);
115 double comm2 = getFrequency(2);
116 if ( !(fabs(freq - comm1) <= 0.0001) && !(fabs(freq - comm2) <= 0.0001) ) {
117 //cerr << "Frequency not tuned: " << freq << " Radio1: " << comm1 << " Radio2: " << comm2 << endl;
122 if ( _propagation_model == 0) {
123 fgSetString("/sim/messages/atc", text.c_str());
125 else if ( _propagation_model == 1 ) {
126 // TODO: free space, round earth
127 double signal = LOS_calculate_attenuation(tx_pos, freq, ground_to_air);
129 SG_LOG(SG_GENERAL, SG_BULK, "Signal below receiver minimum sensitivity: " << signal);
130 //cerr << "Signal below receiver minimum sensitivity: " << signal << endl;
134 SG_LOG(SG_GENERAL, SG_BULK, "Signal completely readable: " << signal);
135 //cerr << "Signal completely readable: " << signal << endl;
136 fgSetString("/sim/messages/atc", text.c_str());
137 /** write signal strength above threshold to the property tree
138 * to implement a simple S-meter just divide by 3 dB per grade (VHF norm)
140 fgSetDouble("/sim/radio/comm1-signal", signal);
143 else if ( _propagation_model == 2 ) {
144 // Use ITM propagation model
145 double signal = ITM_calculate_attenuation(tx_pos, freq, ground_to_air);
147 SG_LOG(SG_GENERAL, SG_BULK, "Signal below receiver minimum sensitivity: " << signal);
148 //cerr << "Signal below receiver minimum sensitivity: " << signal << endl;
151 if ((signal > 0.0) && (signal < 12.0)) {
152 /** for low SNR values implement a way to make the conversation
153 * hard to understand but audible
154 * in the real world, the receiver AGC fails to capture the slope
155 * and the signal, due to being amplitude modulated, decreases volume after demodulation
156 * the workaround below is more akin to what would happen on a FM transmission
157 * therefore the correct way would be to work on the volume
160 string hash_noise = " ";
161 int reps = (int) (fabs(floor(signal - 11.0)) * 2);
162 int t_size = text.size();
163 for (int n = 1; n <= reps; ++n) {
164 int pos = rand() % (t_size -1);
165 text.replace(pos,1, hash_noise);
168 double volume = (fabs(signal - 12.0) / 12);
169 double old_volume = fgGetDouble("/sim/sound/voices/voice/volume");
170 SG_LOG(SG_GENERAL, SG_BULK, "Usable signal at limit: " << signal);
171 //cerr << "Usable signal at limit: " << signal << endl;
172 fgSetDouble("/sim/sound/voices/voice/volume", volume);
173 fgSetString("/sim/messages/atc", text.c_str());
174 fgSetDouble("/sim/radio/comm1-signal", signal);
175 fgSetDouble("/sim/sound/voices/voice/volume", old_volume);
178 SG_LOG(SG_GENERAL, SG_BULK, "Signal completely readable: " << signal);
179 //cerr << "Signal completely readable: " << signal << endl;
180 fgSetString("/sim/messages/atc", text.c_str());
181 /** write signal strength above threshold to the property tree
182 * to implement a simple S-meter just divide by 3 dB per grade (VHF norm)
184 fgSetDouble("/sim/radio/comm1-signal", signal);
193 /*** Implement radio attenuation
194 based on the Longley-Rice propagation model
196 double FGRadio::ITM_calculate_attenuation(SGGeod pos, double freq, int transmission_type) {
200 /** ITM default parameters
201 TODO: take them from tile materials (especially for sea)?
203 double eps_dielect=15.0;
204 double sgm_conductivity = 0.005;
207 if( (freq < 118.0) || (freq > 137.0) )
208 frq_mhz = 125.0; // sane value, middle of bandplan
211 int radio_climate = 5; // continental temperate
212 int pol=1; // assuming vertical polarization although this is more complex in reality
213 double conf = 0.90; // 90% of situations and time, take into account speed
217 int p_mode = 0; // propgation mode selector: 0 LOS, 1 diffraction dominant, 2 troposcatter
221 double clutter_loss; // loss due to vegetation and urban
222 double tx_pow = _transmitter_power;
223 double ant_gain = _antenna_gain;
226 if(transmission_type == 1)
227 tx_pow = _transmitter_power + 6.0;
229 if((transmission_type == 1) || (transmission_type == 3))
230 ant_gain = _antenna_gain + 3.0; //pilot plane's antenna gain + ground station antenna gain
232 double link_budget = tx_pow - _receiver_sensitivity + ant_gain;
234 FGScenery * scenery = globals->get_scenery();
236 double own_lat = fgGetDouble("/position/latitude-deg");
237 double own_lon = fgGetDouble("/position/longitude-deg");
238 double own_alt_ft = fgGetDouble("/position/altitude-ft");
239 double own_alt= own_alt_ft * SG_FEET_TO_METER;
242 //cerr << "ITM:: pilot Lat: " << own_lat << ", Lon: " << own_lon << ", Alt: " << own_alt << endl;
244 SGGeod own_pos = SGGeod::fromDegM( own_lon, own_lat, own_alt );
245 SGGeod max_own_pos = SGGeod::fromDegM( own_lon, own_lat, SG_MAX_ELEVATION_M );
246 SGGeoc center = SGGeoc::fromGeod( max_own_pos );
247 SGGeoc own_pos_c = SGGeoc::fromGeod( own_pos );
249 /** position of sender radio antenna (HAAT)
250 sender can be aircraft or ground station
252 double ATC_HAAT = 30.0;
253 double Aircraft_HAAT = 5.0;
254 double sender_alt_ft,sender_alt;
255 double transmitter_height=0.0;
256 double receiver_height=0.0;
257 SGGeod sender_pos = pos;
259 sender_alt_ft = sender_pos.getElevationFt();
260 sender_alt = sender_alt_ft * SG_FEET_TO_METER;
261 SGGeod max_sender_pos = SGGeod::fromGeodM( pos, SG_MAX_ELEVATION_M );
262 SGGeoc sender_pos_c = SGGeoc::fromGeod( sender_pos );
263 //cerr << "ITM:: sender Lat: " << parent->getLatitude() << ", Lon: " << parent->getLongitude() << ", Alt: " << sender_alt << endl;
265 double point_distance= 90.0; // regular SRTM is 90 meters
266 double course = SGGeodesy::courseRad(own_pos_c, sender_pos_c);
267 double distance_m = SGGeodesy::distanceM(own_pos, sender_pos);
268 double probe_distance = 0.0;
269 /** If distance larger than this value (300 km), assume reception imposssible */
270 if (distance_m > 300000)
272 /** If above 8000 meters, consider LOS mode and calculate free-space att */
273 if (own_alt > 8000) {
274 dbloss = 20 * log10(distance_m) +20 * log10(frq_mhz) -27.55;
275 SG_LOG(SG_GENERAL, SG_BULK,
276 "ITM Free-space mode:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm, free-space attenuation");
277 //cerr << "ITM Free-space mode:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm, free-space attenuation" << endl;
278 signal = link_budget - dbloss;
283 double max_points = distance_m / point_distance;
284 deque<double> _elevations;
285 deque<string> materials;
288 double elevation_under_pilot = 0.0;
289 if (scenery->get_elevation_m( max_own_pos, elevation_under_pilot, NULL )) {
290 receiver_height = own_alt - elevation_under_pilot + 3; //assume antenna located 3 meters above ground
293 double elevation_under_sender = 0.0;
294 if (scenery->get_elevation_m( max_sender_pos, elevation_under_sender, NULL )) {
295 transmitter_height = sender_alt - elevation_under_sender;
298 transmitter_height = sender_alt;
301 if(transmission_type == 1)
302 transmitter_height += ATC_HAAT;
304 transmitter_height += Aircraft_HAAT;
306 SG_LOG(SG_GENERAL, SG_BULK,
307 "ITM:: RX-height: " << receiver_height << " meters, TX-height: " << transmitter_height << " meters, Distance: " << distance_m << " meters");
308 //cerr << "ITM:: RX-height: " << receiver_height << " meters, TX-height: " << transmitter_height << " meters, Distance: " << distance_m << " meters" << endl;
310 unsigned int e_size = (deque<unsigned>::size_type)max_points;
312 while (_elevations.size() <= e_size) {
313 probe_distance += point_distance;
314 SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, probe_distance ));
315 const SGMaterial *mat = 0;
316 double elevation_m = 0.0;
318 if (scenery->get_elevation_m( probe, elevation_m, &mat )) {
319 if((transmission_type == 3) || (transmission_type == 4)) {
320 _elevations.push_back(elevation_m);
322 const std::vector<string> mat_names = mat->get_names();
323 materials.push_back(mat_names[0]);
326 materials.push_back("None");
330 _elevations.push_front(elevation_m);
332 const std::vector<string> mat_names = mat->get_names();
333 materials.push_front(mat_names[0]);
336 materials.push_front("None");
341 if((transmission_type == 3) || (transmission_type == 4)) {
342 _elevations.push_back(0.0);
343 materials.push_back("None");
346 _elevations.push_front(0.0);
347 materials.push_front("None");
351 if((transmission_type == 3) || (transmission_type == 4)) {
352 _elevations.push_front(elevation_under_pilot);
353 _elevations.push_back(elevation_under_sender);
356 _elevations.push_back(elevation_under_pilot);
357 _elevations.push_front(elevation_under_sender);
361 double max_alt_between=0.0;
362 for( deque<double>::size_type i = 0; i < _elevations.size(); i++ ) {
363 if (_elevations[i] > max_alt_between) {
364 max_alt_between = _elevations[i];
368 double num_points= (double)_elevations.size();
369 //cerr << "ITM:: Max alt between: " << max_alt_between << ", num points:" << num_points << endl;
370 _elevations.push_front(point_distance);
371 _elevations.push_front(num_points -1);
372 int size = _elevations.size();
373 double itm_elev[size];
374 for(int i=0;i<size;i++) {
375 itm_elev[i]=_elevations[i];
376 //cerr << "ITM:: itm_elev: " << _elevations[i] << endl;
379 if((transmission_type == 3) || (transmission_type == 4)) {
380 // the sender and receiver roles are switched
381 point_to_point(itm_elev, receiver_height, transmitter_height,
382 eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
383 pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
387 point_to_point(itm_elev, transmitter_height, receiver_height,
388 eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
389 pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
391 SG_LOG(SG_GENERAL, SG_BULK,
392 "ITM:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm, " << strmode << ", Error: " << errnum);
393 cerr << "ITM:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm, " << strmode << ", Error: " << errnum << endl;
395 clutterLoss(frq_mhz, distance_m, itm_elev, materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
396 cerr << "Clutter loss: " << clutter_loss << endl;
397 //if (errnum == 4) // if parameters are outside sane values for lrprop, the alternative method is used
399 signal = link_budget - dbloss - clutter_loss;
404 /*** Calculate losses due to vegetation and urban clutter (WIP)
405 * We are only worried about clutter loss, terrain influence
406 * on the first Fresnel zone is calculated in the ITM functions
408 void FGRadio::clutterLoss(double freq, double distance_m, double itm_elev[], deque<string> materials,
409 double transmitter_height, double receiver_height, int p_mode,
410 double horizons[], double &clutter_loss) {
412 if (p_mode == 0) { // LOS: take each point and see how clutter height affects first Fresnel zone
413 int j=1; // first point is TX elevation, last is RX elevation
414 for (int k=3;k < (int)itm_elev[0];k++) {
416 double clutter_height = 0.0; // mean clutter height for a certain terrain type
417 double clutter_density = 0.0; // percent of reflected wave
418 get_material_properties(materials[j-1], clutter_height, clutter_density);
419 //cerr << "Clutter:: material: " << materials[j-1] << " height: " << clutter_height << ", density: " << clutter_density << endl;
420 double grad = fabs(itm_elev[2] + transmitter_height - itm_elev[(int)itm_elev[0] + 2] + receiver_height) / distance_m;
421 // First Fresnel radius
422 double frs_rad = 548 * sqrt( (j * itm_elev[1] * (itm_elev[0] - j) * itm_elev[1] / 1000000) / ( distance_m * freq / 1000) );
424 //cerr << "Clutter:: fresnel radius: " << frs_rad << endl;
425 //double earth_h = distance_m * (distance_m - j * itm_elev[1]) / ( 1000000 * 12.75 * 1.33 ); // K=4/3
427 double min_elev = SGMiscd::min(itm_elev[2] + transmitter_height, itm_elev[(int)itm_elev[0] + 2] + receiver_height);
428 double d1 = j * itm_elev[1];
429 if ((itm_elev[2] + transmitter_height) > ( itm_elev[(int)itm_elev[0] + 2] + receiver_height) ) {
430 d1 = (itm_elev[0] - j) * itm_elev[1];
432 double ray_height = (grad * d1) + min_elev;
433 cerr << "Clutter:: ray height: " << ray_height << " ground height:" << itm_elev[k] << endl;
434 double clearance = ray_height - (itm_elev[k] + clutter_height) - frs_rad * 8/10;
435 double intrusion = fabs(clearance);
436 //cerr << "Clutter:: clearance: " << clearance << endl;
437 if (clearance >= 0) {
440 else if (clearance < 0 && (intrusion < clutter_height)) {
442 clutter_loss += clutter_density * (intrusion / (frs_rad * 2) ) * freq/100;
444 else if (clearance < 0 && (intrusion > clutter_height)) {
445 clutter_loss += clutter_density * (clutter_height / (frs_rad * 2 ) ) * freq/100;
454 else if (p_mode == 1) { // diffraction
456 if (horizons[1] == 0.0) { // single horizon: same as above, except pass twice using the highest point
457 int num_points_1st = (int)floor( horizons[1] * (double)itm_elev[0] / distance_m );
458 int num_points_2nd = (int)floor( (distance_m - horizons[1]) * (double)itm_elev[0] / distance_m );
460 /** perform the first pass */
462 int j=1; // first point is TX elevation, last is obstruction elevation
463 for (int k=3;k < num_points_1st ;k++) {
465 double clutter_height = 0.0; // mean clutter height for a certain terrain type
466 double clutter_density = 0.0; // percent of reflected wave
467 get_material_properties(materials[j-1], clutter_height, clutter_density);
468 //cerr << "Clutter:: material: " << materials[j-1] << " height: " << clutter_height << ", density: " << clutter_density << endl;
469 double grad = fabs(itm_elev[2] + transmitter_height - itm_elev[num_points_1st + 2] + clutter_height) / distance_m;
470 // First Fresnel radius
471 double frs_rad = 548 * sqrt( (j * itm_elev[1] * (num_points_1st - j) * itm_elev[1] / 1000000) / ( num_points_1st * itm_elev[1] * freq / 1000) );
473 //cerr << "Clutter:: fresnel radius: " << frs_rad << endl;
474 //double earth_h = distance_m * (distance_m - j * itm_elev[1]) / ( 1000000 * 12.75 * 1.33 ); // K=4/3
476 double min_elev = SGMiscd::min(itm_elev[2] + transmitter_height, itm_elev[num_points_1st + 2] + clutter_height);
477 double d1 = j * itm_elev[1];
478 if ( (itm_elev[2] + transmitter_height) > (itm_elev[num_points_1st + 2] + clutter_height) ) {
479 d1 = (num_points_1st - j) * itm_elev[1];
481 double ray_height = (grad * d1) + min_elev;
482 //cerr << "Clutter:: ray height: " << ray_height << " ground height:" << itm_elev[k] << endl;
483 double clearance = ray_height - (itm_elev[k] + clutter_height) - frs_rad * 8/10;
484 double intrusion = fabs(clearance);
485 //cerr << "Clutter:: clearance: " << clearance << endl;
486 if (clearance >= 0) {
489 else if (clearance < 0 && (intrusion < clutter_height)) {
491 clutter_loss += clutter_density * (intrusion / (frs_rad * 2) ) * freq/100;
493 else if (clearance < 0 && (intrusion > clutter_height)) {
494 clutter_loss += clutter_density * (clutter_height / (frs_rad * 2 ) ) * freq/100;
503 /** and the second pass */
506 for (int k=last;k < num_points_2nd ;k++) {
508 double clutter_height = 0.0; // mean clutter height for a certain terrain type
509 double clutter_density = 0.0; // percent of reflected wave
510 get_material_properties(materials[j-1], clutter_height, clutter_density);
511 //cerr << "Clutter:: material: " << materials[j-1] << " height: " << clutter_height << ", density: " << clutter_density << endl;
512 double grad = fabs(itm_elev[last] + clutter_height - itm_elev[(int)itm_elev[0] + 2] + receiver_height) / distance_m;
513 // First Fresnel radius
514 double frs_rad = 548 * sqrt( (l * itm_elev[1] * (num_points_2nd - l) * itm_elev[1] / 1000000) / ( num_points_2nd * itm_elev[1] * freq / 1000) );
516 //cerr << "Clutter:: fresnel radius: " << frs_rad << endl;
517 //double earth_h = distance_m * (distance_m - j * itm_elev[1]) / ( 1000000 * 12.75 * 1.33 ); // K=4/3
519 double min_elev = SGMiscd::min(itm_elev[last] + clutter_height, itm_elev[(int)itm_elev[0] + 2] + receiver_height);
520 double d1 = l * itm_elev[1];
521 if ( (itm_elev[last] + clutter_height) > (itm_elev[(int)itm_elev[0] + 2] + receiver_height) ) {
522 d1 = (num_points_2nd - l) * itm_elev[1];
524 double ray_height = (grad * d1) + min_elev;
525 //cerr << "Clutter:: ray height: " << ray_height << " ground height:" << itm_elev[k] << endl;
526 double clearance = ray_height - (itm_elev[k] + clutter_height) - frs_rad * 8/10;
527 double intrusion = fabs(clearance);
528 //cerr << "Clutter:: clearance: " << clearance << endl;
529 if (clearance >= 0) {
532 else if (clearance < 0 && (intrusion < clutter_height)) {
534 clutter_loss += clutter_density * (intrusion / (frs_rad * 2) ) * freq/100;
536 else if (clearance < 0 && (intrusion > clutter_height)) {
537 clutter_loss += clutter_density * (clutter_height / (frs_rad * 2 ) ) * freq/100;
546 else { // double horizon: same as single horizon, except there are 3 segments
550 else if (p_mode == 2) { // troposcatter: use the first smooth earth horizon as mid point
556 /*** Material properties database
557 * height: median clutter height
558 * density: radiowave attenuation factor
560 void FGRadio::get_material_properties(string mat_name, double &height, double &density) {
562 if(mat_name == "Landmass") {
567 else if(mat_name == "SomeSort") {
572 else if(mat_name == "Island") {
576 else if(mat_name == "Default") {
580 else if(mat_name == "EvergreenBroadCover") {
584 else if(mat_name == "EvergreenForest") {
588 else if(mat_name == "DeciduousBroadCover") {
592 else if(mat_name == "DeciduousForest") {
596 else if(mat_name == "MixedForestCover") {
600 else if(mat_name == "MixedForest") {
604 else if(mat_name == "RainForest") {
608 else if(mat_name == "EvergreenNeedleCover") {
612 else if(mat_name == "WoodedTundraCover") {
616 else if(mat_name == "DeciduousNeedleCover") {
620 else if(mat_name == "ScrubCover") {
624 else if(mat_name == "BuiltUpCover") {
628 else if(mat_name == "Urban") {
632 else if(mat_name == "Construction") {
636 else if(mat_name == "Industrial") {
640 else if(mat_name == "Port") {
644 else if(mat_name == "Town") {
648 else if(mat_name == "SubUrban") {
652 else if(mat_name == "CropWoodCover") {
656 else if(mat_name == "CropWood") {
660 else if(mat_name == "AgroForest") {
671 /*** implement simple LOS propagation model (WIP)
673 double FGRadio::LOS_calculate_attenuation(SGGeod pos, double freq, int transmission_type) {
675 if( (freq < 118.0) || (freq > 137.0) )
676 frq_mhz = 125.0; // sane value, middle of bandplan
680 double tx_pow = _transmitter_power;
681 double ant_gain = _antenna_gain;
683 double ATC_HAAT = 30.0;
684 double Aircraft_HAAT = 5.0;
685 double sender_alt_ft,sender_alt;
686 double transmitter_height=0.0;
687 double receiver_height=0.0;
688 double own_lat = fgGetDouble("/position/latitude-deg");
689 double own_lon = fgGetDouble("/position/longitude-deg");
690 double own_alt_ft = fgGetDouble("/position/altitude-ft");
691 double own_alt= own_alt_ft * SG_FEET_TO_METER;
693 if(transmission_type == 1)
694 tx_pow = _transmitter_power + 6.0;
696 if((transmission_type == 1) || (transmission_type == 3))
697 ant_gain = _antenna_gain + 3.0; //pilot plane's antenna gain + ground station antenna gain
699 double link_budget = tx_pow - _receiver_sensitivity + ant_gain;
701 //cerr << "ITM:: pilot Lat: " << own_lat << ", Lon: " << own_lon << ", Alt: " << own_alt << endl;
703 SGGeod own_pos = SGGeod::fromDegM( own_lon, own_lat, own_alt );
705 SGGeod sender_pos = pos;
707 sender_alt_ft = sender_pos.getElevationFt();
708 sender_alt = sender_alt_ft * SG_FEET_TO_METER;
710 receiver_height = own_alt;
711 transmitter_height = sender_alt;
713 double distance_m = SGGeodesy::distanceM(own_pos, sender_pos);
715 if(transmission_type == 1)
716 transmitter_height += ATC_HAAT;
718 transmitter_height += Aircraft_HAAT;
720 /** radio horizon calculation with wave bending k=4/3 */
721 double receiver_horizon = 4.12 * sqrt(receiver_height);
722 double transmitter_horizon = 4.12 * sqrt(transmitter_height);
723 double total_horizon = receiver_horizon + transmitter_horizon;
725 if (distance_m > total_horizon) {
729 // free-space loss (distance calculation should be changed)
730 dbloss = 20 * log10(distance_m) +20 * log10(frq_mhz) -27.55;
731 signal = link_budget - dbloss;
732 SG_LOG(SG_GENERAL, SG_BULK,
733 "LOS:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm ");
734 //cerr << "LOS:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm " << endl;
739 /*** Material properties database
741 void FGRadio::set_material_properties() {