Board index FlightGear Development Aircraft

JSBSim Actuator vs. Property-rule noise-spike filter

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

JSBSim Actuator vs. Property-rule noise-spike filter

Postby Necolatis » Fri Apr 07, 2017 1:41 am

Hi,

I am looking for a filter that will limit the rate of change of a property.

Whats important is that its a heading, so when it goes from 359 to say 1 degrees, it should not move slowly down from 359 till it reach 1, but move the 2 degrees as limited by the rate of moving only 2 degrees, not 357.

I have looked at JSBSim Actuator and Property-rule noise-spike filter. Neither seems to support this as I got it from documentation.

I could do it in Nasal, but I would prefer a more elegant solution using some filters/components.

Any help appreciated.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1986
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: JSBSim Actuator vs. Property-rule noise-spike filter

Postby Thorsten » Fri Apr 07, 2017 5:21 am

Well, headings are a bitch to process. Usually I end up with something like this (that's from Shuttle contingency flight AP rules which need to cope with all sorts of angular shit, like flying 106 deg pitch, flying with beta = 180 degree,...)

Code: Select all
      <fcs_function name="systems/ap/contingency/heading-arg-raw">
      <function>
         <abs>
         <difference>
            <property>/orientation/heading-deg</property>
            <property>velocities/course-deg</property>
         </difference>
         </abs>
      </function>
      </fcs_function>

      <fcs_function name="systems/ap/contingency/heading-arg-subtracted">
      <function>
         <abs>
         <difference>
            <property>systems/ap/contingency/heading-arg-raw</property>
            <value>360.0</value>
         </difference>
         </abs>
      </function>
      </fcs_function>

      <switch name="systems/ap/contingency/heading-arg">
         <default value="systems/ap/contingency/heading-arg-raw"/>
         <test value="systems/ap/contingency/heading-arg-subtracted">
            systems/ap/contingency/heading-arg-raw GT 180.0
         </test>

      </switch>

      <switch name="systems/ap/contingency/heading-sign">
         <default value="1"/>
         <test value="-1">
            systems/ap/contingency/heading-arg GT 90.0
         </test>   
      </switch>


so basically you compute two different solutions corresponding (in your case) to counting up and counting down and then use a switch to decide which to use and feed to the time-delayed tag as target.

Also, you probably need to run it through a post-processing filter using <mod> to make 0 = 360. So this is all possible using JSBSim elements, but hardly elegant.

(I seem to have read somewhere that FG-native AP components can actually handle angles if some option is set, but I never used them much).
Thorsten
 
Posts: 11087
Joined: Mon Nov 02, 2009 8:33 am

Re: JSBSim Actuator vs. Property-rule noise-spike filter

Postby Richard » Fri Apr 07, 2017 5:40 am

JSBSim function as below.

properties:

* something/current - change this to e.g. heading
* something/demand - what the value should be, e.g. demanded heading

output will be something/heading-delta-demand - and it is the amount to add to the current value to get to the demand value. Use this demand delta as amount to change current by.


Code: Select all
        <!-- RJH:2017-04:
            work out heading demand (from 0 to 360) wrapping values around the zero point
                from 0 to 359: delta -1
                from 1 to 2: delta 1
                from 2 to 1: delta -1
                from 359 to 0: delta 1
               
                in traditional language:
                double GetROC(double current, double demand)
                {

                    if (Math.Abs(current-demand) > 180)
                        if (current > demand)
                            return (demand+180) - (current-180);
                        else
                            return (demand-180) - (current+180);

                    return demand-current;
                }
        -->
        <fcs_function name="something/heading-delta-demand">
            <function>
                <ifthen>
                    <ge>
                        <abs>
                            <difference>
                                <property>something/current</property>
                                <property>something/demand</property>
                            </difference>
                        </abs>
                        <value>180</value>
                    </ge>
                    <ifthen>
                        <ge>
                            <property>something/current</property>
                            <property>something/demand</property>
                        </ge>
                        <difference>
                            <sum>
                                <property>something/demand</property>
                                <value>180</value>
                            </sum>
                            <difference>
                                <property>something/current</property>
                                <value>180</value>
                            </difference>
                        </difference>
                        <difference>
                            <difference>
                                <property>something/demand</property>
                                <value>180</value>
                            </difference>
                            <sum>
                                <property>something/current</property>
                                <value>180</value>
                            </sum>
                        </difference>
                    </ifthen>
                    <difference>
                        <property>something/demand</property>
                        <property>something/current</property>
                    </difference>
                </ifthen>
            </function>
        </fcs_function>
Last edited by Richard on Fri Apr 07, 2017 6:35 am, edited 1 time in total.
Richard
 
Posts: 716
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: JSBSim Actuator vs. Property-rule noise-spike filter

Postby Necolatis » Fri Apr 07, 2017 5:53 am

Thanks for the inputs both. Used Richards function, with some rate calculations afterwards.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1986
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: JSBSim Actuator vs. Property-rule noise-spike filter

Postby Thorsten » Fri Apr 07, 2017 6:22 am

Ah, I didn't even realize there was an <ifthen> tag... That's pretty useful.
Thorsten
 
Posts: 11087
Joined: Mon Nov 02, 2009 8:33 am


Return to Aircraft

Who is online

Users browsing this forum: Google [Bot], Necolatis and 3 guests