Software Downloads   Home  >   About  >   Technology Transfer  >   Software and Downloads  >   Small Fixed-Wing UAS

SUAS Code: Small Fixed-Wing UAS State Estimation Examples

SUAS Code image

SUAS Code is a set of heavily commented MATLAB® routines that provide example methods for performing state estimation (i.e., position and orientation) of a fixed-wing unmanned aircraft system (UAS) using GPS, gyros, accelerometers, and a magnetometer as sensors. The code is meant as a companion to the Johns Hopkins APL Technical Digest article “Fundamentals of Small Unmanned Aircraft Flight,” by Jeff Barton. UASs are also referred to as unmanned aerial vehicles (UAVs) or drones.

Five state estimation methods are provided, based on algorithms presented in the Johns Hopkins APL Technical Digest article. The user can choose which method to use:

  • Extended Kalman filter (EKF)-based attitude and heading reference system (AHRS) using Euler angles and a two-dimensional magnetometer
  • EKF-based AHRS using quaternions and a three-dimensional magnetometer
  • Feedback AHRS using Euler angles and a two-dimensional magnetometer
  • EKF-based inertial navigation system (INS) using Euler angles and a two-dimensional magnetometer
  • EKF-based INS using quaternions and a three-dimensional magnetometer


Simply run the script uav_state_estimation.m from MATLAB®. The routine will query you for which method you wish to use. No additional toolboxes are required to run the routines, although the code shows how the Symbolic Toolbox can be used to derive necessary EKF matrices.

Running the script contents.m will display and describe all the files contained in SUAS Code.

The stand-alone MATLAB® script rotation_examples.m is also provided, which describes the transformations between the various rotation methods used within SUAS Code: Euler angles, direction cosine matrices (DCMs), and quaternions.

The EKF methods in SUAS Code use the included function file perform_ekf.m, which is a generic discrete-time EKF implementation. However, because nonlinear dynamic models are often more intuitively represented in continuous time, perform_ekf.m makes use of a continuous-time state dynamics model. Thus, a user may find that perform_ekf.m is useful for other research and educational applications beyond SUAS Code.


SUAS Code is available for download.

Please fill out the required information on the form below to receive a download link. Your submission of this form will serve as the acceptance of the End User License Agreement (EULA). It is intended that this code be freely available for academic, personal education, and research purposes. Any other uses, especially for commercial purposes, should be discussed with the APL Office of Technology Transfer. We also ask that you follow this process to receive the code rather than sharing copies so that we can keep track of usage.

Please note that SUAS Code is provided as-is, with no warranty and no guarantees of technical support or maintenance, etc. However, please feel free to contact the author via e-mail ( if you experience any problems using the code, find any bugs, or have suggestions for future improvement. SUAS Code usage has been verified in MATLAB® versions R2009b and R2011a on a Windows-based machine.


Please use the SUAS Code website on the MatLab Central Link Exchange to post any comments or ratings.

Example Output of SUAS Code

Upon running uav_state_estimation.m from MATLAB®, you will be queried to select one of several provided simulation-generated UAV “truth” data files, as well as which state estimation method you wish to use:


As a result, the routine will provide MATLAB® structures containing the UAV truth data, the synthetically derived UAV sensor data, and the resulting state estimation data. In addition, the routine will generate a figure representing the state estimation output:




OTT: Heather Curran, 240-228-7262