Last week was mostly spent on writing about the early stage developments (starting here) and it serves as a recap on everything I’ve done so far. This is why there is a noticeable gap in the post timeline.

Adding an autopilot was not on the list of features at first. While analysing and endlessly recalibrating the aircraft its stability (read more in Modeling part 3: Stability and Control) I figured that having an autopilot would help out substantially. In part 3 I also mentioned the control output to be dangerously sensitive, providing immediate response and ignoring the airframe and pilot limits. This makes it harder to properly calibrate the aircraft. The pitch limiter solves this problem.

All updates are found in the changelog.

Autopilot control system

The autopilot currently supports two modes:

  • speed hold/autothrottle
  • altitude hold

For both cases, a PID controller is implemented. Here is a nice read on how A PID is used in autpilot systems, it definitely helped me out.

Just like most autopilots, there is a master hold switch and individiual hold switch. The GUI is not yet implemented, everything is in dat.gui. The autopilot altitude hold still needs to be fine tuned by ajdusting the gains, but it will eventually hold at near reference altitude (there is some total error).

Pitch limiter

The pitch limiter is an inverse proportional controller. It reduces the actual elevator deflection with increase in load factor and uses the ultimate design load factor as a reference value.

var x = Phaser.Math.clamp(Math.abs(myAircraft.n / myAircraft.nmax), 0.1, 1);
myAircraft.limiter = 1 / (myAircraft.limiterGain * x + 0.1);

//in control input function
myAircraft.elevator.angle = pitchValue * 15 * myAircraft.direction * myAircraft.limiter;

Mission

The autopilot is demonstrated.

Briefing

Initial altitude 10.000ft, 450 KTAS. Autopilot master switch is enabled during start. Hold is set at 15.000ft , 450KTAS.

Flight

Notice how the holding altitude is currently off by a couple of hundred feet. The autopilot still needs some fine tuning. Speed is controlled by adjusting throttle output, hence the only way to slow down is by pushing the throttle back.

Scramble JS uses Phaser 2 as game engine. Fore more info, visit Phaser.io.

Subscribe to my mailing list