32
Lecture 9: PID Control Professor Katie Driggs-Campbell March 2, 2021 ECE484: Principles of Safe Autonomy

Lecture 9: PID Control

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 9: PID Control

Lecture 9: PID ControlProfessor Katie Driggs-Campbell

March 2, 2021

ECE484: Principles of Safe Autonomy

Page 2: Lecture 9: PID Control

Administrivia β€’ Safety training information posted on discord

β€’ MP1 due this weekβ–ͺ Demo due Thursday

β–ͺ Report due Friday

β€’ Milestone report due Friday 3/19 by 5pmβ–ͺ Rubric posted tonight

Page 3: Lecture 9: PID Control

Today’s Plan

β€’ Review some properties of dynamical systems and differential equations

β€’ Take a look at PID controllers

β€’ Build up to waypoint following using the models discussed last week!

Page 4: Lecture 9: PID Control

Typical planning and control modulesβ€’ Global navigation and planner

β–ͺ Find paths from source to destination with static obstaclesβ–ͺ Algorithms: Graph search, Dijkstra, Sampling-based planningβ–ͺ Time scale: Minutesβ–ͺ Look ahead: Destinationβ–ͺ Output: reference center line, semantic commands

β€’ Local planner β–ͺ Dynamically feasible trajectory generationβ–ͺ Dynamic planning w.r.t. obstaclesβ–ͺ Time scales: 10 Hzβ–ͺ Look ahead: Secondsβ–ͺ Output: Waypoints, high-level actions, directions / velocities

β€’ Controllerβ–ͺ Waypoint follower using steering, throttleβ–ͺ Algorithms: PID control, MPC, Lyapunov-based controllerβ–ͺ Lateral/longitudinal controlβ–ͺ Time scale: 100 Hzβ–ͺ Look ahead: current stateβ–ͺ Output: low-level control actions

Page 5: Lecture 9: PID Control

Dynamical Systems Model

Describe behavior in terms of instantaneous laws:𝑑π‘₯ 𝑑

𝑑𝑑= ሢπ‘₯(𝑑) = 𝑓 π‘₯ 𝑑 , 𝑒 𝑑

where 𝑑 ∈ ℝ, π‘₯ 𝑑 ∈ ℝ𝑛, 𝑒 𝑑 ∈ β„π‘š, and 𝑓:ℝ𝑛 Γ— β„π‘š β†’ ℝ𝑛 gives the dynamics / transition function

Page 6: Lecture 9: PID Control

ሢπ‘₯2ሢπ‘₯1

= βˆ’1/4 βˆ’2/53 βˆ’1/4

π‘₯1π‘₯2

Ξ»1=βˆ’0.25βˆ’i1.10Ξ»2=βˆ’0.25+i1.10

ሢπ‘₯2ሢπ‘₯1

= 1/4 βˆ’2/53 βˆ’1/4

π‘₯1π‘₯2

Ξ»1=+i0.1066Ξ»2=-i0.1066

ሢπ‘₯2ሢπ‘₯1

= 1/2 βˆ’2/53 βˆ’1/4

π‘₯1π‘₯2

Ξ»1=0.125+i1.029Ξ»2=-0.125-i1.029

Examples ሢπ‘₯2ሢπ‘₯1

= βˆ’1/4 βˆ’2/53 βˆ’1/2

π‘₯1π‘₯2

Ξ»1=βˆ’0.375βˆ’i1.088Ξ»2=βˆ’0.375+i1.088

Page 7: Lecture 9: PID Control

Control Paradigm

Page 8: Lecture 9: PID Control

Error Dynamics

Page 9: Lecture 9: PID Control

Feedback Control

Page 10: Lecture 9: PID Control

PID Controllers

β€’ Proportional 𝑒 = π‘˜π‘π‘’

β€’ Integral 𝑒 = π‘˜π‘–βˆ« 𝑒 𝜏 π‘‘πœ

β€’ Derivative 𝑒 = π‘˜π‘‘ αˆΆπ‘’

π‘˜π‘ UE

π‘˜π‘–1

𝑠UE

π‘˜π‘‘π‘  UE

U

Page 11: Lecture 9: PID Control

Linear Error Dynamics and Stability

Page 12: Lecture 9: PID Control

Viewing as a Second Order System

β€’ The second order system is: αˆ·π‘’ + 𝑐1 αˆΆπ‘’ + 𝑐2𝑒 = 0

β€’ In standard form, we write:

αˆ·π‘’ 𝑑 + 2πœ‰πœ”π‘› αˆΆπ‘’ 𝑑 + πœ”π‘›2𝑒 𝑑 = 0

where πœ‰ is the damping ratio and πœ”π‘› is the natural frequency

β€’ The eigenvalues are given as:

πœ†1,2 = βˆ’πœ‰πœ”π‘› Β± πœ”π‘› πœ‰2 βˆ’ 1

β€’ Note that the system is stable iff πœ”π‘› and πœ‰ are positive

Page 13: Lecture 9: PID Control

Second Order Dynamics: Casesβ€’ Overdamped: 𝜁 > 1

β€’ Roots 𝑠1 and 𝑠2 are distinct

β€’ πœƒπ‘’ 𝑑 = 𝑐1𝑒𝑠1𝑑 + 𝑐2𝑒

𝑠2𝑑

β€’ Time constant is the less negative root

β€’ Critically damped: 𝜁 = 1β€’ Roots 𝑠1 and 𝑠2 are equal and real

β€’ πœƒπ‘’ 𝑑 = (𝑐1+𝑐2𝑑)π‘’βˆ’πœ”π‘›π‘‘

β€’ Time constant is given by 1/πœ”π‘›

β€’ Underdamped: 𝜁 < 1β€’ Roots are complex conjugates:

𝑠1,2 = βˆ’πœπœ”π‘› Β± π‘—πœ”π‘› 1 βˆ’ 𝜁2

β€’ πœƒπ‘’ 𝑑 = (𝑐1cosπœ”π‘‘π‘‘ + 𝑐2 sinπœ”π‘‘π‘‘)π‘’βˆ’πœπœ”π‘›π‘‘

Page 14: Lecture 9: PID Control

Simple Damped Spring System

π‘š ሷπ‘₯ + 𝑏 ሢπ‘₯ + π‘˜π‘₯ = 𝐹

ሷπ‘₯ +𝑏

π‘šαˆΆπ‘₯ +

π‘˜

π‘šπ‘₯ = 𝑒

ሷπ‘₯ + 2πœ‰πœ”0 ሢπ‘₯ + πœ”02π‘₯ = 𝑒

πœ‰ damping ratio

πœ”0 natural frequency

π‘š ሷπ‘₯ + 𝑏 ሢπ‘₯ + π‘˜π‘₯ = 𝑒

β„’ π‘š ሷπ‘₯ + 𝑏 ሢπ‘₯ + π‘˜π‘₯ =

π‘šπ‘ 2𝑋 𝑠 + 𝑏𝑠𝑋 𝑠 + π‘˜π‘‹ 𝑠

Transfer Function:𝑋 𝑠

π‘ˆ(𝑠)=

1

π‘šπ‘ 2 + 𝑏𝑠 + π‘˜

Poles:

𝑠 =βˆ’π‘ Β± 𝑏2 βˆ’ 4π‘šπ‘˜

2π‘š

Page 15: Lecture 9: PID Control

Undamped Case: 𝑏 = 0 Overdamped Case: 𝑏2 βˆ’ 4π‘šπ‘˜ > 0

Underdamped Case: 𝑏2 βˆ’ 4π‘šπ‘˜ < 0 With Feedback Control

Sorry – no video!

Page 16: Lecture 9: PID Control

Break!

Page 17: Lecture 9: PID Control

Simple vehicle model: Dubin’s car

β€’ Key assumptionsβ–ͺ Front and rear wheel in the plane in a stationary

coordinate system

β–ͺ Steering input, front wheel steering angle 𝛿

β–ͺ No slip: wheels move only in the direction of the plane they reside in

β€’ Zeroing out the accelerations perpendicular to the plane in which the wheels reside, we can derive simple equations

Reference: Paden, Brian, Michal Cap, Sze Zheng Yong, Dmitry S. Yershov, and Emilio Frazzoli. 2016. A survey of motion planning and control techniques for self-driving

urban vehicles. IEEE Transactions on Intelligent Vehicles 1 (1): 33–55.

Page 18: Lecture 9: PID Control

Dubin’s Model

Page 19: Lecture 9: PID Control

Path following control

‒ The path followed by a robot can be represented by a trajectory or path parameterized by time→ from a higher-level planner

β€’ Defines the desired instantaneous pose 𝑝 𝑑

𝑝 𝑑 = [π‘₯ 𝑑 , 𝑦 𝑑 , πœƒ 𝑑 ]

Page 20: Lecture 9: PID Control

Open-loop waypoint following

β€’ We can write an open-loop controller for a robot that is naturally controlled via angular velocity, such as a differential-drive robot:

π‘’πœ”,𝑂𝐿 𝑑 =𝑣 π‘‘πœ” 𝑑

=ሢπ‘₯ 𝑑 2 + αˆΆπ‘¦ 𝑑 2

αˆΆπœƒ 𝑑

β€’ We can write an open-loop controller for a robot with car-like steering:

π‘’πœ…,𝑂𝐿 𝑑 =𝑣 π‘‘πœ… 𝑑

=

ሢπ‘₯ 𝑑 2 + αˆΆπ‘¦ 𝑑 2

αˆΆπœƒ 𝑑

ሢπ‘₯ 𝑑 2 + αˆΆπ‘¦ 𝑑 2

Page 21: Lecture 9: PID Control

Path following control

‒ The path followed by a robot can be represented by a trajectory or path parameterized by time→ from a higher-level planner

β€’ Defines the desired instantaneous pose 𝑝 𝑑

PlantSensor Controller

Input/waypoint

Control𝑒(𝑑)

Output

Feedback

Noise Disturbance

𝑝 𝑑 = [π‘₯ 𝑑 , 𝑦 𝑑 , πœƒ 𝑑 ]

Page 22: Lecture 9: PID Control

Path following control

β€’ Desired instantaneous pose 𝑝 𝑑

β€’ How to define error between actual pose 𝑝𝐡 𝑑 and desired pose 𝑝 𝑑 in the form of 𝑦𝑑 𝑑 βˆ’ 𝑦(𝑑)?

𝑝 𝑑 = [π‘₯ 𝑑 , 𝑦 𝑑 , πœƒ 𝑑 ]

𝑝𝐡 𝑑 = [π‘₯𝐡 𝑑 , 𝑦𝐡 𝑑 , πœƒπ΅ 𝑑 ]

Page 23: Lecture 9: PID Control

Path following controlThe error vector measured vehicle coordinates

e 𝑑 = [𝛿𝑠 𝑑 , 𝛿𝑛 𝑑 , π›Ώπœƒ 𝑑 , 𝛿𝑣 𝑑 ]

[𝛿𝑠, 𝛿𝑛] define the coordinate errors in the vehicle’s reference frame: along track error and cross track error

β€’ Along track error: distance ahead or behind the target in the instantaneous direction of motion.

𝛿𝑠 = cos πœƒπ΅ 𝑑 π‘₯ 𝑑 βˆ’ π‘₯𝐡 𝑑 + 𝑠𝑖𝑛 πœƒπ΅ 𝑑 𝑦 𝑑 βˆ’ 𝑦𝐡 𝑑

β€’ Cross track error: portion of the position error orthogonal to the intended direction of motion

𝛿𝑛 = βˆ’sin πœƒπ΅ 𝑑 π‘₯ 𝑑 βˆ’ π‘₯𝐡 𝑑 + π‘π‘œπ‘  πœƒπ΅ 𝑑 𝑦 𝑑 βˆ’ 𝑦𝐡 𝑑

β€’ Heading error: difference between desired and actual orientation and directionπ›Ώπœƒ = πœƒ 𝑑 βˆ’ πœƒπ΅ 𝑑𝛿𝑣 = 𝑣 𝑑 βˆ’ 𝑣𝐡(𝑑)

β†’ Each of these errors match the form 𝑦𝑑 𝑑 βˆ’ 𝑦(𝑑)

𝑝 𝑑 = [π‘₯ 𝑑 , 𝑦 𝑑 , πœƒ 𝑑 , 𝑣(𝑑)]

𝑝𝐡 𝑑 = [π‘₯𝐡 𝑑 , 𝑦𝐡 𝑑 , πœƒπ΅ 𝑑 , 𝑣𝐡(𝑑)]

πœƒπ΅

𝛿𝑠

𝛿𝑛

π›Ώπœƒ

Page 24: Lecture 9: PID Control

A simple P-controller example

β€’ Given a simple system: αˆΆπ‘¦ 𝑑 = 𝑒 𝑑 + 𝑑 𝑑

β€’ Using proportional (P) controller:

𝑒 𝑑 = βˆ’πΎπ‘ƒπ‘’ 𝑑 = βˆ’πΎπ‘ƒ(𝑦 𝑑 βˆ’ 𝑦𝑑 𝑑 )

αˆΆπ‘¦ 𝑑 = βˆ’πΎπ‘ƒπ‘¦ 𝑑 + 𝐾𝑃𝑦𝑑 𝑑 + 𝑑 𝑑

β€’ Consider constant setpoint 𝑦0 and disturbance 𝑑𝑠𝑠

αˆΆπ‘¦ 𝑑 = βˆ’πΎπ‘ƒπ‘¦ 𝑑 + 𝐾𝑃𝑦0 + 𝑑𝑠𝑠

β€’ What is the steady state output? β–ͺ Set: βˆ’πΎπ‘ƒπ‘¦ 𝑑 + 𝐾𝑃𝑦0 + 𝑑𝑠𝑠 = 0

β–ͺ Solve for 𝑦𝑠𝑠: 𝑦 𝑑 =𝑑𝑠𝑠

𝐾𝑃+ 𝑦0

Page 25: Lecture 9: PID Control

A simple P-controller example

β€’ Given a simple system: αˆΆπ‘¦ 𝑑 = 𝑒 𝑑 + 𝑑 𝑑

β€’ Consider constant setpoint 𝑦0 and disturbance π‘‘π‘ π‘ αˆΆπ‘¦ 𝑑 = βˆ’πΎπ‘ƒπ‘¦ 𝑑 + 𝐾𝑃𝑦0 + 𝑑𝑠𝑠

β€’ Steady state output 𝑦𝑠𝑠 =𝑑𝑠𝑠

𝐾𝑃+ 𝑦0

β€’ Transient behavior:

𝑦 𝑑 = 𝑦0π‘’βˆ’π‘‘/𝑇 + 𝑦𝑠𝑠 1 βˆ’ π‘’βˆ’π‘‘/𝑇 , 𝑇 = 1/𝐾𝑃

β€’ To make steady state error small, we can increase 𝐾𝑃 at the expense of longer transients

Page 26: Lecture 9: PID Control

Control Law

Control input is given by 𝑒 = π‘Ž, 𝛿 ⊀

where π‘Ž is the acceleration and 𝛿 is the steering angle

𝑒 = 𝐾

π›Ώπ‘ π›Ώπ‘›π›Ώπœƒπ›Ώπ‘£

𝐾 =𝐾𝑠 0 0 𝐾𝑣0 𝐾𝑛 πΎπœƒ 0

PlantSensor Controller

𝑝 𝑑 = [π‘₯ 𝑑 , 𝑦 𝑑 , πœƒ 𝑑 ]

Control

𝑒 𝑑 =π‘Žπ›Ώ

Output

Feedback

Noise Disturbance

Page 27: Lecture 9: PID Control

Control Law

𝐾 =𝐾𝑠 0 0 𝐾𝑣0 𝐾𝑛 πΎπœƒ 0

The pure-pursuit controller produced by this gain matrix performs a PD-control. It uses a PD-controller to correct along-track error.

The control on curvature is also a PD-controller for cross-track error because π›Ώπœƒ is related to the derivative of 𝛿𝑛.

Page 28: Lecture 9: PID Control

Summary

β€’ Reviewed linear systems and stability of differential equations

β€’ Looked at PID controllers as a way to regulate systems using state feedback

‒ Derived a waypoint following error dynamics→This will be MP2! Tutorial on 3/11.

β€’ Next time: Advanced Control Topics!

Page 29: Lecture 9: PID Control

Extra Slides

Page 30: Lecture 9: PID Control

Hybrid system model

Nonlinear hybrid dynamics

Physical plant

𝑑π‘₯

𝑑𝑑= π‘“π‘šπ‘œπ‘‘π‘’ π‘₯, 𝑒

merge left𝑑π‘₯

𝑑𝑑= 𝑓𝑙𝑒𝑓𝑑(π‘₯, 𝑒)

cruise𝑑π‘₯

𝑑𝑑= π‘“π‘π‘Ÿπ‘ (π‘₯, 𝑒)

merge right𝑑π‘₯

𝑑𝑑= π‘“π‘Ÿπ‘–π‘”β„Žπ‘‘(π‘₯, 𝑒)

speed up𝑑π‘₯

𝑑𝑑= 𝑓𝑒𝑝(π‘₯, 𝑒)

slow down𝑑π‘₯

𝑑𝑑= π‘“π‘‘π‘œπ‘€π‘›(π‘₯, 𝑒)

Decision and control software

Interaction between computation and physics can lead to unexpected behaviors

Typical system models

Page 31: Lecture 9: PID Control

Run

Walk

Each of the modes of a walking robot are asymptotically stable

Is it possible to switch between them to make the system unstable?

Hybrid Instability: Switching between two stable linear models

Page 32: Lecture 9: PID Control

Run

Walk

Yes! By switching between them the system becomes unstable