User:Awexome/GACM

From FlightGear wiki
Jump to navigation Jump to search

Generic Autopilot Command Module

Generic Autopilot Command Module. Generic: because it is intended to be aircraft independent, freeing the user and developer from the administrative and bug-prone effort of porting code from one aircraft to another. As hinted, this rather small project was motivated by the need for the flexibility to test code and autopilot functions developed in one aircraft, but intended for use and sharing across other aircraft. Thus, the design strategy was to develop a very minimalist system, leaving most, if not all of the autopilot-mode activation to the particular aircraft. Generally, aircraft and their designs feature varying autopilot interfaces and command structures. However, most autopilot systems feature generic functions such as lateral heading navigation, fms based navigation, altitude and speed setting, etc.

This Generic Autopilot Command Module allows the developer to simply issue flight commands which are processed by particular aircraft modules. In doing so, 'Giorj' must transparently 'select' and load the AP Kommand Module for a particular aircraft, as illustrated in the code below.

   !fgLastKmd.getValue()
   and fgLastKmd.setIntValue(ACKmd[0]);
  # prev. version - ver. 0.75
  #
  if(fgKmdIfaceOK) {
    setprop("fgKmdIface/params",ACKmd);
    return 1;
  }

In the earlier design and version of this system (see, code above), 'Giorj' sends the pilot's command to the particular aircraft module loaded. The particular module was responsible for processing the sent command, and sending the processed data to the fgcommand processor within its own code space. For example, when loaded, the module commanding a 777-200ER 'listened' for commands on its interface node.

Source code

Although this version worked, the code duplication for each aircraft type module and the related challenges in maintaining replicated code across all aircraft using this system was seen to be an unnecessary burden for developers and users. This led to a restructuring of the command processing by the individual aircraft modules and the centralization of such processing. The current version of this Generic Autopilot Command Module simplifies the administration of modules and centralizes the processing of autopilot command. 'Giorj' is back in charge! :)

In the updated system, 'Giorj' transparently loads the module for a particular aircraft and processes the pilot command using the particular aircraft autopilot syntax :) The code segment below illustrates the process.

Source code

One positive implication of this alternative design is that the individual aircraft modules become smaller; from not needing to process the pilot's commands directly. The modules become very lean, easy to distribute and to maintain by the particular aircraft developers or a centralized module developer. It also becomes much easier to update and upgrade 'Giorj', the key processing model of the Generic Autopilot Command Module. The code segments at the end of this presentation shows the key aspects of the modules for various aircraft. I welcome the participation of aircraft developers, flightdirector developers and maintainers in helping to validate the autopilot command syntax for the aircrafts referred to the code segments below, and to help in developing command modules for other featured in the FGFS gallery. Neat!.


To the Skies with Passion.