Board index FlightGear Support Interfacing

Importing state vectors directly into FlightGear  Topic is solved

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

Importing state vectors directly into FlightGear

Postby FSpilot1822 » Sat Sep 12, 2020 5:12 pm

Hello,

I’m going to use a program that generates state vectors to animate the motion of an aircraft and I would like to display this in FlightGear. I’m trying to find a way to import those state vectors directly through the CPU into FlightGear without using third party software such as Simulink. Would anyone have any suggestions on how to do this?
FSpilot1822
 
Posts: 3
Joined: Sat Sep 12, 2020 5:06 pm

Re: Importing state vectors directly into FlightGear  

Postby Hooray » Sat Sep 12, 2020 5:28 pm

Depending on your concrete requirements, there are a handful of primary means:


In other words, you will want to share a few more details about your specific needs (for instance, it would be good to know whether you are able to patch/rebuild fgfs from source).

If you have previously written networking code, the multiplayer route is pretty straightforward.

Nasal scripting is fairly accessible without having to write any low-level stuff.
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: 11951
Joined: Tue Mar 25, 2008 8:40 am

Re: Importing state vectors directly into FlightGear

Postby FSpilot1822 » Mon Sep 21, 2020 12:00 am

I have a separate program that I would like to run side by side with FlightGear. That program generates state vectors and I would like to pipe those in real time directly to FlightGear and have an aircraft show up and move in FlightGear while I am running the other program. I am doing this for a class project and I don’t have any experience yet with FlightGear, so if you could provide me with some tips on which methods might work best for this, that would be helpful.
FSpilot1822
 
Posts: 3
Joined: Sat Sep 12, 2020 5:06 pm

Re: Importing state vectors directly into FlightGear

Postby Johan G » Mon Sep 21, 2020 6:08 am

FSpilot1822 wrote in Mon Sep 21, 2020 12:00 am:[...] I would like to pipe those in real time directly to FlightGear and have an aircraft show up and move in FlightGear while I am running the other program.

I do not think that it will be as easy as just a regular pipe. Hopefully this FlightGear wiki article is a good starting point:

Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 6017
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.2
OS: Windows 10, 64 bit

Re: Importing state vectors directly into FlightGear

Postby Hooray » Mon Sep 21, 2020 12:46 pm

Some background info on fgfs + piping:

https://sourceforge.net/p/flightgear/ma ... /31900851/
curt wrote:For what it's worth, the "ExternalPipe" fdm was setup to cover much of the
areas you have touched on. It's probably not exactly what you want but
here was some of my logic in how/why I setup it up the way I did.

- Using a network interface adds some indeterminism ... sometimes
network packets are delayed or stack up depending on what is going on with
the machine so there isn't a guaranteed lockstep relationship between the
simulator the the flight dynamics.
- Usually the network interface is good, but I observed times when it
had extra delays in packets getting where they needed to go.
- As an alternative, I setup a pair of "named pipes". Pipes are a unix
construct, they look like a file to the program, but what you write into
them is collected and held for some other application to read out.
Unfortunately these are not supported in windows. Pipes are single
direction, thus the need for two of them for bi-directional communication.
A pipe is really simple: you open it up like any other file, and one
process writes into it; the other process reads from it. In between the OS
can buffer some amount of information until the reader grabs it. You can
use blocking reads (carefully) to ensure FlightGear and your external FDM
run in exact lockstep.
- Pipes imply both processes will run on the same machine, a network
interface would allow the processes to live on separate machines.
- The ExternalPipe interface supports a flexible property interface, so
the external FDM process can send any name/value pairs it wishes to send
and the interface will dutifully copy them into the FlightGear property
tree. The FDM side can also send a list of property names it would like to
receive in reply and the interface will dutifully send them over the
outgoing pipe every frame. This was a nice addition, and there is plenty
of bandwidth through a named pipe to do this in clear text, even with a lot
of extra property values.

History: I used this as part of a project I did with ATC flight sim. They
had their own proprietary flight dynamics applications that modeled
specific aircraft in the code itself. These models had all the necessary
source documentation and flight test data to satisfy FAA certification
testing requirements of the final simulator. In addition, this external
code modelled many of the aircraft systems for one of their high end sims.
This required the ability to be flexible in what values were sent back and
forth and enabled me to drive some instrument gauges directly from the
external code.

Regards,

Curt.



https://sourceforge.net/p/flightgear/ma ... gear-devel
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: 11951
Joined: Tue Mar 25, 2008 8:40 am

Re: Importing state vectors directly into FlightGear

Postby Johan G » Mon Sep 21, 2020 9:28 pm

Hooray wrote in Mon Sep 21, 2020 12:46 pm:Some background info on fgfs + piping [...]

I find very little documentation. In the FlightGear Manual dated September 25, 2018:

Page 17:
It is even possible to drive FlightGear’s scene display using an external FDM running on a differentcomputer or via named pipe on the local machine – although this might not be a setup recommended topeople just getting in touch withFlightGear.

Page 33:
--fdm=abcd
Select the core flight model. Options are jsb, larcsim, yasim, magic, balloon, external, pipe, ada, null. This option can normally be ignored, as the --aircraft option will set the FDM correctly.


Source code likely is here:
flightgear/src/FDM/ExternalPipe/ExternalPipe.cxx ("next")

It seems like it might be using a custom protocol, in essence the generic protocol.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 6017
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.2
OS: Windows 10, 64 bit

Re: Importing state vectors directly into FlightGear

Postby FSpilot1822 » Wed Sep 23, 2020 3:17 am

Thank you all for the help you have provided so far. In Hooray’s post where it says that pipes are not compatible with Windows, does that mean I need to use a computer with a different operating system or is there a way to work around that with Windows? My OS is Windows 10 64 but, version 2004.

When setting up the pipes, I would like to know what type of files I should create and where I should place them. All I would like to pipe to FG is the state vector, which includes values like longitude, latitude, altitude, roll, pitch, and yaw. These will be generated by an external program.
FSpilot1822
 
Posts: 3
Joined: Sat Sep 12, 2020 5:06 pm

Re: Importing state vectors directly into FlightGear

Postby Johan G » Wed Sep 23, 2020 8:52 am

There are other ways than pipes. See wiki article I linked to above. Unfortunately I have never driven FlightGear with external data, so I may not be of all that much help. :|
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 6017
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.2
OS: Windows 10, 64 bit

Re: Importing state vectors directly into FlightGear

Postby Hooray » Wed Sep 23, 2020 6:05 pm

If you don't want to use pipes, just use sockets - it's what I'd recommend using anyway.
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: 11951
Joined: Tue Mar 25, 2008 8:40 am


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests