Linear Optimal Control How does this guy remain upright? Overview - - PowerPoint PPT Presentation

linear optimal control
SMART_READER_LITE
LIVE PREVIEW

Linear Optimal Control How does this guy remain upright? Overview - - PowerPoint PPT Presentation

Linear Optimal Control How does this guy remain upright? Overview 1. expressing a linear system in state space form 2. discrete time linear optimal control (LQR) 3. linearizing around an operating point 4. linear model predictive control 5.


slide-1
SLIDE 1

How does this guy remain upright?

Linear Optimal Control

slide-2
SLIDE 2

Overview

  • 1. expressing a linear system in state space form
  • 2. discrete time linear optimal control (LQR)
  • 3. linearizing around an operating point
  • 4. linear model predictive control
  • 5. LQR variants
  • 6. model predictive control for non-linear systems
slide-3
SLIDE 3

A simple system

k b m

Force exerted by the spring: Force exerted by the damper: Force exerted by the inertia of the mass:

slide-4
SLIDE 4

A simple system

k b m

Consider the motion of the mass

  • there are no other forces acting on the mass
  • therefore, the equation of motion is the sum of the forces:

This is called a linear system. Why?

slide-5
SLIDE 5

A simple system

k b

m

Let's express this in ''state space form'':

slide-6
SLIDE 6

A simple system

k b

m

Let's express this in ''state space form'':

slide-7
SLIDE 7

A simple system

k b

m

Let's express this in ''state space form'':

slide-8
SLIDE 8

A simple system

k b m

Let's express this in ''state space form'':

slide-9
SLIDE 9

A simple system

k b m

Let's express this in ''state space form'':

where

slide-10
SLIDE 10

A simple system

k b

m

Your finger

f

Suppose that you apply a force:

slide-11
SLIDE 11

A simple system

Suppose that you apply a force:

slide-12
SLIDE 12

A simple system

Suppose that you apply a force:

Canonical form for a linear system

slide-13
SLIDE 13

Continuous time vs discrete time

Continuous time Discrete time

slide-14
SLIDE 14

Continuous time vs discrete time

Continuous time Discrete time

What are A and B now?

slide-15
SLIDE 15

Continuous time vs discrete time

Continuous time Discrete time

What are A and B now?

slide-16
SLIDE 16

Simple system in discrete time

We want something in this form:

slide-17
SLIDE 17

Simple system in discrete time

We want something in this form:

slide-18
SLIDE 18

Simple system in discrete time

We want something in this form:

slide-19
SLIDE 19

Simple system in discrete time

We want something in this form:

slide-20
SLIDE 20

Continuous time vs discrete time

CT DT CT DT

slide-21
SLIDE 21

Exercise: write DT system dynamics

Viscous damping External force

slide-22
SLIDE 22

Exercise: write DT system dynamics

Something else...

slide-23
SLIDE 23

Overview

  • 1. expressing a linear system in state space form
  • 2. discrete time linear optimal control (LQR)
  • 3. linearizing around an operating point
  • 4. linear model predictive control
  • 5. LQR variants
  • 6. model predictive control for non-linear systems
slide-24
SLIDE 24

The linear control problem

Given:

System:

slide-25
SLIDE 25

The linear control problem

Given:

System: Cost function: where:

slide-26
SLIDE 26

The linear control problem

Given:

System: Cost function: where:

slide-27
SLIDE 27

The linear control problem

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

slide-28
SLIDE 28

The linear control problem

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

Important problem! How do we solve it?

slide-29
SLIDE 29

One solution: least squares

slide-30
SLIDE 30

One solution: least squares

slide-31
SLIDE 31

where

One solution: least squares

slide-32
SLIDE 32

where:

One solution: least squares

slide-33
SLIDE 33

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

One solution: least squares

slide-34
SLIDE 34

Given:

System: Cost function:

Calculate:

Initial state: U that minimizes J(X,U)

One solution: least squares

slide-35
SLIDE 35

Substitute X into J: Minimize by setting dJ/dU=0: Solve for U:

One solution: least squares

slide-36
SLIDE 36

Solve for optimal trajectory:

What can this do?

Start here End here at time=T

Image: van den Berg, 2015

slide-37
SLIDE 37

This is cool, but... – only works for finite horizon problems – doesn't account for noise – requires you to invert a big matrix

What can this do?

slide-38
SLIDE 38

Bellman optimality principle:

Let's try to solve this another way

Why is this equation true?

slide-39
SLIDE 39

Bellman optimality principle:

Let's try to solve this another way

Cost-to-go from state x at time t Cost-to-go from state (Ax+Bu) at time t+1 Cost incurred on this time step Cost incurred after this time step

slide-40
SLIDE 40

Let's try to solve this another way

For the sake of argument, suppose that the cost-to-go is always a quadratic function like this: where:

slide-41
SLIDE 41

Let's try to solve this another way

For the sake of argument, suppose that the cost-to-go is always a quadratic function like this: where: Then:

slide-42
SLIDE 42

Let's try to solve this another way

For the sake of argument, suppose that the cost-to-go is always a quadratic function like this: where: Then: How do we minimize this term? – take derivative and set it to zero.

slide-43
SLIDE 43

Let's try to solve this another way

How do we minimize this term? – take derivative and set it to zero.

  • ptimal control as a function of state

– but: it depends on P_{t+1}...

slide-44
SLIDE 44

Let's try to solve this another way

How do we minimize this term? – take derivative and set it to zero.

  • ptimal control as a function of state

– but: it depends on P_{t+1}... How solve for P_{t+1}???

slide-45
SLIDE 45

Let's try to solve this another way

Substitute u into V_t(x):

slide-46
SLIDE 46

Let's try to solve this another way

Substitute u into V_t(x):

slide-47
SLIDE 47

Let's try to solve this another way

Substitute u into V_t(x):

slide-48
SLIDE 48

Let's try to solve this another way

Substitute u into V_t(x):

slide-49
SLIDE 49

Let's try to solve this another way

Substitute u into V_t(x):

Dynamic Riccati Equation

slide-50
SLIDE 50

Example: planar double integrator

Air hockey table m=1 b=0.1 u=applied force Initial position

  • f the puck

Initial velocity Goal position Build the LQR controller for: Initial state: Time horizon: Cost fn:

slide-51
SLIDE 51

Example: planar double integrator

Air hockey table

Step 1: Calculate P backward from T: P_100, P_99, P_98, … , P_1 HOW?

slide-52
SLIDE 52

Example: planar double integrator

Air hockey table

Step 1: Calculate P backward from T: P_100, P_99, P_98, … , P_1

slide-53
SLIDE 53

Example: planar double integrator

Air hockey table

Step 1: Calculate P backward from T: P_100, P_99, P_98, … , P_1

slide-54
SLIDE 54

Example: planar double integrator

Air hockey table

Step 1: Calculate P backward from T: P_100, P_99, P_98, … , P_1

slide-55
SLIDE 55

Example: planar double integrator

Air hockey table

Step 1: Calculate P backward from T: P_100, P_99, P_98, … , P_1 ... ...

slide-56
SLIDE 56

Example: planar double integrator

Air hockey table

Step 2: Calculate u starting at t=1 and going forward to t=T-1 ... ...

slide-57
SLIDE 57

Example: planar double integrator

  • rigin

0.2 1 0.2

slide-58
SLIDE 58

Example: planar double integrator

u_x, u_y t

slide-59
SLIDE 59

Example: planar double integrator

slide-60
SLIDE 60

Example: planar double integrator

  • rigin
slide-61
SLIDE 61

Example: planar double integrator

  • rigin
slide-62
SLIDE 62

The infinite horizon case

So far: we have optimized cost over a fixed horizon, T. – optimal if you only have T time steps to do the job But, what if time doesn't end in T steps? One idea: – at each time step, assume that you always have T more time steps to go – this is called a receding horizon controller

slide-63
SLIDE 63

The infinite horizon case

Time step E l e m e n t s

  • f

P m a t r i x Notice that elt's of P stop changing (much) more than 20 or 30 time steps prior to horizon. – what does this imply about the infinite horizon case?

slide-64
SLIDE 64

The infinite horizon case

Time step E l e m e n t s

  • f

P m a t r i x Notice that elt's of P stop changing (much) more than 20 or 30 time steps prior to horizon. – what does this imply about the infinite horizon case? Converging toward fixed P

slide-65
SLIDE 65

The infinite horizon case

We can solve for the infinite horizon P exactly: Discrete Time Algebraic Riccati Equation

slide-66
SLIDE 66

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

So, what are we optimizing for now?

slide-67
SLIDE 67

So, how do we control this thing?

slide-68
SLIDE 68

Overview

  • 1. expressing a linear system in state space form
  • 2. discrete time linear optimal control (LQR)
  • 3. linearizing around an operating point
  • 4. linear model predictive control
  • 5. LQR variants
  • 6. model predictive control for non-linear systems
slide-69
SLIDE 69

Inverted pendulum

How do we get this system in the standard form:

?

EOM for pendulum:

slide-70
SLIDE 70

Inverted pendulum

EOM for pendulum: How do we get this system in the standard form:

slide-71
SLIDE 71

Inverted pendulum

EOM for pendulum: How do we get this system in the standard form:

!!!!!!!

slide-72
SLIDE 72

Linearizing a non-linear system

Idea: use first-order Taylor series expansion

  • riginal non-linear system
slide-73
SLIDE 73

Linearizing a non-linear system

Idea: use first-order Taylor series expansion

  • riginal non-linear system

first order term Linearize about

slide-74
SLIDE 74

Linearizing a non-linear system

Idea: use first-order Taylor series expansion

  • riginal non-linear system

first order term Linearize about We just linearized the system about x^*

slide-75
SLIDE 75

Linearizing a non-linear system

Suppose that x^* is a fixed point (or a steady state) of the system... Then:

slide-76
SLIDE 76

Linearizing a non-linear system

Suppose that x^* is a fixed point (or a steady state) of the system... Then: where Change of coordinates

slide-77
SLIDE 77

Example: pendulum

Unit length

slide-78
SLIDE 78

Example: pendulum

Unit length Linearize about:

slide-79
SLIDE 79

Example: pendulum

where

slide-80
SLIDE 80

Overview

  • 1. expressing a linear system in state space form
  • 2. discrete time linear optimal control (LQR)
  • 3. linearizing around an operating point
  • 4. linear model predictive control
  • 5. LQR variants
  • 6. model predictive control for non-linear systems
slide-81
SLIDE 81

Linear Model Predictive Control

Drawbacks to LQR: hard to encode constraints – suppose you have a hard goal constraint? – suppose you have piecewise linear state and action constraints? Answer: – solve control as a new optimization problem on every time step

slide-82
SLIDE 82

Linear Model Predictive Control

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

slide-83
SLIDE 83

Linear Model Predictive Control

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

We're going to solve this problem by expressing it explicitly as a quadratic program

slide-84
SLIDE 84

Quadratic program

Minimize: Subject to:

slide-85
SLIDE 85

Quadratic program

Minimize: Subject to: Constants are part of problem statement: x is the variable Problem: find the value of x that minimizes the objective subject to the constraints

slide-86
SLIDE 86

Quadratic program

Quadratic objective function Linear inequality constraints Linear equality constraints Minimize: Subject to:

slide-87
SLIDE 87

Quadratic program

Minimize: Subject to:

slide-88
SLIDE 88

Quadratic program

Minimize: Subject to:

Why?

slide-89
SLIDE 89

Quadratic program

Quadratic objective function

slide-90
SLIDE 90

Quadratic program

Quadratic objective function Inequality constraints

slide-91
SLIDE 91

Quadratic program

Quadratic objective function equality constraints

slide-92
SLIDE 92

QP versus Unconstrained Optimization

Minimize: Subject to: Original QP

slide-93
SLIDE 93

QP versus Unconstrained Optimization

Minimize: Unconstrained version of original QP Subject to:

slide-94
SLIDE 94

QP versus Unconstrained Optimization

Minimize: Unconstrained version of original QP How do we minimize this expression?

slide-95
SLIDE 95

QP versus Unconstrained Optimization

Minimize: Unconstrained version of original QP How do we minimize this expression?

slide-96
SLIDE 96

Linear Model Predictive Control

Minimize: Subject to:

slide-97
SLIDE 97

Linear Model Predictive Control

Minimize: Subject to:

What are the variables?

slide-98
SLIDE 98

Linear Model Predictive Control

Minimize: Subject to: What other constraints might we want add?

slide-99
SLIDE 99

Linear Model Predictive Control

Minimize: Subject to:

slide-100
SLIDE 100

Linear Model Predictive Control

Minimize: Subject to: Can't express these constraints in standard LQR

slide-101
SLIDE 101

Linear MPC Receding Horizon Control

Minimize: Subject to: Re-solve the quadratic program on each time step: – always plan another T time steps into the future

slide-102
SLIDE 102

Controllability

A system is controllable if it is possible to reach any goal state from any

  • ther start state in a finite period of time.

When is a linear system controllable? It's property of the system dynamics...

slide-103
SLIDE 103

Controllability

A system is controllable if it is possible to reach any goal state from any

  • ther start state in a finite period of time.

When is a linear system controllable? Remember this?

slide-104
SLIDE 104

Controllability

What property must this matrix have?

slide-105
SLIDE 105

Controllability

This submatrix must be full rank. – i.e. the rank must equal the dimension of the state space

slide-106
SLIDE 106

NonLinear Model Predictive Control

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

slide-107
SLIDE 107

NonLinear Model Predictive Control

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

slide-108
SLIDE 108

NonLinear Model Predictive Control

Given:

System: Cost function: where:

Calculate:

Initial state: U that minimizes J(X,U)

slide-109
SLIDE 109

Minimize: Subject to:

NonLinear Model Predictive Control

But, this is a nonlinear constraint – so how do we solve it now? Sequential quadratic programming – iterative numerical optimization for problems with non-convex

  • bjectives or constraints

– similar to Newton's method, but it incorporates constraints – on each step, linearize the constraints about the current iterate – implemented by FMINCON in matlab...