Board index FlightGear Support Hardware

Changes in handling flaps with Nasal in FG 3.6

Joysticks, pedals, monitors.

Changes in handling flaps with Nasal in FG 3.6

Postby vanosten » Sat Aug 08, 2015 4:45 pm

Hi

I am a bit confused about how to make joystick assignments for flaps in FG 3.6 RC.

The following worked fine in earlier versions across aircraft and still works with e.g. aircraft=cap10c:
Code: Select all
controls.flapsDown(1);
settimer(func { gui.popupTip(sprintf("Flaps: %.2f", getprop("/controls/flight/flaps")));}, 3);


However when I use the same with aircraft=extra500 or aircraft=c172p nothing happens.

Contrary to this the following does not seem to work anymore with cap10c, but works fine with extra500 or c172p.
Code: Select all
setprop("/controls/flight/flaps", 0);
gui.popupTip("Flaps fully retracted");


Looking at the internal properties browser there also seems to be a difference between aircrafts whether I should have a look at /surface-positions/flaps_pos_norm or /controls/flight/flaps to get the current value.

And then in $FGDATA/Nasal/controls.nas ca. line 130 it states
# Wrapper around stepProps() which emulates the "old" flap behavior for configurations that aren't using the new mechanism.

Well if this is the old way, where can I find the new way?

=> Could someone resolve my confusion and point me to code/properties, which work across aircraft?

Thanks a lot.
Maintaining osm2city. Contributing with ground attack stuff to the OPRF FlightGear military-simulation community.
vanosten
 
Posts: 542
Joined: Sat Sep 25, 2010 6:38 pm
Location: Denmark - but I am Swiss
Pronouns: he/his
Callsign: HB-VANO
Version: latest
OS: Win 10 and Ubuntu

Re: Changes in handling flaps with Nasal in FG 3.6

Postby Thorsten » Sat Aug 08, 2015 7:14 pm

The default chain seems to be:

* '[' and ']' have key bindings to call controls.flapsDown(1) or controls.flapsDown(-1) respectively (keyboard.xml)

* flapsDown sets /controls/flight/flaps (dependent on whether /sim/flaps exists, there are two different ways to compute the effect, but they all end up in the same property) (controls.nas)

* from there for JSBSim it would end up as /fdm/jsbsim/fcs/flap-cmd-norm

* how the airfoil actually moves is then up to JSBSim (for instance, if a hydraulics system is not active, JSBSim may not translate the command into an actual movement).

* for YaSim I don't know for sure

Any aircraft may override the chain at any point. For instance the Space Shuttle doesn't have classical flaps, and the key bindings are instead used for the yaw control of RCS thrusters. The body flap is trimmed up and down by 'f' and 'shift+f' which have their own associated Nasal script and set a separate property, so /controls/flight/flaps never has any meaning - so there is no fully generic solution. Also, it usually makes a difference whether the controls have issued a command and whether an airfoil actually moves - they are different properties *-pos-norm vs. *-cmd-norm for instance.

I've seen flap implementations which are continuous and those which go in steps, and there are a few exotic cases of flaps going both directions (like for the Shuttle). I guess the safest bet is to target /controls/flight/flaps - this should cover most.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Changes in handling flaps with Nasal in FG 3.6

Postby vanosten » Sat Aug 15, 2015 7:32 am

Thank you for the answer. So handling depends on the flight dynamics model and the real aircraft. However the the aircraft modeller should know both. If we assume that the modellers are pretty consistent (at least when it comes to core stuff) in assigning keyboard commands, then the question (which I could not find a function for) is: can one emulate hitting a keyboard key from Nasal?

Ok, there is Keyboard function priority list disproving my assumption of consistency, but still it would be easier to make an aircraft specific switch statement in Nasal to call a key assignment then reading the aircraft model of what to call.
Maintaining osm2city. Contributing with ground attack stuff to the OPRF FlightGear military-simulation community.
vanosten
 
Posts: 542
Joined: Sat Sep 25, 2010 6:38 pm
Location: Denmark - but I am Swiss
Pronouns: he/his
Callsign: HB-VANO
Version: latest
OS: Win 10 and Ubuntu

Re: Changes in handling flaps with Nasal in FG 3.6

Postby Johan G » Tue Aug 18, 2015 8:25 pm

Some posts regarding keyboard bindings related to the generic autopilot was moved to the topic Looking for aircraft with 'paper cut' bugs
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6634
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Changes in handling flaps with Nasal in FG 3.6

Postby Philosopher » Wed Aug 19, 2015 1:00 am

To execute a key there's a couple steps involved (I recall doing this once... I don't know if I still have the code):
  • find the value of the key. Might as well use character constants (backquotes) like this: `a`
  • find the node in the property tree. I forgot specifics, but its something like /input/keyboard/key[i]/
  • find the binding. This can be key[i]/binding, or key[i]/mod-up/binding, mod-shift, etc. etc. (again, fuzzy on the details sorry)
  • execute the binding! see props.nas, specifically props.runBinding of course :)

HTH
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Changes in handling flaps with Nasal in FG 3.6

Postby vanosten » Sun Apr 09, 2017 1:17 pm

So an example would be like follows.

Using the magnificient Viggen you find the keybindings in fgaddon/Aircraft/JA37/ja37-input.xml.
Code: Select all
      <key n="93">
         <name>]</name>
         <desc>Increase radar range</desc>
         <repeatable>true</repeatable>
         <binding>
                <command>property-cycle</command>
                <property>/instrumentation/radar/range</property>
                <value type="int">15000</value>
                ...


Then in the joystick specific xml:
Code: Select all
  <button n="12">
    <desc>Increase Radar Range</desc>
    <repeatable>false</repeatable>
    <binding>
      <command>nasal</command>
      <script>props.runBinding(props.getNode('/input/keyboard/key[93]/binding'))</script>
    </binding>
  </button>
Maintaining osm2city. Contributing with ground attack stuff to the OPRF FlightGear military-simulation community.
vanosten
 
Posts: 542
Joined: Sat Sep 25, 2010 6:38 pm
Location: Denmark - but I am Swiss
Pronouns: he/his
Callsign: HB-VANO
Version: latest
OS: Win 10 and Ubuntu


Return to Hardware

Who is online

Users browsing this forum: No registered users and 5 guests