Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Howto:Implement pushback"

From FlightGear wiki
Jump to: navigation, search
(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.

Revision as of 06:48, 6 May 2009

A KLM Boeing 747-400 ready for pushback at EHAM. This is the Goldhofert truck.

Currently, pushback is only used on JSBSim planes. It should be possible with YASim aswell, but it has never be done yet.

Please note: this system does not work over a multiplay network.

Systems/pushback.xml

Create the following directory, if not present $FG_ROOT/Aircraft/.../Systems and create a file named pushback.xml with the following content:

<?xml version='1.0' encoding='UTF-8' ?>
<system name="pushback">
 <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">

   <switch name="systems/pushback/linked">
     <default value="-1"/>
     <test value="0">
       /sim/model/pushback/position-norm gt 0.95
       /gear/gear/wow == 1
       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>
     <output>external_reactions/pushback/magnitude</output>
   </switch>

 </channel>
</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)

After the </propulsion> tag we add a reference to the pushback system:

 <system file="pushback"/>

And at the end of the FDM, the following is needed to attach the forces of the pushback to the aircraft. The location should be somewhere near the nose wheel of the aircraft (where the pushback truck is connected).

<external_reactions>

 <force name="pushback" frame="BODY">
  <location unit="IN">
   <x>  -139 </x>
   <y>    0.0 </y>
   <z>  -71.0 </z>
  </location>
  <direction>
   <x>1</x>
   <y>0</y>
   <z>0</z>
  </direction>
 </force>

</external_reactions>

-set.xml

Between the <model> tags in the -set.xml file add the definitions for the speed-hold controller:

<model>
 <pushback>
  <kp type="double">100</kp>
  <ki type="double">25</ki>
  <kd type="double">0</kd>
  <position-norm type="double">0</position-norm>
 </pushback>
</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 menu dialog. A generic one is available at $FG_ROOT/gui/Dialogs/pushback.xml. 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.

<menubar>
 <default>
    
  <menu n="5">
   <item n="10">
    <label>Pushback</label>
    <name>pushback</name>
    <binding>
     <command>dialog-show</command>
     <dialog-name>pushback</dialog-name>
    </binding>
   </item>
  </menu>

 </default>
</menubar>

Models/ .xml

In your planes model file, we add a reference to one of the generic pushback models, or a custom made truck, shipped with your plane. Edit the offsets to fit your plane; the z offset should be at ground level, while the x offset is at the nosewheel(center).

<model>
 <name>Pushback</name>
 <path>Models\Airport\Pushback\Goldhofert.xml</path>
 <offsets>
  <x-m>-25.0</x-m>
  <y-m>0</y-m>
  <z-m>-4.0</z-m>
 </offsets>
</model>