## 11.4. Motion Control with Torque or Force Inputs (Part 3 of 3)

#### 11.4. Motion Control with Torque or Force Inputs (Part 3 of 3)

This video introduces the computed-torque motion control method for robots, where the control inputs are torques or forces. The controller is defined both in joint space as well as task space.

Recall our dynamics for a single-joint robot. I'll lump together the gravity and friction terms into a single term h. In the last video we learned about PID feedback control. While it can give good performance, it still requires error to accumulate before it will command a torque. If we have a good dynamic model of the robot, there is no need to wait for error to start commanding a torque.

Our dynamic model is M-tilde and h-tilde, based on estimates of the inertia of the robot, the gravitational term, and friction. If the model is perfect, then M-tilde equals M and h-tilde equals h at all times. With our dynamic model, we can design a feedforward controller. At each time instant, we apply the torque M-tilde times theta_d-double-dot plus h-tilde of (theta_d, theta_d-dot). The desired position, velocity, and acceleration at any time instant comes from the known desired trajectory at that time instant; there is no feedback from the joint.

Of course feedforward control will not work well on its own, as we never have a perfect model of the dynamics. There is no mechanism to recover from errors.

Let's consider a control law that combines the benefits of a good dynamic model and the stabilization of the PID controller. Here is one possibility. The first term of the control law is M-tilde times an acceleration, which is the sum of the feedforward acceleration at this time instant plus an acceleration generated by a PID controller. The M-tilde model turns the feedforward plus feedback acceleration into a joint torque. The second term of the control law provides the torque h-tilde that is estimated to be needed to balance friction and gravity at the current state.

Notice that if the error is always zero, this control law reduces to the feedforward controller. This control law goes by different names, but it's often called computed torque control. Because of the possibility of instability raised by integral control, the integral term can be eliminated.

If the model M-tilde and h-tilde is exact, we can remove the tildes in our analysis of the control law. Then the commanded acceleration theta-double-dot, which is the sum of feedforward and feedback terms, is achieved exactly by the commanded torques. The second derivative of the error is theta_d-double-dot minus theta-double-dot. Plugging in the commanded acceleration, the error dynamics can be expressed like this. Taking the derivative, we get this third-order homogeneous differential equation, yielding zero steady-state error. This linear error dynamics applies along arbitrary trajectories of the robot, since the use of the dynamic model effectively linearizes the dynamics.

Let's apply the computed torque controller to track the trajectory shown here. Our model of the dynamics is not perfect, as you can see from this simulation of the trajectory when using only feedforward control. The robot starts out approximately on the trajectory, but over time the actual trajectory diverges from the desired due to error in the model.

We could instead try a PID controller with no dynamic model. Finally, we could try computed torque, which provides better tracking than either of the other two controllers. We could also look at a standard measure of the control effort exerted by the motor, the time integral of the torque squared. At first, the PID control effort is the lowest, before the error builds up to start driving the torque. Soon, though, the PID control effort exceeds the control effort of the computed torque method. This is typical behavior of the computed torque method: it provides better trajectory tracking than pure feedback control with lower control effort.

In short, if we have a reasonable model of the robot's dynamics, we should use it in the controller.

To summarize, the single-joint computed torque control law is given here. This controller generalizes readily to multi-joint robots. The difference is that tau, theta_d, and theta_e are vectors, h-tilde is a vector of Coriolis, gravity, and possibly friction terms, M-tilde is a model of the robot's configuration-dependent mass matrix, and K_p, K_i, and K_d are diagonal matrices, each consisting of a positive scalar times the identity matrix. The linearization of the dynamics provided by the model M-tilde and h-tilde makes each joint have the same stable linear error dynamics.

This is a block diagram of the computed torque controller. The measured position and velocity of the robot feed back to the PID controller, to the calculation of the M-tilde matrix, and to the calculation of the h-tilde vector.

This controller provides good performance when the dynamic model of the robot is reasonably good. If the dynamic model is poor, then using it in the controller could actually hurt performance compared to a model-free feedback controller. Also, evaluating the mass matrix and h-vector could be computationally intensive for real-time control. For this reason, simpler versions of this control law are common. For example, PD feedback control plus gravity compensation can provide good performance, and it is much less computationally expensive to evaluate a model of gravitational torques than it is to compute a full dynamic model.

Finally, we could express the computed torque control law in terms of the task-space dynamics of the robot, derived in Chapter 8. The end-effector wrench F_b, expressed in the end-effector frame, equals the end-effector mass matrix Lambda times the end-effector acceleration V_b-dot plus the wrench eta due to Coriolis and gravity terms. Our dynamic model is Lambda-tilde and eta-tilde.

Recalling the joint-space computed torque control law, by analogy we write the task-space computed torque control with F_b, Lambda-tilde, and eta-tilde replacing tau, M-tilde, and h-tilde, respectively. The analog to the feedforward acceleration theta_d-double-dot is the time-derivative of the desired twist, V_d-dot. Technically, this feedforward acceleration should be expressed in the current end-effector frame, but let's ignore that detail. The analogy to the PI terms replaces theta_e by the twist X_e that takes the current end-effector frame to the desired end-effector frame in unit time. Finally, the analogy to theta_e-dot is the twist V_e, which is the desired twist V_d, expressed in the current end-effector frame, minus the current twist V_b. This is the resulting control law, and the actual torques applied at the joints are obtained by pre-multiplying the control wrench F_b by the Jacobian transpose. Other simpler task-space control laws could be formulated, but they all involve computing an end-effector wrench and then pre-multiplying by the Jacobian transpose to get the joint forces and torques tau.

This completes our study of motion control where the controller commands joint forces or torques. In the next video we move on to force control.