Click here to Skip to main content
15,879,535 members
Articles / Web Development / HTML
Tip/Trick

Optimal Control of a Two-Link Manipulator

Rate me:
Please Sign up or sign in to vote.
4.85/5 (27 votes)
10 May 2019CPOL6 min read 29.9K   8   15   7
This post demonstrates examples of calculation of optimal control policies for two-link manipulator using linear-quadratic control combined with quasilinearization.

Table of Contents

Problem Statement

In this blog, I'd like to apply the technique and software presented in my CodeProject article Simple Software for Optimal Control [1] to governance of a two-link manipulator. .NET code for the article provides solution for this problem. The mathematic model of the manipulator is taken from write-up A two-link manipulator: simulation and control design [2] by Stephen Dodds (advisor Dr. Mahboub Baccouch). It is expected that the reader is familiar with [1] since its terminology, notation and formulas are widely used here.

The simplified model of the two-link vertically oriented manipulator is depicted below [2].

Image 1
Simplified model of a two-link manipulator

Here Mi are lumped masses, Li are lengths of the links and Θi are links' displacement angles. Math description of the model is given with formulas (1).

Image 2
Image 3
Image 4    (1)

The system is essentially nonlinear. For its optimal control, we will apply method of linear-quadratic control combined with quasilinearization and appropriate software provided in [1].

According to notation used in [1], state vector x corresponds to vector z in (1). The system is actuated with two motors producing torques T1 and T2 rotating the links. For the sake of simplicity, it is assumed that the motors are inertialess. Control vector m of dimension 2 corresponds to the torques. The torques are denotes as fΘ1 and fΘ2 in formulas (1).

Our goal is to suggest such control of the system which provides transition from its initial position to a prescribed final position and its fixation in the final position. The transition should be fast. However, during this transition values of angular velocities and torques should be kept within some reasonable limits to avoid damage of system's mechanics.

For numerical sample, it is assumed masses in kg, lengths in m, time in s and torques in N⋅m. Therefore g = 9.81 m/s2. Angles are assumed in degrees for a better reading. The following parameters are taken for numeric sample:

M1 = M2 = 1
L1 = L2 = 1

Δt = 0.01, N = 1001.

Optimization Policies

The goal spoken out above should be formalized. The suggested approach is to minimize integral quadratic cost function described in [1]. Below, we demonstrate application of two optimization policies to the system. The case 1 is characterized with:

  • permanent desirable final values for Θ1 and Θ2 angles which are desirable coordinates r0 and r2 respectively,
  • permanent weight factors for the Θ-s as Q00 and Q22, and
  • permanent limits to external control parameters (torques) implemented with unit matrix Z and zero vector u.

The case 2 implies:

  • variable desirable values for Θ1 and Θ2 angles (r0 and r2 respectively) calculating as

    rk = if k < s⋅N then xinit + (rfinal - xinit) / (s⋅N) else rfinal     (2)

    where k is timestep, and s is threshold value, s < 1.

  • permanent desirable derivatives from angles Θ-s equal to zero,
  • unit weight matrix Q, and
  • torques are not controlled, i. e. matrix Z = 0.

In both cases, we confine ourselves with just one iteration enabling in conjunction with constant weight matrices to achieve constant values of feedbacks.

These two optimization policies are applied to the following two movements.

Movements

The first movement

xinit =  $ \begin{bmatrix} 0 \\ 0 \\  0 \\ 0 \end{bmatrix} $ ,    xfinal =  $\begin{bmatrix} 45 \\ 0 \\  30 \\ 0 \end{bmatrix}$

and

The second movement

xinit =  $ \begin{bmatrix} 45 \\ 0 \\  30 \\ 0 \end{bmatrix} $ ,    xfinal =  $\begin{bmatrix} 60 \\ 0 \\  -30 \\ 0 \end{bmatrix}$

The First Movement

Input

Case 1

$ Q = \begin{bmatrix} 5000 &0 &0 &0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 5000 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix} , Z = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} , r = \begin{bmatrix} 48.5 \\ 0 \\ 32 \\ 0 \end{bmatrix} , u = 0$

Case 2

$ Q = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} , Z = 0 , r = \begin{bmatrix} (2)where \hspace{2 mm} s=0.6, r_{final}=48.6\\ 0 \\ (2)where \hspace{2 mm} s=0.6, r_{final}=32\\ 0 \end{bmatrix} $

Result Transients

Image 5
Θ1
Image 6
1/dt
Image 7
T1
Image 8
Θ2
Image 9
2/dt
Image 10
T2

The Second Movement

Input

Case 1

$ Q = \begin{bmatrix} 5000 &0 &0 &0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 5000 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix} , Z = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} , r = \begin{bmatrix} 66.5 \\ 0 \\ -19 \\ 0 \end{bmatrix} , u = 0$

Case 2

$ Q = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} , Z = 0 , r = \begin{bmatrix} (2) where \hspace{2 mm} s=0.6, r_{final}=66.5\\ 0 \\ (2) where \hspace{2 mm} s=0.6, r_{final}=-20.5\\ 0 \end{bmatrix} $

Result Transients

Image 11
Θ1
Image 12
1/dt
Image 13
T1
Image 14
Θ2
Image 15
2/dt
Image 16
T2

Calculated Feedbacks and Permanent Inputs of Close-Loop System

Case 1

Feedback  

46.7   7.07   -46.6   -7.06
46.6   7.06  46.6 7.06

Input for the First Movement

13.4
65.5

Input for the Second Movement

69.5
38.6

Case 2

Feedback

49.9   50.5   -49.8   -50.5
49.7   50.5  49.8 50.5

Although formally in the case 2 input of close-loop system is not constant, calculations show results very close to the constant values below.

Input for the First Movement

14.4
70.0

Input for the Second Movement

75.5
39.9

Discussion

Problem of two-link manipulator optimal control is not a simple one. The system is essentially nonlinear. Its solution requires effective coordinated control by two channels (torques). As it is shown above, the technique for minimization of integral quadratic cost function presented in [1] allows designer to easily calculate various control policies. In fact, I performed a lot of calculations with various values of desirable vectors and weight matrices members, and the above results constitute just a small part of them. For both discussed sets of input data, we managed to obtain reasonable control policies with just one iteration ensuring constant value of feedbacks. It is interesting that obtained control policies include positive feedbacks from angle and angular velocity of the second link to the first actuator in both control cases. Both control channels have similar feedback values because masses M1 and M2 and link lengths L1 and L2 are equal.

For further research, check the system controlled with suggested policies for stability and sensitivity to model inaccuracy is required. And of course, it is always interesting to generate more control policies, e.g., with more that one iterations process. For technical implementation of control will be useful to provide effective measurement / estimation of feedback parameters (that are links angles and angular velocities). For the real life system dynamics of actuators should be included to mathematical model of controlled object.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Israel Israel


  • Nov 2010: Code Project Contests - Windows Azure Apps - Winner
  • Feb 2011: Code Project Contests - Windows Azure Apps - Grand Prize Winner



Comments and Discussions

 
QuestionVery useful Pin
Brian Bartlett12-Mar-15 10:32
Brian Bartlett12-Mar-15 10:32 
AnswerRe: Very useful Pin
Igor Ladnik12-Mar-15 15:30
professionalIgor Ladnik12-Mar-15 15:30 
GeneralGood to read Pin
Gaurav Aroraa12-Mar-15 0:37
professionalGaurav Aroraa12-Mar-15 0:37 
GeneralRe: Good to read Pin
Igor Ladnik12-Mar-15 2:15
professionalIgor Ladnik12-Mar-15 2:15 
GeneralRe: Good to read Pin
Gaurav Aroraa12-Mar-15 9:29
professionalGaurav Aroraa12-Mar-15 9:29 
GeneralVectors and matrices are not properly formatted, alas... Pin
Igor Ladnik8-Mar-15 9:46
professionalIgor Ladnik8-Mar-15 9:46 
GeneralDone by the editor - thanks! Pin
Igor Ladnik9-Mar-15 19:49
professionalIgor Ladnik9-Mar-15 19:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.