## Part III : Adaptive Control

In Part II of this trilogy, we demonstrate some effects of model uncertainty on inverse dynamics control. When modeling error increases, closed-loop performance degrades. More parameter variation could even destabilize the system. Some robust nonlinear control scheme can be implemented, normally by switching the control laws in accordance with some specified constraints to compensate model uncertainty. This approach requires estimation of nominal values for plant parameters, and may cause some undesirable effect such as shattering. In this section we introduce an alternative approach, called *adaptive control*, that is useful when only plant structure is known, but no estimated parameter value is needed.

Here we provide an example of adaptive control law that is discussed in [1],[2], among other robotic texts. It relies on a plant property known as *linearity in the parameter*, which can be stated briefly as follow: There exist an matrix function and an -dimensional vector such that the Euler-Lagrange equation can be parameterized as

(1)

is called a regressor, and is a parameter vector. Note that the size of parameter space, or the total number of parameters needed to describe the dynamics, is not unique. In general, a rigid body can be described with 10 parameters: total mass, 6 independent members of inertia tensor, and 3 Cartesian coordinates representing the center of mass. Therefore, a robot with links has at most parameters. However, since the link motion is constrained by the connection between adjacent joints, the number of parameters is practically less than that.

Here we show how the 2-link manipulator is parameterized. This structure will be exploited by the adaptive control scheme in this article.

From the equation of motion of the 2-link manipulator in Part I , the inertia terms can be grouped as

(2)

by substituting them into the members of inertia matrix

(3)

The Christoffel symbols need no additional parameter since they are functions of the members of inertia matrix. The gravity terms, on the other hand, have new parameters after setting

(4)

The gravity terms and hence becomes

(5)

Substituting all these terms into the equation of motion yields an equation in the form (1), with

(6)

(7)

Now we state without proof an adaptive control problem for a general robot dynamical equation in the form

(8)

with the adaptive control law chosen as

(9)

where is a positive definite matrix, positive definite and usually diagonal, , , , and , and the parameter adaptation law

(10)

The robot trajectory described by the model (8) will globally converge to and asymptotically, which implies must converge to zero. Since is bounded, it can be shown that

(11)

asymptotically. The derivation details, rather too lengthy for an online article, are provided in [3].

Note that the equation (11) does not imply that must converge to since parameter convergence to the real value depends on the structure of matrix, together with both trajectory commands and actual values. Nevertheless, the mentioned approach can be classified as direct *adaptive control problem*; that is, finding a control such that tracking error is bounded, instead of finding the real values of system parameters (the so-called *indirect adaptive control problem*).

A block diagram of adaptive control scheme discussed thus far can be shown as in Figure 3.1, consisting of 3 major parts

- : describing the control from inverse dynamics estimation, which is basically nonlinear compensation and joint decoupling
- : providing stability and tracking error reduction, similar to a PD control
- : parameter vector estimation, updated online with convergence rate specified by matrix

Using the structure in Figure 3.1, now we are ready to construct an adaptive control scheme for the 2-link manipulator. First, we need to make a slight modification to the development in (1) – (7) above, since from Figure 3.1 the dynamical equation to be parameterized is in the form

(12)

This gives the same parameter vector as in (7), but the regressor in this case is not , but . It is straightforward to verify that

(13)

*Note :* Here we use abbreviation etc.

By using (13), we can construct an Xcos model for adaptive control simulation of the 2-link manipulator as in Figure 3.2, which, however complicated, is just a concrete example of the structure in Figure 3.1. Note in the diagram of Figure 3.2 that the adaptive controller is wrapped in a superblock, with its internal detail as shown in Figure 3.3. So, instead of building all of these by your own, it is strongly recommended that you use the adaptive_2link_track.zcos file that comes with RTSX to save time and effort. Also for your convenience, all the parameter setup, trajectory generation, and gains for the adaptive controller are contained in the script file setup_adaptive_2link.sce .

To demonstrate tracking capability of adaptive control, we apply a pair of multi-segment trajectory commands for the two joints. From Chapter 4 of [3], we see that RTSX has a specific command mstraj to generate multi-segment trajectory. Unfortunately, this command provides only joint positions, not their derivatives required by the diagram in Figure 3.2. So for this example we need to create a multi-segment trajectory manually.

Suppose we want to create a two-joint, three-segment trajectory during the period 0 – 5 seconds, with specified boundary values for each segment, using the quintic polynomial generator qpoly. The following set of commands is just an example on how to do it

t1=0:0.01:1.99; t2 = 0:0.01:0.99; // first joint trajectory [q11_d,qd11_d,qdd11_d]=qpoly(0,10,t1,0,10); [q12_d,qd12_d,qdd12_d]=qpoly(10,-5,t1,10,-5); [q13_d,qd13_d,qdd13_d]=qpoly(-5,0,t2,-5,0); q1_d = [q11_d;q12_d;q13_d]; qd1_d = [qd11_d;qd12_d;qd13_d]; qdd1_d = [qdd11_d;qdd12_d;qdd13_d]; // second joint trajectory [q21_d,qd21_d,qdd21_d]=qpoly(0,-5,t2,0,-10); [q22_d,qd22_d,qdd22_d]=qpoly(-5,10,t1,-10,10); [q23_d,qd23_d,qdd23_d]=qpoly(10,0,t1,10,0); q2_d = [q21_d;q22_d;q23_d]; qd2_d = [qd21_d;qd22_d;qd23_d]; qdd2_d = [qdd21_d;qdd22_d;qdd23_d]; |

Note that nonzero velocity are specified at the segment boundaries other than the start and end of trajectory. Now we convert the data to “From workspace” block format as before

t=0:0.01:4.99; t=t'; Q1_d.time = t; Q1_d.values = q1_d Qd1_d.time = t; Qd1_d.values = qd1_d; Qdd1_d.time = t; Qdd1_d.values = qdd1_d; Q2_d.time = t; Q2_d.values = q2_d Qd2_d.time = t; Qd2_d.values = qd2_d; Qdd2_d.time = t; Qdd2_d.values = qdd2_d; |

Since the adaptive controller has 3 sets of adjustable gains, and unlike a standard controller such as PID, there is no rule of thumb on how to select good values for them. So the tuning procedure is more like trial and error.

First we play around on the gain, which is quite similar to the gain of PD control in some aspects; i.e., used to stabilize the closed-loop system and improve tracking performance. From our experiment, the values yield good tracking.

Next, we examine , which controls parameter convergence. Varying the scalar value from 10 – 100 has no significant effect on the responses. So we finally leave it at .

The last set of gains is , which casts weights on velocity and acceleration compensation for the trajectory. Choosing gives the trajectory tracking responses as shown in Figure 3.4, with, from top to bottom, position, velocity, and acceleration of each joint. It can be seen that tracking performance of joint 2 (right) is satisfactory, while there is still noticeable tracking error at joint 1 (left). So we crank the gain up to , resulting in the tracking response of Figure 3.5. The position and velocity for both joints now track the command quite well, though the acceleration now becomes more noisy.

*Note :* one must keep in mind this is a simulation result. In practice, a mechanical structure is unlikely to provide such abrupt change in acceleration.

The above simulation results reveals the nice feature of adaptive control scheme. The controller does not need an estimated value of any parameter. Only knowledge of plant structure in parameterized form is sufficient. Moreover, no expensive (and noise-prone) sensor is required to measure joint acceleration. The adaptive control does have some drawbacks such as 1) Its complexity might lead to implementation problem, especially on an embedded system with limited resources. 2) There is no systematic way to tune the controller gains 3) It may not be suitable for plant with unmodelled dynamics, or in an environment with high exogenous noise signals.

### Scilab/Xcos Files

For your convenience, here are the model and script files used in this article.

- adaptive_2link_track.zcos — adaptive control of 2-link manipulator
- setup_adaptive_2link.sce — model initialization script

To run the above script file in Scilab, type exec(‘setup_adaptive_2link.sce’,-1);

### References

- M.W.Spong, S. Hutchinson and M. Vidyasagar, Robot Modeling and Control. John Wiley & Sons. 2006.
- B. Siciliano, L. Sciavicco, L. Villani and G. Oriolo, Robotics: Modeling, Planning and Control, Springer 2010.
- V. Toochinda, Robot Analysis and Control with Scilab and RTSX, Mushin Dynamics, 2014.

Pingback: Scilab Recipe 3: Xcos Blocks Seasoning | Scilab Ninja