Virtual CoPilot: Difference between revisions

Jump to navigation Jump to search
19,820 bytes added ,  12 September 2014
m
no edit summary
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{Stub}}
{{Stub}}
{{WIP}}
{{WIP}}
== Problem ==
{{Note|{{FGCquote
  |Update: There are now at least 3 different solutions to implement a virtual copilot for FG: [http://flightgear.org/forums/viewtopic.php?f{{=}}18&t{{=}}14440&p{{=}}144294&hilit{{=}}copilot#p144294 viewtopic.php?f{{=}}18&t{{=}}14440&p{{=}}144294&hilit{{=}}copilot#p144294]
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=146708#p146708
    |title=<nowiki>Re: The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Wed Jan 04</nowiki>
  }}
}}
}}
{{FGCquote
  |At the moment, there are about 3 different approaches to implement a "copilot" module for FlightGear - all of them being developed separately, as standalone programs talking to FG using socket connections. <br/>
<br/>
While that is good from a design point of view, I think it is somewhat unfortunate because the people who work separately creating 3 different copilot solutions, could certainly work together and create a single one.<br/>
<br/>
The real issue is that FG being cross platform software, it is generally understood to be a good idea that contributions to FG can also be used by all FG users, regardless of their platform/OS.<br/>
<br/>
I haven't taken a look at FGCopilot yet, but that is also because I am on Linux and I assume that I cannot easily run your code?<br/>
<br/>
redneck's project is more promising in this aspect because it is built using Java, which is multi-platform in general.<br/>
<br/>
Also, redneck's project is reusing code that has been developed by FG core developers - so it is more efficient from a certain angle.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=144294#p144294
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Thu Dec 08</nowiki>
  }}
}}
{{FGCquote
  |personally I would suggest to look into working together with redneck to improve his project - there are obviously many things that could be implemented here. And redneck got a head start already. If you already know Delphi, understanding and writing Java should be straightforward actually. So if you have any ideas or feature requests, I am sure that redneck's project would be a solid foundation actually.<br/>
<br/>
Honestly, I don't think we even need to keep this separate from FG - anybody doing projects like these will inevitably need to deal with the FG property tree, which is usually done using a socket connection. This is more complicated than it needs to be. If you already know a programming language, learning Nasal is actually EASY - and Nasal has native support for dealing with the FG property tree and its API.<br/>
<br/>
Bottom line being, 99% of the work you are doing could be done more easily by switching to Nasal instead. This would also have the added advantage of Nasal code being automatically cross-platform, too. Once people switch to using Nasal, they also ensure that ALL FG users can easily make use of their contributions.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=144294#p144294
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Thu Dec 08</nowiki>
  }}
}}
{{FGCquote
  |Obviously, there are some things that are easy in a separate language/toolkit, which are more complicated or next to impossible from Nasal space, but usually that would only require modifying or adding 2-3 new Nasal extension functions, which would also be useful for all other Nasal scripts.<br/>
<br/>
Seriously, even redneck mentioned a while ago that Nasal should be seriously considered here, especially because the telnet/props route has been shown to become too slow pretty soon
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=144294#p144294
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Thu Dec 08</nowiki>
  }}
}}
{{FGCquote
  |I am absolutely convinced that these autopilot/copilot tools are a great idea for FG, but I also believe anybody not coding this directly IN FlightGear by using Nasal, is making it more complicated than necessary. So, I will try to support anybody who is actually looking into porting this over to "native FlightGear space" by reimplemting such efforts in Nasal space instead - adding a bunch of extension functions to enrich the API is easy and well documented actually. Anybody knowing C++ (or Java for that matter), should be able to understand what's involved: [[Howto:Extending_Nasal]]<br/>
<br/>
<br/>
Finally, it is usually a good idea to add announcements to the FlightGear newsletter (created and maintained using the wiki)- you can even create a new wiki article introducing your project, and linking to it from the newsletter. Let us know if you need any help contributing to the newsletter: [[Next_newsletter]]
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=144294#p144294
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Thu Dec 08</nowiki>
  }}
}}
{{FGCquote
  |Hooray is onto something here really. I have noticed on several aircraft some autopilot Nasal scripts that are supposed to takeoff and land on their own, however no matter what I try these scripts fail to run, these are found on the A-10, SU-37, YF-23, B-2 and a couple others I believe. So the code is there, we just need to get it to run.<br/>
<br/>
This really dives into the realm of UAV work, something I have been working on for about a year myself with the X-47B. I think maybe we should make a new wiki page devoted to UAV's and the like since there are many of us that like these kind of aircraft and systems. Thoughts?
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=147030#p147030
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>pygmyskunk</nowiki>
    |date=<nowiki>Sat Jan 07</nowiki>
  }}
}}
{{FGCquote
  |One of the problems is going to be that such a feature is pretty aircraft specific. That's probably part of the reason why people keep coming up with their own implementations. To get something like this started, you'd first of all need to start VERY simple, i.e. by making this work with the simplest aircraft you can find (such as the ufo) and then incrementally start making it more configurable, so that support for more complex aircraft can be added. This could be accomplished by using aircraft specific setup files that could be declared in XML space and loaded by Nasal scripts.<br/>
<br/>
So that aircraft developers could specialize the default setup, specifically for a certain aircraft.<br/>
<br/>
The wiki article you mentioned would probably be a good thing to collect all ideas, the step would probably be collecting all existing steps and seeing if/how they could be generalized and integrated to form a single script.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=147035#p147035
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Sat Jan 07</nowiki>
  }}
}}
{{FGCquote
  |There's actually quite some interest in UAV stuff recently. And in fact, Curt recently provided a fully working uav demo by scripting the f14b to do carrier ops too. Unfortunately, the source code was obfuscated - so it would be of little use here, but it goes to show that it's definitely possible to come up with something like this.<br/>
<br/>
It's probably just a matter of getting people to collaborate, rather than starting scripts from scratch ;-)
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=147035#p147035
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Sat Jan 07</nowiki>
  }}
}}
== Background ==
{{FGCquote
  |FGCopilot makes interaction with the plane for the copilot possible in probably '''any''' aircraft. Copilot can:
* retract and extend flaps
* arm/retract spoilers
* retract/extend gear
* put throttle on IDLE
* toggle parking brakes
* toggle reversers
* toggle landing lights
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=143548#p143548
    |title=<nowiki>FGCopilot</nowiki>
    |author=<nowiki>SP-WKA</nowiki>
    |date=<nowiki>Mon Nov 28</nowiki>
  }}
}}
{{FGCquote
  |I like the idea but I think there needs to be some other way of merging the idea into FlightGear itself. Im on linux so I dont believe I can run the code you've supplied. I think if you hacked this into FG itself, perhaps as a property 'editor' instead of just a property browser, that would be a better way to go. I would imagine with some work this could be added as another protocol to link 2 players together.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=143811#p143811
    |title=<nowiki>Re: FGCopilot</nowiki>
    |author=<nowiki>dr1</nowiki>
    |date=<nowiki>Fri Dec 02</nowiki>
  }}
}}
{{FGCquote
  |state machines would be helpful here, IMO, unless you just need something basic. Offtopic, but I've thought a little bit about this and I think a custom syntax (read: DSL) would be helpful... [/egoist] (oh wait, I still need to get it off the ground) <br/>
But I do not like the idea of using XML at all as I think you (Hooray) might've suggested before, my limit of XML tolerance is FDMs and PropertyList, not scripts, as those tags get comber some. Maybe having something in a Nasal object would be possible as well, something like a pseudo-linked list with loops would not be hard.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=174913#p174913
    |title=<nowiki>Re: Copilot announcements: Nasal don't works!</nowiki>
    |author=<nowiki>Philosopher</nowiki>
    |date=<nowiki>Sat Jan 19</nowiki>
  }}
}}
{{FGCquote
  |Zakalawe has recently started adding state machine support to SimGear: [https://gitorious.org/fg/simgear/commit/22ea8ebe258da45df9fc2b77904c2dcf79cd0f57 https://gitorious.org/fg/simgear/commit ... cf79cd0f57]<br/>
It will probably take a while until this becomes available to Nasal scripts, but Tom has added a module called "cppbind" to SimGear to more easily expose C++ stuff to Nasal scripts (and vice versa).<br/>
<br/>
None of this is currently documented, but it may still be the best option for more complex needs eventually.<br/>
At the moment, this seems to be specific to the AP system though.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=175323#p175323
    |title=<nowiki>Re: Copilot announcements: Nasal don't works!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Sat Jan 26</nowiki>
  }}
}}
{{FGCquote
  |Basically, PropertyList XML files already support stateful expressions using the SGCondition syntax. While that's pretty verbose, it's still pretty straightforward.<br/>
I think the tutorial system uses them, too (? - havent' checked)<br/>
Arguably, XML code is easier to use and edit for non-programmers than scripting "code".<br/>
<br/>
Anyway, the property conditions stuff is also accessible from Nasal.<br/>
Regarding state machines and DSLs, there's tons of stuff available actually. But we would obviously need to come up with something that can be properly integrate in FG.<br/>
<br/>
Now, regarding the OPs questions, I'd suggest to stop using the current approach and instead check out the tutorial system - it was written with such use-cases in mind, and it should be much more straightforward to develop a corresponding tutorial and extend/improve the tutorial system once the need arises.<br/>
<br/>
At the end of the day, it's all still XML, properties and some Nasal "glue" code: [[Tutorials]]<br/>
People who are able to write simple Nasal scripts on their own should actually find it pretty straightforward to work with the tutorial system and extend it as required.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=174916#p174916
    |title=<nowiki>Re: Copilot announcements: Nasal don't works!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Sat Jan 19</nowiki>
  }}
}}
== Objective ==


== Runway Overrun Protection System ==
== Runway Overrun Protection System ==
Line 45: Line 220:
     |author=<nowiki>onox</nowiki>
     |author=<nowiki>onox</nowiki>
     |date=<nowiki>Mon Aug 18</nowiki>
     |date=<nowiki>Mon Aug 18</nowiki>
  }}
}}
== FREDA Announcements ==
{{FGCquote
  |Who would be interested in contributing to/helping to test a new feature for FG?  The Virtual Co-pilot!!<br/>
<br/>
The Virtual Co-Pilot would assist with pre-flight route-planning, checklists and change nav and comms frequencies en-route as well as keep the captain awake on long -haul flights with witty banter.<br/>
Right now this is only an idea and I'm looking for folk to do the actual work, suggest an initial interface and further features.<br/>
<br/>
For instance,  on GA aircraft, Virtual Co-Pilot would prompt you to do FREDA checks every 15 mins.<br/>
<br/>
Work is in the pipeline which should allow expansion/integration of the Route Manager and Interactive Map. Lets be ready to take advantage of these new features.<br/>
<br/>
Anyway, over to the FG community for ideas......
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=96031#p96031
    |title=<nowiki>The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>willie</nowiki>
    |date=<nowiki>Mon Sep 20</nowiki>
  }}
}}
{{FGCquote
  |That should actually be pretty possible to do, with just a piece of Nasal code.<br/>
I don't think this would need to be very complicated. If you have previously done some Nasal programming, that's fairly easy to do.<br/>
<br/>
One could even think about letting the "copilot" script do checks like pre-taxi, pre-takeoff, approach etc.<br/>
<br/>
It would just be a matter of writing the corresponding "checklists" in the property tree XML format (for example for V speeds), then Nasal could do the whole check upon firing a listener - and even use a sound configuration file saying "CHECKED, CLEAR ..." (or use the festival text to speech facility).
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=96037#p96037
    |title=<nowiki>Re: The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Mon Sep 20</nowiki>
  }}
}}
{{FGCquote
  |I would suggest to write all aircraft specific checks to an XML file that can be customized for each aircraft, then a piece of Nasal code could load the file into the property tree and do the corresponding checks (or issue a reminder)
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=96037#p96037
    |title=<nowiki>Re: The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Mon Sep 20</nowiki>
  }}
}}
{{FGCquote
  | I just put together a very simple first version of a "FREDA" copilot script for use in FlightGear, you may want to play with it.<br/>
It's not really complicated at all, if you know some JavaScript it will be really easy to understand how the whole thing works.<br/>
<br/>
All of this is basically written in about 20 lines of Nasal code, so it's compact too.<br/>
You will need to save the file as "copilot.nas" in $FG_ROOT/Nasal
<syntaxhighlight lang="nasal">
# copilot.nas (to be placed in $FG_ROOT/Nasal)
##
# implements a very simple prototype of a timer based virtual 'copilot' script in Nasal issuing "FREDA" reminders to the console, screen and to the festival TTS
# see: http://flightgear.org/forums/viewtopic.php?f=6&t=9556
#
# for details on FREDA please see:
#  http://www.worldlingo.com/ma/enwiki/en/Freda
#  http://www.squidoo.com/learning-to-fly-freda-pats-the-cat
#
# TODO: these settings should probably become property based, so that they can be easily configured using a GUI dialog
# configuration settings (0: disabled, 1: enabled for boolean settings)
var config = {enable_freda:1, print_to_console:1, print_to_screen:1, use_festival:0, reminder_delay_mins:1, gui_message_delay_secs:5 };
# vector with FREDA messages
var FREDA = [
        "FREDA (fuel):ensure fuel is sufficient and being consumed at the expected rate. 'Lean out' the carburettor  to the most economical setting. Set the fuel selector switch to take fuel from one or other of the wing tanks, or both, depending on fuel remaining and aircraft balance limits",
        "FREDA (radio):ensure the radio is tuned to the correct frequency for the nearest airfield. Listen for announcements. Communicate with airfield when entering or leaving restricted airspace",
        "FREDA (engine):check oil temperature and pressure, and other engine indicators.",
        "FREDA (DI):check directional indicators (compass, gyroscope, artificial horizon, etc.) to ensure correct heading.",
        "FREDA (altimeter):check altimeter shows correct altitude. Gain or lose height if necessary. Adjust altimeter to the correct atmospheric pressure setting for the local area",
];
var minutes_to_seconds=60;
var delay_secs = config.reminder_delay_mins*minutes_to_seconds;
var remind = func(msg) {
    if (config.print_to_console) print(msg);
        if (config.print_to_screen)  screen.log.write(msg); #gui.popupTip(msg, config.gui_message_delay_secs);
    if (config.use_festival)    setprop("/sim/sound/speech", msg);
};
var print_freda_reminders = func {
  foreach (var msg; FREDA )
    remind(msg);
  settimer(print_freda_reminders, delay_secs);
};
var init_copilot = func {
  if (!config.enable_freda) return;
  if (config.use_festival and getprop("/sim/sound/voices/enabled")!=1) print("Warning: /sim/sound/voices/enabled is 0");
  settimer(print_freda_reminders, delay_secs);
  print('Copilot script initialized and running, next reminder due in ',config.reminder_delay_mins, ' minutes' );
};
# register the callback for running the init function
_setlistener("/sim/signals/nasal-dir-initialized", init_copilot);
</syntaxhighlight>
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=96049#p96049
    |title=<nowiki>Re: The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Mon Sep 20</nowiki>
  }}
}}
{{FGCquote
  |If you want to make changes to it, you can directly fork the script here: [http://codepad.org/sSM4Guru http://codepad.org/sSM4Guru]<br/>
<br/>
There are many possibilities for really improving this significantly, just starting to use XML based files for really doing whole checks would be really powerful and useful. And making the whole script configurable using a gui dialog would also be a good idea.<br/>
<br/>
All of this is fairly easy to do, what I have provided so far is just meant to be a "proof of concept" - and maybe it's useful enough to be used as the foundation for new features. Let me know what you think.<br/>
<br/>
It would probably also be a good idea to integrate this with:<br/>
[[index.php/Howto:_Calculate_V-speeds]]<br/>
[[index.php/Howto:_Implement_copilot_announcements]]<br/>
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=96049#p96049
    |title=<nowiki>Re: The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Mon Sep 20</nowiki>
  }}
}}
{{FGCquote
  | this was really just meant to get you started ... it's obviously a very simple script. But there are many features that could be added to such a "virtual copilot" scripts. Many of which could even already be implemented without requiring any additions to the C++ code. <br/>
<br/>
As a first step, I would suggest to integrate this with the V speeds callouts tutorials (see the two links I posted), as a next step one could then support the use of XML files for doing aircraft specific checks or copilot activities. Personally, I would suggest to base the whole thing initially on the C172p, because it's well developed and pretty well featured, too. <br/>
<br/>
I think there is indeed lots of potential for such an addon!
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=96230#p96230
    |title=<nowiki>Re: The Virtual Co-pilot!!!!!</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Wed Sep 22</nowiki>
   }}
   }}
}}
}}

Navigation menu