Engineering Flight Simulator

Department of Automatic Control
and Systems Engineering

Home
Department
University
FAQS
Contact Us
Book
Introduction
Videos
Gallery
Systems
Research
Students
Teaching
Links
Publications

Teaching

The flight simulator is used to support undergraduate teaching and for undergraduate and postgraduate projects. The modular structure of the simulator enables students to develop software without needing detailed knowledge of the simulator and without interfering with baseline modules.

In addition to writing code modules in C, students are able to access primary flight variables and to set control inputs for autopilot functions in Matlab using an interface developed for the simulator. In the 2nd year control systems design laboratory, students are provided with a linearised Matlab model of the Boeing 747 aircraft to enable them to design a simple controller, for example, an altitude-hold system. When this controller is working, they are able to test their Matlab software with the flight simulator operating in real-time and record flight data from the simulator.

In the final year, undergraduates undertake a project which represents half of their final year assessment. Similarly, postgraduate students spend the period from May to the start of September on an individual project, which represents one third of the final assessment.

Titles of projects using the flight simulator in recent years include:

  • Terrain Avoidance for Military Aircraft
  • Compression Methods for Terrain Reference Navigation
  • PC Based Flight Management System
  • Development of a Simulink Model for a Large Transport Aircraft
  • Parameter Identification of an Aircraft Model
  • Derivation of Aircraft Models from Particle Based Flow Modelling
  • Modelling and Simulation of the Lynx Helicopter
  • Development of a Sea-state Model for the Flight Simulator
  • Runway Edge Detection in a Radar Image
  • Model of the UH-1H Helicopter

Writing Real-Time Matlab Scripts for the Flight Simulator

A real-time Matlab script for a flight control law for the flight simulator must be updated at 50 Hz to match the simulator update rate. A template script is shown below to access the simulation variables and to pass the control inputs back to the flight simulator. The script starts by opening an Ethernet UDP socket and then enters the real-time loop where it calls 'UDP_Recv' to read the incoming UDP packet containing the simulator variables. The function 'UDP_Data_Get' is used to access the individual variables in the packet. The control law can then be computed for a single frame, in this example to compute the elevator position. The computed variables are transmitted in a UDP packet to the flight simulator by the function call 'UDP_Send'.

 

 

%{
Matlab Flight Simulator Autopilot Altitude Hold Exercise.
Note the autothrottle speed-hold should be activated.
%}

ONERAD = 180.0/pi;
Href = -3000.0 * 0.3048; % ft -> m
de = 0.0;
demin = -0.4;
demax = 0.4;
done = 0;

% load the UDP interface
if (libisloaded('mlab_udp.dll') == 0)
  loadlibrary('mlab_udp.dll','mlab_udp.h');
end

% libstruct C structure objects. Requires DLL to be loaded
rx_obj = libstruct('MATLAB_UDP_RX_MSG');
tx_obj = libstruct('MATLAB_UDP_TX_MSG');

% libpointer objects for referencing libstruct objects
rx_obj_p = libpointer('MATLAB_UDP_RX_MSG', rx_obj);
tx_obj_p = libpointer('MATLAB_UDP_TX_MSG', tx_obj);

% Initialise libstruct objects
initobjects

% Start UDP communication library
calllib('mlab_udp','UDP_Start',12345);
if (ans ~= 1)
  disp('!!! UDP_Start failed !!!');
end

%
% Main Loop
%
while done==0

  % Wait-for flight simulator packets to arrive.
  calllib('mlab_udp','UDP_Recv');
  if (ans ~= 1)
    disp('!!! UDP_Recv error !!!');
  end

  % Extract data into a Matlab libstruct object
  calllib('mlab_udp','UDP_Data_Get',rx_obj_p);

  % Access/compute altitude hold using simulation variables
  U = rx_obj.U;
  Udot = rx_obj.Udot;
  H = rx_obj.Altitude;
  pitch = rx_obj.Pitch;
  alpha = rx_obj.Alpha;
  q = rx_obj.Q;
  Vd = rx_obj.Vd;
  done = ~rx_obj.Active;

  %
  % STUDENT CODE TO COMPUTE ELEVATOR VARIABLE de STARTS HERE
  %

  %
  % END OF STUDENT CODE
  %

  % Fill in the return data structure fields
  tx_obj.Elevator = de;

  % Transmit data back to flight simulator
  calllib('mlab_udp','UDP_Data_Set',tx_obj_p);
  calllib('mlab_udp','UDP_Send');
  if (ans ~= 1)
    disp('!!! UDP_Send error !!!');
  end

end

% Stop the simulation
calllib('mlab_udp','UDP_Stop');

% Clean up the libstruct and libpointer objects and the library
clear rx_obj
clear tx_obj
clear rx_obj_p
clear tx_obj_p
unloadlibrary mlab_udp