Board index FlightGear Development Canvas

Multiple Flight Plans

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Multiple Flight Plans

Postby artix » Thu Feb 26, 2015 6:42 pm

Hello, in the latest weeks i had to time to work on the canvas framework because of my job, but in the latest days i've found a bit of time and today i've added support for multiple flight plans to the RTE/WPT layers.
This feature is based on two points:

- First of all i've changed LineSymbol so that it's now possible to pass an hash as model (until now it only accepted vectors). Hash-models must contain a mandatory "path" member that should contain the path vector (containing the same data used when the model is a vector). Using hashes allows developers to pass more data to the LineSymbol so that, for example, it's possible to pass the flight-plan type or ID (ie. primary, temporary, alternate, ...) that can be used by the RTE in order to use different styles for different flight plans.

- I've added a new class called RouteDriver that can be used by MapStructure layers in order to fetch info about routes and flight-plans in a totally aircraft-agnostic fashion. The default RouteDriver class just provides the basic, builtin FG flight-plan (the one you get by calling flightplan() ) as its lonely flight-plan. I've also added a basic MultiRouteDriver subclass that allows developers to add multiple flight-plans. But the most powerful feature of the RouteDriver is that every aircraft developer can subclass it and create its own route driver that provides route data to MapStructure layers. By this way, also custom (non builtin) flight plans can be easily supported. The RouteDriver methods are called by MapStructure layers in order to know how many flight-plans were created, the type of each flight plan, the size of each flight plan and the waypoints of each flight plan. Every developer is free to override those methods in order to provide informations to MapStructure that are based on their own aircraft-specific flight-plan implementation.

Here are to screenshots displaying what can be done with multiple flight plans:

Image

ND showing both active (green) route and temporary (yellow) route

Image

ND showing both primary active route (green) and "missed-approach" route (blue)

You can find this implementation on the topics/airbus_nd branch (altough it would be more appropriate to create a separate branch for it, being an aircraft-agnostic feature): https://gitorious.org/fg/canvas-hackers-fgdata/commits/1bfcebddab339d39eada1f9c855285146b6487cd

This feature is currently under development and has to be improved. In the next days i will provide more detailed informations on how the RouteDriver works and how it interacts with MapStructure Layers.
artix
 
Posts: 93
Joined: Wed Jun 25, 2014 8:42 pm
OS: Mac OS X

Re: Multiple Flight Plans

Postby Hooray » Fri Feb 27, 2015 1:11 pm

sounds very good to me - I guess you already found some comments suggesting that we were hoping to address this "eventually" ? So your work is appreciated. How does it integrate with non-aircraft use of MS layers - i.e. in the Canvas-map dialog ?

I will probably provide more detailed feedback once I had a chance to look at your code

EDIT:
- the MapDriver stuff looks good
- but shouldn't this be a "LayerDriver" ?
- I mean, the fplan stuff is layer specific, not map specific
- which also applies to all the other "driver" hashes we have
- so I would suggest to rename this to "LayerDriver" and make it more generic
- so that this can also be used for configuring other layers (think WXR layer API etc)

and then, it should be part of MapStructure.nas itself probably - i.e. added as a helper function there

For your recent changes to be reviewed and committed by any of the Boeing maintainers, it would help to also extend the boeing style accordingly

BTW: I suggest you read up on "git rebase" or "git pull --rebase" to avoid messing up the git history for people tracking your work :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: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Multiple Flight Plans

Postby Gijs » Fri Feb 27, 2015 5:26 pm

Nice work! Looking forward to merging it with the Boeing style.
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9386
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Multiple Flight Plans

Postby Hooray » Fri Feb 27, 2015 5:56 pm

I would move the WPTModel stuff into the RouteDriver class now - that way, the lcontroller files can be cleaned up, using a common class - i.e. maintained in a single place.
And then, the whole for loop is redundant, too:

Code: Select all
var planCount = driver.getNumberOfFlightPlans();
    for(var idx = 0; idx < planCount; idx += 1){
        var fp = driver.getFlightPlan(idx);
        var fpSize = fp.getPlanSize(idx);
        for (var i = 0; i < fpSize; i+=1)
            append(result, WPT_model.new(fp, i));
    }


i.e. this can be generalized and turned into a function of the RouteDriver that simply returns a vector (result) - so that this would simplify all lcontrollers using this layer.

Otherwise, this is looking really good to me - and more and more in line with the original MVC design that MapStructure is trying to establish as the "best practice".
I still think navdisplay.mfd contains too much aircraft specific code, and that the airbus specific integration layer (ND.nas) is far too excessive.
And performance-wise, caching needs to be adopted in new layers, or all Airbus aircraft will be suffering from frame rate issues sooner or later.

The MapDrivers.nas stuff is pretty clever and the right approach in my opinion - but we're now overloading the concept of "driver hashes" in quite a few places, without any code reuse at all.
i.e. we have an aircraftpos.controller, and an NDSourceDriver hash and a few other hashes encapsulating aircraft specific stuff.
Ideally, such things should be encapsulated in a single place - so that we can support different data sources (think flight plans, WXR APIs, navaid sources) just by providing a corresponding hash.
Currently, the old code is looking increasingly ugly and like a huge hack.

So I think it would make sense to unify those different "driver hashes" and come up with a "LayerDriver" that serves as the container for the APIs populating a layer (via searchCmd) - basically, that should satisfy all needs then - i.e. the main/ai aircraft use-case, but also different WXR APIs or different/custom flight plan/route manager implementations (omega95 basically re-invented the route manager from scratch in some of his aircraft).

While I don't necessarily agree with re-inventing the wheel, it is a good thing for the ND/MS frameworks to encapsulate layer-specific data providers so that different data sources can be used.
If done properly, you could even use a web API for all online flying, including even navaids, STARs, SIDs etc.


Also, it seems that TheTom may have a bit more time in the weeks to come, so maybe we can find a way to get Gijs' projection code adapted for the Canvas map next month ?

PS: You may want to update the wiki accordingly, and add an announcement to the newsletter - as well as send a heads-up to fellow airbus developers.
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: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Multiple Flight Plans

Postby artix » Sat Feb 28, 2015 9:21 am

Gijs wrote in Fri Feb 27, 2015 5:26 pm:Nice work! Looking forward to merging it with the Boeing style.


I did not merge it with the Boeing style because i don't know how different flight-plans (ie. missed-approach/alternate, temporary, secondary, ...) are rendered on the Boeing ND (in terms of colors, line dash, ...). Where can I find some documentation about it?
artix
 
Posts: 93
Joined: Wed Jun 25, 2014 8:42 pm
OS: Mac OS X

Re: Multiple Flight Plans

Postby Gijs » Sat Feb 28, 2015 7:43 pm

It's basically:
  • Active route: continuous line (magenta)
  • Active route modifications: short dashes (white)
  • Inactive routes: long dashes (blue)
Anyhow, if there's a clear Airbus example I should be able to come up with the Boeing one myself with limited effort. The biggest problem at the moment is that (I think) we don't have any Boeing aircraft that support modified routes etc. At least not yet.
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9386
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10


Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests