Board index FlightGear Support Interfacing

How to convert CSV file to FGTAPE file?

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

How to convert CSV file to FGTAPE file?

Postby AeroFlyWing » Thu Nov 19, 2015 11:49 am

I'm working on application of flight data in CSV format,and I want to control the playback progress like the FGTAPE file playback.
I've read the README.FlightRecorder DOC and other component data item XML file,but I'm not very clear about the data format,and how to generate a FGTAPE except in FlightGear.
So I'm wondering how can I covert CSV file to FGTAPE file.
Any recommend or help would be great appericiate.
AeroFlyWing
 
Posts: 11
Joined: Tue Oct 13, 2015 3:28 pm
Callsign: Tan651
Version: 3.4.0
OS: Windows

Re: How to convert CSV file to FGTAPE file?

Postby Hooray » Thu Nov 19, 2015 12:16 pm

AeroFlyWing wrote in Thu Nov 19, 2015 11:49 am:I'm working on application of flight data in CSV format,and I want to control the playback progress like the FGTAPE file playback.
I've read the README.FlightRecorder DOC and other component data item XML file,but I'm not very clear about the data format,and how to generate a FGTAPE except in FlightGear.
So I'm wondering how can I covert CSV file to FGTAPE file.
Any recommend or help would be great appericiate.


The easiest way would be coming up with a generic protocol to feed your data into fg, and then record the whole thing using the flight recorder - at that point, FG will have converted your CSV data to the internal fgtape format automatically.

Background:
http://wiki.flightgear.org/Logging_properties
http://wiki.flightgear.org/Generic_protocol
http://wiki.flightgear.org/Instant_Replay
http://wiki.flightgear.org/Fgtape
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How to convert CSV file to FGTAPE file?

Postby AeroFlyWing » Fri Nov 20, 2015 6:37 am

Thanks a lot,Hooray.I have tried successfully,but to my most trouble is I have about more than 10 csv files ,and even I set the time x32 speed, I have to wait too long to save the whole progress manually.
I wonder is there any convenient method to convert CSV file to FGTAPE file directly or how can I write such a program to realize that.
Thanks again.
Last edited by Johan G on Fri Nov 20, 2015 3:40 pm, edited 1 time in total.
Reason: No useless quoting please. No need to quote the entire preceeding post.
AeroFlyWing
 
Posts: 11
Joined: Tue Oct 13, 2015 3:28 pm
Callsign: Tan651
Version: 3.4.0
OS: Windows

Re: How to convert CSV file to FGTAPE file?

Postby Hooray » Fri Nov 20, 2015 12:41 pm

what I described is the easiest option - otherwise, you would need to review/modify the C++ code to come up wit a converter tool from scratch.

If you have several files, possibly with hours of data, you could automate the loading/saving using Nasal scripting and a handful of fgcommands to load other CSV files, and control the flight recorder subsystem accordingly - in fact, you could even append CSV to the same fgtape that way.

If the 32x speed-up is working properly, you could remove the hard-coded restriction to see if your system can speeding up beyond that. If it does not, you can use the minimal startup profile on the wiki to disable most systems (including rendering using draw masks) to reduce the load on the simulator.

But it's s a pain/gain thing obviously, because you may have to touch C++ code and rebuild fgfs.

Personally, I would rather do that than come up with a custom conversion tool - i.e. it is much easier to modify a few hard-coded constants/variables and then use fgfs "as is", than coming up with a tool from scratch.

I guess it would be a good idea to tell us exactly how many hours of flight data you have, and what you are hoping to do with it - and if you are able to rebuild fgfs, and know C++ ?

With a little Nasal scripting (probably not more than 50 lines), you could certainly automate most of the task at hand.

I could tell you exactly how to write a CSV->fgtape conversion tool in C++, i.e. by reusing portions of FlightGear's C++ code, but I don't consider that effective - it would be much better to remove hard-coded restrictions that prevent FlightGear from being used for that purpose.

To disable rendering, see: http://wiki.flightgear.org/Draw_masks
There also is a switch/property to disable scenery loading, too.

For the property names related to sim-speed-up, see $FG_ROOT/gui/dialogs/timeofday.xml
You will find that it is using /sim/speed-up
and that it is using $FG_ROOT/Nasal/controls.nas (see line 506)
Which is also where the factor 32 is hard-coded

I would suggest to change that, or make it configurable, and then disable other features like rendering, and then use the minimal startup profile that you can find on the wiki, you will probably want to customize that by adding the draw-masks, and removing the location/offset stuff at the beginning: http://wiki.flightgear.org/Template:Startup_Profile

It will look really bare and simple, but will provide much better performance, which you can use to speed-up the main-loop accordingly

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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How to convert CSV file to FGTAPE file?

Postby AeroFlyWing » Thu Dec 03, 2015 1:42 pm

Thanks so much for your kind reply.
In fact I think the perfect function is to design a GUI to control the file in stream,such as a simple CSV file.
So,Do you mean If I don't use c++ and rebuild FGFS,I have to use Nasal script to set a fastest sim speed despite of hardware limit and covert it into FGTAPE file automatically.
Unfortunately I'm poor at c++,I learned a little Nasal recently through FGFS,now I'm thinking how to write such a Nasal script to make up that GUI.
AeroFlyWing
 
Posts: 11
Joined: Tue Oct 13, 2015 3:28 pm
Callsign: Tan651
Version: 3.4.0
OS: Windows

Re: How to convert CSV file to FGTAPE file?

Postby Hooray » Thu Dec 03, 2015 1:51 pm

Please look at what I wrote: You don't even have to use any coding (neither C++, nor Nasal) to change the max rate.
The easiest way to accomplish this is to merely open the file, remove/adapt the hard-coded constant and then see if your system can handle replaying the CSV file while converting it to a fgtape file.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How to convert CSV file to FGTAPE file?

Postby AeroFlyWing » Thu Dec 03, 2015 2:36 pm

Yeah,it's easy and I realized.
But the problem is that when the simulation speed-up get to x128, the playback duration would reduce to 1/128 in turn.In such case I speed-down the FGTAPE playback,the signal distortion can be very serious,the vision simulation looks so bad!
AeroFlyWing
 
Posts: 11
Joined: Tue Oct 13, 2015 3:28 pm
Callsign: Tan651
Version: 3.4.0
OS: Windows

Re: How to convert CSV file to FGTAPE file?

Postby Hooray » Thu Dec 03, 2015 2:42 pm

I guess, it's your best chance - unless you are willing to tinker with the underlying code.
But even then, you will want to make sure that you understand the approach outlined above, and where its limitations are coming from.
Realistically, it is going to be more work to write a converter from scratch than reusing existing FG/SG code.
Equally, it is going to be much more work than using the existing code in a new code base, instead of just building FlightGear from source and adapting its source code to change it according to your requirements.

Depending on the parameters in your CSV files, there may be a direct mapping to FG/replay properties, or not.
So it would probably be a good idea to tell us exactly what kind of data you have etc.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How to convert CSV file to FGTAPE file?

Postby AeroFlyWing » Thu Dec 03, 2015 2:54 pm

At present I just work on the minimal flight data ie Lon,Lat,Alt,Pitch,Roll,Heading.
I wonder is there possibility to control the file in stream with Nasal?
AeroFlyWing
 
Posts: 11
Joined: Tue Oct 13, 2015 3:28 pm
Callsign: Tan651
Version: 3.4.0
OS: Windows

Re: How to convert CSV file to FGTAPE file?

Postby Hooray » Thu Dec 03, 2015 3:01 pm

What exactly would you like to control via Nasal ?
There's really just a handful of fgcommands related to the instant replay system otherwise the whole thing is a "black box" that can only be configured via XML/properties.
The whole serialization mechanism isn't exposed at all, also it isn't used elsewhere, not even by the network stack (think multiplayer)
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: How to convert CSV file to FGTAPE file?

Postby AeroFlyWing » Thu Dec 03, 2015 4:47 pm

Several days ago,I used a flight data analysis tool that is Tacview.
I just found I can write a program to control the data import to FGFS through UDP,and control the play progress,speed,loop through a GUI.
But that means I have to learn more C++,I'm considering to find similar program's source code for lack of time!
AeroFlyWing
 
Posts: 11
Joined: Tue Oct 13, 2015 3:28 pm
Callsign: Tan651
Version: 3.4.0
OS: Windows


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 1 guest