9.1 Introduction
Before the widespread availability of GPS, Loran, and other electronic navigation aids, pilots used visual cues from terrain to navigate. Now everyone uses GPS. We want to return to the good old days of terrain-based navigation. We will design a system that will be able to match terrain with a database. It will then use that information to determine where it is flying.
9.2 Modeling Our Aircraft
9.2.1 Problem
We want a three-dimensional aircraft model that can change direction.
9.2.2 Solution
Write the equations of motion for three-dimensional flight.
9.2.3 How It Works
The motion of a point mass through three-dimensional space has three degrees of freedom. Our aircraft model is therefore given three degrees of spatial freedom. The velocity vector is expressed as a wind-relative magnitude (V ) with directional components for heading (ψ) and flight path angle (γ). The position is a direct integral of the velocity and is expressed in y = North, x = East, h = Vertical coordinates. In addition, the engine thrust is modeled as a first-order system where the time constant can be changed to approximate the engine response times of different aircraft.
As you can see in Figure 9.3, the radius of the turn is 15 km as expected. The drag and lift remain constant. In practice, we would have a velocity and flight path angle control system to handle disturbances or parameter variations. For our deep learning example, we just use the ideal dynamics. Figure 9.4 shows the simulation outputs.
9.3 Generating Terrain
9.3.1 Problem
We want to create an artificial terrain model from a set of terrain “tiles.” A tile is a segment of terrain from a bigger picture, much like bathroom tiles make up a bathroom wall, unless, of course, you have the modern fiberglass shower.
9.3.2 Solution
Find images of terrain and tile them together. There are many sources of terrain tiles. Google Earth is one.
9.3.3 How It Works
9.4 Close-Up Terrain
9.4.1 Problem
We want higher-resolution terrain.
9.4.2 Solution
Specialize the terrain code to produce a small segment of higher-resolution terrain suitable for experiments with a commercial drone.
9.4.3 How It Works
Figure 9.7 shows the terrain. It is 2 degrees by 2 degrees.
9.5 Building the Camera Model
9.5.1 Problem
We want to build a camera model for our deep learning system. We want a model that emulates the function of a drone-mounted camera. Ultimately, we will use this camera model as part of a terrain-based navigation system, and we’ll apply deep learning techniques to do terrain navigation.
9.5.2 Solution
We will model a pinhole camera and create a high-altitude aircraft. A pinhole camera is a lowest-order approximation to a real optical system. We’ll then build the simulation and demonstrate the camera.
9.5.3 How It Works
We’ve already created an aircraft simulation in Recipe 9.2. The addition will be the terrain model and the camera model. A pinhole camera is shown in Figure 9.8. A pinhole camera has an infinite depth of field, and the images are rectilinear.
We want our camera to see 16 pixels by 16 pixels from the terrain image in Figure 9.7. We will assume a flight altitude of 10 km. Figure 9.9 gives the dimensions.
The code is shown as follows. We convert everything to pixels, get the image using [~,~,i] = getimage(h), and get the segment.
The terrain image from the camera is blurry because it has so few pixels.
9.6 Plotting the Trajectory
9.6.1 Problem
We want to plot our trajectory over an image.
9.6.2 Solution
Create a function to draw the image and plot the trajectory on top.
9.6.3 How It Works
9.7 Creating the Training Images
9.7.1 Problem
We want to create training images for our terrain model.
9.7.2 Solution
We build a script to read in the 64 by 64 bit image and create training images.
9.7.3 How It Works
9.8 Training and Testing
9.8.1 Problem
We want to create and test a convolutional neural network. The neural net will be trained to associate images with an x and y location.
9.8.2 Solution
We create and test a convolutional neural network in TerrainNeuralNet.m. This will be trained on the images created earlier and will be able to return the x and y coordinates. Convolutional neural networks are widely used for image identification.
9.8.3 How It Works
We have an image layer to read in each image. We next convolve them with filters. The weights of the filters are determined during the learning. We normalize the outputs and pass through the ReLU activation function. Pooling compresses the data. Padding sets the output size equal to the input size. As seen by the layers printout, no padding is needed since the images are all the same size. The first layer has eight 3 by 3 pixel filters. The second layer has 32 3 by 3 pixel filters. The final set of layers is used to classify the images. As noted in the previous section, each image has a unique “class” which is associated with its location. We use a constant learning rate. The batch size is smaller than the default.
We get 100% accuracy. You can explore changing the number of layers and trying different activation functions. Training takes a few minutes.
9.9 Simulation
9.9.1 Problem
We want to test our deep learning algorithm using our terrain model.
9.9.2 Solution
We build a simulation using the trained neural net.
9.9.3 How It Works
Figure 9.16 shows the trajectory and the camera view. We simulate one full circle.
The identified terrain segment and the path, based on the neural network location, are shown in Figure 9.17. The neural net classifies the terrain it is seeing. The location of each image is read out and used to plot the trajectory.
This chapter showed how a neural network can be used to identify terrain for aircraft navigation. We simplified things by flying at a constant altitude, using a pinhole camera model with fixed image orientation, and ignoring clouds and other complications. We used a convolutional neural network to train the neural net with good results. As noted, higher-resolution images and a Kalman filter would produce a smoother trajectory.