I'm implementing a set of loops to control pitch-and-roll angular positions.

In an inner-loop, motor speeds are adjusted to achieve desired angular rates of rotation (the "inner-loop setpoints").

An outer-loop decides these desired angular rates (the "inner-loop setpoints") based on the aircraft's angular positions.


  • Frequency = ~400Hz
  • Outer PV = input angular position (in degrees)
  • Outer SP = desired angular position - input angular position (in degrees)


  • Frequency = ~760Hz
  • Inner PV = input angular rotation (in degrees-per-second)
  • Inner SP = constant1 * Outer MV (in degrees-per-second)
  • PWM = Inner MV / constant2 (as percentile)

I understand what I-gain does and why this is important, but I'm not able to see any practical reason for also having I-gain specified in the outer-loop. Surely the inner-loop would compensate for any accumulated error, leaving no error to compensate for in the outer-loop, or is my thinking flawed?

Any example gain values to elaborate would be greatly appreciated.

  • $\begingroup$ ...and there I find a major flaw in the assignment of Outer SP $\endgroup$
    – Biscuits
    Commented Mar 16, 2016 at 18:58

4 Answers 4


In my own experience, it is not necessary Integral term in any of these loops. I got a fine PD tuning of both inner and outer loop. See for instance this paper, where I firstly tuned PD only with PSO.

Wikipedia shows a simple animation of each of the effects of P-I-D in any tuning https://en.wikipedia.org/wiki/PID_controller#Manual_tuning.


Integral gain is how you eliminate steady state error. An integral gain in the inner loop means you'll (eventually) have no steady state error on the angular velocity.

What ensures no steady state error on angular position, which is arguably the more important of the two? Outer loop integral error.

  • $\begingroup$ Plus consider that any real system has a real lag between commanded position and achieved position. If your integral loop responds to this natural lag in behavior, it will result in an overshoot when the system eventually gets to its setpoint. $\endgroup$
    – SteveO
    Commented Mar 17, 2016 at 2:10
  • 1
    $\begingroup$ An error in angular position would give a desired angular rate which would be achieved if there was an integral term in the inner loop. There would be no steady state error in either case. $\endgroup$
    – holmeski
    Commented Mar 18, 2016 at 16:09
  • $\begingroup$ Thanks Chuck, your first sentence makes perfect sense - it's the second one that troubles me. @holmeski said it exactly how I see it. $\endgroup$
    – Biscuits
    Commented Mar 18, 2016 at 18:02
  • $\begingroup$ @Biscuits - Ask yourself, "Where does the angular error go?" Angular position reference is an input to the outer loop, as is angular position feedback. The output - angular error - is then acted on by the outer PID loop. The outer PID loop then feeds a speed request to the inner PID loop. My point is that the outer PID loop will never request the speed required to get the angular position feedback equal to the angular position reference. $\endgroup$
    – Chuck
    Commented Mar 18, 2016 at 18:50
  • $\begingroup$ @holmeski , Biscuits - refer to the comment above and: I think you're thinking of this backwards. If the outer loop had an integral gain, then it could drive angular position error to zero, even if the inner loop did not have integral gain. Ultimately you don't actually care about angular speed; it's just a means to the end, which is angular position. $\endgroup$
    – Chuck
    Commented Mar 18, 2016 at 18:51

Let's assume that the inner loop, whose input is desired angular rate and output is motor input, can track the desired angular rate. Some internet fellow has taken care of that for us. I'm going to be considering a step change in desired position:

Let $e = x_{des} - x$ and $ \dot e = -\dot x$ this will be our outer loop controller

$$\dot x = k_p e + k_d \dot e$$

substituting in $\dot e$ gives

$$ -\dot e = k_p e + k_d \dot e$$

which can be rearranged as

$$\dot e = - \frac{k_p}{k_d + 1} e$$

which is a first order system. I've ignored inner loop dynamics but that should be fine, inner loop dynamics should be at least an order of magnitude faster than the outer loop dynamics.

I am not saying that integral control is not useful, just that it is not strictly necessary in the outer loop. It is easy to imagine a situation where the inner loop is not behaving correctly that results in a steady state error.

The px4 flight stack for multicopters approaches attitude control with pd control for angular position and pid control for body rate control.

https://pixhawk.org/users/multirotor_pid_tuning (link broken)


Each control system has its own characteristics (overshoot, damping, settling time, response time, etc).

The outer loop is just another control system, so it may have a steady state (residual) error. And the I term is necessary to get rid of it.

If you had a third level controller (e.g lateral acceleration) you would still need another I term. And if you had a higher level outer loop (e.g. Speed), you would still need yet another I term in that loop. If you had yet another higher level (outer) loop (e.g. Position), you would again need an I term. Otherwise you run the risk of not reaching your target location.

Of course if the intermediate control variables are not important (e.g acceleration), you might just cancel that I term of that loop. However, any time you want to get rid of the steady state error of any of your variables (in any of the loops), you use an integral term.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.