Board index FlightGear Development Canvas

Canvas ND on another aircraft than Boeing and Airbus

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.

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby xcvb » Fri Dec 02, 2016 5:51 pm

Hi

I wonder if there is a way to get the airports white, the VOR/DMEs green and if there is already something in the mapstructure for such a vertical route display as marked in this image:

Image

BR
xcvb
 
Posts: 88
Joined: Sat Mar 14, 2015 2:08 pm
Version: 2018.1.1
OS: Fedora 27

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby clm76 » Sat Dec 03, 2016 8:55 am

Hi,

I wonder if there is a way to get the airports white, the VOR/DMEs green

Yes, it's possible. I changed some colors, text size ... on the Citation X. The link will come today evening (sorry, I'm a little bit late)

and if there is already something in the mapstructure for such a vertical route display as marked in this image:

I'll work on that after the RMU. To my knowledge, only Omega95 has developed a nasal VSD (Vertical Situation Display), but it needs to be reviewed.
http://wiki.flightgear.org/Howto:Implement_a_Vertical_Situation_Display_in_Nasal
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby Hooray » Sat Dec 03, 2016 10:33 am

Colors can be customized using custom styles: http://wiki.flightgear.org/Canvas_MapStructure#Styling

For the time being, the MapStructure framework does not contain support for VSDs (aka VERTICAL layers) - but it should be straightforward to generalize and adapt Omega95's work accorrdingly: http://wiki.flightgear.org/Canvas_MapSt ... cal_Layers

Gijs also mentioned that he was interested in working on the VSD a while ago.

Omega95's VSD: http://wiki.flightgear.org/FlightGear_N ... on_Display

Image

Image
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: 11340
Joined: Tue Mar 25, 2008 8:40 am

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby xcvb » Sat Dec 03, 2016 1:44 pm

OK, my fault. The correct property is color_default and not just color.
The VSD of the Honeywell Primus 2000 is quite simple and I guess it makes no sense to include this special behaviour in a framework.

Differences to other VSDs:
- aircraft symbol is always located in the center and not depending on the flight level
- terrain is not shown

So this can be solved by just drawing some simple lines.
xcvb
 
Posts: 88
Joined: Sat Mar 14, 2015 2:08 pm
Version: 2018.1.1
OS: Fedora 27

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby Hooray » Sat Dec 03, 2016 4:24 pm

Actually, a VSD should be comparatively simple either way - because it's mainly a graph with two axes (x/y) where you are plotting your current altitude against the terrain elevant using a certain range - behind the scenes, you merely need to sample the terrain along the vector of your current flight path (or flight plan) - i.e. geodinfo() calls and/or using the built-in terrain presampler that TorstenD implemented for Thorsten's advanced weather system.

It would be a good idea to prototype the whole thing using a standalone Canvas GUI dialog, e.g. by adapting a related example:

http://wiki.flightgear.org/Canvas_Snipp ... enVG_Paths
Image

I am not sure if Torsten's hard-coded terrain presampler is documented anywhere, but Thorsten's AW code should contain examples on using it correctly - maybe Thorsten's can provide more specific pointers ?

The most relevant wiki articles documenting the geodinfo() calls would be:

http://wiki.flightgear.org/Howto:Terrai ... g_in_Nasal
http://wiki.flightgear.org/Nasal_library#geodinfo.28.29

Once we have a working prototype, this should be easy to adapt to support different kinds of aircraft, and different styles.
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: 11340
Joined: Tue Mar 25, 2008 8:40 am

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby xcvb » Sun Dec 04, 2016 1:39 pm

Is there a way to reduce the refresh rate of the mapstructure layers?
xcvb
 
Posts: 88
Joined: Sat Mar 14, 2015 2:08 pm
Version: 2018.1.1
OS: Fedora 27

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby Hooray » Sun Dec 04, 2016 3:35 pm

yeah, there is some "update_on" field that /can/ take a hz (hertz) value, which ends up in the maketimer() call determining how often a layer is updated without being bound to a listener/property update, e.g.: WXR:

Code: Select all
update_on:[ {rate_hz: 0.1}, ...


Unfortunately, there still is the back-end part in navdisplay.mfd which contains a bunch of hard-coded updates

If in doubt, tell us a little more about the layer you are working on.
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: 11340
Joined: Tue Mar 25, 2008 8:40 am

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby clm76 » Mon Dec 05, 2016 9:20 am

Hi,

There is a bug with Canvas Navdisplay in Fg2017.1.0 : By decreasing the range (instrumentation/efis/inputs/range-nm), Fg breaks without message except TRACE : "".
Same problem with the 777.
No problem with Fg2016.4.0
I sent a bug report : ticket 1921
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby xcvb » Tue Dec 06, 2016 7:11 pm

I wonder what I do wrong:

Code: Select all
var ndlayers = [{name:'APT',style:{scale_factor:0.6,label_font_color:[1,1,1],color_default:[1,1,1]}},
      {name:'DME',style:{scale_factor:0.6,color_default:[0,1,0]}},
      {name:'WPT',style:{scale_factor:0.6,color_default:[0,1,0]}}];

var canvas_nd = {
   new: func(canvasGroup)
   {
      var m = { parents: [canvas_nd] };
      m.group = canvasGroup;
      m.map = canvasGroup.createChild('map');

      var font_mapper = func(family, weight)
      {
         if(family == "'Liberation Sans'" and weight == "normal") {
            return "LiberationFonts/LiberationSans-Regular.ttf";
         }
      };

      canvas.parsesvg(canvasGroup, "Aircraft/do328/Models/Instruments/EICAS/nd.svg", {'font-mapper': font_mapper});

      var svg_keys = ["compass","hdg"];
      foreach(var key; svg_keys) {
         m[key] = canvasGroup.getElementById(key);
      }

      ### mapstructure ###
      m.map.setController("Aircraft position");
      m.map.setRange(20);
      m.map.setTranslation(283,310);

      foreach(var layer; ndlayers) {
         m.map.addLayer(
            factory: canvas.SymbolLayer,
            type_arg: layer.name,
            visible: 1,
            style: layer.style,
            priority: layer['z-index']
         );
      }

      m.active = 0;
      return m;
   },
   update: func()
   {
      var heading = getprop("orientation/heading-magnetic-deg");

      if(heading != nil){
         me.hdg.setText(sprintf("%3.0f",heading));
         me.compass.setRotation(-heading*math.pi/180);
      }

      if(me.active == 1) {
         settimer(func me.update(), 0.3);
      }
   },
   show: func()
   {
      me.active = 1;
      me.update();
      me.group.show();
   },
   hide: func()
   {
      me.active = 0;
      me.group.hide();
   }
};

This works but the framerate is that bad that I would not call this usable.
xcvb
 
Posts: 88
Joined: Sat Mar 14, 2015 2:08 pm
Version: 2018.1.1
OS: Fedora 27

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby xcvb » Tue Dec 06, 2016 10:20 pm

OK, I found the solution. By defining your own map controller you can get the control over the refresh rate of the mapstructure.
xcvb
 
Posts: 88
Joined: Sat Mar 14, 2015 2:08 pm
Version: 2018.1.1
OS: Fedora 27

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby Hooray » Sat Dec 10, 2016 5:11 pm

Thanks for the update, feel free to add your code to the wiki so that people can more easily do these things - the TRACE issue seems unrelated though, i.e. more likely to be related to recently reverted experimental tinkering with the SGPropertyNode code that affected Canvas based 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: 11340
Joined: Tue Mar 25, 2008 8:40 am

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby xcvb » Sun Dec 11, 2016 10:10 am

This is the first time I do something with canvas so there could be a better solution. This is the way I solved it:

Code: Select all
var ndlayers = [{name:'APT',visible:1,style:{scale_factor:0.6,label_font_color:[1,1,1],color_default:[1,1,1],line_width:4}},
      {name:'DME',visible:1,style:{scale_factor:0.6,color_default:[0,1,0],line_width:4}},
      {name:'WPT',visible:1,style:{scale_factor:0.6,line_width:4}},
      {name:'RTE',visible:0,style:{scale_factor:0.6,color:[0,1,0],line_width:3}}];

var hdg = props.globals.getNode("orientation/heading-magnetic-deg");
var lon = props.globals.getNode("position/longitude-deg");
var lat = props.globals.getNode("position/latitude-deg");

var do328_controller = {
   parents: [canvas.Map.Controller],

   new: func(map) {
      var m = { parents: [do328_controller],map:map };
      m.timer = maketimer(0.1, m, m.update_layers);
      m.timer.start();

      # this check is missing in RTE.lcontroller
      setlistener("/autopilot/route-manager/active", func {
         if(getprop("/autopilot/route-manager/active")) {
            m.map.getLayer("RTE").setVisible(1);
         }
      }, 1);
      return m;
   },

   update_layers: func() {
      me.map.setPos(lat.getValue(),lon.getValue(),hdg.getValue());
      me.map.update();
   },

   del: func() {print("cleaning up nd controller");}
};

var canvas_nd = {
   new: func(canvasGroup)
   {
      var m = { parents: [canvas_nd] };
      m.group = canvasGroup;
      m.map = canvasGroup.createChild('map');

      var font_mapper = func(family, weight)
      {
         if(family == "'Liberation Sans'" and weight == "normal") {
            return "LiberationFonts/LiberationSans-Regular.ttf";
         }
      };

      canvas.parsesvg(canvasGroup, "Aircraft/do328/Models/Instruments/EICAS/nd.svg", {'font-mapper': font_mapper});

      var svg_keys = ["compass","hdg"];
      foreach(var key; svg_keys) {
         m[key] = canvasGroup.getElementById(key);
      }

      ### NavDisplay ###
      m.map.setRange(20);
      m.map.setTranslation(283,310);
      m.map.setPos(lat.getValue(),lon.getValue(),hdg.getValue());
      m.map.setController(do328_controller);

      foreach(var layer; ndlayers) {
         m.map.addLayer(
            factory: canvas.SymbolLayer,
            type_arg: layer.name,
            visible: layer.visible,
            style: layer.style,
            priority: layer['z-index']
         );
      }

      m.active = 0;
      return m;
   },
   update: func()
   {
      var heading = hdg.getValue();

      if(heading != nil) {
         me.hdg.setText(sprintf("%3.0f",heading));
         me.compass.setRotation(-heading*math.pi/180);
      }

      if(me.active == 1) {
         settimer(func me.update(), 0.1);
      }
   },
   show: func()
   {
      me.active = 1;
      me.update();
      me.group.show();
   },
   hide: func()
   {
      me.active = 0;
      me.group.hide();
   }
};

The trick is the do328_controller I used instead of "Aircraft position" which reduces the refresh rate of the mapstructure to every 0.1 seconds. I wonder why there is a check in the WPT.lcontroller if the autopilot was initialized but not in the RTE.lcontroller.
xcvb
 
Posts: 88
Joined: Sat Mar 14, 2015 2:08 pm
Version: 2018.1.1
OS: Fedora 27

Re: Canvas ND on another aircraft than Boeing and Airbus

Postby Hooray » Sun Dec 11, 2016 4:10 pm

If all that needs changing is the maketimer interval, my preference/suggestion would be to make this configurable via the ctor (constructor) of the ND/MapStructure code (if it isn't already, haven't looked at that code in months, if not even years ... but regardless of what the code currently looks like, it should take exactly two lines of code that need changing, nothing more).

Like I mentioned elsewhere, my suggestion would be to team up with other people currently working with the ND/MapStructure code and create a corresponding team clone to more easily share your changes, so that these can be hopefully reviewed and committed upstream sooner or later.
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: 11340
Joined: Tue Mar 25, 2008 8:40 am

Previous

Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests