Board index FlightGear Development Nasal

Spoken GCA

Nasal is the scripting language of FlightGear.

Re: Spoken GCA

Postby Hooray » Wed Dec 27, 2017 11:38 pm

wow, it seems you have turned FlightGear into a plotting application meanwhile ;-)
Regarding the docs, I would suggest not to write any unless you have done some benchmarking and are satisfied with the performance ?
The point being that during the development of the fgplot tool, there were some performance issues that needed to be ironed out first.
Thus, I would not write/update any docs unless you are sure that the code will remain "as is" ?
For benchmarking purposes, it might be best to do some aggressive plotting - either using a handful of different graphs, or different functions plotted to the same graph.
As a matter of fact, most of the original fgplot topic was really all about potential performance improvements.

By the way, your plotProperty helper would be easy to reuse for a UI-driven mode where the property can be made user-configurable using a Canvas LineInput: http://wiki.flightgear.org/Canvas_Snipp ... put_Dialog

That would mean that you could more easily change/reconfigure the property to be used for the x/y axis (e.g. by clickign the axis/label)

I still have to look at your other changes to make any helpful comments - other than that, it seems that you have meanwhile definitely outgrown the original atc/gca purpose - so you may just as well ask one of the fgdata committers to commit your modules and/or move your helpers to a separate "plotting" addon, because none of this is specific to the atc/gca use-case anymore (if that is something you'd like to do, it might be a good idea to look at some of the original fgplot discussions/features to see what this was originally all about, I think it was primarily used for plotting fdm/autopilot properties...)

Again, I still have to look at your other changes to really understand what else you have changed there - but I think it's pretty safe to say that you have literally created a new API that could be used for developing all sorts of new features.
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 GCA

Postby rleibner » Thu Dec 28, 2017 12:37 am

Hooray wrote in Wed Dec 27, 2017 11:38 pm:wow, it seems you have turned FlightGear into a plotting application meanwhile ;-)
Yeah, soon I will use FGFS instead of Inkscape !! :lol: :lol:
By the way, I am totally out of the original subject of this thread.Next posting to the forum will be under his Development/Canvas branch.
Hooray wrote in Wed Dec 27, 2017 11:38 pm:Regarding the docs, I would suggest not to write any unless you have done some benchmarking and are satisfied with the performance ?
Copy that.
Hooray wrote in Wed Dec 27, 2017 11:38 pm:... you may just as well ask one of the fgdata committers to commit your modules and/or move your helpers to a separate "plotting" addon ...
May I move them by myself or must I ask for a clearence first ?
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 GCA

Postby Hooray » Thu Dec 28, 2017 1:44 pm

I think it's safe to commit those modules to fgdata, because it's nowhere else being used.
You may still want to provide a concrete "application", e.g. some kind of simple Canvas GUI dialog for plotting arbitrary properties, integrated with the menubar - so that people actually understand what the commit/module is all about.

Given what you have meanwhile, it would seem pretty straightforward to show a Canvas UI dialog and let people configure the axes/properties using a simple "UI" (think like the GCA GUI) and then show a matching diagram

Obviously, at this point this could just as well be another addon - but personally, I do believe that the plotting helpers should be part of fgdata/Nasal/canvas sooner or later, because it would be generally useful.

Looking at the original fgplot screenshots in the wiki, I think you have already exceeded its functionality - even though I do think it was maintaining a history of each graph and would show different graphs per diagram, but I haven't used it in years to be honest.

Image


PS: Adding native property plotting support to fgfs is actually a long-standing, originally put forward by Curt himself: http://wiki.flightgear.org/FGPlot#Background
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 GCA

Postby clm76 » Sat Jan 06, 2018 7:27 pm

Hi,

I think there is a problem in the module "par_class.nas", function "flipX" :
Code: Select all
flipX: func(toogle=1) {
 if(toogle) me.flip *= -1;
 me.x0 = me.size.width - me.x0;
 var elements = [me.Hgrid, me.Vcone,me.Vgrid, me.Hcone, me.Hcenter, me.Vcenter, me.terrain, me.asph, me.compass];
 foreach(elem;elements) plot2D.flipX(elem,me.size.width);
 me.cs1Text.setTranslation(t,0);
 me.cs2Text.setTranslation(t,0);
 me.wndow.clearFocus();
}, # flipX

these lines :
Code: Select all
 me.cs1Text.setTranslation(t,0);
 me.cs2Text.setTranslation(t,0);

return a nasal error "undefined symbol : t" when pushing the button "FLIP" on "P A R Screen"
clm76
 
Posts: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Spoken GCA

Postby rleibner » Sat Jan 06, 2018 10:11 pm

clm76 wrote in Sat Jan 06, 2018 7:27 pm:I think there is a problem in the module "par_class.nas", function "flipX" :

Yes, I've been working in the plot2D/graph helpers and must review the SpokenGCA code.
Hope the next week a new version of SpokenGCA will be available (may be with a new skin).

Anyway, thanks for the feedback.
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 GCA

Postby Hooray » Sun Jan 07, 2018 5:59 pm

rleibner wrote in Sat Jan 06, 2018 10:11 pm:Hope the next week a new version of SpokenGCA will be available (may be with a new skin).


FWIW, your way of setting up the skin using a hash with arguments is pretty elegant - I forgot to mention that you can obtain the coordinates for the hotspot by using a global event listener on the canvas/group and make that print the coordinates for drag/drop to the console. That way, it is easy to come up with the coordinates for all widgets, but also for the inner screen region - i.e. where you'd probably use clipping and/or a canvas image child to reference the actual graph canvas.

If you are planning on adding such a skin also to your GCA addon, my suggestion would be to come up with a helper class, e.g. something like "Skinnable", using an outer image and an inner one (potentially, even a vector of images). The helper class could also contain support for setting up hot-spots specific tooltips.

I've been in touch with Stuart about this, mainly in the context of his recent FG1000 work, so if you should come up with such a helper class (or even just a wiki tutorial demonstrating the approach), that may be helpful in and of itself.

Apart from that, my suggestion for your code would be to structure it so that it can support independent instances of the graph/oscilloscope, i.e. to allow people to use multiple oscilloscope instances concurrently.
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 GCA

Postby rleibner » Mon Jan 08, 2018 2:59 pm

Hooray wrote in Sun Jan 07, 2018 5:59 pm:... you can obtain the coordinates for the hotspot by using a global event listener on the canvas/group and make that print the coordinates for drag/drop to the console.
Yes, I noticed and that's exactly how I picked up the coordinates.

A Skinnable helper class ... Yes, it should not be difficult to achieve.
However, there is one issue that worries me:
I think the addons method is a great achievement that we must defend and encourage.
And ask the user to move the images to his $FG-ROOT folder ... is totally contrary to the philosophy of the addons.
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 GCA

Postby Hooray » Mon Jan 08, 2018 7:53 pm

like I said, if you cannot make the Canvas system access any images in the addon folder, that would seem to because the Canvas APIs are probably still unaware of the way addons work - slawekmikula ran into the same issue when he was trying to load some stuff, but it got fixed when he posted on the devel list.

First of all, it might be a good idea though to be sure that there is an actual problem (see my response referring to IORules)
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 GCA

Postby clm76 » Tue Jan 30, 2018 7:58 pm

Hi Rodolpho,

A nasal error "nil used in numeric context" in the module "gca_class.nas", function "setRunway", line :
Code: Select all
 me.touch.set_alt(1+geo.elevation(latlon[0],latlon[1]));

occurs when the destination runway is too far from the aircraft position and the tile is not yet loaded.
To prevent this, I suggest to perform a test in the module "control.nas" like this :

old :
Code: Select all
# Choose best rwy
var best = chooseRwy(info.runways);

# Instance GCAController
...

new :
Code: Select all
# Choose best rwy
var best = chooseRwy(info.runways);
var rwy_object = airportinfo(icao).runways[best];
var test = geo.Coord.new().set_latlon(rwy_object.lat,rwy_object.lon)
           .apply_course_distance(rwy_object.heading,rwy_object.threshold);
var latlon = test.latlon();
if (geo.elevation(latlon[0],latlon[1]) == nil) {
  gui.popupTip("Destination too far, tile not loaded",3);
  return;
}

# Instance GCAController
...
clm76
 
Posts: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Spoken GCA

Postby Hooray » Tue Jan 30, 2018 8:25 pm

Yes, that does make sense (unfortunately) - I seem to remember that someone once touched the so called "tile manager" to also make it serve requests of locations that are not yet loaded, but don't remember the details:

https://sourceforge.net/p/flightgear/ma ... /27885835/
ThorstenB wrote:https://sourceforge.net/p/flightgear/ma ... /26186083/
Curt wrote:I think you are on the right track by looking at the tile cache. The
original design used a distance based metric for removing the tiles that are
the furthest away, but somewhere along the way we got talked into switching
this to a time stamp based approach.

Along the way we added some code that could query the ground height at
arbitrary locations, not just the current aircraft location, so this
complicates the whole tile caching scheme because a variety of locations and
tiles could be referenced. I wonder if we somehow get into a situation
where the cache isn't big enough for all the tiles we are trying to
reference? Or some combination with how we reference tiles as stopped
playing nice with the tile cache management scheme?

The tile manager is capable of satisfying multiple requests. Anyone can
give it a position, range and a timeout. It will then try to load all
tiles in the range specified. And it will stop loading them after the
timeout - unless you have updated the request with a new timeout. So you
could tell it every 5 seconds that you're interested in a certain area
around the aircraft, and use a timeout of 5,01 seconds. A matter of
memory and loading speed though ;-).


I think the corresponding C++ APIs would be this one: https://sourceforge.net/p/flightgear/fl ... r.cxx#l519

Code: Select all
/** Schedules scenery for given position. Load request remains valid for given duration
 * (duration=0.0 => nothing is loaded).
 * Used for FDM/AI/groundcache/... requests. Viewer uses "schedule_tiles_at" instead.
 * Returns true when all tiles for the given position are already loaded, false otherwise.
 */
bool FGTileMgr::schedule_scenery(const SGGeod& position, double range_m, double duration);


However, I don't think this code is currently exposed to Nasal (scripting space). Looking at the code, one possible workaround to still make the scheduler trigger a scenery load is using the AI system by loading an invisible 3D model using those coordinates, according to: https://sourceforge.net/p/flightgear/fl ... t.cxx#l544

As far as I can tell, this should trigger the scheduler and make it load the missing tile/s.

Again, tanker.nas is probably our best guess here ... in the meantime, coming up with a custom view and changing its coordinates accordingly may be another feasible workaround: https://sourceforge.net/p/flightgear/ma ... /26185931/

(Obviously, it would be much better to expose the API to scripting space ... but these things often take years unfortunately - as a matter of fact, it might be a rather benign and simple change to modify f_geodinfo() accordingly and ensure that these requests end up scheduling scenery automatically)
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 GCA

Postby rleibner » Wed Jan 31, 2018 9:59 pm

Now, since the Oscilloscope's code has has a certain degree of maturity (I hope so) and his wiki page, I think it's time to face old debts : the 2 issues pointed by clm76.
Even more, I must bring to SpokenGCA the latest versions of skinnable/graph/plot2D helpers and rework SpokenGCA in order to make use of their new features.

Unless you think there are more urgent tasks.
In the meantime, I will study the 2 possible workarounds (the invisible -or not- AI model, or the custom view)
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 GCA

Postby Hooray » Wed Jan 31, 2018 10:57 pm

Those two "workarounds" were so far just ideas actually, I cannot say for sure if they're going to work here - but it should be relatively easy to test via the Nasal Console.
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 GCA

Postby rleibner » Wed Jan 31, 2018 11:53 pm

I've just searched "custom view" at the wiki and the forum: Nothing found.
I tested to edit the "/sim/current-view/viewer-lat-deg" (and "lon") prop: Do not works.
Any tip?

(I have not yet explored the AI model way)
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 GCA

Postby Hooray » Thu Feb 01, 2018 9:20 pm

Background at: http://wiki.flightgear.org/Howto:Config ... FlightGear

Dedicated Nasal module at: https://sourceforge.net/p/flightgear/fg ... l/view.nas

PS: FGCamera can probably be considered to be the "reference" implementation for Nasal based views.
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 GCA

Postby AndersG » Thu Feb 01, 2018 10:00 pm

Another example of a view manager managed view (which might be the most suitable way to interface Nasal control with a specific view):
https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Aircraft/Generic/WalkView/walkview.nas

The view manager is part of the Nasal/view.nas file linked in the previous post.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2525
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

PreviousNext

Return to Nasal

Who is online

Users browsing this forum: No registered users and 0 guests