Board index FlightGear Development Aircraft Autopilot and route manager

xml elements - AP

Designing a stable autopilot is one of the hardest things. Need help?

xml elements - AP

Postby jaxsin » Thu Jan 28, 2016 1:03 pm

I am in the process of trying to learn how to build a functioning AP for the b1900d that is more updated, but I am running into issues.

I am confused by by the way the code is nested, sometimes I see this

Code: Select all
<reference>0</reference>


Code: Select all
<reference><value>0</value></reference>


Which is the correct way? Or how about the <prop> vs <property> element? Are they the same?

the difference between <u_min/u_max> and <min/max> and when to use?

My second questions go to some AP stuff in particular. I see in the generic-autopilot.xml most things are a 2 stage controller implementation, is this the preferred method these days?

as an example can someone explain to me the 2 stage controller below and why it was implemented as such.
Code: Select all
  <!-- 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 (DG based) Stage 1</name>
    <debug>false</debug>
    <enable>
      <prop>/autopilot/locks/heading</prop>
      <value>dg-heading-hold</value>
    </enable>
    <input>
      <prop>/autopilot/internal/heading-bug-error-deg</prop>
    </input>
    <reference>
      <value>0.0</value>
    </reference>
    <output>
      <prop>/autopilot/internal/target-roll-deg</prop>
    </output>
    <config>
      <Kp>-1.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>-20.0</u_min> <!-- minimum output clamp -->
      <u_max>20.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>


and with that being said, Why couldn't you just use a <pi-simple-controller> for step #1. From what I see the proportional gain is 1 and as such step 1 is nothing more then an integrator? What is this doing as an integrator before it is sent to stage #2? I'm so close to wrapping my head around this, just need someone to take 5 minutes and spell out the obvious when it comes to PID control. I get the theory, but maybe not the practical solution.

#3. Is the appropriate way to fly the AP making changes to the control surfaces like the aileron and elevator or should one be using the Aileron-trim Elevator-trim? In the original b1900d AP it uses the *-trim for aileron and elevator. I have read somewhere that an issue was fixed with the b1900d after switching aileron-trim to just aileron. Is there a general consensus now that when building an AP forget the control trim surfaces?
jaxsin
 
Posts: 396
Joined: Mon Dec 28, 2015 3:54 pm

Re: xml elements - AP

Postby Necolatis » Thu Jan 28, 2016 1:10 pm

Which is the correct way? Or how about the <prop> vs <property> element? Are they the same?

the difference between <u_min/u_max> and <min/max> and when to use?


Did you check these resources?:

http://wiki.flightgear.org/Howto:Design_an_autopilot
http://wiki.flightgear.org/Autopilot_co ... _reference
"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: xml elements - AP

Postby jaxsin » Thu Jan 28, 2016 1:45 pm

yes I did and this is where half of my confusion comes from. As stated in the above post, things are done differently? What is current, what does and does not work?

I've read so much now I need to weed out the old versus new information. No reason to waste my time doing things wrong. I do not have time to do things wrong. So this is why I asked.

I have read all the links provided in the sticky at the top of this subforum posted by Hooray and my questions still stand!!!
jaxsin
 
Posts: 396
Joined: Mon Dec 28, 2015 3:54 pm

Re: xml elements - AP

Postby Necolatis » Thu Jan 28, 2016 2:11 pm

> Which is the correct way?

Both is valid, use what you like best.

> Are they the same?

Yes, but <prop> is deprecated so avoid using that.

> <u_min/u_max> and <min/max>

Its not stated clearly, but I think:
u_xxx for PID filter (inside the <config>) and xxx for the other filters.

> 2 stage controller implementation

For some uses its a good solution. In your example the first determines how much the plane should bank to get to the desired heading. The second controls the ailerons to try and get the plane close to those degrees that was computed in the first stage.

A 2 stage implementation has the big advantage to reuse code. The second stage you listed above could be used as the final stage for several A/P settings: mag heading, true heading, nav1-hold and wing leveler. Its also useful if you want to do more computations than one PID filter can handle.
"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: xml elements - AP

Postby jaxsin » Thu Jan 28, 2016 6:29 pm

Right, OK. Good!

I think I am starting to figure just what is going on. It helps when you know what the 'target pitch' is, check elevator trim preset!!! :) Today has been a good day, thank you
jaxsin
 
Posts: 396
Joined: Mon Dec 28, 2015 3:54 pm


Return to Autopilot and route manager

Who is online

Users browsing this forum: No registered users and 1 guest