Board index FlightGear Development Nasal

Spoken ATC

Nasal is the scripting language of FlightGear.

Re: Spoken ATC

Postby Hooray » Mon Jul 24, 2017 6:50 pm

rleibner wrote:or to move all logic to ''conditions'' into the properties tree and use a statemachine approach.

Doing the latter, what can we expect?

Less number of lines and more elegance in the code (although less readable).

And saving ... what? 1 or 1.5 msec?I wonder if it's worth it. I repeat, I'm speaking <u>exclusively of SpokenATC</u>.

Now, if the weight argument here is to preserve a uniform style in the FGFS addons, I can understand it.<ref>{{cite web


Referring to your other comments, I don't think this was ever about "performance" actually - Torsten mentioned the structure of the code and how a state machine-based approach may be preferable, but personally I tend to look at this from a fgdata standpoint, i.e. XML-based config files are much more likely to be edited/maintained than Nasal code, just like Nasal code is more likely to be edited/maintained by others compared to say GLSL or C++

Thus, I really think that Thorsten's analysis is spot-on - it really is a pain/gain thing, and there is very little to be gained given the degree of work involved - however, speaking purely on technical grounds, I tend to agree with Torsten (which isn't necessarily always the case either ...) - and from a fgdata/contributor standpoint, I think that some kind of XML-based markup may help lower the barrier to entry for those wanting to get involved in helping extend/maintain the system, without necessarily being "coders".

Thus, I don't have any preference, other than what Thorsten pointed out previously when he remarked, that I was speaking about architectural issues, that are not at all specific to your addon - but depending on how you'd like to see this evolve over time, my assertion is that some kind of simple XML-based system may encourage more folks to get involved, especially if accompanied by a few short tutorials illustrating how to customize the system.

Then again, this is a purely theoretical benefit as long as this isn't the case obviously - and that, too, is a recurring theme - one of the longest standing suggestions related to the "random buildings" subsystem was to make it Nasal configurable, so that non C++ folks could get involved - and for a number of years (dating back as far as 2012), the consensus has been the following:

Subject: Random Buildings
stuart wrote:Torsten has rather hit the nail on the head:

it would be somewhat far-fetched to ask Stuart to make a faster Nasal interface than the existing one just because someone might eventually work on it.


Yes, it would be possible but it probably represents 10 hours of speculative development that I don't have time for right now. Given that people don't seem to making significant use of the tools already available by modifying materials.xml (at least not in a way that is making itself as far as git), I just don't see sufficient interest. That may change once these changes are available, as it'll give people a lot more scope for creating cities.

-Stuart


These days however, things seem to have changed a little - mainly because of all the momentum created by the varous OSM2* efforts.

But keep in mind, for the better part of the last 5 years, Stuart and Thorsten were right about this - which kinda supports Thorsten's pain/gain notion in a fairly compelling way :D
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Spoken ATC

Postby Torsten » Tue Jul 25, 2017 2:01 pm

Hi Rodolfo
rleibner wrote in Mon Jul 24, 2017 4:29 pm:Alternatives are either to keep the nested if/elsif scheme (cumbersome yes but quite readable) or to move all logic to conditions into the properties tree and use a statemachine approach.

Just pick what suits best for you. My personal preferrence would be to avoid Nasal as much as possible.
Every single object (variable, function, everything) add to the garbage collectors workload. Sure, the spoken atc addon is small compared to other "frameworks" but every little bit helps. We have xml based conditions and state machines for a reason.
(Take my statement with a grain of salt - I hate Nasal with a passion)

Do you need any help with using SVN+FGAddon for maintaining your code?

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: Spoken ATC

Postby rleibner » Tue Jul 25, 2017 5:02 pm

Torsten wrote in Tue Jul 25, 2017 2:01 pm:Do you need any help with using SVN+FGAddon for maintaining your code?

you guessed, yes I do ! :oops:
Trying to svn commit, I got:
Code: Select all
svn: E000013: Can't open file '/svn/p/flightgear/fgaddon/db/txn-current-lock': Permission denied

What ? There is not even such a file!
Embarrassed and ashamed ...

On the other hand, I'm trying to understand how to use 'conditions'
I made:
Code: Select all
<PropertyList>
   . . .
  <relpos type="string"></relpos>

         <binding> 
    <condition>
     <greater-than>
     <property>/position/altitude-agl-ft</property>
     <value>30</value>
     </greater-than>
    </condition>
         <command>property-assign</command>
          <property>/instrumentation/comm/atc/relpos</property>
          <value type="string">flying</value>
        </binding>

        <binding>
    <condition>
     <less-than-equals>
     <property>/position/altitude-agl-ft</property>
     <value>30</value>
     </less-than-equals>
    </condition>
          <command>property-assign</command>
          <property>/instrumentation/comm/atc/relpos</property>
          <value type="string">on ground</value>
        </binding>

expecting to see how relpos value changes when I raise up the UFO: nothing happened.
I'm making a mistake and donno which one.
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: Spoken ATC

Postby Thorsten » Tue Jul 25, 2017 6:05 pm

Alternatives are either to keep the nested if/elsif scheme (cumbersome yes but quite readable) or to move all logic to conditions into the properties tree and use a statemachine approach.


Personally, I think the performance impact of what you're trying to do is negligible so you should code how you feel you can maintain it best. At least I haven't seen the impact of the Garbage Collector for the last years - the growing CPU powers have solved (or perhaps rather hidden) the issue pretty efficiently and today's bottlenecks on modern hardware are usually elsewhere (unless you code very inefficiently).

Also - should you end up needing to exchange a lot of data between property tree and Nasal, that's likely more expensive than any gain you'd get from using property rules.

(Disclaimer: I do not hate Nasal at all, I think it's rather useful and versatile...)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Spoken ATC

Postby rleibner » Tue Jul 25, 2017 6:35 pm

Thorsten wrote in Tue Jul 25, 2017 6:05 pm:Also - should you end up needing to exchange a lot of data between property tree and Nasal, that's likely more expensive than any gain you'd get from using property rules.

I suspected that, but as said before
For now I will continue to improve the script as it is, according to the bug reports I receive.
In the meantime, I'll work on a state machine model. Once I have it, we will compare advantages/disadvantages and take a final decision


Any suggestions for my troubles with svn commit?
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: Spoken ATC

Postby Hooray » Tue Jul 25, 2017 7:32 pm

Just for the record, I am with Thorsten on this one - Nasal's garbage collector (GC) and Nasal in general are far more often considered the culprit than they really are - as a matter of fact, I think it was AndersG who once came up with patches to move the GC to a different thread (there were issues related to Nasal/ghost handling, showing up especially on Canvas/rendering code, potentially invoked by another thread), also I have posted working patches to incrementally init the Nasal subsystem to load modules only on demand, as well as entirely disable Nasal, and still many other subsystems are causing the type of "lag" (stuttering) that is usually attributed to Nasal, despite Nasal itself being either "clean" or not even running at all.




I also don't think that it's going to matter in this case - anyway, people with commit access to SG/FG would seem to be in a perfect position to do something about the underlying issue, which is not Nasal per se, but rather making C++ data structures and systems (think property rules) available to Nasal coders so that these can be dynamically re-configured and instantiated, and maybe even help getting the GC patches reviewed/discussed, improved and committed - even if just as an experimental option.

viewtopic.php?f=30&t=28084&p=265773&hilit=andersg+thread+collector#p265773
AndersG wrote in Tue Nov 24, 2015 4:07 pm:There were some serious issues with my patch - namely that the destruction of some C++ side FG objects kept alive by Nasal references must not be invoked on a different thread. I didn't see the crashes, but they appeared for people using Canvas heavy aircraft.
James did some work to fix these problems but I'm not sure how completely he managed. I still run the patch with his updates, however, and for the aircraft (I don't think I use any canvases, though) I use it works.

Running the Nasal GC in a different thread could certainly be revisited, and if the GC updated to an incremental one it could be done without impacting the main loop much.

As an aside: when testing/measuring performance it is rather important to measure within the expected domain. E.g. different parts of FlightGear scale their load (computation per unit of time) differently with frame rate, e.g.:
1. JSBSim uses about the same amount of CPU (for a particular FDM) no matter the frame rate (down to hitting the max simulation time per frame).

2. Per frame work (including Nasal timer 0 loops) will increase with the frame rate. Going from 20 fps to 2000 fps will thus increase this load by two orders of magnitude.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Spoken ATC

Postby rleibner » Tue Jul 25, 2017 10:25 pm

Dear fellows,
I know the differences of opinions. All the arguments have already been extensively exposed in this forum.
I am doing my best, not thinking of me, but the best for everyone in FGFS users and developers.

It is time for me to go ahead with the task, and the truth is that I am stuck.
I beg that someone can give me a clue on the two issues I raised before about svn commit and conditions use.

Respectfully yours,
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: Spoken ATC

Postby Thorsten » Wed Jul 26, 2017 6:48 am

Can you give us the sequence of commands you tried before getting the error?

How did you checkout the repository, what did you do then, are you trying to use it with your SF account,...? Did this work before and suddenly stopped, or did this fail the first time? Is this a temporary thing perhaps?
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Spoken ATC

Postby rleibner » Wed Jul 26, 2017 3:11 pm

First I tried a
Code: Select all
svn checkout https://svn.code.sf.net/p/flightgear/fgaddon/trunk flightgear-fgaddon

When I realized I was downloading the whole trunk, I aborted the process, deleted the ~/flightgear-fgaddon directory and
Code: Select all
 svn co https://svn.code.sf.net/p/flightgear/fgaddon/trunk/Addons/SpokenATC

Then I edited the files. At present, status is:
Code: Select all
rodolfo@6200:~$ svn st ./SpokenATC/
M       SpokenATC/init.nas
M       SpokenATC/phraseology.nas
M       SpokenATC/spoken_atc.nas
?       SpokenATC/svn-commit.4.tmp
?       SpokenATC/svn-commit.tmp
M       SpokenATC/voice.nas


And commit attempts give:
Code: Select all
rodolfo@6200:~/SpokenATC$ sudo svn --username rleibner --password <mypsswd>  commit
svn: E000013: Falló el commit (detalles a continuación):
svn: E000013: Can't open file '/svn/p/flightgear/fgaddon/db/txn-current-lock': Permission denied
svn: E000013: Su mensaje de commit fue dejado en un archivo temporario:
svn: E000013:    '/home/rodolfo/SpokenATC/svn-commit.3.tmp'

As said before, to make a chmod has no sense since there is not a '/svn/p/flightgear/fgaddon/db/txn-current-lock' file in my PC.
:?:
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: Spoken ATC

Postby rleibner » Wed Jul 26, 2017 4:10 pm

About how to use conditions, I grep for '<conditions>' and found only in binding context (keyboard, joystick and mice.xml).
In other words, dont know if it's possible to change a property value using a condition branch on the node.
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: Spoken ATC

Postby Thorsten » Wed Jul 26, 2017 5:34 pm

https://stackoverflow.com/questions/319 ... tdb-db-txn

Seems to suggest it's a permission error server-side. If so TorstenD has to take a look, please write him a PM if he doesn't see this.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Spoken ATC

Postby Richard » Wed Jul 26, 2017 7:59 pm

I think this is the standard svn error that I've seen countless times. It's something on the Sourceforge infrastructure and the only way around it seems to be to commit in smaller chunks, or from a faster connection, or keep trying until it works.

Unless of course those paths match your local drive, in which case an svn cleanup may be required.
Richard
 
Posts: 810
Joined: Sun Nov 02, 2014 11:17 pm
Version: Git
OS: Win10

Re: Spoken ATC

Postby bugman » Thu Jul 27, 2017 11:33 am

You have made a read-only checkout. For a writeable checkout copy, please follow the instructions at:

Regards,
Edward

Edit: Do not use sudo for developmental work (git or svn)!
bugman
Moderator
 
Posts: 1808
Joined: Thu Mar 19, 2015 10:01 am
Version: next

Re: Spoken ATC

Postby rleibner » Tue Aug 01, 2017 8:50 pm

Hello everyone,

I'm working in a new version based on a state machine style.
Also I'm replacing phraseology.nas by a phraseology.xml.
And my goal is to have a phraseology.xml easily customizable by the user, something like:
Code: Select all
<PropertyList>
   . . .
  <gognd type="string">Contact ground at </gognd>
  <gognd type="string">%TOKEN("/satc/freqs/gnd")</gognd>
  <gognd type="string">. </gognd>
     . . .

Am I clear? A kind of token getting the value of another property located somewhere in the tree.
Is that possible? :?:
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: Spoken ATC

Postby Hooray » Sat Aug 05, 2017 2:19 pm

I haven't looked at any of your code or changes recently - but if you haven't done so already, I would strongly suggest to introduce a <version> tag for any custom files, so that you can easily make compatible changes in the future, or at least show a warning if a file isn't suitable to be used in conjunction with a more recent version of the addon.

Basically, all you need is a <version>1</version> tag and then parse that to see if the addon version matches the data file in use.

This is one of the most common problems that FlightGear's XML files have, because we missed to version our stuff properly - which also applies to Nasal code and its dependencies.
It took literally years for aircraft to be "somewhat" versioned. Despite numerous patches floating around here (and on the original avsim forums).
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

PreviousNext

Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest