Week-9
Week-9
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
CPS Examples
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Course Organization
Topic Week Hours
CPS : Motivational examples and compute platforms 1 2.5
Real time sensing and communication for CPS 2 2.5
Real time task scheduling for CPS 3 2.5
Dynamical system modeling, stability, controller design 4 2.5
Delay-aware Design; Platform effect on Stability/Performance 5 2.5
Hybrid Automata based modeling of CPS 6 2.5
Reachability analysis 7 2.5
Lyapunov Stability, Barrier Functions 8 2.5
Quadratic Program based safe Controller Design 9 2.5
Neural Network (NN) Based controllers in CPS 10 2.5
State Estimation using Kalman Filters (KF) 11 2.5 TE
OF
TECHNO
LO
GY
ITU
IAN INST
KH
ARAGPUR
Attack Detection and Mitigation in CPS 12 2.5
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Section 1
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Optimal Control
Suppose a dynamical system evolve following
ẋ = f (x, u, t)where x ∈ Rn , u ∈ Rm are states and control inputs for the system
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
1
Ref: Optimal Control, B.D.O. Anderson, J.B. Moore, Prentice Hall
yog, kms kOflm^
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Section 2
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
T AΓ T T
E [v (kh)v (kh)] = R1 = e R1C , E [v (kh)e (kh)] = R12 , E [e(kh)e (kh)] = R2
IND
19 5 1
Foundations of Cyber Physical Systems 0 Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
ZNh ZNh
2
J = |x(t)| dt = = x T (t)x(t)dt
0 0
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
2
Ref: Computer-Controlled Systems:Theory and Design, Karl J. Astrom, Bjorn Wittenmark,
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
h ZNh
x(t) i
Q1C Q12C
TE
OF
TECHNO
LO
GY
ITU
IAN INST
KH
T T
ARAGPUR
=E [x (t) u (t)]Qc , Qc = (all are symmetric)
IND
T
0
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
▶ The objective is to design proper optimal control signals that minimize this loss
function .
h ZNh
x(t) i
T T
J=E [x (t) u (t)]Qc
u(t)
0
x(t)
▶ Notice that, J is a parabolic function w.r.t .
u(t)
▶ Hence there will be a global minima which we intend to find as part of this optimal
control problem.
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
IND
kh kh
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
(k+1)h
Z
Q2 = (Γ T (s, kh)Q1C Γ (s, kh) + 2Γ T (s, kh)Q12C + Q2C )ds
kh
Since u(t) is constant over t ∈ [kh, (k + 1)h)
h N−1
X
x(kh)
x(Nh) i
T T T T
J=E [x (kh) u (kh)]Q + [x (Nh) u (Nh)]Q0
u(kh) u(Nh)
k=0
Q1 Q12
where, Q = T
Q12 Q2
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Section 3
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Safety as Invariance
Consider a harmonic oscillator with
continuous-time
dynamical system equation
0 −1
ẋ = x
1 0
• The domain: D = (x1 ≥ 0) ∧ (x2 ≥ 0) ∈ R2 ,
• The initial state-space:
X0 = (1 ≤ x1 ≤ 2) ∧ (x2 = 0),
• The unsafe region:
U = (x1 ≤ 2) ∧ (x2 ≤ 2) ∧ (x1 + x2 ≥ 3).
• Notice that to guarantee the system safety
the system design must have the safe set
S = D \ U as invariant TE
OF
TECHNO
LO
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Safety as Invariance
Consider the following Barrier certificate
candidate for this continuous-time
dynamical system
• The barrier function :
B(x1 , x2 ) = x12 + x22 − 4.3. Notice that,
▶ The zero level set of B separates safe
and unsafe operating regions of this
system.
▶ Also, the function is decreasing inside
the domain (and in initial region)
▶ Ḃ ≤ 0 ⇒ S is invariant i.e. the system TECHNO
OF LO
TE
is safe
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
3
Ref: Control barrier functions: Theory and applications, Ames, Aaron D. Ames, Samuel Coogan,
IND
19 5 1
Magnus Egerstedt, Gennaro Notomista, Koushil Sreenath, Paulo Tabuada, ECC 2019
yog, kms kOflm^
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
• A control strategy based on CLF that ensures exponential stability with γ decay rate is
∂V (x, u) ∂V (x, u)
Kclf (x) = {u ∈ Cu : f (x) + g (x)u ≤ −γV (x, u)}
∂x ∂x TE
OF
TECHNO
LO
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
4
set of x s.t. V (x) ≤ c
yog, kms kOflm^
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Understanding CLF
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
a
Note that −λB bounds the positive slope of B in the sublevel
set of B(0) and it gradually reduces as B approaches 0 TE
OF
TECHNO
LO
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
5
{x s.t. B(x) ≤ 0}
yog, kms kOflm^
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Note: Here δ is a slack variable introduced for relaxing the constraints. No such
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Example : ACC
Consider an an adaptive cruise control system with
continuous-time
dynamical
system equation
Ḋ v 0
= + u, m = 1650kg , g = 9.81m/s 2
v̇ − Fmr 1/m
| {z } | {z }
f (x) g (x)
u = wheel force Fw ∈ [−0.3mg , 0.3mg ], and rolling
resistence Fr = 0.1 + 5v + 0.25v 2 .
D2
▶ The unsafe region: U = {x ∈ D : D − 0.6g < 1.8v }
a
▶ Consider CLF V = (v − vd )2 desired speed
vd = 24m/s and a
Ref: "Control Barrier Function based
Quadratic Programs with Application
(14−v )2
▶ CBF B = + 1.8v − D toAdaptive Cruise Control" by Aaron D. Ames, TE
OF
TECHNO
LO
GY
ITU
6.54 Jessy W. Grizzle and Paulo Tabuada
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur
Introduction to Optimal Controller Design Linear Quadratic Regulator Optimal Safe Controller Design
Example : ACC
TECHNO
OF LO
TE
GY
ITU
IAN INST
KH
ARAGPUR
IND
19 5 1
Foundations of Cyber Physical Systems Soumyajit Dey, Associate Professor, CSE, IIT Kharagpur