Howto:Implement pushback: Difference between revisions

New pushback implementation with cruise control
(Systems/pushback.xml: simpler and declared required property)
(New pushback implementation with cruise control)
Line 9: Line 9:
  <?xml version='1.0' encoding='UTF-8' ?>
  <?xml version='1.0' encoding='UTF-8' ?>
  <system name="pushback">
  <system name="pushback">
   <property>/sim/model/pushback/magnitude</property>
   <property>/sim/model/pushback/target-speed-fps</property>
  <property>/sim/model/pushback/kp</property>
  <property>/sim/model/pushback/ki</property>
  <property>/sim/model/pushback/kd</property>
   <channel name="Pushback">
   <channel name="Pushback">
     <switch name="systems/pushback/force">
       <default value="0"/>
     <switch name="systems/pushback/linked">
       <test value="/sim/model/pushback/magnitude">
       <default value="-1"/>
       <test value="0">
         /sim/model/pushback/position-norm gt 0.95
         /sim/model/pushback/position-norm gt 0.95
         /gear/gear/wow == 1
         /gear/gear/wow == 1
         gear/unit[0]/wheel-speed-fps lt 500
         gear/unit[0]/wheel-speed-fps lt 50
      </test>
    </switch>
    <summer name="systems/pushback/speed-error">
      <input>/sim/model/pushback/target-speed-fps</input>
      <input>-gear/unit[0]/wheel-speed-fps</input>
    </summer>
    <pid name="systems/pushback/force">
      <input>systems/pushback/speed-error</input>
      <kp>/sim/model/pushback/kp</kp>
      <ki>/sim/model/pushback/ki</ki>
      <kd>/sim/model/pushback/kd</kd>
      <trigger>systems/pushback/linked</trigger>
    </pid>
    <switch name="systems/pushback/output">
      <default value="0"/>
      <test value="systems/pushback/force">
        systems/pushback/linked == 0
       </test>
       </test>
       <output>external_reactions/pushback/magnitude</output>
       <output>external_reactions/pushback/magnitude</output>
     </switch>
     </switch>
   </channel>
   </channel>
  </system>
  </system>
This is the "cruise control" for the pushback truck. You define the cruise speed at the dialog and the controller varies the external force in a way that the actual speed matches your given value. The working horses here are the summer, which compares actual and reference speed, and the PID controller which calculates the resulting force. A basic description is: "the more actual and reference speed differ, the more force is applied (kp) plus the more time passes until the reference speed is reached, the more force is applied (ki)". The switches check, if the pushback truck is actually linked to the aircraft.


===.xml (FDM)===
===.xml (FDM)===
Line 48: Line 75:


===-set.xml===
===-set.xml===
Between the <model> tags in the -set.xml file we set three properties to false (0). Note: if the model tags are already there, you do no need to add them again. Just place the stuff between them. If you want the truck to be connected on startup, set linked and position-norm to 1. Note: if the model tags are already there, you do no need to add them again. Just place the stuff between them.
Between the <model> tags in the -set.xml file add the definitions for the speed-hold controller:
 
  <model>
  <model>
   <pushback>
   <pushback>
   <magnitude>0</magnitude>
   <kp type="double">100</kp>
   <linked>0</linked>
  <ki type="double">25</ki>
   <position-norm>0</position-norm>
   <kd type="double">0</kd>
   <position-norm type="double">0</position-norm>
   </pushback>
   </pushback>
  </model>
  </model>
The values for kp, ki and kd control how the cruise control reacts and may be adjusted depending on the mass of the aircraft. The pushback dialog allows changing of these properties at runtime.
Note: if the model tags are already there, you do no need to add them again. Just place the stuff between them. If you want the truck to be connected on startup, position-norm to 1.


Below the </sim> tag, we add our [[Menubar|menu]] dialog. A generic one is available at <tt>$FG_ROOT/gui/Dialogs/pushback.xml</tt>. Add the following lines to include it in the Equipment menu of the aircraft. Note: if the menubar and default tags are already there, you do no need to add them again. Just place the stuff between them.
Below the </sim> tag, we add our [[Menubar|menu]] dialog. A generic one is available at <tt>$FG_ROOT/gui/Dialogs/pushback.xml</tt>. Add the following lines to include it in the Equipment menu of the aircraft. Note: if the menubar and default tags are already there, you do no need to add them again. Just place the stuff between them.