Board index FlightGear Development Tutorials and missions

Tutorials/Missions/Adventures: requests for features

Interactive in-sim tutorials and missions

Re: Tutorials/Missions/Adventures: requests for features

Postby DFaber » Tue Apr 22, 2014 10:13 am

Hooray wrote in Mon Apr 21, 2014 2:59 pm:But looking at your code example, we may get along with just supporting a <nasal> block per "model", and maybe making the path dynamic, so that a single nasal block can control multiple instances of an object. For example, think in terms of having multiple NPCs, AI aircraft or tanks - those should ideally just be "instances" of a corresponding "AIEntity" class.

That would really be an improvment. While researching ways to move npcs/vehicles I'm currently stuck to one nasal block per step. The Models embedded Nasal doesn't work with the Tutorial System (and I think it is better this way), but for more than one moving model I currently need to stuff multiple vehicle Nasal functions in one block, rather than include a generic one and adjust it's behaviour via Properties.

Greetings
Detlef Faber
FlightGear Development:
http://flightgear-de.net

German FlightGear Forum
http://forum.flightgear-de.net
DFaber
 
Posts: 687
Joined: Fri Dec 01, 2006 7:51 pm
Location: Aachen, Germany
Version: GIT
OS: Linux

Re: Tutorials/Missions/Adventures: requests for features

Postby Hooray » Tue Apr 22, 2014 3:22 pm

DFaber wrote in Tue Apr 22, 2014 10:13 am:
Hooray wrote in Mon Apr 21, 2014 2:59 pm:But looking at your code example, we may get along with just supporting a <nasal> block per "model", and maybe making the path dynamic, so that a single nasal block can control multiple instances of an object. For example, think in terms of having multiple NPCs, AI aircraft or tanks - those should ideally just be "instances" of a corresponding "AIEntity" class.

That would really be an improvment. While researching ways to move npcs/vehicles I'm currently stuck to one nasal block per step. The Models embedded Nasal doesn't work with the Tutorial System (and I think it is better this way), but for more than one moving model I currently need to stuff multiple vehicle Nasal functions in one block, rather than include a generic one and adjust it's behaviour via Properties.


I still need to check what's required to pull this off, but I don't think it should be very difficult - but maybe Marius_A or Philosopher can also have a look ?
Regarding step-wise progressing, it should still work kinda well by not using a lot of custom Nasal code, but rather generic helper functions/classes, possibly in a global namespace - so that each vehicle merely uses an instance. But I think we better support arbitrary Nasal per model/AI and allow stuff to be controlled that way - we could use a pre-defined function or class that needs to be provided by the developer, which is instantiated and gets the ai/models/ branch passed as a props.Node

I am not sure why Nasal embedded in models doesn't work currently, but I guess that it's simply not implemented, but would be straightforward to change, it just involves loading the code and compile()/bind/() and call() on it.
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: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Tutorials/Missions/Adventures: requests for features

Postby DFaber » Wed Apr 23, 2014 6:53 am

Hooray wrote in Tue Apr 22, 2014 3:22 pm:I am not sure why Nasal embedded in models doesn't work currently, but I guess that it's simply not implemented, but would be straightforward to change, it just involves loading the code and compile()/bind/() and call() on it.


I'm unsure if we really want that. Embedded Nasal would require to either code all possible movement profiles (roaming, searching, follow a path, find a way to, etc. ) in one Nasal block, or to create a lot of XML Wrapper files for each Model and each function. I think the most conveniant way is, like in the Tutorial System, to load a Model, specify appearence/control Properties and load a specific Nasal function for it's behaviour.

The AI System btw. has it's drawbacks regarding non-aircraft Entities. Also it is hard to pass specific Properties to an AI Model. It will always try to bank and pitch, which needs to be corrected per Model. This all can be solved by using animations and Nasal, but creates a lot overhead.

Greetings
Detlef Faber
FlightGear Development:
http://flightgear-de.net

German FlightGear Forum
http://forum.flightgear-de.net
DFaber
 
Posts: 687
Joined: Fri Dec 01, 2006 7:51 pm
Location: Aachen, Germany
Version: GIT
OS: Linux

Re: Tutorials/Missions/Adventures: requests for features

Postby Marius_A » Wed Apr 23, 2014 5:43 pm

Simplified banner pickup/towing. Currently using models and Nasal code from Moyes Dragonfly:


Regarding Nasal in <models>...</models>: it's not implemented yet.

P.S. I have made minor modification to walk.nas to make it compatible with tutorial system:
Code: Select all
# ...
var walker_model = {
   index:   0,
   add:   func {
         if (getprop("sim/model/crew/walker/visible")) {
            if (getprop("logging/walker-position")) {
               print("walker_model.add");
            }
         var manager = props.globals.getNode("/models", 1);
            var i = 0;
            for (; 1; i += 1)
               if (manager.getChild("model", i, 0) == nil)
                  break;
            
            props.globals.getNode("models/model[" ~ i ~ "]/path", 1);
            props.globals.getNode("models/model[" ~ i ~ "]/longitude-deg-prop", 1);
            props.globals.getNode("models/model[" ~ i ~ "]/latitude-deg-prop", 1);
            props.globals.getNode("models/model[" ~ i ~ "]/elevation-ft-prop", 1);
            props.globals.getNode("models/model[" ~ i ~ "]/heading-deg-prop", 1);
            
            setprop ("models/model[" ~ i ~ "]/path", "Aircraft/Generic/Human/Models/walker.xml");
            setprop ("models/model[" ~ i ~ "]/longitude-deg-prop", "sim/walker/longitude-deg");
            setprop ("models/model[" ~ i ~ "]/latitude-deg-prop", "sim/walker/latitude-deg");
            setprop ("models/model[" ~ i ~ "]/elevation-ft-prop", "sim/walker/altitude-ft");
            setprop ("models/model[" ~ i ~ "]/heading-deg-prop", "sim/walker/model-heading-deg");
            props.globals.getNode("models/model[" ~ i ~ "]/load", 1);
            me.index = i;
         }
      },
   remove:   func {
         if (getprop("logging/walker-position")) {
            print("walker_model.remove");
         }
         props.globals.getNode("/models", 1).removeChild("model", me.index);
         walker_model.reset_fall();
      },
# ...
Marius_A
 
Posts: 89
Joined: Wed Dec 04, 2013 2:20 pm

Re: Tutorials/Missions/Adventures: requests for features

Postby Hooray » Wed Apr 23, 2014 9:07 pm

Thanks for the update, looking really good - I guess we should "outsource" mission development, so that we can focus on providing the underlying building blocks and framework.
Marius_A wrote in Wed Apr 23, 2014 5:43 pm:Regarding Nasal in <models>...</models>: it's not implemented yet.


Let me know if there's any real showstopper so that I can take a look.

BTW: I would suggest to look at tanker.nas and consider it a "demo" - basically, we should be able to add a "model" section with an enclosed Nasal section that allows multiple instances of a model to be created and controlled independently - as in having possibly dozens of tankers or other AI vehicles, such as DFaber's jeep or LesterBoffo's scooter 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: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Tutorials/Missions/Adventures: requests for features

Postby Marius_A » Thu Apr 24, 2014 9:43 am

Hooray wrote in Wed Apr 23, 2014 9:07 pm: I would suggest to look at tanker.nas and consider it a "demo" - basically, we should be able to add a "model" section with an enclosed Nasal section that allows multiple instances of a model to be created and controlled independently - as in having possibly dozens of tankers or other AI vehicles, such as DFaber's jeep or LesterBoffo's scooter etc.

Thanks for the information. I have looked at the tanker.nas. It's definitely worth studying.
I'm currently working on AI scenarios support:
Code: Select all
<init>
  <AI-scenarios>
    <scenario include="*.*">
  </AI-scenarios>
</init>
...
<step>
  <AI-scenarios>
    <scenario include="*.*">
  </AI-scenarios>
</step>
...
<end>
  <AI-scenarios>
    <scenario include="*.*">
  </AI-scenarios>
</end>
Marius_A
 
Posts: 89
Joined: Wed Dec 04, 2013 2:20 pm

Re: Tutorials/Missions/Adventures: requests for features

Postby ludomotico » Thu Apr 24, 2014 11:04 am

If some developer is looking into it, I have started to write some test missions and already hit some walls :)

My test mission will be a precision landing competition: http://www.fai.org/gac-our-sport/precision-flying Currently, only the landing part. Check the video in the linked page and the competition rules in Documents->Sporting code->Competition rules->precision flying

(I think this mission could be easily transformed into an acrobatics competition, for example)

My current issues, more to come:

- The issue about how to load and reload missions, already discussed :)
- dynamic markers. A marker is a latitude/longitude position defined in the mission file, and FlightGear informs about how far away the marker is, or the heading to reach the marker position. Afaik, the latitude/longitude position of a marker cannot be changed from nasal space. This makes missions linked to specific locations.
User avatar
ludomotico
 
Posts: 1013
Joined: Tue Apr 24, 2012 1:01 pm
Version: git
OS: Debian GNU/Linux

Re: Tutorials/Missions/Adventures: requests for features

Postby Marius_A » Thu Apr 24, 2014 12:19 pm

I volunteer to help creating your mission.
If you're interested, maybe we could start new topic "Mission: Precision landing competition" (the material of such topic could be used to write "mission making tutorial", and the mission itself could be the first "official" FlightGear mission :) )?

ludomotico wrote in Thu Apr 24, 2014 11:04 am:- The issue about how to load and reload missions

I will write more detailed instructions soon.

ludomotico wrote in Thu Apr 24, 2014 11:04 am:dynamic markers. A marker is a latitude/longitude position defined in the mission file, and FlightGear informs about how far away the marker is, or the heading to reach the marker position. Afaik, the latitude/longitude position of a marker cannot be changed from nasal space. This makes missions linked to specific locations.


That gave me an idea: the whole mission could have an optional "bounding box" with it's local coordinate system for mission objects. That box could be placed in any place on the scenery:
Code: Select all
<bounding-box>
  <lat/>
  <lon/>
  <heading/>
</bounding-box>
Marius_A
 
Posts: 89
Joined: Wed Dec 04, 2013 2:20 pm

Re: Tutorials/Missions/Adventures: requests for features

Postby Hooray » Thu Apr 24, 2014 4:53 pm

Thanks for the information. I have looked at the tanker.nas. It's definitely worth studying.

yeah, and it is a bit more straightforward than bombable.nas :D
but basically bombable combines the concepts of tanker.nas and fox2.nas to have AI "bots" that can even fire AI missiles, all using the same method. So it is kinda powerful.

I'm currently working on AI scenarios support

sounds like a good idea to integrate these two systems a bit more

ludomotico wrote in Thu Apr 24, 2014 11:04 am:- The issue about how to load and reload missions

I will write more detailed instructions soon.


right, we also discussed that a while ago, and basically this should be directly added as a feature to the system, i.e. it should also handle reset/re-init:
http://wiki.flightgear.org/Tutorials#Re ... at_runtime


ludomotico wrote in Thu Apr 24, 2014 11:04 am:dynamic markers. A marker is a latitude/longitude position defined in the mission file, and FlightGear informs about how far away the marker is, or the heading to reach the marker position. Afaik, the latitude/longitude position of a marker cannot be changed from nasal space. This makes missions linked to specific locations.


a dynamic marker should be straightforward to implement, it would just need to be a wrapper for a geo.Coord object, along with an update() method that is called for position updates.
We're doing this in the MapStructure/TFC layer - so that AI traffic gets its position updates.


That gave me an idea: the whole mission could have an optional "bounding box" with it's local coordinate system for mission objects. That box could be placed in any place on the scenery:

I would still consider using some helper class, so that such positions do not have to be static - i.e. once there is a class wrapping geo.Coord, the same bounding box could even be dynamic - as in carrier landings for example, where the bounding box would be defined by the position of the -moving- carrier
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: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Tutorials/Missions/Adventures: requests for features

Postby ludomotico » Fri Apr 25, 2014 3:14 am

You can download the first version of the precision landing competition mission from https://dl.dropboxusercontent.com/u/131 ... ssions.zip

Beware: there are lots of bugs, this is not only a wip but also a proof-of-concept. Not intended for final users yet!

Description:

This is a precision landing competition under the rules of the International Air Sports Federation (http://www.fai.org). You will perform four landings as close as possible to the "zero line" (a broad line painted on the runway). The goal is getting a score as low as possible. Scores go from zero (perfect landing) to 200-300 (out the grill). The further you land from the zero line, the more score you get. Landing before the zero line is penalized.

The four landings are:

1.- normal landing. Use power and flaps at your discretion
2.- Idle landing. If you use power 30 seconds before landing, this landing scores 200 points. Use flaps at your discretion.
3.- Idle landing without flaps. If you use power or flaps 30 seconds before landing, this landing scores 200 points.
4.- Obstable landing. There is a rope 50m before the zero line and 2m above the ground. Your approach must be above this rope. If you touch the rope, this landing scores 400 points.

Your final score will be the addition of all your partial scores.

The airfield for this competition is LECD-La Cerdanya (http://www.aerodromlacerdanya.cat), a small airfield in the Pyrinees close to the French-Spanish border. LECD has a runway 07/25 of 1150m. The competition will be held in runway 25. For GA aircrafts, you must use left turns. There is a river you can use to estimate visually your left base leg.

Good luck!


Installation guide:

1.- unzip the file in FG_ROOT. You'll get a new directory FG_ROOT/Missions.
2.- add a line <tutorial include="Missions/precision_landing.xml"/> to your favorite aircraft. I have only tested the c172p. In this case, add the line at the end of FG_ROOT/Aircraft/c172p/Tutorials/c172-tutorials.xml
3.- Run fgfs, go to LECD runway 25 and run help->tutorials->precision landing

Why LECD? Because it is fully modeled including all its buildings, it hosts precision landing competitions also in real life and it is the airport I liked the most from the small set I have landed in RL :) Visual approach chart: http://www.aerodromlacerdanya.cat/FitxaLECD-112012.pdf (I'm afraid the only version available is in Catalan)

Hints: configure "fair weather" in the weather dialog and use Rembrandt to get the shadow of the aircraft on the runway!
Last edited by ludomotico on Fri Apr 25, 2014 12:12 pm, edited 2 times in total.
User avatar
ludomotico
 
Posts: 1013
Joined: Tue Apr 24, 2012 1:01 pm
Version: git
OS: Debian GNU/Linux

Re: Tutorials/Missions/Adventures: requests for features

Postby Hooray » Fri Apr 25, 2014 4:55 am

thanks for that, as I mentioned elsewhere, I guess now would be a good time to commit all the stuff that Marius_A, DFaber und you have been working to a single repository and integrate things there, so that others can help more easily. I am not going to do any 3D or texturing stuff, but I can help with Nasal related things, as well as adding Canvas-based features to the system so that things like the route can be visualized prior to actually flying the mission, i.e. next to the introduction - kinda like a "mission briefing" like you would get to see in a real game or combat simulator. For example, see these FSX screen shots (which we can now fully recreate using Nasal/Canvas):

Image

Image

Image

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: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Tutorials/Missions/Adventures: requests for features

Postby ludomotico » Fri Apr 25, 2014 10:03 am

I was planning to write a list of things to check, but you were faster :)

* Mission briefings. Most of the building blocks to create missions are there, except mission briefings. At first, I would be happy if there is an easy way to show dialogs from nasal space. By "easy", I mean a single nasal call to show a window with an image and text, or ideally a "notebook window" showing a set of images linked to a set of texts with prev/next buttons. Also, the snapshots you provide show some interesting pieces of data our missions should include as metadata: estimated duration of the mission, whereabouts, difficulty, aircrafts... Currently, only a description and an airport are provided by the xml file.
* Multiplayer. I don't know if MP integrates in any way with the tutorials/missions system. Probably they work together but do not communicate each other. For example: how can we send our score to other players? Or remove a rescued person from all connected players at the same time?
* Scoring. I don't like competitiveness, but I acknowledge we must collect a "list of requirements" regarding scoring. I'll write my thoughts in the post you opened recently.
* Loading METAR from a string is not as straightforward as I though :) Checking the weather dialog, it seems there are lots of things to do before and after loading a raw METAR string. I even think some of these settings (such as /environment/realwx/enabled) are remembered when FlightGear ends. I believe missions shouldn't change the user configuration. Is there an "easy way" to load a METAR string or we need a function loadmetar() in the __tutorials namespace?
User avatar
ludomotico
 
Posts: 1013
Joined: Tue Apr 24, 2012 1:01 pm
Version: git
OS: Debian GNU/Linux

Re: Tutorials/Missions/Adventures: requests for features

Postby Marius_A » Fri Apr 25, 2014 2:18 pm

Hooray wrote in Fri Apr 25, 2014 4:55 am:now would be a good time to commit all the stuff that Marius_A, DFaber und you have been working to a single repository and integrate things there, so that others can help more easily


At the moment I can share this: link


Installation:
  • Extract "Tutorials" folder to FG_ROOT;
  • Extract tutorial.nas to FG_ROOT/Nasal/tutorial/ (backup the original file).

To reload tutorials I'm currently using joystick bindings (temporary solution until GUI dialog is modified):
Code: Select all
   <button n="10">
   <desc>Reload tutorial</desc>
   <repeatable type="bool">false</repeatable>
      <binding>
         <command>nasal</command>
         <script>tutorial.reloadTutorial();</script>
      </binding>
   </button>

 <button n="11">
  <desc>Tutorial dialog</desc>
   <repeatable type="bool">false</repeatable>
      <binding>
         <command>nasal</command>
         <script>
            setprop("/nasal/tutorial/enabled", 1);
            settimer(func{gui.showDialog("tutorial")}, 0);
         </script>
      </binding>
 </button>


The missions should be registered in list.xml (will be automatic later):
Code: Select all
<PropertyList>
   <tutorial>
      <path>/Tutorials/Helicopter_missions/Oil-Rig-Landing/Oil-Rig-Landing.xml</path>
   </tutorial>
   <tutorial>
      <path>/Tutorials/Banner-pickup.xml</path>
   </tutorial>
   <tutorial>
      <path>/Tutorials/Precision-landing/precision_landing.xml</path>
   </tutorial>
   <!-- ... -->
</PropertyList>


3d models can be loaded in each step.
Changed model placement procedure. Use this:
Code: Select all
         <model>
            <path>Tutorials/Generic/Models/marker-d20.xml</path>
            <latitude-deg>37.50087011</latitude-deg>
            <longitude-deg>-122.5125049</longitude-deg>
            <altitude-ft>1.0</altitude-ft> <!--NEW-->
            <heading-deg>120.0</heading-deg>
         </model>

instead of this:
Code: Select all
         <model>
            <path>Tutorials/Generic/Models/marker-d20.xml</path>
            <latitude-deg>37.50087011</latitude-deg>
            <longitude-deg>-122.5125049</longitude-deg>
            <elevation-ft>31.0</elevation-ft>  <!--OLD-->
            <heading-deg>120.0</heading-deg>
         </model>
Marius_A
 
Posts: 89
Joined: Wed Dec 04, 2013 2:20 pm

Re: Tutorials/Missions/Adventures: requests for features

Postby ludomotico » Fri Apr 25, 2014 4:12 pm

I have not tested your files yet, but I'll use your proposed directory structure from now on.

I like very much the idea of linking models to steps and removing these models when a step ends.

Why does your tutorials.nas include functions to manage banners? Since banners are specific to a mission, I think they must be defined in the <nasal> section of the specific mission file, not in the general file. Hoops, on the other hand, seem a generic object useful for many cases and I agree they can be defined in tutorial.nas
User avatar
ludomotico
 
Posts: 1013
Joined: Tue Apr 24, 2012 1:01 pm
Version: git
OS: Debian GNU/Linux

Re: Tutorials/Missions/Adventures: requests for features

Postby Hooray » Fri Apr 25, 2014 8:07 pm

Some questions:
  • is everybody here familiar with git/gitorious ? Or would you like me to set up a branch where I commit everything we've got so far ?
  • you mentioned keyboard bindings, I was wondering if we should explore supporting keyboard/joystick bindings as part of the framework ? I think those can now be changed/applied at runtime, so should be possible to dynamically modify bindings now - that would allow us to support custom bindings, which could be kinda useful ?
  • I also like the fact that models can now be dynamically loaded/unloaded, I'd just still retain the old behavior for the sake of simplicity
  • looking at tutorial.nas, it's fairly simple and compact code, it would be interesting to see if any other features there should support recursion, too ? For example, conditions allowing models, allowing conditions would then be possible. Basically, recursion is the single most powerful component that we could support, because then, everything else will be implicitly supported through nesting. In combination with Nasal blocks, we should have everything required to make this fairly generic with very little changes required.

I am thinking of supporting a handful of extensions for most building blocks:

  • allowing custom nasal for every element (including models)
  • allowing conditions for each element
  • allowing use of include/params to reuse existing building blocks easily (implicitly supported, but need to focus more on XML than Nasal then)
  • allow tutorials.nas to be extended via XML: viewtopic.php?f=79&t=22849#p207122
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: 11317
Joined: Tue Mar 25, 2008 8:40 am

PreviousNext

Return to Tutorials and missions

Who is online

Users browsing this forum: No registered users and 1 guest