# Guidance, Navigation and Control Introduction

This article and video covers the very basics of Guidance, Navigation and Control as it applies to aerospace applications. You will learn to build a simple missile airstrike simulation using Matlab and Simulink. Optionally, you can also visualize everything using FlightGear.

The simulation will involve a missile flying at a constant speed originally at a specified latitude, longitude and altitude flying towards a stationary target at a specified latitude, longitude and altitude (MSL). The missile will be controlled from its pitch rate. I just selected random coordinates from Google Earth. The field of GN&C consists of three subdisciplines.

1. Guidance: Where do you want your object to go?

2. Navigation: How is the object's position measured?

3. Control: How are you controlling the object (is it via speed, attitude etc.) - this implies that Control Theory is needed

There are many types of control algorithms used, most commonly the Proportional-Integral-Derivative (PID) control. For this simulation, an LQG (Linear Quadratic Gaussian) controller will be used. This is essentially a Linear Quadratic Regulator (LQR) controller combined with a Kalman Filter for state estimation. In real world applications, there is noise present in a sensor measurement, and the Kalman Filter provides an accurate estimation. The following diagram is an overview of the entire design. Note that you can use any programming language. It is just easiest to do in Simulink due to its Model Based Design methodology. The reference for the LQG controller is here (John's Hopkins University Applied Physics Laboratory) The above diagram can be broken down as follows:

1. The desired pitch angle is converted into the desired pitch rate via PID controller.

2. The missile outputs the estimated pitch angle, along with angle of attack and flight path angle

3. From the flight path angle and speed, the position is determined and converted to latitude and longitude using the Flat Earth to LLA block from the Aerospace Toolbox.

4. This current position along with the obstacle and target location is passed to the Guidance Command method which calculates the desired flight path angle to avoid the obstacle and accurately hit the target.

5. This desired flight path angle is converted into the desired pitch angle from the angle of attack, and then passed into the PID controller, the loop repeats.

6. The simulation terminates when the altitude of the missile equals the target altitude.

In the video I walk you step by step how to create the GN&C system in both Matlab and Simulink along with testing it. You will learn useful Matlab commands such as LQG, Kalman, LQR. You will create the open loop system, design the LQR controller, and then check that the closed loop system is stable and has good performance.

You will first have to run the model.m file before running the simulink_model.slx file to run the simulation. Lastly, if you already have connected Matlab to FlightGear (if you have not, see the Matlab tutorials here), then the runfg.bat file can be used to visualize everything in FlightGear. Creating the Missile airframe dynamic state space system along with the Kalman Filter is arguably the most complex part of the code, since noise has to be artifically added and variables need to be converted properly. This complete subsystem is presented below: At the top left, the variables are extracted from the Matlab workspace from the script file. Going from left to right, the desired pitch rate is converted into the fin deflection actuator input by: u = r-Kx. This is the standard state feedback formula. The middle contains the state space and the Kalman filter, and the outputs are on the right. In order from (1) to (6) the outputs are: Angle of attack, pitch rate, acceleration in Z, estimated pitch rate, actual pitch angle, and estimated pitch angle. Please follow along the video to implement this yourself. You will have a working GN&C dynamic simulation at the end!

That's it for now! Thank you for reading

Vinayak