1
0
Fork 0

functional radio signal attenuation

This commit is contained in:
adrian 2011-09-04 13:56:03 +03:00
parent 4801b28c42
commit 3a82ce7696
2 changed files with 78 additions and 30 deletions

View file

@ -26,6 +26,7 @@
#include <algorithm> #include <algorithm>
#include <math.h> #include <math.h>
#include <stdlib.h>
#include <deque> #include <deque>
#include <osg/Geode> #include <osg/Geode>
@ -736,10 +737,17 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent,
double snr = calculate_attenuation(rec, parent, ground_to_air); double snr = calculate_attenuation(rec, parent, ground_to_air);
if (snr <= 0) if (snr <= 0)
return; return;
if (snr > 0 && snr < 10) { if (snr > 0 && snr < 12) {
//for low snr values implement a way to make the conversation //for low SNR values implement a way to make the conversation
//hard to understand (perhaps eliminate letters from words or such //hard to understand but audible
return; string hash_noise = " ";
int reps = fabs((int)snr - 11);
int t_size = text.size();
for (int n=1;n<=reps * 2;n++) {
int pos = rand() % t_size -1;
text.replace(pos,1, hash_noise);
}
} }
if (rec->allowTransmissions()) { if (rec->allowTransmissions()) {
@ -753,12 +761,12 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent,
} }
} }
int FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, double FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent,
int ground_to_air) { int ground_to_air) {
///////////////////////////////////////////////// //////////////////////////////////////////////////
/// Implement radio attenuation /// Implement radio attenuation //
/// based on the Longley-Rice propagation model /// based on the Longley-Rice propagation model//
///////////////////////////////////////////////// //////////////////////////////////////////////////
FGScenery * scenery = globals->get_scenery(); FGScenery * scenery = globals->get_scenery();
// player aircraft position // player aircraft position
@ -767,64 +775,96 @@ int FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynam
double own_alt_ft = fgGetDouble("/position/altitude-ft"); double own_alt_ft = fgGetDouble("/position/altitude-ft");
double own_alt= own_alt_ft * SG_FEET_TO_METER; double own_alt= own_alt_ft * SG_FEET_TO_METER;
cerr << "ITM:: pilot Lat: " << own_lat << ", Lon: " << own_lon << ", Alt: " << own_alt << endl;
SGGeod own_pos = SGGeod::fromDegM( own_lon, own_lat, own_alt ); SGGeod own_pos = SGGeod::fromDegM( own_lon, own_lat, own_alt );
SGGeod max_own_pos = SGGeod::fromDegM( own_lon, own_lat, SG_MAX_ELEVATION_M ); SGGeod max_own_pos = SGGeod::fromDegM( own_lon, own_lat, SG_MAX_ELEVATION_M );
SGGeoc center = SGGeoc::fromGeod( max_own_pos ); SGGeoc center = SGGeoc::fromGeod( max_own_pos );
SGGeoc own_pos_c = SGGeoc::fromGeod( own_pos );
// position of sender // position of sender radio antenna (HAAT)
// sender can be aircraft or ground station // sender can be aircraft or ground station
double ATC_HAAT = 30.0;
double Aircraft_HAAT = 7.0;
double sender_alt_ft,sender_alt; double sender_alt_ft,sender_alt;
double transceiver_height=0.0;
double receiver_height=0.0;
SGGeod sender_pos; SGGeod sender_pos;
if(ground_to_air) { if(ground_to_air) {
sender_alt_ft = parent->getElevation(); sender_alt_ft = parent->getElevation();
sender_alt = sender_alt_ft * SG_FEET_TO_METER; sender_alt = sender_alt_ft * SG_FEET_TO_METER + ATC_HAAT;
sender_pos= SGGeod::fromDegM( parent->getLongitude(), sender_pos= SGGeod::fromDegM( parent->getLongitude(),
parent->getLatitude(), sender_alt ); parent->getLatitude(), sender_alt );
} }
else { else {
sender_alt_ft = rec->getAltitude(); sender_alt_ft = rec->getAltitude();
sender_alt = sender_alt_ft * SG_FEET_TO_METER; sender_alt = sender_alt_ft * SG_FEET_TO_METER + Aircraft_HAAT;
sender_pos= SGGeod::fromDegM( rec->getLongitude(), sender_pos= SGGeod::fromDegM( rec->getLongitude(),
rec->getLatitude(), sender_alt ); rec->getLatitude(), sender_alt );
} }
double point_distance= 100.0; // regular SRTM is 90 meters SGGeoc sender_pos_c = SGGeoc::fromGeod( sender_pos );
double course = SGGeodesy::courseDeg(own_pos, sender_pos); cerr << "ITM:: sender Lat: " << parent->getLatitude() << ", Lon: " << parent->getLongitude() << ", Alt: " << sender_alt << endl;
double point_distance= 90.0; // regular SRTM is 90 meters
double course = SGGeodesy::courseRad(own_pos_c, sender_pos_c);
double distance_m = SGGeodesy::distanceM(own_pos, sender_pos); double distance_m = SGGeodesy::distanceM(own_pos, sender_pos);
double probe_distance = 0.0;
cerr << "ITM:: Distance: " << distance_m << endl;
double max_points = distance_m / point_distance; double max_points = distance_m / point_distance;
deque<double> _elevations; deque<double> _elevations;
SGGeod probe_pilot = SGGeod::fromGeoc(center.advanceRadM( course, 0 ));
double elevation_under_pilot = 0.0;
if (scenery->get_elevation_m( probe_pilot, elevation_under_pilot, NULL )) {
receiver_height = own_alt - elevation_under_pilot;
}
_elevations.push_front(receiver_height);
SGGeod probe_sender = SGGeod::fromGeoc(center.advanceRadM( course, distance_m ));
double elevation_under_sender = 0.0;
if (scenery->get_elevation_m( probe_sender, elevation_under_sender, NULL )) {
transceiver_height = sender_alt - elevation_under_sender;
}
// If distance larger than this value (400 km), assume reception imposssible // If distance larger than this value (400 km), assume reception imposssible
// technically 400 km is no problem if LOS conditions exist, // technically 400 km is no problem if LOS conditions exist,
// but we do this to spare resources // but we do this to spare resources
if (distance_m > 400000) if (distance_m > 400000)
return -1; return -1.0;
while (_elevations.size() < (deque<double>::size_type)max_points) { int e_size = (deque<unsigned>::size_type)max_points;
SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, point_distance ));
while (_elevations.size() < e_size) {
probe_distance += point_distance;
SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, probe_distance ));
double elevation_m = 0.0; double elevation_m = 0.0;
if (scenery->get_elevation_m( probe, elevation_m, NULL )) { if (scenery->get_elevation_m( probe, elevation_m, NULL )) {
_elevations.push_front(elevation_m); _elevations.push_front(elevation_m);
//cerr << "ITM:: Probe elev: " << elevation_m << endl;
} }
} }
/* _elevations.push_front(transceiver_height);
double max_alt_between=0.0; double max_alt_between=0.0;
for( deque<double>::size_type i = 0; i < _elevations.size(); i++ ) { for( deque<double>::size_type i = 0; i < _elevations.size(); i++ ) {
if (_elevations[i] > max_alt_between) { if (_elevations[i] > max_alt_between) {
max_alt_between = _elevations[i]; max_alt_between = _elevations[i];
} }
} }
*/
double num_points= (int)_elevations.size(); double num_points= (double)_elevations.size();
_elevations.push_front(distance_m); cerr << "ITM:: Max alt between: " << max_alt_between << ", num points:" << num_points << endl;
_elevations.push_front(point_distance);
_elevations.push_front(num_points -1); _elevations.push_front(num_points -1);
int size = _elevations.size(); int size = _elevations.size();
double itm_elev[size]; double itm_elev[size];
for(int i=0;i<size;i++) { for(int i=0;i<size;i++) {
itm_elev[i]=_elevations[i]; itm_elev[i]=_elevations[i];
//cerr << "ITM:: itm_elev: " << _elevations[i] << endl;
} }
////////////// ITM default parameters ////////////// ////////////// ITM default parameters //////////////
@ -835,8 +875,8 @@ int FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynam
double frq_mhz = 125.0; // middle of bandplan double frq_mhz = 125.0; // middle of bandplan
int radio_climate = 5; // continental temperate int radio_climate = 5; // continental temperate
int pol=1; // assuming vertical polarization int pol=1; // assuming vertical polarization
double conf = 0.70; // my own tests in Radiomobile have worked best with these values double conf = 0.90; // my own tests in Radiomobile have worked best with these values
double rel = 0.70; // ^^ double rel = 0.80; // ^^
double dbloss; double dbloss;
char strmode[150]; char strmode[150];
int errnum; int errnum;
@ -848,8 +888,16 @@ int FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynam
// !!! small aircraft have portable transmitters which operate at 36 dBm output (4 Watts) // !!! small aircraft have portable transmitters which operate at 36 dBm output (4 Watts)
// later store this value in aircraft description // later store this value in aircraft description
// ATC comms usually operate high power equipment, thus making the link asymetrical; this is ignored for now // ATC comms usually operate high power equipment, thus making the link asymetrical; this is ignored for now
if(ground_to_air)
double transmitter_power = 49.0;
else
double transmitter_power = 43.0; double transmitter_power = 43.0;
double link_budget = transmitter_power - receiver_sensitivity; if(ground_to_air)
double antenna_gain = 5.0; //pilot plane's antenna gain + Controller antenna gain
else
double antenna_gain = 2.0; //pilot plane's antenna gain + AI aircraft antenna gain
double link_budget = transmitter_power - receiver_sensitivity + antenna_gain;
// first Fresnel zone radius // first Fresnel zone radius
// frequency in the middle of the bandplan, more accuracy is not necessary // frequency in the middle of the bandplan, more accuracy is not necessary
@ -863,10 +911,10 @@ int FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynam
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate, eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
pol, conf, rel, dbloss, strmode, errnum); pol, conf, rel, dbloss, strmode, errnum);
cerr << "Attenuation: " << dbloss << ", Mode: " << strmode << ", Error: " << errnum << endl; cerr << "ITM:: Attenuation: " << dbloss << " dBm, " << strmode << ", Error: " << errnum << endl;
if (errnum !=0 && errnum !=1) //if (errnum !=0 && errnum !=1)
return -1; // return -1;
double snr = link_budget - dbloss; double snr = link_budget - dbloss;
return snr; return snr;

View file

@ -304,7 +304,7 @@ public:
string getGateName(FGAIAircraft *aircraft); string getGateName(FGAIAircraft *aircraft);
virtual void render(bool) = 0; virtual void render(bool) = 0;
virtual string getName() = 0; virtual string getName() = 0;
int calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, int ground_to_air); double calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, int ground_to_air);
private: private: