This log will be brief in demonstration, tightly packed with explanation, so fasten your seatbelts!
All updates are found in the changelog.
Auto manoeuvring
Let’s start with the demonstration first in order to figure out how it works:
Mission
Auto manoeuvring is demonstrated.
Briefing
Initial altitude 7.000ft, speed 600KTS. The Auto manoeuvre system is enabled. You are NOT flying the plane.
Flight
Note that the aircraft is almost in complete autonomous flight! Also notice the green paths showing up incidentally (actually just me clicking the generateFlightPath button) during flight and notice how the aircraft is trying to follow these paths.
Path generation
Phaser 3 is armed with some nice tools to implement path generation and these paths are actually Bezier Curves, which prove to be extremely useful, because we can generate any path we want with them.
By forcing the aircraft to follow this path, we can facilitate auto flight.
Utilizing autopilot
The previous log demonstrated the attempt of implementing AI using reinforcement learning, which was super interesting , but experimental. I am still convinced that this approach can provide results, but I had to proceed with an alternative and decided not to reside to this method for now, but instead further utilize the existing autopilot control system.
The autopilot control system currently implements an all purpose PID controller, so I put my focus on utilizing the PID.
The altitude controller keeps the aircraft steady at some height and controls the \(\boldsymbol{y}\) of the aircraft. If you rethink this in terms of Bezier curves, then the altitude controller forces the aircraft follow a horizontal line, which is Aa bezier curve with control points:
\[\boldsymbol{P_0 = (x_0, y_0), P_1 = (x_1, y_0), P_2 = (x_1, y_0),P_3= (x_3, y_0)}\]The altitude controller , controls the error:
\[\boldsymbol{e_{alt} = y_{reference} - y_{actual} }\]By adjusting to a controller that not only considers \(\boldsymbol{y}\), but also \(\boldsymbol{x}\) as input, we can control the aircraft based upon distance checking:
\[\boldsymbol{e_{automan} = \sqrt{(y_{reference}- y_{actual} )^2 +(x_{reference}- x_{actual} )^2} }\]Pictorially and going back to paths:
This shows that the distance between any point normal to the aircraft that intersects a path determines the error (notice yellow normal line in video). The intersection point can be retrieved via Bezier - Line intersection test.
What’s next
The final step is to add some sort of descision making logic to the auto manoeuvring system. Completing this allows me to focus on less aircraft related stuff. I have already been working on some vehicle designs for ground objects(targets), the spritesheets still have to be assembled. A Vehicle class is already prepared and will need further implementation once vehicles will be added to the simulation.
Scramble JS uses Phaser 3 as game engine. Fore more info, visit Phaser.io.