Board index FlightGear Development New features

When there isn't ATIS freq

Discussion and requests for new features. Please note that FlightGear developers are volunteers and may or may not be able to consider these requests.

When there isn't ATIS freq

Postby rleibner » Wed Jun 07, 2017 11:09 pm

Hi everyone,
At some airports -when there is not an available ATIS freq-, Ground or even Tower can give you the METAR data, often at initial contact.
The question is: Can we simulate such behavior ?
I would like to take the mouse as if it were the PTT and listen to the sweet voice of the air controller. :)

I mean something like
Code: Select all
 <!-- Pseudo-code -->
    <binding>
         <command>nasal</command>
         <script>
            MetarString = getprop("/environment/metar/data");
            MetarEnglish= Translate(MetarString);
            setprop("/sim/sound/voices/atc", MetarEnglish);
         </script>
   </binding>


Sounds crazy? Or perhaps it's a yet developed feature. :oops:
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: When there isn't ATIS freq

Postby Thorsten » Thu Jun 08, 2017 6:48 am

It's not hard to code a simple Q/A with a tower. I've done some for Space Shuttle mission control - you can ask it questions and it will answer. See

https://sourceforge.net/p/fgspaceshuttl ... al/mcc.nas

for the code.

Might be nice to have this option available - feel free to code it and I can test the waters for including it once there's a demo.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: When there isn't ATIS freq

Postby rleibner » Sun Jun 11, 2017 11:04 pm

Hi,
In fact, this is what I had in mind:
1.- Create the $FG_ROOT/Nasal/test.nas (or the name you want) and copy&past the fllwg:
Code: Select all
# test.nas (save in $FG_ROOT/Nasal)

 var metar = func() {
    var M_vec = split(" ", getprop("/environment/metar/data"));

  # Parsing the METAR string *************************** 
    for(var i=0;i<size(M_vec);i=i+1) {
      if(streq(right(M_vec[i],2), "KT")){
        var wind_dir = left(M_vec[i],3);
        var wind_vel = substr(M_vec[i],3,2);
        wind_gust = (streq(substr(M_vec[i],5,1),"G")) ? substr(M_vec[i],6,2) : " ";
        }       
      if(streq(left(M_vec[i],1),"Q")) {
        var qnh = right(M_vec[i],4);
        var q = substr(sprintf("%f", 0.02953* num(qnh)),0,5);
        break;
        }
    }
  # ******************************************************
   
    var v_list = ["This is",airportinfo().name,"tower. Winnde",wind_vel,"knots from",wind_dir];
    if(!streq(" ",wind_gust)){
      append(v_list, "gusts up to",wind_gust,"knots");
      }
    append(v_list, ". Q n h ",qnh,"or",q, "inches. Contact when ready.");
     
    var voice = string.join(" ",v_list);
    var t_list = ["QNH:",qnh,"hPa = ",q,"in Hg.\nWind:",wind_vel,"kt from ",wind_dir];
    gui.popupTip(sprintf(string.join(" ",t_list)),15);
    setprop("/sim/sound/voices/atc", voice);
};

2.- Include theese lines into your $FGFS_ROOT/keyboard.xml file:
Code: Select all
 <key n="60">
  <name>less-than</name>
  <desc>Custom command</desc>
  <binding>
   <command>nasal</command>
   <script>
     test.metar()
     </script>
  </binding>
 </key>

3.- On the ground, after starting the engines and while waiting for warm up, press the "<" key.

It works for me. Feel free to correct the fraseology and suggest optimizations.
Would be great if we could check whether the comm tunned freq has sense.
Also it would be great to include your callsign in the answer.
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: When there isn't ATIS freq

Postby sanhozay » Mon Jun 12, 2017 10:04 am

I think trying to write a Nasal parser for environment/metar/data is likely to give you a lot of pain. I've fixed bugs in the C++ parser so I've seen how awkward it is. There are many cases that you won't have thought of that will break your parser.

If you want to construct a weather report, I'd suggest using the properties under environment/metar. These are derived by the existing parser and are more reliable than you will achieve in your Nasal parser in the short term.

So, for example, you can construct wind speed from "base-wind-speed-kt" and "gust-wind-speed-kt". Temperature and dewpoint are easy. You have "environment/metar/decoded" which already has a text that indicates precipitation. Clouds are more difficult, but iterating through environment/metar/clouds/later[0..n] is easier than trying to parse it.
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 12:57 pm
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: When there isn't ATIS freq

Postby Torsten » Mon Jun 12, 2017 1:27 pm

There is already an implementation to generate spoken words from weather data.
It also distinguishes if you are on LIVE data (METAR) or generated weather (read /environment/* properties)

This is what the ATIS system currently uses and it should be trivial to adapt this to an "on-click" feature to ask any ATC for current WX.


Torsten
flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 648
Joined: Fri Feb 01, 2008 10:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: When there isn't ATIS freq

Postby rleibner » Mon Jun 12, 2017 8:55 pm

Hi,

Yes sanhozay, I think you are right: it's safer and easier to pick the data from the /environment/metar properties.
I'll work on that.

Torsten wrote in Mon Jun 12, 2017 1:27 pm:There is already an implementation to generate spoken words from weather data.

I know, Torsten. But it works -if I'm not mistaken- when tunning an ATIS freq. And the case here is "When there isn't ATIS freq".

Anyway, as a former private pilot, after starting the engine I used to turn on the radio and contact the tower:
    CX-BEX: -"Adami Tower, this is CX-BEX from platform"
    Tower: - "Goodmorning Bravo Echo Xray, wind is [...], QNH [...] and the runway in use is [...]. Contact when ready."
And these days, in front of the computer, I just miss that ... :(
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: When there isn't ATIS freq

Postby Torsten » Tue Jun 13, 2017 1:13 pm

I know, Torsten. But it works -if I'm not mistaken- when tunning an ATIS freq. And the case here is "When there isn't ATIS freq".

That's correct, However, the code to turn environment properties into spoken weather is already there, no need to re-implement this.

I understand your feature request as "if I have tuned a radio to a ATC station in range and I'd like that ATC station to give me the weather at that station (extended feature request: any station) in spoken words"
As we already have a weather-speaker, this boils down to some code in commradio.cxx lines 702ff that does something like
Code: Select all
  case FGPositioned::AnyKindOfATCStation:
    if( requestWeatherButtonPressed )
      _metarBridge->requestMetarForId(AirportWithMetarNearStation(tunedATCStation)


Please note that the properties under /enviroinment contain weather data at the aircraft's position (which is usually not the same as the ATC station's position).

Torsten
flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 648
Joined: Fri Feb 01, 2008 10:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: When there isn't ATIS freq

Postby rleibner » Tue Jun 13, 2017 5:02 pm

Torsten wrote in Tue Jun 13, 2017 1:13 pm:As we already have a weather-speaker, this boils down to some code in commradio.cxx lines 702ff that does something like ...

OK, I got it.
Unfortunately I have not yet studied FGCom and I'm afraid programming in C is beyond my capacity (yet).
In the meantime, I've reviewed my script to base it on properties (as you and sanhozay suggest).
Code: Select all
# test.nas (save in $FG_ROOT/Nasal)

 var metar = func() {
      var spell = func(str) {
      var s = split("",str);
      for(var i=0;i<size(s);i=i+1) {
        if(streq(s[i],".")) { s[i]="point" };
          };
      return string.join(" ",s);
      };
  # *******************************************
 
    var q =  sprintf("%.2f",getprop("/environment/metar/pressure-sea-level-inhg"));
    var rw = spell(getprop("/sim/atc/runway"));
    var wd = spell(sprintf("%d",getprop("/environment/metar/base-wind-dir-deg")));
    var wv = spell(sprintf("%d",getprop("/environment/metar/base-wind-speed-kt")));
    var wg = spell(sprintf("%d",getprop("/environment/metar/gust-wind-speed-kt")));
    var q_ = spell(q);
    var qnh_ = spell(sprintf("%d",q/0.02953));
   
    var v_list = ["This is ",airportinfo().name," tower. Runway in use is ",rw,
                  ". Winnde ",wv," knots from ",wd];
    if(!streq("0",wg)){
      append(v_list, ", gusts up to ",wg," knots.");
      };
    append(v_list, ". Q n h ",qnh_," or ",q_, " inches. Contact when ready.");
     
    var voice = string.join("",v_list);
    setprop("/sim/sound/voices/atc", voice);
};
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4


Return to New features

Who is online

Users browsing this forum: No registered users and 5 guests