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 Gijs » Mon Dec 08, 2014 1:58 pm

Not right now, but I remember seeing some figures on wing bending (on the ground) as a function of fuel load. I'll see if I can dig them up. For starters, we do know the mass ofcourse.
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9544
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Wing flex -- spring/damper Nasal module

Postby wlbragg » Mon Dec 08, 2014 5:50 pm

radi,

Your example 787-8 calls a model subfolder called FlightDeck, neither your example or my existing 787-8 have a model\FlightDeck.
Where is the base 787-8 you used?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
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 radi » Tue Dec 09, 2014 1:15 pm

Umm, I might have based that on an outdated version of
http://wiki.flightgear.org/Boeing_787-8 ... _the_787-8
but it should be trivial to adapt this for any JSBsim plane that already has a wingflex animation. Just make sure the aircraft calls wingflex.nas once and adapt the existing wing flex animation to use /sim/model/wing-flex/z-m. Then perhaps change the animation's <factor> and maybe K because most wings are not as flexible at the 787's, and you're done.
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 radi » Tue Dec 09, 2014 1:23 pm

Gijs,

it'd be great if you can dig that up. I'll think about how to best include the added/variable mass, and play a bit with the model to see if I can get a plausible set of parameters, but it'd really help to have some real-world numbers.
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 radi » Mon Dec 15, 2014 1:45 pm

I added wing tanks to the equation, and it's looking good! With full tanks wings bend down when sitting on the runway, and the eigenfrequency is lower. Now real numbers on what amount of wing flex to expect would _really_ help to fine tune this! ;)
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 » Mon Dec 15, 2014 7:25 pm

I added wing tanks to the equation

You have this in GIT somewhere or in your original dropbox post?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
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 radi » Mon Dec 15, 2014 10:09 pm

Haven't published the latest update yet. Give it some more days.
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 radi » Mon Dec 29, 2014 10:29 am

I've pushed the latest version including the wing tank feature to https://gitorious.org/fg/radis-fgdata . You will need
    Aircraft/Generic/wingflexer.nas
    Aircraft/Generic/updateloop.nas

Find an implementation example in Aircraft/787-8.

Edit: I'm happy for someone to put this on fgdata -- I'm afraid because I mixed commits of wingflexer.nas and Nasal/touchdown_watcher.nas, I can't create a clean merge request? (git noob here..)
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 radi » Mon Jan 26, 2015 1:28 pm

I have created a first PropertyList version of the wing flexer. Comments welcome!

Systems/wingflexer.xml:
(note, for simplicity I write most of my properties to /a/ during development so I don't have to navigate to /sim/models/...)
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
    <debug>true</debug>

    <!-- limit time step -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/delta-sec</output>
        <input>
            <property>/sim/time/delta-sec</property>
        </input>
        <max>0.05</max>
    </filter>

    <!-- fuselage z (up) acceleration in m/s^2
         we get -g in unaccelerated flight, and large negative numbers on touchdown -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/a_f</output>
        <input>
            <expression>
                <product>
                    <property>/accelerations/pilot/z-accel-fps_sec</property>
                    <value>0.3048</value> <!-- FT2M -->
                </product>
            </expression>
        </input>
    </filter>

    <!--
        # compute total mass of one wing, using the average fuel mass in both wing tanks.
        # The averaging factor 0.5 is lumped into fuel_frac_on_2
        me.m = me.m_dw + me.fuel_frac_on_2 * (getprop(me.fuel_node_left) + getprop(me.fuel_node_right));
    -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/m</output>
        <input>
            <expression>
                <sum>
                    <property>/a/m_dw</property>
                    <product>
                        <property>/a/fuel_frac_on_2</property>
                        <sum>
                            <property>/consumables/fuel/tank/level-kg</property>
                            <property>/consumables/fuel/tank[1]/level-kg</property>
                        </sum>
                    </product>
                </sum>
            </expression>
        </input>
    </filter>

    <!-- lift force. Convert to N and use 1/2 (one wing only) -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/F_l</output>
        <input>
            <expression>
                <product>
                    <property>/fdm/jsbsim/forces/fbz-aero-lbs</property>
                    <product>
                        <property>/environment/gravitational-acceleration-mps2</property>
                        <value>0.226796</value> <!-- LB2KG / 2-->
                    </product>
                </product>
            </expression>
        </input>
    </filter>


    <!-- z_ofs = getprop("/environment/gravitational-acceleration-mps2") * me.m_dw / me.k; -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/z-ofs</output>
        <input>
            <expression>
                <div>
                    <product>
                        <property>/environment/gravitational-acceleration-mps2</property>
                        <property>/a/m_dw</property>
                    </product>
                    <property>/a/k</property>
                </div>
            </expression>
        </input>
    </filter>

    <!--
        me.z = (2.*me.z1 - me.z2 + dt * ( (me.d * me.z1 - dt * (F_l + me.k * me.z1)) / me.m + dt *
                                        a_f)) / (1. + me.d * dt / me.m);
    -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/z</output>
        <input>
            <expression>
                <div>
                    <sum>
                        <difference>
                            <product>
                                <value>2.</value>
                                <property>/a/z1</property>
                            </product>
                            <property>/a/z2</property>
                        </difference>
                        <product>
                            <property>/a/delta-sec</property>
                            <sum>
                                <div>
                                    <difference>
                                        <product>
                                            <property>/a/d</property>
                                            <property>/a/z1</property>
                                        </product>
                                        <product>
                                            <property>/a/delta-sec</property>
                                            <sum>
                                                <property>/a/F_l</property>
                                                <product>
                                                    <property>/a/k</property>
                                                    <property>/a/z1</property>
                                                </product>
                                            </sum>
                                        </product>
                                    </difference>
                                    <property>/a/m</property>
                                </div>
                                <product>
                                    <property>/a/delta-sec</property>
                                    <property>/a/a_f</property>
                                </product>
                            </sum>
                        </product>
                    </sum>
                    <sum>
                        <value>1.</value>
                        <product>
                            <property>/a/d</property>
                            <div>
                                <property>/a/delta-sec</property>
                                <property>/a/m</property>
                            </div>
                        </product>
                    </sum>
                </div>
            </expression>
        </input>
    </filter>

    <!--
         z2 = z1
         z1 = z
         z-m = z + z_ofs
    -->
    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/z2</output>
        <input>
            <property>/a/z1</property>
        </input>
    </filter>

    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/a/z1</output>
        <input>
            <property>/a/z</property>
        </input>
    </filter>

    <filter>
        <type>gain</type>
        <gain>1.</gain>
        <output>/sim/model/wing-flex/z-m</output>
        <input>
            <expression>
                <sum>
                    <property>/a/z</property>
                    <property>/a/z-ofs</property>
                </sum>
            </expression>
        </input>
    </filter>

</PropertyList>



Some questions:
1. I'm using the gain filter to compute /some/property = f(/some/other/property). Is there a better way?
2. Is there something like listeners (as in Nasal) for stuff that rarely ever changes? For example, internally I need k, which is k = /sim/model/wing-flex/K * /sim/model/wing-flex/m where both K and m rarely ever change.
3. As suggested by the wiki, I'm including the wingflexer code like so:
787-8-set.xml:
Code: Select all
<PropertyList>
        <a include="Systems/wingflexer-params.xml"/>
   <sim>
        <systems>
               <property-rule n="100">
                        <name>wing flexer property rule</name>
                        <path>Systems/wingflexer.xml</path>
                </property-rule>
       </systems>
   <sim>

Can I load the PropertyList to a path other than /sim/systems? E.g., to /sim/model/wingflexer?
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 Johan G » Mon Jan 26, 2015 10:54 pm

Sweet 8)

Doing it using property rules has a few great advantages, in particular doing it at FDM rate and without being affected by Nasals garbage collection. I suspect it will also work better with reset and re-init.

As for doing it somewhere else than in /sim/systems the only thing I can think of is try and see. ;)

In the wiki article about the property rules there is a tip box about using aliases. I guess you can use that instead of /a/, but I have not tried using it myself yet.
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: 6629
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 Hooray » Tue Jan 27, 2015 6:40 pm

Johan G wrote in Mon Jan 26, 2015 10:54 pm:Doing it using property rules has a few great advantages, in particular doing it at FDM rate


property rules don't run at FDM rate, they run at frame rate, quoting the wiki:
http://wiki.flightgear.org/Property_rule
our beloved wiki wrote:The FlightGear xml based autopilot system can run at FDM rate or at frame rate. Using a <autopilot> tag in your aircraft's -set.xml adds the autopilot at FDM rate, using a <property-rule> runs the same configuration at frame rate.


and without being affected by Nasals garbage collection. I suspect it will also work better with reset and re-init.

property rules don't use any Nasal, so they cannot be affected by Nasal space issues, which makes this kinda obvious - reset/re-init advantages are also primarily a matter of the people maintaining the underlying code, no matter if it's Nasal, C++, property rules or FDMs. Reset/re-init, and the AP system, just happen to be actively maintained currently.

As for doing it somewhere else than in /sim/systems the only thing I can think of is try and see. ;)


supporting custom locations for property rules, as well as custom/configurable resolutions, could indeed be pretty useful.
We could get rid of quite a bit of legacy Nasal code doing systems modeling if property rules, and more generally the AP system, were fully exposed/available to Nasal.

However, given the current situation, we're exchanging a fairly flexible Nasal space implementation with one that purely lives in property space for the sake of much better performance, while sacrificing all the flexibility - i.e. we are not longer able to easily apply the wing flex module to AI aircraft for instance, which would have been trivial using just Nasal. But this is not primarily a Nasal vs. property-rules issue, but one of mutual integration - which is the whole reason why people tend to reinvent the wheel ...
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 Jan 27, 2015 10:10 pm

Hooray wrote in Tue Jan 27, 2015 6:40 pm:property rules don't run at FDM rate, they run at frame rate, quoting the wiki...

Thanks for clarifying that. :oops:
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: 6629
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 Torsten » Tue Jan 27, 2015 11:02 pm

That's interesting how you used delta-sec and the gain filter for storing zn values.
Good work! But it's probably a bit overkill. Would it make sense to implement that integrator in a generic way as a seperate C++ filter?

Some answers to your questions:

1. I'm using the gain filter to compute /some/property = f(/some/other/property). Is there a better way?

No, the gain filter is the cheapest filter in the system. All others more or less derive their functionality from it.

2. Is there something like listeners (as in Nasal) for stuff that rarely ever changes?

No.

3. Can I load the PropertyList to a path other than /sim/systems? E.g., to /sim/model/wingflexer?

No, that path is hardcoded.

BTW, adding the file as a property-rule let the filters run at frame rate. Use <autopilot> instead of <property-rule> and updates happen at FDM rate.
Not very self explaining, I admit. It's a tribute to history.

Torsten
flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 648
Joined: Fri Feb 01, 2008 10:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: Wing flex -- spring/damper Nasal module

Postby radi » Wed Jan 28, 2015 10:57 am

Indeed, it's overkill and not very readable. So a new filter that integrates z" + a z' + b z = c would make things a lot easier. I'll look into that -- where in SG/FG should I look first?

BTW, adding the file as a property-rule let the filters run at frame rate. Use <autopilot> instead of <property-rule> and updates happen at FDM rate.
Not very self explaining, I admit. It's a tribute to history.


No worries -- the wiki explains that part quite well. And running at frame rate is enough.
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 » Wed Jan 28, 2015 9:06 pm

radi wrote in Wed Jan 28, 2015 10:57 am:Indeed, it's overkill and not very readable. So a new filter that integrates z" + a z' + b z = c would make things a lot easier. I'll look into that -- where in SG/FG should I look first?


You could look at digitalfilter.cxx.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 3:45 pm

PreviousNext

Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests