State Estimation for Nonlinear Model Predictive ...

89 downloads 0 Views 546KB Size Report
Hardware and a Guided Parafoil,” M.S. thesis, Dept. Aeronautics and. Astronautics., Massachusetts Institute of Technology., America, 2004. [4] N. C. Jacob and ...
1

State Estimation for Nonlinear Model Predictive Control: EKF and UKF Approaches Moeti P. Sekhonyana, Mohohlo S. Tsoeu Department of Electrical Engineering Private Bag X3, Rondebosch, 7701 University of Cape Town, South Africa

[email protected] ,[email protected]

Abstract—This paper presents a state estimation based nonlinear model predictive control (NMPC) scheme for a feedback control of a magnetic levitation system. The study specifically focuses on comparing the closed-loop performances of the two competing nonlinear optimal state estimation methods: extended Kalman filter (EKF) and unscented Kalman filter (UKF) when integrated into the NMPC formulation. The EKF and UKF are utilized to estimate the state variables of the magnetic levitation system and unmeasured disturbances which are fed into the NMPC algorithm and then used for state prediction purposes. Their performances are assessed in terms of the disturbance rejection and set-point tracking performance of the proposed NMPC algorithm. The simulation results show that UKF performs better than EKF in the sense that it seems to provide relatively accurate plant and disturbance state estimates to the NMPC algorithm. The results also show that the computational time of UKF is relatively large compared to that of EKF, but in general UKF seems to outperform EKF. Index Terms—Nonlinear Model Predictive Control, Unscented Kalman Filter, Extended Kalman Filter, Magnetic Levitation System

A

I. INTRODUCTION

conventional process control problem formulation usually has disturbance rejection and set-point tracking as its main control objectives. This means that if a state of a controlled process is far away from a set-point, then a control input is determined to steer the state towards the set-point or if the state is already close to the set-point, then the control input is determined to keep the state there, in the face of unmeasured disturbances [1]. Over the past two decades, there grew a strong feeling that process constraints satisfaction and multivariable interactions handling should be considered as additional objectives of process control [2]. With their ability to handle constraints and interactions in their framework [3][4], MPC schemes have since gained popularity in process industries. Despite their long history of success, linear MPC (LMPC) schemes are not the best candidates for feedback control of highly nonlinear processes. Nonlinear MPC (NMPC) schemes have been proposed as alternatives to LMPC. NMPC inherits essential properties of LMPC such as systematic handling of

constraints and interactions. In contrast, it employs nonlinear process models for prediction purposes, which makes it theoretically appealing for processes with significant nonlinearity [4]. For detailed discussions on how to formulate and solve various NMPC problems, see [1] and [5]. An implementation of NMPC algorithm requires that an entire state vector of a controlled process be accessible for measurement in real-time [6]. Realistically, this is not always possible and rather, only process outputs are measurable. All unobservable state variables need to be estimated from noisy measurements using state estimation methods. A common method used to deal with unmeasured disturbances is an augmentation method in which a disturbance model is appended to the process model and disturbance states are then estimated [7]-[8]. The disturbance dynamics is usually modelled as additive step input or output functions. The aforementioned problems render state estimation and disturbance estimation problems important when developing MPC algorithms as such. This study is intended to conduct a comparative analysis of EKF and UKF when integrated into a nonlinear model predictive control of magnetic levitation system. The successful implementation of NMPC algorithm depends largely on estimation accuracy of states and disturbances. There are many publications that discuss about integration of EKF into the NMPC formulation for estimating states and disturbances, but from a study of optimal state estimation as a topic, we are aware that in most cases UKF outperforms EKF. The comparison of the closed-loop performances of EKF and UKF in this work is therefore carried out in terms of disturbance rejection and set-point tracking of the proposed NMPC algorithm as main control objectives. The magnetic levitation is chosen since it has significant nonlinearity that can demonstrate the application of NMPC, EKF and UKF, and it is also simple to handle. For a detailed information on how to model magnetic levitation systems, see [9]-[10] and for the detailed literature of EKF and UKF, see [11]-[14]. This paper is organized as follows. Section II discusses the dynamic modeling of magnetic levitation system. Section III discusses NMPC formulation. In section IV, state estimation algorithms: EKF and UKF are presented. The simulation results are presented in Section V. Section VI concludes this paper with a few remarks.

2 II. MAGNETIC LEVITATION SYSTEM MODEL A magnetic levitation system considered here is a nonlinear, open-loop unstable system [9]. It operates by generating a voltage-controlled magnetic field within which a ferromagnetic ball moves upwards and downwards or even gets suspended. A vertical motion of a ball is governed by force balance equation which is easily derived from Newton’s 2nd law of motion. On the other hand, a flow of current in an electrical subsystem is governed by voltage balance equation which is derived from Kirchhoff’s voltage law. The total dynamic model is therefore given as

TABLE I SIMULATION PARAMETERS OF MAGNETIC LEVITATION SYSTEM Parameters Units Values

m g R L C

kg

x1, 0

m m

0.02 9.81 10 0.01 0.005 0.12 0

x 2, 0

m/s

0

A

0

m

0,

m/s

-0.4,

A

0,

1.5

V

0,

15

m/s2 Ω

H

N/A2

xm

dp dv (36) = v, m = −mg + F ( p, I ) + η x 3, 0 dt dt x1, L , x1,U d (L( p )I ) (1) + RI = e x 2, L , x 2,U dt where p is ball’s position, v is ball’s velocity, m is ball’s x3, L , x3,U mass, g is gravitational constant, I is coil current, η is a u L , uU term that takes care of modeling errors, R is coil resistance and e is applied voltage. F and L are electromagnetic force and total inductance, respectively given by

F ( p, I ) = C

I2

(x m − p )

2

L( p ) ≈ L1 +

,

2C xm − p

(2)

T where x = [x1 , x2 , x3 ] x1 = p , x 2 = v , x3 = I , control input u = e and (1)(2), the state space model is given by

x1 = x 2 , x 3 = −

state

vector

x 2 = − g +

Cx3

2

m( x m − x1 )

2

+

η,

x3 R 2C u x3 − x2 + 2 L L ( x m − x1 ) L

(3)

The objective of state estimation based NMPC is to drive

[

The closed-loop implementation configuration of NMPC shown in Fig. 1 consists of state estimator which generates the estimates of state and disturbances. The estimates are then fed into the NMPC algorithm where they are used to generate the state and disturbance predictions which form part of the optimal control problem (OCP) discussed later in this section. Both NMPC and state estimator algorithm employ a nominal nonlinear augmented model of the controlled process. A. Model Structure Consider a discrete-time nonlinear state space model

m

x to track the set-point x sp = x1sp , x2sp , x3sp

0.4

III. NONLINEAR MODEL PREDICTIVE CONTROL ALGORITHM

where C is magnetic force constant x m is maximum distance between a ball and electromagnet and L1 is coil inductance.

Considering a

0.12

]

T

in the face of

unmeasured disturbances. Hence, from (3) given x1sp ,

gm are derived. The x2sp = 0 and x3sp = ( x m − x1 ) C initial state vector x0 = [x1, 0 , x 2 , 0 , x3, 0 ]T is given at the beginning of a simulation and, state and control constraints are given by

x1, L , x 2, L , x3, L , u L ≤ x1 , x 2 , x3 , u ≤ x1,U , x 2,U , x3,U , uU

(4)

The simulation parameters of the magnetic levitation system we consider here together with their corresponding values are listed in Table 1.

(5) y k = h( x k ) + Γd d k where x k is state vector, u k is control input, vk and Γv are input disturbance vector and matrix, respectively, yk is x k +1 = f ( x k , u k ) + Γv v k ,

measurement vector, d k and Γd are output disturbance vector and matrix, respectively. f and h are state transition and measurement functions, respectively. An augmented state space model is constructed by appending the input and output disturbance models to (1) as done in [4], [7] and [8] and it is given by

 x k +1   f (x k , u k ) Γv  0  v  =       , y = h(x ) + Γ d (6) 0 k d k  k +1    +  I  v k + 0  d k k  I    0  0 d k +1  

[

By defining x k ← xkT vkT d kT compactly as

]

T

as in Fig. 1, we can write (6)

3

x k +1 = f (x k , u k ) ,

y k +1 = h(x k +1 )

(7)

Notice that (7) has a structure similar to (6), but without additive terms. (7) is called a nominal nonlinear augmented model of a controlled process. A state prediction model is therefore, obtained by simulating f over a prediction horizon N p and it is given by

x k +i|k = f (x k +i −1|k , u k +i −1 ), i = 0,1,  , N p − 1

(8)

where x k +i|k is a predicted state trajectory and “ |k ” means that a prediction is made at time instant k .

OCP min J = x k + N p − x ksp+ N p u (.)

2 Qk + N p

(10)

+ J1 + J 2

subject to

(11)

x k |k = x k

x k +i|k = f (x k +i|k , u k +i )

(12)

x L ≤ x k + i|k ≤ x U

(13)

u L ≤ u k +i ≤ uU u k + i = u k + N c −1 , ∀i = N c , N c + 1,  , N p − 1

(14)

k k +1.

Algorithm 1: The OCP is solved in every obtain the optimal control inputs

u

* i for

(15)

in the NMPC algorithm to

A. NMPC Formulation The NMPC algorithm utilizes state prediction model to obtain the predicted states and then at every k , it solves the OCP to determine an optimal control input trajectory

ui* . Only

u0* is implemented as a control law at k + 1 . Then the model is updated and a procedure is repeated for all future time steps. The NMPC algorithm is therefore, presented in Algorithm 2 [1] as follows Fig. 1. A schematic of the closed-loop configuration of NMPC

NMPC A. Optimal Control Problem Formulation An optimal control problem (OCP) that we discuss here has a cost function taken from [3], which has quadratic form . 2

For

k = 0,1,  1) Measure the output

yk of the process.

vˆk

and is defined as a sum of two terms J1 and J 2 . J 1 penalizes a distance of x k + i|k from a set-point trajectory x ksp+ i and J 2

2) Obtain state and disturbance estimates, xˆ k ,

penalizes a distance of control trajectory uk + i from a desired

3) Solve the finite-horizon OCP presented in Algorithm 1 and obtain the optimal control input trajectory ui* , i = 0,1,  , N p − 1 .

control trajectory uksp+ i . The quadratic forms of J 1 and J 2 are weighted with symmetric matrices Qk + i and Rk + i , respectively

and hence, J 1 and J 2 are given by J1 =

2

N p −1

∑x i =0

k + i|k

− x ksp+ i

Qk + i

,

J2 =

and dˆk using either EKF or UKF.

4) Define the NMPC-feedback law 2

N p −1

∑u i =0

k +i

− u ksp+ i

it in the next time instant. (9)

*

Algorithm 2: The general NMPC algorithm with a changing set-point.

Rk + i

The OCP algorithm is therefore, presented in Algorithm 1 [4]. J = 0 if and only if a state coincides with a given set-point while J > 0 if and only if the state is away from set-point. Therefore, optimization of process’ performance corresponds to solving (10) subjected to the constraints given by (11)-(15) for the optimal control input trajectory u i .

µ k = u0* and use

IV. STATE ESTIMTION In this section, we provide a brief literature of EKF and UKF employed in this work. For the detailed literature of EKF and UKF, see [11]. Both algorithms assume that x k is represented by the probability distribution function (pdf) which captures its uncertainty [6] and that the noise is additive. Using (7), we present EKF and UKF algorithms in the following subsections.

4 A. EKF Algorithm The EKF inherits most of the essential properties of linear Kalman filter (LKF). The only difference is that EKF computes Jacobian matrices at each time step to determine a linearized process model. The Jacobian matrices are computed as follows Fk =

∂f (x k , u k ) ∂x k xˆ

,

H k +1 =

k | k ,u k

∂h(x k +1 ) ∂x k xˆ

(16)

Time-update equations: xˆ k +1|k = f xˆ k|k , u k

)

(17) (18)

T

Pk +1|k = Fk Pk|k Fk + Q k

(

T

K k +1 = Pk +1|k H k +1 H k +1 Pk +1|k H k +1 + R k +1

xˆ k +1|k +1 = xˆ k +1|k + K k +1 (y k +1 − h(xˆ k +1|k ))

)

−1

Pk +1|k +1 = (I − K k +1 )Pk +1|k

(19) (20) (21)

B. UKF Algorithm UKF is a derivative-free alternative to EKF [6] and it works by selecting a minimal set of points called sigma points to capture true mean and covariance of a state. Sigma points are then propagated through the nonlinearity using unscented transformation (UT) technique, to calculate statistics of a random variable. Literature suggests that UKF provides improved results compared to EKF in most case, but at the cost of large computational burden. Here we discuss UKF algorithm and show how the UKF state estimates and covariance are determined. Time-update equations: We begin by calculating scaling parameter λ and weighting parameters wm and wc which are defined as follows

λ = α (n + κ ) − n λ n+λ

wm( i ) = wc(i ) =

, wc(0 ) =

(n + κ )Pk|k )i is the root of (n + κ )Pk |k . where

(

λ n+λ

(

)

+ 1−α 2 + β , i = 0

1 , i = 1,...,2n 2(n + λ )

xˆ k |k −

(n + κ )Pk |k ]

(25)

i th column of the matrix square-

χ i ,k +1|k = f (χ i ,k|k , u k ), i = 0,1,  ,2n

(26)

The a priori state estimate and a priori covariance are calculated as weighted averages of transformed points given by 2n

xˆ k +1|k = ∑ wm(i ) χ i ,k +1|k

(27)

i =0

2n

Pk +1|k = ∑ wc(i ) (χ i ,k +1|k − xˆ k +1|k )(χ i ,k +1|k − xˆ k +1|k ) + Q k

(28)

T

Measurement-update equations: The transformed sigma points are then propagated through h as follows

ψ i ,k +1|k = h(χ i ,k|k ), i = 0,1,  ,2n

(29)

The mean and covariance of the measurement vector and cross-covariance are calculated as follows 2n

yˆ k +1|k = ∑ wm(i )ψ i ,k +1|k

(30)

i =0

2n

Pkyy+1 = ∑ wc(i ) (ψ i ,k +1|k − yˆ k +1|k )(ψ i ,k +1|k − yˆ k +1|k ) + R k +1 T

(31)

i =0

2n

Pkxy+1 = ∑ wc(i ) (χ i ,k +1|k − xˆ k +1|k )(ψ i ,k +1|k − yˆ k +1|k )

T

(32)

i =0

UKF state estimate and its covariance are calculated from the LKF equations as follows

( )

K k +1 = Pkxy+1 Pkyy+1

2

wm(0 ) =

(n + κ )Pk |k

i =0

Measurement-update equations: T

χ k |k = [xˆ k |k xˆ k |k +

The sigma points are then propagated through f as follows

k +1| k

Once Jacobian matrices are calculated, the LKF time-update and measurement-update equations given by (17)-(20) are applied to linear process model to determine the EKF state estimates and covariance, using:

(

Now, a set of 2n + 1 sigma points is computed according to the following

−1

(33)

(22)

xˆ k +1|k +1 = xˆ k +1|k + K k +1 (y k +1 − yˆ k +1|k )

(34)

(23)

Pk +1|k +1 = Pk +1|k − K k +1Pkyy+1 K Tk +1

(35)

(24)

where α ∈ [0,1] controls a size of sigma-point distribution and κ ≥ 0 is chosen such that it guarantees semi-positive definiteness of a covariance matrix. β (optimal choice is β = 2 ) is introduced to affect weighting of zeroth sigmapoint for calculation of covariance, n is the size of state vector.

The choice of tuning parameters influences the total performance of state estimation method and hence closed-loop performance of NMPC algorithm. Increasing the initial state estimation error covariance matrix P0 and process noise covariance matrix Q leads to faster convergence rate of state estimate and aggressive control inputs that result in faster disturbance rejection and set-point tracking of NMPC with the

5 possibility of oscillations. Increasing P0 and Q further may result in divergence of estimate and hence divergence of NMPC algorithm. In contrast, increasing the measurement noise covariance matrix R results in smaller bound on the estimation error due to measurement noise. V. SIMULATION RESULTS In this section, we present simulation results that compare closed-loop performances of EKF and UKF algorithms when integrated into the NMPC formulation. All necessary simulations were made on magnetic levitation system with each simulation running for 500 time steps. Moreover, sampling times of algorithms were assumed to coincide with that of a plant and it was chosen to be T = 0.01s throughout the simulations. The NMPC formulation was supplied with and the weighting matrices Nc = 4 N p = 10 ,

(

shows that the plots of EKF based NMPC seems to coincide with those of UKF based NMPC. It is depicted that both EKF and UKF suppress the offsets that are seen in Fig. 1 in the similar way. In addition, the results also show that both EKF and UKF are robust to the step input and output disturbances. The normalized root mean squared error (NRMSE) that quantifies the distance of ball’s position estimate from actual position is depicted in a plot in row three column one of Fig. 3. The NRMSE is approximately zero, which shows that the position estimate is accurate for both UKF and EKF. The NRMSE that

)

and Q = diag 250 0.1 1 10 - 3 10 - 3 10 - 3 10 - 3 10 - 3 R = 0.0001 . On the other hand, UKF was supplied with α = 10 −04 , β = 2 and κ = 0 which remain unchanged. η was assumed to be a step function in order to introduce plantmodel mismatches. The input disturbance vk and output disturbance d k were assumed to occur at 0.7 s and 2.2 s , respectively in order to demonstrate robustness of state estimation based NMPC to disturbances. To conduct the performance evaluations, the state estimators were integrated into NMPC, each at the time, and then ran simulations. Comparative results were presented graphically in terms of controller performance (set-point tracking and tracking error quantified by normalized root mean squared error (NRMSE)), estimation accuracy (state estimation error quantified by NRMSE) and computational time given in Table 2. Table 2 shows the computational times of EKF and UKF for iteration before they were integrated into NMPC. The computational time is quantified by CPU time and the table depicts that UKF has larger computational time compared to EKF.

Fig. 2. Comparison of closed-loop NMPC performance with and without plant-model mismatch. η is given a value of 0.01N in the force balance equation.

TABLE 2 COMPUTATIONAL TIME OF STATE ESTIMATION METHODS

State Estimator EKF UKF

Average CPU time (s) 0.014140 0.018022

Fig. 2 shows simulation results that compare the performance of NMPC algorithm with and without plant-model mismatches in the absence of state estimator. The plots depict that there is a significant offset in controller performance in the presence of plant-model mismatch as compared to controller without plantmodel mismatch. In order to demonstrate the closed performances of EKF and UKF in the NMPC formulation in the presence of plantmodel mismatches and unmeasured disturbances, the step input and output disturbances were applied at 0.7 s and 2.2 s . η = 0.01N as in the previous simulation. Fig. 3

Fig. 3. Comparison of closed-loop EKF and UKF based NMPC performance with plant-model mismatch η = 0.01N and unit step input and output disturbances applied at

0.7 s and 2.2 s , respectively.

quantifies the distance of ball’s position from the set-point is

6 depicted in a plot in row three column two. Initially, the NRMSE is one and quickly decays to zero as time progresses, indicating the faster set-point tracking is achieved. The peaks occurring at 0.7 s and 2.2 s are due to step input and output disturbances and the ones occurring at 1.5s and 0.3s are due to set-point changes. To further demonstrate performances of EKF and UKF algorithms, step input and output disturbances are increased in magnitudes while uncertainty parameter is now given as η = 0.04 N and the closed-loop performance of NMPC algorithm is investigated as before. Fig. 4 shows that UKF has relatively better disturbance rejection and faster set-point tracking after the disturbances have occurred. NRMSE plot in row three column one shows that EKF position estimates are significantly degraded which lead into set-point tracking problem depicted in NRMSE plot in row three column two. This tells us that when modeling errors and unmeasured disturbances increase while the tuning parameters are kept low EKF degrades faster than UKF and if they are increased further the performance of UKF starts to degrade.

set-point tracking capabilities of the proposed NMPC algorithm. The dynamics of the magnetic levitation system were modeled and then used in the simulations. In general, the closed-loop simulation results suggest that UKF provides better closed-loop performance compared to EKF in the presence of large modeling errors and unmeasured disturbances in the NMPC formulation. As future work, the formal analysis of state estimation in NMPC will be conducted in a multiobjective optimization framework with set-point tracking, noise immunity, disturbance rejection, system’s response time and magnitude of control inputs set as process control objectives so that tools such as Pareto analysis can be used for comparison and decision making in design process. REFERENCES [1] [2]

[3] [4] [5]

[6]

[7] [8] [9] [10] [11]

Fig. 4. Comparison of closed-loop EKF and UKF based NMPC performance with plant-model mismatch η = 0.04 N and unit step input and output disturbances applied at

0.7 s and 2.2 s time steps, respectively.

[12]

[13]

VI. CONCLUSION In this paper, the state estimation based nonlinear model predictive control scheme has been developed and implemented for the feedback control of a magnetic levitation system. The simulation tests were run to evaluate the closedloop performances of the two competing state estimation methods: EKF and UKF in terms of disturbance rejection and

[14]

L. Grune and J. Pannek, Nonlinear Model Predictive Control (Communications and Control Engineering). London Dordrecht, Heidelberg: New York, 2011, pp. 1, 43-55. A. Flores-Tlacuahuac, P. Morales and M. Rivera-Toledo, “Multiobjective Nonlinear Model Predictive Control of a Class of Chemical Reactors,” Industrial &Engineering Chemical Research.., vol. 51, no. 17, pp. 5891-5899, Dec. 2011. A. Alaniz, “Model Predictive Control with Application to Real-time Hardware and a Guided Parafoil,” M.S. thesis, Dept. Aeronautics and Astronautics., Massachusetts Institute of Technology., America, 2004. N. C. Jacob and R. Dhib, “Unscented Kalman Filter based Nonlinear Model Predictive Control of a LDPE autoclave reactor,” Journal of Process Control., vol. 21, pp. 1332-1344, Aug. 2011. D. Limon, A. Ferramosca, I. Alvarado, T. Alamo and E. F. Camacho, “MPC for Tracking of Constrained Nonlinear Systems,” Decision and Control, 2009 held jointly with the 2009 28th Chinese Control Conference. CDC/CCC 2009. Proceedings of the 48th IEEE Conference on, pp.7978-7983, 2009. S. Papp, K Gyorgy, A. Kelemen and L. Jakab-Farkas, “Applying the Extended and Unscented Kalman Filters for Nonlinear State Estimation,” Inter-Eng 2012 Conference Proceedings, Tg Mures .., pp. 233-239, 2012. M. S. Tsoeu, “Lecture Notes: EEE4093F – Model Predictive Control (MPC),” Dept. Elec. Eng., Control and Instrumentation, University of Cape Town.., Lecture Notes. U. Maeder, “Augmented Models in Estimation and Control,” Ph.D. dissertation, No. 19278, ETH Zurich, 2010. I. Ahmad and M. A. Javaid, “Nonlinear Model and Controller Design for Magnetic Levitation System,” Recent Advances in Signal Processing, Robotics and Automation, pp. 324-328, 2010. C. S. Teodorescu, “Nonlinear Control Design with Inequality Constraints: Application to Magnetic Levitation System,” Physcon 2009, Catania, Italy, Sept, 2009. D. Simon, Optimal State Estimation: Kalman, H infinity, and Nonlinear Approaches (John Wiley & Sons, Inc., Publication). Hoboken, New Jersey: U.S., 2006, pp. 395-459. S. M. Chow, E. Ferrer and J. R. Nesselroade, “An Unscented Kalman Filter Approach to the Estimation of Nonlinear Dynamical Systems Models,” Multivariate Behavioral Research .., vol. 42, no. 2, pp. 283321, Dec. 2007. E. A. Wan and R. Van Der Merwe, “The Unscented Kalman Filter for Nonlinear Estimation,” Adaptive Systems for Signal Processing, Communications, and Control Symposium 2000. AS-SPCC. The IEEE 2000.., pp. 153-158, Dec. 2000. Y. Zhou, J. Xu and G. M. Dimirovski, “The Unscented Kalman Filtering in Extended Noise Environments,” American Control Conference, 2009, ACC’09.., pp. 1865-1870, 2009.