Board index FlightGear Development Nasal

Wing flex -- spring/damper Nasal module

Nasal is the scripting language of FlightGear.

Re: Wing flex -- spring/damper Nasal module

Postby radi » Mon Feb 02, 2015 8:12 am

Thanks onox. I looked into that, and adding an integration "filter" to C++ was easier than I had thought! Questions:

How can I pass parameters between two .xml files? I'd like to have an aircraft-specific file 787-8/wingflexer-params.xml that gets included by the actual wingflexer code in Generic/wingflexer.xml. The wiki page mentions "aliased property names", but I can't seem to find an example.

I know I can make wingflexer-params.xml set the value of properties, e.g. to set the spring stiffness. But for increased flexibility (ha ha), I'd like to make the fuel mass property path a variable. Wingflexer-params.xml could of course have a gain filter that reads the actual fuel mass for the aircraft in question and writes it to /sim/systems/wingflexer/fuel-mass, but if there's a better way...

EDIT: upon re-reading the wiki page:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
 <PropertyList>
   <params>
     <controls>
       <aileron>controls/flight/aileron</aileron>
     </controls>
   </params>
 </PropertyList>

Does this mean I can now access /sim/systems/params/controls/aileron and this will give me the value of /controls/flight/aileron?
OSM buildings for LOWI, EDDC
Custom scenery for VHXX YMML
Edit .stg via the FG Object Placement Tool
radi
 
Posts: 659
Joined: Mon Aug 25, 2008 5:24 pm
Location: YMML, EDDC

Re: Wing flex -- spring/damper Nasal module

Postby onox » Mon Feb 02, 2015 8:38 am

I think so yes. You write something like:

Code: Select all
<property alias="path/to/params/controls/aileron"/>


Not sure if you can set the params thing. Have never tried that. In my code I have always written "<property>" where you wrote "<aileron>". Not sure if that's needed either :)

While you are at it: could you add a filter called "function" that is always a gain filter with a gain of 1.0? That would make my code a bit easier to read.

Edit: seems gain is 1.0 by default. It's still ugly though that a <filter> element can have different types. IMHO it's nicer to write <function>, <gain>, <noise-spike>, etc. More like how JSBSim does it.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 3:45 pm

Re: Wing flex -- spring/damper Nasal module

Postby radi » Tue Feb 03, 2015 12:28 pm

OK, now I got how the aliased property stuff works, and I can alias a fixed number of wing tanks. Say, wingflexer-params.xml will alias whichever nodes correspond to left and right wing tanks to /sim/systems/wingflexer/wing-tank-left-kg and -right-kg. FIne. But what if there are more than two wing tanks? Is there a way to pass a variable list of properties to the property-rule .xml?
OSM buildings for LOWI, EDDC
Custom scenery for VHXX YMML
Edit .stg via the FG Object Placement Tool
radi
 
Posts: 659
Joined: Mon Aug 25, 2008 5:24 pm
Location: YMML, EDDC

Re: Wing flex -- spring/damper Nasal module

Postby Hooray » Tue Feb 03, 2015 12:48 pm

radi wrote in Tue Feb 03, 2015 12:28 pm:But what if there are more than two wing tanks? Is there a way to pass a variable list of properties to the property-rule .xml?


... which funnily brings us back to the "multiple-instances" use case that was previously supported easily by your implementatioin using Nasal :mrgreen:
What people tend to do in such cases is, use a tiny Nasal wrapper for syncing/copying different properties to a fixed set of input/output properties and you'll be all set: you'll get native code performance, while Nasal is handling the flexibiltiy.

In general, it would be right to extend the property rule/AP systems accordingly, or at least expose those systems to scripting space, so that people don't need to come up with such hybrid workarounds...
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Wing flex -- spring/damper Nasal module

Postby Johan G » Tue Feb 03, 2015 5:48 pm

Psst: PropertyList XML files#Aliased properties. :wink:

In cases where there are only one tank per wing you may be able to instruct aircraft developers to alias the relevant properties in the <Aircraft>-set.xml file. Otherwise, as Hooray mentioned, instructing them to use property rules/autopilot to sum up the contents of multiple wing tanks are probably a good way.

The issue then left is making it easy for the aircraft developers to find those instructions and finally hope that they actually read them. :roll: :wink:
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: Wing flex -- spring/damper Nasal module

Postby onox » Wed Feb 04, 2015 5:33 pm

No need for Nasal. Just a simple filter that computes the sum for those aircraft that have multiple tanks per wing. (+ the alias). Aircraft with 1 tank per wing only need the alias.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 3:45 pm

Re: Wing flex -- spring/damper Nasal module

Postby Johan G » Sun Feb 28, 2016 12:53 pm

There is a topic related to showing wing flex in the replays: Showing WingFlex in Replay. Not all that easy it seems. :?
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: Wing flex -- spring/damper Nasal module

Postby chris_blues » Fri Apr 29, 2016 4:20 pm

I'm having a little trouble finding out the right values to input into the filter. After banging my head on the property browser I'm about to give up.

Problem: I can't find out which was first: chicken or the egg:
lift_force_lbs = aircraft_weight_lbs * load_factor - total_weight_on_wheels_lbs

If you think about it, you'll find that:
total_weight_on_wheels = gross weight - lift_force

So, my conclusion would be that this line actually is:
lift_force = (weight * loadFactor) - weight

So, how do get to this total_weight_on_wheels_lbs??? :evil:

-----------------------------------------------------

My other problem is, that under certain conditions the calculations explode right in my face! I get z-m = x E+130 and more. When crossing into a different METAR under Detailed weather for instance. Or on init, or when the simulation stalls for loading some scenery-models...

wingflexer-params.xml:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
  <params>
    <m-wing-dry-kg type="double">200</m-wing-dry-kg>
    <K type="double">5000</K>
    <D type="double">80</D>
    <fuel-frac type="double">0.375</fuel-frac>
    <lift-node-lbs alias="/yasim/fbz-aero-lbs"/>
    <fuel-node-1-kg alias="/consumables/fuel/tank/level-kg"/>
    <fuel-node-2-kg alias="/consumables/fuel/tank[1]/level-kg"/>
    <fuel-node-3-kg type="double">0.</fuel-node-3-kg>
    <fuel-node-4-kg type="double">0.</fuel-node-4-kg>
    <z-fac type="double">0.1</z-fac>
  </params>
</PropertyList>


Filter:
Code: Select all
<filter>
    <name>Lift force on the wings for wingflexer</name>
    <debug>false</debug>
    <type>gain</type>
    <input>
      <expression>
        <difference>
          <product>
            <property>yasim/gross-weight-lbs</property>
            <property>accelerations/n-z-cg-fps_sec</property>
          </product>
          <property>yasim/gross-weight-lbs</property>
        </difference>
      </expression>
    </input>
    <output>/yasim/fbz-aero-lbs</output>
  </filter>


Is there some way to clamp z-m to some reasonable value? Or better: the value that explodes so that z-m goes crazy in return?

----------------------------------------

Edit:

Why not incorporate /environment/ridge-lift-fps and /environment/thermal-lift into this calculations?
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian stable 64bit - i7 8x2.8GHz - 20GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
Retired
 
Posts: 1577
Joined: Mon May 03, 2010 2:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian stable 64

Re: Wing flex -- spring/damper Nasal module

Postby Thorsten » Fri Apr 29, 2016 6:16 pm

Why not incorporate /environment/ridge-lift-fps and /environment/thermal-lift into this calculations?


Because they don't alter the forces on the plane, they alter the reference frame in which the plane moves. A plane feels wind only when you look at groundspeed, otherwise you compute aerodynamics in a frame where the air is still.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Wing flex -- spring/damper Nasal module

Postby chris_blues » Fri Apr 29, 2016 7:15 pm

Maybe I just don't understand, what exactly these props are generated for, but don't thermals and ridge lift put lift-force onto the wings?

When I had the fortune of a RL-flight, we had lots of thermals, and considerable wingflex as a result...
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian stable 64bit - i7 8x2.8GHz - 20GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
Retired
 
Posts: 1577
Joined: Mon May 03, 2010 2:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian stable 64

Re: Wing flex -- spring/damper Nasal module

Postby radi » Sat Apr 30, 2016 2:11 pm

It's been a while since I've looked into how to possibly blend Wingflexer with Yasim... I could be wrong, but didn't Yasim provide weight_on_wheels already? I'd think it ought to, to calculate ground reactions properly.

Regarding your maths, the second equation is essentially the same as the first, except that you omitted the load factor.

Good thinking about clamping. Short of figuring out what causes the spikes, clamping (or some non-linear damping) should do the trick. Seems like property rules support input/output clamping:
http://wiki.flightgear.org/Autopilot_configuration_reference#Input_clamping_.3Cmin.3E_and_.3Cmax.3E

There is absolutely no need to manually include updrafts, gusts, ridge lift etc. In fact, it'd not only be bad design, it'd be plain wrong. As a first order approximation, wing bending is caused by the net lift acting on the wing (i.e. the aerodynamic lift minus the wing's gross weight), which counters the fuselage's gross weight. As Thorsten mentioned, to produce lift, the wing -- and in our sim world, the FDM -- only really cares about how fast the air is approaching, aka the free stream velocity, and at which angle. That free stream velocity already is the sum of ground speed, winds, gusts, thermals, ridge lift, etc. If it wasn't, your simulated aircraft wouldn't react to either of them.

Actually, one of the fun parts when adjusting wingflexer's parameters for the 787 was putting the plane on autopilot, ramping the gusts slider all the way up, and then watching the wings 'flap' :D
Last edited by radi on Sat Apr 30, 2016 2:20 pm, edited 1 time in total.
OSM buildings for LOWI, EDDC
Custom scenery for VHXX YMML
Edit .stg via the FG Object Placement Tool
radi
 
Posts: 659
Joined: Mon Aug 25, 2008 5:24 pm
Location: YMML, EDDC

Re: Wing flex -- spring/damper Nasal module

Postby chris_blues » Sat Apr 30, 2016 2:17 pm

Well, if YaSim provides weight_on_wheels, then I couldn't find it! In /gear/gear[1 and 2]/wow is a double which only switches from 1 to 0. There's no in between. It behaves like a bool. And interestingly /gear/gear[0]/wow is in fact a bool...
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian stable 64bit - i7 8x2.8GHz - 20GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
Retired
 
Posts: 1577
Joined: Mon May 03, 2010 2:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian stable 64

Re: Wing flex -- spring/damper Nasal module

Postby radi » Sat Apr 30, 2016 2:28 pm

If yasim exposes neither lift nor the true weight-on-wheels, then you're somewhat out of luck. You could still use
lift \approx weight * load_factor, which will give you proper wing flex under gusts etc, but you won't get flexing on touch down.
Internally, yasim must calculate both, and I vaguely recall having found the part in the yasim code where it actually does, but I stopped back then before I had figured out how to expose those quantities.
OSM buildings for LOWI, EDDC
Custom scenery for VHXX YMML
Edit .stg via the FG Object Placement Tool
radi
 
Posts: 659
Joined: Mon Aug 25, 2008 5:24 pm
Location: YMML, EDDC

Re: Wing flex -- spring/damper Nasal module

Postby wlbragg » Sat Apr 30, 2016 4:42 pm

If yasim exposes neither lift nor the true weight-on-wheels, then you're somewhat out of luck.

---- HACK WARNING ----
For touchdown wing flex you could cheat and use a variable that holds WOW a loop back. When that var == 0 and WOW == 1 do a simulated wingflex. It's a hack, but might get you a visual something close to what you want. You might even tie AGL into it and the higher the rate AGL changes at this point in time the more wing flex you could assign.
---- END HACK WARNING ----

Or you could make a JSBSim version! :lol:
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7609
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Wing flex -- spring/damper Nasal module

Postby Thorsten » Sat Apr 30, 2016 5:22 pm

When I had the fortune of a RL-flight, we had lots of thermals, and considerable wingflex as a result...


I suspect that was rather caused by local eddies. You do get wingflex if the updraft on the left wing is different from the updraft on the right wing (then you also get a rolling moment...), i.e. if the upwelling airmass is on a scale smaller than your wingspan. But we don't resolve this in FG (pretty much all of YaSim would break down and a JSBSim FDM would need quite some tweaks to handle this correctly even if we would feed the parameters).

Maybe I just don't understand, what exactly these props are generated for, but don't thermals and ridge lift put lift-force onto the wings?


Think about it this way - how would the plane possibly know that the surrounding air moves upward relative to the Earth (or at all?) - all it can know is how the surrounding air moves relative to the plane.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Previous

Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest