Hi!
I'd like to follow an AI aicraft with realistic and "complex" behaviour. The simple way described on wiki just gives a heading, roll, ...
I am not sure what exactly you mean by "sophisticated AI aircraft" and "complex behavior", but AI aircraft in FlightGear are currently implemented in a different fashion from conventional FlightGear aircraft, i.e. these are actually separate aircraft models, textures and also logics/systems that drive each AI aircraft instance.
In other words, AI aircraft do not make use of FDM configuration files to create a realistic simulation, nor do they make use of the built-in autopilot facility, instead they use flight plans and a small performance-db.xml file to specify performance numbers for different types of aircraft (the latter of which is a relatively recent addition).
So it is normal to see less fidelity compared to conventional FlightGear aircraft that are simulated differently and more completely.
My idea (tested) was to record a previous flight done by me (thanks to a protocol dedicated to write directly in the good format), then reinject it in a flightplan of AI.
Well, to my knowledge AI aircraft cannot currently be driven by pre-recorded flight data.
On the other hand, having a way to optionally use such flight data to drive AI traffic would obviously be a pretty useful addition to the AI traffic system, as several others said already!
The plethora of possible instruction-like scenarios is an excellent example for the potential use-cases of such a feature.
But my tests don't work maybe because of limitations : flightplans are not dedicated to that ...
Yes, flight plans do not provide the "resolution" that you would normally require to redo/show a certain segment of previously recorded flight. Also, a flight plan works in terms of "waypoints" or route segments, whereas you are interested in replaying actual high fidelity flight data.
On the other hand, there are other FlightGear systems such as the multiplayer system or the replay system that do work with all of the required data.
Fundamentally, the AI traffic system that you are envisioning is basically a hybrid based on the current replay system and the multiplayer system, because it needs to record a user's flight data and be able to "replay" it as virtual traffic, in addition to the user's aircraft that is then also to be flown separately.
I can try to code if someone has a good guess how to start, because i don't want to go in a bad direction.
What do you mean by code?
Nasal scripting or are you familiar with C++ programming?
Are you able to build FlightGear from source?
If so, I would personally recommend to look into the replay and multiplayer systems, because these contain already all the features that you would need to extend the AI traffic system so that it can be driven from recorded flight data.
So if you are interested in doing C++ development, taking a look at these two systems would seem like a good idea to get started:
Basically, the replay system (implemented in
$FG_SRC/Aircraft replay.c/h[xx])can show you how to sample flight data at runtime while the multiplayer system (implemented in
$FG_SRC/Multiplayer) shows you how traffic nodes are inserted into FlightGear at runtime (internally, the multiplayer system uses pretty much the same AIModel backend as the AI Traffic system to render traffic).
You will need both capabilities to extend the AI system (implemented in
$FG_SRC/AIModel) accordingly.
The replay system could probably be easily used by just exposing it to the property tree using a dedicated sub node in the tree, something along the lines of /replay which contains all relevant configuration parameters and another branch with the actual flight data sampled (like /replay/timestamp ).
This would also make it possible for replay data to be inspected/modified by Nasal scripts, at the same time adding the capability to serialize the replay buffer to an XML file for saving and loading recorded flights.
A flexible implementation would also allow the user to select those properties (or toplevel nodes) that are to be sampled (like a subscription), because this will obviously differ among different aircraft and use-case scenarios.
On the other hand, with some patience, you can probably also achieve this without any programming at all:
For example, doing a flight on multiplayer, recording the flight and replaying it on multiplayer while connecting to the same fgms instance with another fgfs client, will show the whole recorded flight so that you can fly in formation if you want to.