> It cousnt work like that in the sim. If I want to roll from 180 to 27o
> it turns gently.. in the sim it violently turns the first few degrees..
You mean it immediately slams the ailerons to full deflection? I'm sure you
could somehow limit that. The simplest method that's more advanced than
limiting throw is limiting the rate the aircraft is commanded to roll. For
reference, here's the code from the autopilot file: (787-autopilot.xml)

  <!-- Heading Bug Hold.  2 stage cascade controller. -->

  <!-- Stage #1 sets target roll based on diff between current heading -->
  <!-- and heading bug. -->
  <pid-controller>
    <name>Heading Bug Hold (FDM mag heading based) Stage 1</name>
    <debug>false</debug>
    <enable>
      <prop>/autopilot/locks/heading</prop>
      <value>dg-heading-hold</value>
    </enable>
    <input>
      <prop>/autopilot/internal/fdm-heading-bug-error-deg</prop>
    </input>
    <reference>
      <value>0.0</value>
    </reference>
    <output>
      <prop>/autopilot/internal/target-roll-deg</prop>
    </output>
    <config>
      <Kp>-5.0</Kp>        <!-- proportional gain -->
      <beta>1.0</beta>     <!-- input value weighing factor -->
      <alpha>0.1</alpha>   <!-- low pass filter weighing factor -->
      <gamma>0.0</gamma>   <!-- input value weighing factor for -->
                           <!-- unfiltered derivative error -->
      <Ti>10.0</Ti>        <!-- integrator time -->
      <Td>0.00001</Td>     <!-- derivator time -->
      <u_min>-30.0</u_min> <!-- minimum output clamp -->
      <u_max>30.0</u_max>  <!-- maximum output clamp -->
    </config>
  </pid-controller>

  <!-- Stage #2 drives the ailerons to achieve the desired roll deg. -->
  <pid-controller>
    <name>Heading Bug Hold (DG based) Stage 2</name>
    <debug>false</debug>
    <enable>
      <prop>/autopilot/locks/heading</prop>
      <value>dg-heading-hold</value>
    </enable>
    <input>
      <prop>/orientation/roll-deg</prop>
    </input>
    <reference>
      <prop>/autopilot/internal/target-roll-deg</prop>
    </reference>
    <output>
      <prop>/controls/flight/aileron</prop>
    </output>
    <config>
      <Kp>0.1</Kp>        <!-- proportional gain -->
      <beta>1.0</beta>    <!-- input value weighing factor -->
      <alpha>0.1</alpha>  <!-- low pass filter weighing factor -->
      <gamma>0.0</gamma>  <!-- input value weighing factor for -->
                          <!-- unfiltered derivative error -->
      <Ti>10.0</Ti>       <!-- integrator time -->
      <Td>0.00001</Td>    <!-- derivator time -->
      <u_min>-1.0</u_min> <!-- minimum output clamp -->
      <u_max>1.0</u_max>  <!-- maximum output clamp -->
    </config>
  </pid-controller>

You could change the second reference line to:
<prop>/autopilot/internal/target-limited-roll-deg</prop>
then make a simple nasal file that takes the delta time (using
/sim/time/elapsed-sec) and rate-limits the autopilot command like so (I
can't test this, as my FlightGear doesn't work)

var ratelimit = 10;        # degrees per second
var dtime = 0;
var time = 0;
var chg = 0;
limitroll = func {
        settimer(limitroll, 0);
        dtime = getprop("/sim/time/elapsed-sec") - time;
        time += dtime;
        chg = getprop("/autopilot/internal/target-roll-deg") -
getprop("/autopilot/internal/target-limited-roll-deg");
        if (chg > ratelimit * dtime) chg = ratelimit * dtime;
        if (chg < -ratelimit * dtime) chg = -ratelimit * dtime;
        setprop("/autopilot/internal/target-limited-roll-deg",
getprop("/autopilot/internal/target-limited-roll-deg") + chg);
}
settimer(limitroll, 0);

This method should work (in theory,) although (as I said before,) my
FlightGear is not currently working, so I can't test this. It may need to be
modified.

> The issue is from my point of view is that I can turn into a new
> heading, violently as a pilot and it will take time to react. The
> autopilot heading bug does not.. it turn there immedeadetly almost..

The autopilot should simply drive the ailerons/elevator/trim/thrust just as
a pilot would. The limits are the same, although the maximum rate of roll
does seem high. I believe this is because it is sudden and holds the
ailerons in their maximum position. Limiting the roll rate like above or
limiting the aileron throw (the u_min and u_max "tags") should fix the
problem.

> Precisely the the problem. I think we need to document it as well..

I know there's a document available, at
http://www.flightgear.org/Docs/XMLAutopilot/. That has information about the
autopilot's algorithm and tuning. However, the most can be learned by
combining it and reading through an existing autopilot configuration.

I hope this helps.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to