Board index FlightGear Development Aircraft Flight dynamics model

YASim development tools

Good sims require good FDMs (the "thing" that makes an aircraft behave like an aircraft).

YASim development tools

Postby jsb » Thu Feb 22, 2018 4:14 pm

Hi,

I created a little tool to visualize some of the YASim internals while running Flightgear. It uses nasal and canvas and is implemented as add-on so you can load it with FG as needed (that is, you have to start fgfs with --addon as described in the README).

You can download it at https://sourceforge.net/p/flightgear/fgaddon/HEAD/tree/trunk/Addons/YASimDevel/
A documentation is drafted in the wiki at http://wiki.flightgear.org/YASim_Development_Tools

It is currently more a prove of concept but some features may be usefull, e.g. when calibrating the center of gravity for a yasim based aircraft
jsb
 
Posts: 220
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: YASim development tools

Postby Michat » Fri Feb 23, 2018 9:23 pm

I love this. Really useful.


Thanks and 29.92 for you.
User avatar
Michat
 
Posts: 963
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

Re: YASim development tools

Postby Hooray » Sat Feb 24, 2018 12:07 pm

Agreed, this should probably be added to the newsletter - I am sure that Andy Ross would love to learn about this, given that he came up both features, i.e. YASim and Nasal - so he'll certainly appreciate seeing how things have gone full circle over the years - despite neither YASim nor Nasal having been actively maintained recently.
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: 11354
Joined: Tue Mar 25, 2008 8:40 am

Re: YASim development tools

Postby Hooray » Tue Feb 27, 2018 6:11 pm

Regarding your "reload" approach - that's pretty clever, but I think you may also have to check that not just the timer terminates but also that there is no active loop (callback) running - basically, even if each timer is stopped - an instance may still be active if I am not mistaken (which would match the semantics of settimer API).

Given that this is pretty critical, I would also suggest to return a success/error value to the caller - and invoke everything in a call() expression to see if any errors were triggered.
Other than that, this looks really good to me - and I would suggest to generalize the corresponding routines so that this can be more easily used elsewhere - for instance, Stuart's FG1000 also has a need for this, and the current method used there is isn't as sophisticated as your's (admittedly, it's been a while since I looked at the cleanup code there).
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: 11354
Joined: Tue Mar 25, 2008 8:40 am

Re: YASim development tools

Postby jsb » Tue Feb 27, 2018 7:59 pm

Thanks :) It took quite some time to get it working... somehow - nasal is powerful but confusing - if you do not use it regularly you forget the funky details (func, closure, namespace etc).
Please feel free to suggest patches or copy things to some generic place for re-use.
jsb
 
Posts: 220
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: YASim development tools

Postby Hooray » Tue Feb 27, 2018 8:05 pm

Yeah, kudos to you for getting this working !

To be honest, we tried to get the exact same thing working a few years ago for MapStructure layers, and after a while we just gave up - it was such a messy and fragile thing, i.e. code should normally be designed with this in mind, adding such functionality at a later time is unlikely to work too well ;-)

I suppose, sooner or later rominet will also run into this (Reloading/restarting potentially running stuff at runtime)
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: 11354
Joined: Tue Mar 25, 2008 8:40 am

Re: YASim development tools

Postby jsb » Wed Feb 28, 2018 4:35 pm

I thought about generalizing this but I simply have not enought time at the moment. Since sourceforge is not in good shape it is kind of hard to get my yasim bugfix into the release candidate, which I consider kind of must have or many people might be unhappy with the "downside" of the improvements I made to yasim over the last weeks. My lessons learned here is: I should have build a big testbed earlier.
jsb
 
Posts: 220
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: YASim development tools

Postby jsb » Wed Feb 28, 2018 6:37 pm

If some canvas GUI guru is around: putting a menu-bar or button-bar into the window would be nice - I am pretty sure I could find all that is needed on the wiki but... see above... so many things to do, so little time...
jsb
 
Posts: 220
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: YASim development tools

Postby Michat » Wed Feb 28, 2018 6:47 pm

Hi there I've edited the Wiki of March Section developmant news. http://wiki.flightgear.org/FlightGear_Newsletter_March_2018
Be free to change if needed.
User avatar
Michat
 
Posts: 963
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

Re: YASim development tools

Postby Hooray » Sun Mar 04, 2018 12:48 pm

jsb wrote in Wed Feb 28, 2018 6:37 pm:If some canvas GUI guru is around: putting a menu-bar or button-bar into the window would be nice - I am pretty sure I could find all that is needed on the wiki but... see above... so many things to do, so little time...


the easiest option would be using a vbox layout with buttons added for each entry: http://wiki.flightgear.org/Canvas_Snippets

There's also a simple proof-of-concept here: http://wiki.flightgear.org/Canvas_Snippets

My suggestion would be to use a ScrollArea to make the menu scroll-able

Here's another Canvas dialog using a few buttons at the top: http://wiki.flightgear.org/Howto:Reset/ ... leshooting
Image

So you can basically copy/paste and adapt the code as needed.
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: 11354
Joined: Tue Mar 25, 2008 8:40 am

Re: YASim development tools

Postby jsb » Mon Mar 05, 2018 8:08 pm

Nice examples :) I played around a little with this but I do not understand yet, how to add a gui bar at the top of my window and my free-style canvas below it. Do I need two canvas?
Is there a layout item for a canvas?
What does not seem to work is myLayout.addItem(myCanvas); or myLayout.addItem(myRootGroup);
jsb
 
Posts: 220
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: YASim development tools

Postby Hooray » Tue Mar 06, 2018 3:06 pm

Any Canvas can be treated as a raster image - thus, I would simply use a separate Canvas to do your drawing there, and then reference it as a Canvas.Image
Canvas.Image elements can be added to conventional layouts
This is what both, Stuart (FG1000) and rleibner (PAR tools) are doing, too

You'll basically set up a top-level vbox layout, and then add one hbox to the vbox to serve aas the "button bar" and then you can add the Canvas.Image to serve as the container for the canvas you are using for drawing purposes.
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: 11354
Joined: Tue Mar 25, 2008 8:40 am

Re: YASim development tools

Postby jsb » Thu Mar 08, 2018 1:38 pm

Sorry, I dont get it. I only get an Nasal runtime error: Fatal error in method call: Can not convert to 'canvas.LayoutItem': not a derived hash
Code: Select all
        #-- myCanvas for drawing YASim stuff
        me.myCanvas = canvas.new(me.canvasConfig).setColorBackground(0, 0, 0, 0.5);
        me.myRoot = me.myCanvas.createGroup();       
        me.myRoot.setCenter(me.canvasConfig.size[0]/2, me.canvasConfig.size[1]/2);
        #-- window canvas to hold GUI + my canvas
        me.myWindow = canvas.Window.new(me.canvasConfig.size, "dialog").setTitle(title);
        var wcanvas = me.myWindow.createCanvas().setColorBackground(0, 0, 0, 0.5);
        var root = wcanvas.createGroup();
        var layout = canvas.VBoxLayout.new();
        wcanvas.setLayout(layout);
        var checkboxBar = canvas.HBoxLayout.new();
        layout.addItem(checkboxBar);
        var image = root.createChild("image");       # image for yasim drawing
        image.set("src", me.myCanvas.getPath()); # assign myCanvas as image source

        layout.addItem(image);  # <--- Nasal runtime error: Fatal error in method call: Can not convert to 'canvas.LayoutItem': not a derived hash
  at D:/games/fgaddon/addons/yasimdevel/yasim.nas, line 182
jsb
 
Posts: 220
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: YASim development tools

Postby Hooray » Fri Mar 09, 2018 3:02 pm

layouts expect items to be layout items - thus, you'd want to add a corresponding Canvas widget (not the low-level element itself).
In this case, it would suffice to just add a button (or label) and set the background image to the canvas you want to display.

If in doubt, refer to $FG_ROOT/Nasal/canvas/gui and its widgets folder and Widget.nas for the interface class
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: 11354
Joined: Tue Mar 25, 2008 8:40 am


Return to Flight dynamics model

Who is online

Users browsing this forum: No registered users and 1 guest