Flight Controller

Programming for Mechatronic Systems

Summary

  • The red arrow represents my aircraft
  • The green arrows represent the bogies
  • The blue arrows represent the calculated point of interception between my aircraft and the bogies

Basic functionality: Intercept stationary bogies ✅
Advanced functionality: Intercept moving bogies with unknown velocities ✅
Bonus Marks: Top 3 students in the subject with the most bogies intercepted ✅

Project Overview

In this assignment from the subject Programming for Mechatronic Systems, we were tasked with intercepting the maximum amount of 'bogies' within a 3 minute time frame. To be awarded marks for basic functionality, our program had to intercept the bogies when they were randomly generated within the flight area but were held stationary. Advanced functionality was awarded for intercepting the bogies when they were moving at different, unknown velocities. Bonus marks were awarded for the top 3 students in the subject whose implementation intercepted the most bogies in a fair testing environment.

We were only able to control the linear and angular velocity of our 'aircraft' and these were zero-sum in that, to achieve maximal linear or angular velocity we would have to sacrifice the other. To locate the bogies we were limited to the bearing and range of each bogy relative to our aircraft and the location of our aircraft relative to a static base station which was centered in the middle of the flight area.

First, I broke the assignment down into parts. Using the available variables I designed a flight controller that allowed my aircraft to spend as much time as possible at maximum linear velocity by turning as fast as possible until the bearing of the friendly aircraft was within 15 degrees of the bogy. To pursue a bogy, the flight controller simply attempted to minimise the bearing between the aircraft and the bogy.

Secondly, I used the measurements provided to me to determine the absolute location of the bogies and my aircraft. Following this, I created a function which calculated the time to intercept each bogy which factored in both the distance and time required to make the turn to a certain position in the flight space.

Thirdly, I used a struct to encapsulate all of the relevant data about bogies into a single variable and pushed them into a vector. I then sorted the vector to order the bogies in terms of minimum time of interception. Using multithreading, this would be continually calculated multiple times per second.

With all of this complete, my program already achieved both basic and advanced functionality without any changes required in configuration, however, I wanted to improve on my system. As the bogies flew on straight paths and at constant, although unknown, velocity, my idea was to store the previous bogie positions and time intervals to calculate the future position of the bogie. This would allow my flight controller to predict the interception point and straighten the flight path of my aircraft to minimise interception time. Ultimately, this proved far more difficult than I realised and I spent many days squashing bugs before I was finally able to get it working.

Results

Ultimately, the extra effort of extrapolating the optimised interception point paid off and I was awarded bonus marks for being among the top 3 students in the subject with the most bogies intercepted. Unfortunately, we weren't told where we ranked among these students.

Potential Improvements

To further improve my design I could have implemented a graph search to decide the shortest route to pursue all bogies within the frame.

What I Learnt

This project taught me many things and added fuel to my interest in software engineering and computer science. I gained a foundational understanding of C++, data structures and algorithms (DSA), object oriented program (OOP), multithreading, and the importance of robust testing.

Core Technologies and Skills

C++
Object Oriented Programming (OOP)
Data Structures and Algorithms (DSA)
Multithreading
G Testing
Ubuntu

or