PID Controller

Unrea Engine Marketplace PID Controller

What is a PID Controller?

“A proportional–integral–derivative controller (PID controller) is a control loop feedback mechanism (controller) commonly used in industrial control systems. A PID Controller continuously calculates an error value as the difference between a desired setpoint and a measured process variable and applies a correction based on proportional, integral, and derivative terms” – (Wikipedia) PID Controller

Simply put, PID Controllers are used to reliably automate certain kinds of processes. For example, an aircraft may use PID Controllers in their stability assist systems to maintain orientation in flight. They do this by calculating an error value between a desired setpoint (the pilots commands) and a measured process (the attitude readings form the aircraft sensor data). The PID Controller then outputs the results of it’s calculations to the various control surfaces of the aircraft to reach the desired setpoint.

PID Controllers are also commonly used for stabilizing quadcopters. The PID Controller takes in the angular velocity of the quadcopter from the gyroscope, and stabilizes the flight using the speed of the propellers to control the angle of the quadcopter. The same effects can be achieved in a Blueprint by retreiving a PhysicsBody’s angular velocity and outputting the results of a PID Controller to PhysicsThrusters. PID Controllers are also useful in countless other possible applications!

How to use the PID Controller Actor Component

This PID Controller Blueprint is meant to be used as an Actor Component. You can add it to any actor or pawn that requires some form of simple process automation. Multiple automated processes can be managed in a Blueprint Actor. You must add one PID Controller Component for each process you want to automate.

The main function in the PID Controller Component is the PID function, it must be provided with the following variables:

  • P Gain : The Proportional Gain Term tells the PID Controller to output a value that is proportional to the error value.
  •  I Gain : The Integral Gain Term affects the output based on the magnitude and the duration of the error (the longer an error persists the bigger the output)
  •  D Gain : The Derivative Gain Term “predicts” the error over time by continually calculating the slope of the error. It behaves like a damping value.
  • Set Point is the desired state of your system. This could be mapped to a controller axis or any other variable that changes over time.
  • Measured Point is the current state of your system. This could be the angular velocity of a Physics Body, or the position or rotation of an Actor
  • Min and Max values clamp the output to a desired range.


The PID Controller Actor Component addon for Unreal Engine 4 comes with 6 example pawns that all use PID controllers in a number of different ways.

  • The first example: The Balance Cone example demonstrates basic use of PID Controllers using player input as the set point, the rotation of an object as the Measured Point and Add Torque as the output. Two PID Controllers are needed, one for pitch and the other for roll. The result is similar to built in UE4 Physics Constraint, Angular Motor.
  • The second exmaple: The Flying Cube Example uses three PID Controllers, one for each axis of movement. Player input is used as the Set Point, Linear Velocity is used for the Measured Point and PhysicsThrusters are sent to the output.
  • The third example: The Rocket example demonstrates how two PID Controllers are used to keep a rocket ship upright using thrust vectoring, while a third PID Controller maintains the vertical velocity. The first two PID Controllers use the x and y rotation of the rocket ship body as the Measured Point, user input as the Set Point. The output of the PID Controller is sent to a Physics Constraint angular motor between the rocket ship body and the thruster nozzle to affect the target angle of the nozzle. The third PID Controller uses the linear velocity of the rocket ship body as a measured point, user input as the set point and the output is sent to a Physics Thruster.
  • Examples 4, 5 and 6: demonstrate how PID Controllers can be linked, allowing multiple simple automated processes to produce complex automated behaviors. This 3-part example shows, in increasing complexity, how to create a stabilized thruster platform that can easily be programmed to automatically navigate along pre-determined paths. All using physics and thrusters!




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s