Vehicle Control
本文闡述了控制理論 (Control Theory) 的基本概念,包括開閉環控制 (Open Loop Control, Close Loop Control)、線性時不變系統 (Linear Time Invariant System) 及 PID 控制的概念。
Control Theory
- Control system
- 能夠影響整個系統未來 state 的機制
- Control theory
- 因應 output 來改變 input
Open Loop Control

例如汽車油門要根據汽車的速度變化 (e.g. 上下坡) 而改變

Close Loop Control
只有 input-output 很難去做修正,所以需要透過前一次 output 來修正

- Sensor
- 量測上一次的 output 結果,用來和 reference 比對
- Reference
- 用來比對和 output 的結果,計算出 error
- Controller
- 根據 error 改變 input
例如根據汽車當前的速度,來調整要加速或減速

Linear Time Invariant System
我們可以將 time domain 轉置成 frequency domain 重整一下 loop control

所有的運算和參數都以頻率來表達
- G = Input 運算結果
- H = Sensor 運算結果
- D = Controller 運算結果
- r = reference
- e = error
- y = output
我們可以得到 (誤差等於 reference 減去 sensor 所算的結果)

頻率中 D 到 G 的運算可以視為相乘,我們可以得到 y 等於 e 經過 D 和 G 兩個運算
接著經過一連串的運算
於是我們可以將 output (y) 看成是 reference (r) 經過 運算而來

變成一個 open loop control
Control Methods
PID Control
- PID 分別為三個詞的縮寫
- Proportional gain
- Integral gain
- Differential gain
Proportional gain
Controller 設定一個值來與前一個 error 相乘,得到下一次修改的 input,這個值就叫做 proportional gain。 在下圖,老皮根據終點距離來得到 error 並和 0.1 (proportional gain) 相乘:

- 當距離 100 時,走 10 m/s (100*0.1)
- 當距離 90 時,走 9 m/s (90*0.1)
- 當距離 0 時,就停止了 (0*0.1)

Problem
老皮若想往天空飛,那只用 proportional gain 勢必是無法完美達成的,因為最終會停止掉下來,又往上升上去。 假設老皮的螺旋槳轉速 200 rpm 可以對抗重力維持在空中:
不管設計多少的 gain (2, 5, 10, 100, ...) 都無法讓老皮到達並停留在天空上的終點,這個情況稱為 steady state error (y 會隨時間接近 r,但永遠存在 error)

Integral gain
我們可以加入一個 integrator 來解決 steady state error 造成的問題

新增的 integrator 會累積 error 的資訊來補充 proportional gain 不足的量,例如 error 變成 0 時,integrator 就提供 200 rpm 來讓老皮維持在高空。
Problem
Integrator 若沒有良好設計,會超過 200 rpm 讓老皮繼續往上飛。 而超過 reference 又產生了 negative error,讓 proportional gain 變負,老皮往下降

Differential gain
若能預測 error 變化量,就能預防 integral gain 忽高忽低的問題。

我們在 controller 加上第三個 derivative 元件。因為 error 是往下變小的,變化量就是 error 的斜率 (紅線);因為斜率是負的,所以 derivative 也產生一個負值,來和 integrator 抗衡。
Summary

PID control 可以寫成離散的形式:
其中的 分別就代表了 proportional, integral, differential gain 的參數。通常就是調整這三個參數,來完成一個好的 controller。