In the previous video, we learned that setpoint PD control can eliminate steady-state error

for a torque-controlled joint in the absence of gravity. If we add gravity, though, the

error dynamics are no longer homogeneous. As a result, even if the error dynamics are

stable, at steady state when theta-double-dot and theta-dot are zero, there will be a nonzero

steady state error, m g r cosine theta over K_p.

For example, imagine the initial resting state of the joint is at minus pi over 2. The desired

setpoint is theta_d equals zero. The error response looks like this. The joint stops

short of the desired angle. If we plot the torque due to the proportional term and the

torque due to the derivative term, the derivative term goes to zero in steady state, while the

proportional term provides the torque that holds the arm at its position in gravity.

The point is that there must be error for the controller to provide torque in steady-state,

and therefore the steady-state error cannot be zero.

One solution, as we've seen before, is to add an integral term to the controller, giving

us setpoint PID control. To perform a linear analysis, we have to address the nonlinear

term that depends on the cosine of the angle. I will replace this term by a constant, tau_disturbance.

Replacing by a constant is justified in the upcoming analysis, since I will be considering

the steady-state behavior of the controlled robot, when this nonlinear term approaches

a constant.

Equating the dynamics and the control torque, we get this error dynamics. To get a differential

equation, we can differentiate both sides. The result is a homogeneous third-order differential

equation with this characteristic equation. By adding an integral term to the controller,

we added a state to the dynamics, increasing the order of the differential equation from

second order to third order.

For stability, the roots must all have a negative real component. As for the PD controller,

K_d must be greater than minus b and K_p must be greater than zero. The gain K_i must also

be greater than zero, but unlike K_p and K_d, K_i also has an upper bound for stability.

Before, for our second-order differential equation, the only dangers in choosing large

gains were due to practical considerations, like actuator limits, unmodeled dynamics,

and finite servo frequencies. Now, with a third-order PID-controlled system, even our

ideal linear model shows that choosing K_i too large could result in instability.

Let's see this graphically by plotting the roots in the complex plane. First, let's choose

K_i equal to zero, and choose the gains K_p and K_d to give critical damping, two collocated

roots on the real axis. We'll keep K_p and K_d constant. Next, let's add a small positive

K_i. This creates a third root close to the origin. As we increase the gain K_i, the two

collocated roots move away from each other on the real axis, and the root at the origin

moves left. When we have increased K_i sufficiently, two roots meet on the real axis, while the

third has moved further left. Since the two collocated roots are much slower than the

root far to the left, the transient error response of this third-order system is similar

to that for a critically damped second-order system. The response is slower than for the

original critically damped PD controller, though, because the collocated roots are now

further to the right.

If we continue to increase K_i the two collocated roots break away from the real axis and move

into the right-half plane when K_i reaches its upper bound for stability. The error dynamics

would be unstable for the roots shown. We've drawn the root locus for K_i increasing from

zero, and it demonstrates the key features of adding integral control: The integral term

can improve steady-state response, but it can worsen the transient response. In particular,

adding an integral term could cause overshoot and oscillation, and in the worst case, instability.

Since stability is paramount in control, often robot controllers avoid the use of an integral

term, prioritizing stability over steady-state error reduction. Or, if a nonzero gain K_i

is used, it is chosen to be small. In addition, the magnitude of the integrated error may

be capped at a maximum value.

Let's design our PID controller to place the roots as shown here, which will yield an underdamped

error response. Returning to our example setpoint control problem, we recall that our original

PD controller results in steady-state error. Adding a positive gain K_i, we see that the

PID controller drives the steady-state error to zero. The overshoot shows that the response

is somewhat underdamped. Examining the torques due to the proportional, integral, and derivative

terms, we see that the proportional and derivative terms both go to zero, while the integral

term reaches a nonzero steady state. That is the torque that allows the joint to resist

gravity even when the error is zero.

In the next video, we will combine PID feedback control with a dynamic model of the arm to

derive our gold-standard motion controller, the computed torque controller.