Board index FlightGear Support Interfacing

Turning off the render and starting FG from another process

Connecting two computers, using generic protocol, connecting with Matlab?

Turning off the render and starting FG from another process

Postby chriscalef » Sat Mar 10, 2018 5:44 pm

Hello,

For some years @Hooray and I have discussed the ongoing work with HLA etc. to modularize FlightGear and make it possible to turn off whole subsections of the program in order to hand over control of those areas to another program.

I have had a side burner project for all this time, using FG in conjunction with a game engine (Torque3D) for rendering, and with recent work I'm doing on my front burner project, the thing would almost be a playable game interface, right now. It's definitely gone past the realm of laboratory testing and into the zone of actual fun. However, in terms of the general public it is IMHO fatally flawed by the fact that I have to start up both FlightGear and Torque separately and get everything all arranged in each program to in order to make it work. If I could just start my game, and at some point along the way have it start up FG, with command line variables setting everything up in fgfs, and be able to tell it to just kill the entire rendering process so as to remain completely in the background... then I might actually have something interesting here.

I'm unfortunately still a complete neophyte in terms of the FG codebase, and as I mentioned this being a kind of side burner project for me, I'd really love it if I didn't have to learn the whole engine and go untangle six months worth of spaghetti before I can possibly get what I want. Though I'd still like to hear the route, if this is the case, since it may yet turn into a front burner job at some point.

However, I'd also be interested in any hacks or gimmicky kluges that might avoid major effort but still fulfill my actual needs: a) not taking up desktop space and mental clutter for the end user by showing FG running, and b) saving performance by avoiding FG draw calls.

Thanks for all the hard work! FG is amazing.

Chris
chriscalef
 
Posts: 226
Joined: Wed Feb 20, 2013 9:28 pm

Re: Turning off the render and starting FG from another proc

Postby Hooray » Sat Mar 10, 2018 5:50 pm

If all you need is an invisible window, you can use the method suggested by FredB: http://wiki.flightgear.org/FlightGear_Headless

FredB wrote:The main camera is created in CameraGroup::buildCamera and a pbuffer is allocated when you set osg::GraphicContext::Traits.pbuffer to true. These traits are available in buildCamera because we set width and height there. For debugging purpose, you can add a line like
Code: Select all
window->gc->getTraits()->pbuffer=true;



You'd basically end up with an invisible window, so that fgfs could be treated to create/serve images as needed.

Related topic: Headless mode with access to property tree


For command line options, see: http://wiki.flightgear.org/Command_line_options
This is what existing UI front-ends (separate ones) are also using the start up fgfs as needed, e.g. fgrun etc: http://wiki.flightgear.org/Suggested_software#Frontends

You could probably adapt an existing launcher and start up your software, as well as fgfs that way.

That being said, there's a long-standing discussion/idea to turn fgfs into a library that can be used for unit testing.
Zakalawe and bugman have been working on this, and also recently posted updates on the devel list.
There's also a set of topic branches maintained by bugman that you could take a look at, and I believe there's also a topic on the forum about it.

For bugman's postings mentioning "cppunit", refer to: search.php?st=0&sk=t&sd=d&sr=posts&keywords=cppunit&author=bugman

EDIT:
saving performance by avoiding FG draw calls.


That's a separate thing and not easily possible using fgfs currently, unless you are willing/able to run just the FDM itself, and do away with fgfs :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: 11263
Joined: Tue Mar 25, 2008 8:40 am

Re: Turning off the render and starting FG from another proc

Postby chriscalef » Sat Mar 10, 2018 6:13 pm

Thanks, Hooray!

Aha, I was just about to ask about the performance side.

Maybe it would help if I made the resolution of my invisible window very small?

In truth, though, I'm not even sure if my main complaint, performance-wise, is a render issue or not - what I notice most painfully is that on first loading FG, whenever I first turn my camera to see new parts of the terrain, I get a significant freeze lasting a good part of a second. Not sure if this is from loading terrain or a render issue, but it is _very_ noticeable in even the simplest airports/regions, on a pretty new gaming rig, so it seems like something is badly off somewhere.
chriscalef
 
Posts: 226
Joined: Wed Feb 20, 2013 9:28 pm

Re: Turning off the render and starting FG from another proc

Postby Hooray » Sat Mar 10, 2018 6:15 pm

what exactly are your data requirements here - i.e. what are you doing from an I/O perspective. What inputs do you provide to fgfs and what output do you need ?

To be honest, my impression here is that this is a question that would be better asked on the devel list.

Primarily, because this is a long standing idea and one that a few core developers are/were working towards.

And more recently, it's been gaining some traction again - i.e. due to bugman's work.

In other words, there are currently people around who've previously worked in this direction, and who might want to hear about your use-case. Especially if that matches that their own priorities/roadmaps

Thus, you may be better off asking on the devel list if someone is around to provide pointers on how to go about implementing this.
If you are currently able to patch/rebuild fgfs from source and use latest git/next, I'd certainly mention that, too.

FWIW, I have previously linked fgfs as a lib into another application, and ended up reusing the same method when I used fgfs with an existing Ada code base:


http://wiki.flightgear.org/Howto:Using_ ... FlightGear
Image



With this in mind, and Fred's suggestion, it would seem pretty straightforward to even link fgfs into another application if that's what you'd like to do.

If you don't mind a little tinkering, you could also review the subsystem infrastructure and group rendering related subsystems into their own SGSubystemGroup - at that point, you could -in theory- have fgfs running without any rendering, but would probably want to review the places (code) where there are hard-coded assumptions - e.g. stuff like scenery/terrain that may be scheduled by the tile manager based on some viewer/rendering related protocols.

But in theory it should be possible with a bit of refactoring, and it would seem to align well with recently discussed unit-testing plans mentioned on the devel list.

So, I'd suggest to give the devel list a try - and see if it works for you or not. Obviously, feel free to come back here (or get in touch via PM) if that's not the case.
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: 11263
Joined: Tue Mar 25, 2008 8:40 am

Re: Turning off the render and starting FG from another proc

Postby chriscalef » Sat Mar 10, 2018 6:59 pm

what exactly are your data requirements here - i.e. what are you doing from an I/O perspective. What inputs do you provide to fgfs and what output do you need ?


Currently I'm only using FG to fly the airplane, and also the sound layer is nice to have for the engine sound. I made a protocol xml file (aircraft_out.xml) to tell FG to export my current position and orientation plus the orientation of the various flight surfaces, and I will probably use this to export other properties as I go. I'm trying to set up Torque to receive joystick button data, so I can handle the weapons systems over there, but TBH that is giving me a bit of trouble at the moment, so it would also be nice to figure out how to include button press information in the UDP stream. (Cursory examination of the Property Tree left me still unsure on that point.)
chriscalef
 
Posts: 226
Joined: Wed Feb 20, 2013 9:28 pm

Re: Turning off the render and starting FG from another proc

Postby Hooray » Sat Mar 10, 2018 7:13 pm

If that's all that you need, why don't you just run the FDM itself in standalone mode ? Is it just because of the sound requirement ?
Regarding the joystick issue, there is a dedicated scripting module (controls.nas) that provides APIs which are usually called by the bindings.
This, too, was recently discussed on the devel list - i.e. basically doing Nasal RPC from another process and invoking controls.nas that way.
I believe that a few folks were working on providing a dedicated interface/mechanism for just that.

But again, I am not even sure why you'd want to use fgfs instead of, say, yasim or jsbsim in standalone mode ?
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: 11263
Joined: Tue Mar 25, 2008 8:40 am

Re: Turning off the render and starting FG from another proc

Postby chriscalef » Sat Mar 10, 2018 7:29 pm

why don't you just run the FDM itself in standalone mode ?


It is true, this has been a bit of a tossup. Probably one of the biggest factors is uncertainty about how long it would actually take me to get a standalone FDM version all built and working, versus my bird-in-the-hand situation of just running FG as it is. But also, the engine sound is nice to have. And, I'm not completely decided on the future prospect of loading terrain and/or skybox images from FG, so putting work in toward removing things feels less productive than just trying to beat the existing fgfs into submission.

Re: terrain, though, for now I'm having quite a bit of fun just putting the aircraft onto a nice flat airport in the middle of nowhere with no major obstacles, and then flying it around over a flat ground plane in T3D, and thus completely ignoring the issue of terrain synchronization between the two.
chriscalef
 
Posts: 226
Joined: Wed Feb 20, 2013 9:28 pm

Re: Turning off the render and starting FG from another proc

Postby Hooray » Sat Mar 10, 2018 7:37 pm

To do joystick stuff remotely, you need to understand bindings (fgcommands) and controls.nas

http://wiki.flightgear.org/Bindings
https://sourceforge.net/p/flightgear/fg ... ntrols.nas

Once you take a look at any joystick (keyboard/mouse) config file, you will see that most stuff goes through controls.nas

There is a built-in feature to run/trigger Nasal code remotely via props (telnet) or the mongoose/AJAX httpd interface (which in turn works via the fgcommand layer)
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: 11263
Joined: Tue Mar 25, 2008 8:40 am


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 1 guest