I play tons of them, and being that I know that the vast majority of people, and yourself, understood what I said, this is the reason I wrote it that way. Most people are not programmers, and even if they are part of this project or use the software they still recognize a repeat.
The thing is, a real "holding pattern" isn't really flown that way, you have different types of entry and holding procedures, using different segments - so just flying continuously between two coordinates is at most a VFR holding.
Being that not all planes have some form of computer flight management system, but all have access to the router, and all have the opportunity fly a holding pattern ... I'll let you finish the thought.
thanks, not needed.
I've not started writing nasal yet,
That seems actually like an excellent opportunity to simply go ahead and learn Nasal, right?
so your easy submission would be?
My "easy submission" is the following posting:
When you take a look at the wiki, you'll see that the route manager can be controlled by setting properties:
http://wiki.flightgear.org/Route_managerThe "input" or "control" property is
/autopilot/route-manager/inputSo the route manager dialog is only providing a convenient interface, you could just as well use the property browser or Nasal.
Properties can be set from Nasal using the setprop() command:
http://wiki.flightgear.org/Nasal#setprop.28.29In order to set a property to a certain value/string, you just use a piece of code like the following:
- Code: Select all
setprop("/foo/test", "hello world");
Obviously, this needs to be loaded/run or otherwise invoked by fgfs, for example by using the built-in Nasal console.
So you need to set the next/active waypoint using setprop:
- Code: Select all
setprop("/autopilot/route-manager/input", next);
Now you need to make sure that the undefined "next" variable actually contains sensible and comprehensible input for the route manager system (see the RM wiki page).
To work with a list of pre-defined coordinates, you could use a Nasal vector:
http://wiki.flightgear.org/Nasal#VariablesThe following piece of code declares and initializes an empty vector in Nasal:
- Code: Select all
var coordinates = [];
Now you need to fill in some data (comma separated values):
- Code: Select all
var coordinates = ["SAU","OAK","SFO"];
Note that these are not GPS coordinates, but rather identifiers of VORs located near KSFO. But obviously, you could just as well use any other "fixes" supported by the route manager.
If you were to add these continuously to the RM, you would basically be flying a triangle between SAUSALITO VOR, OAKLAND VOR and SAN FRANCISCO VOR
Once you have your vector populated with some data, you can access individual elements by using a numeric INDEX into the vector using square brackets:
VECTOR[INDEX];
For example:
- Code: Select all
var coordinates = ["SAU","OAK","SFO"];
print ( coordinates[0] ); # will print SAU
print ( coordinates[1] ); # will print OAK
print ( coordinates[2] ); # will print SFO
Note that indexing starts at 0 and not at 1 !
Next, you would need to register a function that gets called during startup, so that it can keep setting the route manager, this is done using a _setlistener() call:
http://wiki.flightgear.org/Nasal#setlistener.28.29Note that the underscore (_) is important, because the low level function must be used here:
- Code: Select all
_setlistener("/sim/signals/nasal-dir-initialized", myCode);
Take a look at:
http://wiki.flightgear.org/Howto:_Creat ... sal_moduleTo ensure that your code gets called repeatedly, at a fixed rate - you need to use a settimer() call:
http://wiki.flightgear.org/Nasal#settimer.28.29Code that can be copied and pasted is available here:
http://wiki.flightgear.org/Howto:_Creat ... m_in_NasalAs you can see at
http://wiki.flightgear.org/Route_manager_internals there is even direct support for re-sequencing a route by setting the current-waypoint index to a different waypoint number in the route.
- Code: Select all
# rm_control.nas (save in $FG_ROOT/Nasal)
var mycode = func {
print("running my route manager controller ");
setprop("/autopilot/route-manager/input", "SFO");
settimer(mycode, 5); # register a timer, invoke the "mycode" function again after 5 second
}
_setlistener("/sim/signals/nasal-dir-initialized", mycode);
When added to $FG_ROOT/Nasal/rm_control.nas, this piece of code will get called at 5 second intervals and keeps adding yet another "SFO" waypoint to the RM route.
Obviously, this is not yet very useful - but if you take another look at
http://wiki.flightgear.org/Route_manage ... ls#Signals you'll see that the RM system also emits so called "signals" by setting a certain property when specific events (such as route re-sequencing) occur. So you could now register a listener to this property and keep setting the property to the next "position" in the vector:
- Code: Select all
# rm_control.nas (save in $FG_ROOT/Nasal)
var pos = ['SAU','OAK','SFO']; # makes sense to start at KSFO with these defaults
var index=0;
var re_sequence = func {
print("running my route manager controller ");
setprop("/autopilot/route-manager/input", pos[index] );
index=index+1;
if (index > 2) index = 0; # reset index to 0 (wrap around)
}
_setlistener("/sim/signals/nasal-dir-initialized", re_sequence );
_setlistener("/autopilot/route-manager/signals/sequenced", re_sequence);
To actually fly the "route", you obviously need to activate the route manager (from code, or by using the RM GUI dialog).
As you'll see, you could even create a small dialog file to repeatedly set the waypoint automatically to a set of specified coordinates.
Just have a look at the implementation of the route manager dialog in $FG_ROOT/gui/dialogs/route-manager.xml:
http://gitorious.org/fg/fgdata/blobs/ma ... anager.xmlIf you are really interested, this could be used to create a realistic holding-pattern autoflight system, that even uses proper entry and exit procedures.
I don't have access to FG at the moment, so I didn't really test any of the code - it's just off the top of my head and mostly contains Nasal pseudo code, so while there are surely some typos - that's basically how it would work.