On Tuesday 05 February 2008, LeeE wrote:
> Thanks for the updates to xmlauto.cxx.
>
> As well as fixing the reload bug in cvs, the enabled tag for the
> filters is very useful.
>
> Would it be possible to add a null filter type i.e. a filter that
> acts as a simple pass-though?

Try the attached diff. This adds a new filter type named pass. It only needs 
an input and an output. Something like this:

   <filter>
    <name>pass-through-filter</name>
    <debug>false</debug>
    <type>pass</type>
    <input>/instrumentation/airspeed-indicator/indicated-speed-kt</input>
    <output>/autopilot/KAP140/settings/airspeed-kt</output>
   </filter>

> The reason I think this would be useful is that it would provide a
> very low-cost method of re-routing control inputs between different
> sub-systems and controllers - the sort of stuff you really need to
> do in Fly-By-Wire/Flight Control Systems.
>
> Also on my wish-list for this area would be the ability to change
> some of the pid controller parameters 'in-flight' without having to
> re-load the A/P e.g. reducing elevator control gain as airspeed
> increases.  Because the resolution/frequency of the controllers is
> effectively limited by the frame-rate there can be practical
> difficulties in tuning a controller to work optimally over wide
> ranges such as you'd get with most of the fast jets - typically
> ~120-150kts during approach and landing up to 700kts (AFAIK YASim
> doesn't do supersonic so I don't try to seriously tune for the
> supersonic regime).

Thats an interesting thought. We could do soething like this:

<config>
  <Kp prop="/autopilot/KAP140/settings/controller01-gain">10.0</Kp>
...

for the parameters that are to be exposed on the property tree. Any parameter 
without the prop attribute gets a constant value as before. Nasal can be used 
to change the value of the exposed parameters.

Another method could be:

<config>
  <Kp>
    <prop>/autopilot/KAP140/settings/controller01-gain</prop>
    <value>10.0</value>
  </Kp>
...

which is consistent with how it's done for the input to the PID controllers, 
but this will break all autopilots.

> Just for info, while re-working the YF-23 I've been playing with
> using closed feedback loop pid controllers as flight surface and
> engine control drivers/servos with some good results:)
>
> The config below is what I'm using as an elevator input driver/servo
> (there's also an identical controller for elevator-trim input,
> aileron input, rudder input and throttle & reheat control inputs)
> and so far it's working pretty well here.
>
>   <pid-controller>
>     <name>Ruddervator Surface Driver</name>
>     <debug>false</debug>
>     <enable>
>       <prop>/autopilot/FCS/locks/elevator</prop>
>       <value>true</value>
>     </enable>
>     <input>
>       <prop>/autopilot/FCS/controls/flight/elevator-norm</prop>
>     </input>
>     <reference>
>       <prop>/autopilot/FCS/internal/target-elevator-norm</prop>
>     </reference>
>      <output>
>       <prop>/autopilot/FCS/controls/flight/elevator-norm</prop>
>     </output>
>     <config>
>       <Ts>0.05</Ts>
>       <Kp>0.45</Kp>
>       <beta>0.00001</beta>
>       <alpha>0.1</alpha>
>       <gamma>0.0</gamma>
>       <Ti>0.05</Ti>
>       <Td>0.0</Td>
>       <u_min>-1.0</u_min>
>       <u_max>1.0</u_max>
>     </config>
>   </pid-controller>

Of course now you can do that with a filter, which should be simpler an less 
expensive.


-- 
Roy Vegard Ovesen
? xmlauto.diff
Index: xmlauto.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Autopilot/xmlauto.cxx,v
retrieving revision 1.28
diff -p -u -r1.28 xmlauto.cxx
--- xmlauto.cxx 4 Feb 2008 20:01:20 -0000       1.28
+++ xmlauto.cxx 5 Feb 2008 18:49:01 -0000
@@ -662,6 +662,8 @@ FGDigitalFilter::FGDigitalFilter(SGPrope
                 filterType = movingAverage;
             } else if (cval == "noise-spike") {
                 filterType = noiseSpike;
+            } else if (cval == "pass") {
+                filterType = pass;
             }
         } else if ( cname == "input" ) {
             input_prop = fgGetNode( child->getStringValue(), true );
@@ -683,11 +685,15 @@ FGDigitalFilter::FGDigitalFilter(SGPrope
 
 void FGDigitalFilter::update(double dt)
 {
-    if ( input_prop != NULL && 
-         enable_prop != NULL && 
-         enable_prop->getStringValue() == enable_value) {
+    if ( (input_prop != NULL && 
+          enable_prop != NULL && 
+          enable_prop->getStringValue() == enable_value) ||
+         (enable_prop == NULL &&
+          input_prop != NULL) ) {
+
         input.push_front(input_prop->getDoubleValue());
         input.resize(samples + 1, 0.0);
+
         if ( !enabled ) {
             // first time being enabled, initialize output to the
             // value of the output property to avoid bumping.
@@ -696,11 +702,6 @@ void FGDigitalFilter::update(double dt)
         }
 
         enabled = true;
-    } else if (enable_prop == NULL &&
-               input_prop != NULL) {
-        input.push_front(input_prop->getDoubleValue());
-        input.resize(samples + 1, 0.0);
-        enabled = true;
     } else {
         enabled = false;
     }
@@ -718,11 +719,6 @@ void FGDigitalFilter::update(double dt)
             double alpha = 1 / ((Tf/dt) + 1);
             output.push_front(alpha * input[0] + 
                               (1 - alpha) * output[0]);
-            unsigned int i;
-            for ( i = 0; i < output_list.size(); ++i ) {
-                output_list[i]->setDoubleValue( output[0] );
-            }
-            output.resize(1);
         } 
         else if (filterType == doubleExponential)
         {
@@ -730,21 +726,11 @@ void FGDigitalFilter::update(double dt)
             output.push_front(alpha * alpha * input[0] + 
                               2 * (1 - alpha) * output[0] -
                               (1 - alpha) * (1 - alpha) * output[1]);
-            unsigned int i;
-            for ( i = 0; i < output_list.size(); ++i ) {
-                output_list[i]->setDoubleValue( output[0] );
-            }
-            output.resize(2);
         }
         else if (filterType == movingAverage)
         {
             output.push_front(output[0] + 
                               (input[0] - input.back()) / samples);
-            unsigned int i;
-            for ( i = 0; i < output_list.size(); ++i ) {
-                output_list[i]->setDoubleValue( output[0] );
-            }
-            output.resize(1);
         }
         else if (filterType == noiseSpike)
         {
@@ -762,13 +748,18 @@ void FGDigitalFilter::update(double dt)
             {
                 output.push_front(input[0]);
             }
+        }
+        else if (filterType == pass)
+        {
+            output[0] = input[0];
+        }
 
-            unsigned int i;
-            for ( i = 0; i < output_list.size(); ++i ) {
-                output_list[i]->setDoubleValue( output[0] );
-            }
-            output.resize(1);
+        unsigned int i;
+        for ( i = 0; i < output_list.size(); ++i ) {
+            output_list[i]->setDoubleValue( output[0] );
         }
+        output.resize(1);
+
         if (debug)
         {
             cout << "input:" << input[0] 
Index: xmlauto.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Autopilot/xmlauto.hxx,v
retrieving revision 1.15
diff -p -u -r1.15 xmlauto.hxx
--- xmlauto.hxx 19 Jan 2008 18:06:05 -0000      1.15
+++ xmlauto.hxx 5 Feb 2008 18:49:01 -0000
@@ -240,7 +240,8 @@ private:
     double rateOfChange;  // The maximum allowable rate of change [1/s]
     deque <double> output;
     deque <double> input;
-    enum filterTypes { exponential, doubleExponential, movingAverage, 
noiseSpike };
+    enum filterTypes { exponential, doubleExponential, movingAverage,
+                       noiseSpike, pass };
     filterTypes filterType;
 
     bool debug;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to