Howto:Design an autopilot: Difference between revisions

Jump to navigation Jump to search
m
Robot: Cosmetic changes
m (+ subforum)
m (Robot: Cosmetic changes)
Line 5: Line 5:
For a technical reference of the used elements, check [[Autopilot Configuration Reference]].
For a technical reference of the used elements, check [[Autopilot Configuration Reference]].


==Pre-design==
== Pre-design ==
Why not make things slightly easier, before we start working on the autopilot? Since we will be updating the autopilot hunderts of times, making tiny adjustments each time, we don't want to reload FlightGear every time. Therefore, we assign an "reload autopilot configuration" action to a key on our keyboard. We've chosen Shift-F5, but it could be any key. Add the code to your <tt>[[$FG_ROOT]]/keyboard.xml</tt> file.
Why not make things slightly easier, before we start working on the autopilot? Since we will be updating the autopilot hunderts of times, making tiny adjustments each time, we don't want to reload FlightGear every time. Therefore, we assign an "reload autopilot configuration" action to a key on our keyboard. We've chosen Shift-F5, but it could be any key. Add the code to your <tt>[[$FG ROOT]]/keyboard.xml</tt> file.
  <key n="261">
  <key n="261">
   <name>F5</name>
   <name>F5</name>
Line 22: Line 22:
  </key>
  </key>


==Creating the autopilot configuration file==
== Creating the autopilot configuration file ==
Create an autopilot.xml file with the following content, somewhere inside your aircraft's root (eg. <tt>Aircraft/747-400/Systems/autopilot.xml</tt>).
Create an autopilot.xml file with the following content, somewhere inside your aircraft's root (eg. <tt>Aircraft/747-400/Systems/autopilot.xml</tt>).
  <?xml version="1.0"?>
  <?xml version="1.0"?>
Line 30: Line 30:
  </PropertyList>
  </PropertyList>


==A first controller: wing leveler==
== A first controller: wing leveler ==
Let's start with a simple wing leveler that keeps your bank angle at zero (or any arbitrary value later). This could be a PID controller with the input from your current roll and a reference of zero. Output should go to your aileron-cmd. Start with:
Let's start with a simple wing leveler that keeps your bank angle at zero (or any arbitrary value later). This could be a PID controller with the input from your current roll and a reference of zero. Output should go to your aileron-cmd. Start with:
* '''Kp:'''  0.00
* '''Kp:'''  0.00
Line 110: Line 110:
This is the base for any lateral hold mode, so try to spend some time on it. It can take some hours if this is your first autopilot.
This is the base for any lateral hold mode, so try to spend some time on it. It can take some hours if this is your first autopilot.


==Pitch hold==
== Pitch hold ==
So, let's move over to a pitch hold. Our goal is to have a controller that maintains an arbitrary pich. The only difference to the wing leveler is that you are only interested in elevator position changes, not absolute values. To put it in other words: increase elevator for more pitch, decrease for less pitch and maintain elevator position if the pitch is right. This calls for a pid-controller, because it only computes offset values. And you will end up with a relative small value for Kp to avoid rapid imediate movements and a relative small value for Ti to have a greater effect over time.
So, let's move over to a pitch hold. Our goal is to have a controller that maintains an arbitrary pich. The only difference to the wing leveler is that you are only interested in elevator position changes, not absolute values. To put it in other words: increase elevator for more pitch, decrease for less pitch and maintain elevator position if the pitch is right. This calls for a pid-controller, because it only computes offset values. And you will end up with a relative small value for Kp to avoid rapid imediate movements and a relative small value for Ti to have a greater effect over time.


Line 117: Line 117:
Again increase you Kp slowly and check each step in FlightGear. I'd expect something like -0.025 resulting in an instanteanous full elevator deflection on a 40 degrees pitch offset. Do not try too large values; it results in instable behaviour very quickly. Now, decrease the value of Ti, probably down to 10 or so. The smaller it gets, the faster the elevator moves and the easier it is to get an unstable loop. Again it is very likely that you won't need Td to get a stable controller.
Again increase you Kp slowly and check each step in FlightGear. I'd expect something like -0.025 resulting in an instanteanous full elevator deflection on a 40 degrees pitch offset. Do not try too large values; it results in instable behaviour very quickly. Now, decrease the value of Ti, probably down to 10 or so. The smaller it gets, the faster the elevator moves and the easier it is to get an unstable loop. Again it is very likely that you won't need Td to get a stable controller.


==Simulating servos==
== Simulating servos ==
Once you have this two axies running, you might want to think about simulating the slow movements of the servo or hydraulic motors that drive the control surfaces. You might have noticed, that the controls react rapidly when enabled which is unrealistic. In a [[Seneca]], the aileron servo takes 12 seconds to move from left to right. The elevator needs 26 seconds and the pitch trim takes 45 seconds for full travel.
Once you have this two axies running, you might want to think about simulating the slow movements of the servo or hydraulic motors that drive the control surfaces. You might have noticed, that the controls react rapidly when enabled which is unrealistic. In a [[Seneca]], the aileron servo takes 12 seconds to move from left to right. The elevator needs 26 seconds and the pitch trim takes 45 seconds for full travel.


Line 142: Line 142:
Spend some time optimizing these pitch and roll channels, they will be used by all other modes and '''have''' to be stable in any case!
Spend some time optimizing these pitch and roll channels, they will be used by all other modes and '''have''' to be stable in any case!


==A simple auto throttle==
== A simple auto throttle ==
  <pid-controller>
  <pid-controller>
   <name>Auto throttle</name>
   <name>Auto throttle</name>
Line 189: Line 189:
  </filter>
  </filter>


==Vertical speed hold==
== Vertical speed hold ==
Let's start with some thinking. For vertical-speed-hold, the controller has to compare your current rate-of-climb with your reference rate-of-climb. The ROC will be controlled by setting the pitch of the aircraft. We already have a pitch-hold controller, so we will set the target-pitch from our rate-of-climb controller. To not make our passengers barf when we enable our controller, it's important to set the target-pitch relative to our current pitch - which once again calls for a pid-controller (because of it's relative output).  
Let's start with some thinking. For vertical-speed-hold, the controller has to compare your current rate-of-climb with your reference rate-of-climb. The ROC will be controlled by setting the pitch of the aircraft. We already have a pitch-hold controller, so we will set the target-pitch from our rate-of-climb controller. To not make our passengers barf when we enable our controller, it's important to set the target-pitch relative to our current pitch - which once again calls for a pid-controller (because of it's relative output).  


Line 238: Line 238:
  </pid-controller>
  </pid-controller>


==Logic-controlled properties==
== Logic-controlled properties ==
These two new elements should give you a rate-of-climb hold mode for your autopilot. If you are not yet confused which controllers should be enabled in what mode, you will be very soon as we will add even more elements. If you are in the need for some logic-controlled properties, the autopilot can do this, too - no need for [[nasal]] helpers! There is a <logic> element that does all the magic:
These two new elements should give you a rate-of-climb hold mode for your autopilot. If you are not yet confused which controllers should be enabled in what mode, you will be very soon as we will add even more elements. If you are in the need for some logic-controlled properties, the autopilot can do this, too - no need for [[nasal]] helpers! There is a <logic> element that does all the magic:


Line 255: Line 255:
This creates two boolean properties: has-power and serviceable, and sets them to true if the electrical system provides more than 10.0 volts. You can build complex logic tables to drive your analog stages of the autopilot.
This creates two boolean properties: has-power and serviceable, and sets them to true if the electrical system provides more than 10.0 volts. You can build complex logic tables to drive your analog stages of the autopilot.


==Altitude hold==
== Altitude hold ==
Now, that you have a ROC-hold mode, you most certainly want an altitude-hold with preselect. This will be a simple linear amplifier without any time dependencies. Again, you have to compare your current altitude with a reference value, but this time there will be no integrator involved. The bigger your offset from the reference altitude is, the bigger your rate of climb/descent should be. Let's assume, 1000ft offset should result in 500fpm ROC. The maximum rate of descent should be 1000fpm and the maximum rate of climb should be 2000fpm. Since there is no integrator involved, we use a simple gain filter to compute the rate of climb:
Now, that you have a ROC-hold mode, you most certainly want an altitude-hold with preselect. This will be a simple linear amplifier without any time dependencies. Again, you have to compare your current altitude with a reference value, but this time there will be no integrator involved. The bigger your offset from the reference altitude is, the bigger your rate of climb/descent should be. Let's assume, 1000ft offset should result in 500fpm ROC. The maximum rate of descent should be 1000fpm and the maximum rate of climb should be 2000fpm. Since there is no integrator involved, we use a simple gain filter to compute the rate of climb:


Line 282: Line 282:
This is nearly all for altitude-hold with altitude-preselect. You can add an altitude-sample-and-hold stage to add a "hold my current altitude" function.
This is nearly all for altitude-hold with altitude-preselect. You can add an altitude-sample-and-hold stage to add a "hold my current altitude" function.


==Heading hold==
== Heading hold ==
For heading hold, you build a two stage system. The first is a comparator comparing your selected heading and the indicated heading. 1. Stage, compute heading offset. Note the period element at the bottom, it normalizes the output into the periodic -180 to +180 range
For heading hold, you build a two stage system. The first is a comparator comparing your selected heading and the indicated heading. 1. Stage, compute heading offset. Note the period element at the bottom, it normalizes the output into the periodic -180 to +180 range


Line 344: Line 344:
Decreasing the gain of 2.5 should help, if your roll-rate is too slow.  
Decreasing the gain of 2.5 should help, if your roll-rate is too slow.  


==NAV modes==
== NAV modes ==
In lateral nav mode, the primary goal of the autopilot is to intercept and maintain a certain ground track. This could be a VOR radial, a LOC course or back course or a GPS track. For most autopilots these are basically the same and it does not know anything about the source of the signal. Everything it knows is your current heading, your desired course and a course offset. And these are the properties, we need for our NAV hold mode.
In lateral nav mode, the primary goal of the autopilot is to intercept and maintain a certain ground track. This could be a VOR radial, a LOC course or back course or a GPS track. For most autopilots these are basically the same and it does not know anything about the source of the signal. Everything it knows is your current heading, your desired course and a course offset. And these are the properties, we need for our NAV hold mode.


Line 446: Line 446:
# heading offset computer
# heading offset computer


==Related content==
== Related content ==
{{Forum|46|Autopilot}}
{{Forum|46|Autopilot}}
* [[Autopilot Configuration Reference]]
* [[Autopilot Configuration Reference]]

Navigation menu