Overall of the MPC
模型預(yù)測(cè)控制(Model Predictive Control)指一類算法左权,周期性基于當(dāng)幀測(cè)量信息在線求解一個(gè)有限時(shí)間開環(huán)優(yōu)化問題,并將結(jié)果的前部分控制序列作用于被控對(duì)象褐墅。根據(jù)所用模型不同拆檬,分為動(dòng)態(tài)矩陣控制(DMC),模型算法控制(MAC)妥凳、廣義預(yù)測(cè)控制(GPC)竟贯。在智能駕駛方向,重點(diǎn)在于基于狀態(tài)空間模型的模型預(yù)測(cè)控制逝钥。
如下圖屑那,MPC控制器在智能駕駛的應(yīng)用
如下為Udacity對(duì)于Model、Cost Function艘款、Constraints的Setup
如何得到最優(yōu)解持际?
Udacity給出的方案是基于CppAD的ipopt控制器(第三方庫)進(jìn)行二次規(guī)劃求解最優(yōu)解。
Vehicel Models
Kinematic Models
Kinematic models are simplifications of dynamic models that ignore tire forces, gravity, and mass.
Dynamic Models
Dynamic models aim to embody the actual vehicle dynamics as closely as possible. They might encompass tire forces, longitudinal and lateral forces, inertia, gravity, air resistance, drag, mass, and the geometry of the vehicle.各State的解釋如下
關(guān)于CTE(車道偏離)和eψ(橫擺角偏離)的解釋如下:
More Studying:
Dynamic Model Forces
Tire Slip Angle滑移角: Alpha = arctan(wheel lateral velocity / wheel longitudinal velocity)
Tire Slip Ratio滑移率: s = Radius of Wheel * Angular Velocity / Longitudinal Velocity
Tire Models
Additional resources: Kinematic and Dynamic Vehicle Models for Autonomous Driving Control Design presents a comparison between a kinematic and dynamic model.
Cost Function
包括CTE(車道偏離)和eψ(橫擺角偏離)等哗咆。
我認(rèn)為實(shí)際應(yīng)用過程中蜘欲,可以根據(jù)規(guī)劃trajectory符合度和平順性等評(píng)估,包括車速偏離晌柬、碰撞cost姥份、縱向加速度、橫向加速度年碘、向心加速度等澈歉。
Constraints
包括Acceleration加速度和Yaw Rate橫擺角加速度的極限約束。
Length and Duration 預(yù)測(cè)Step數(shù)和步長(zhǎng)
MPC預(yù)測(cè)的control inputs [δ,a]僅限于一定范圍的時(shí)間盛泡,包括N = Number of Timesteps 和 dt = Timestep Duration闷祥。
期望N越大越好,dt越小越好。
Latency系統(tǒng)執(zhí)行延遲
In a real car, an actuation command won't execute instantly - there will be a delay as the command propagates through the system. A realistic delay might be on the order of 100 milliseconds.
This is a problem called "latency", and it's a difficult challenge for some controllers - like a PID controller - to overcome. But a Model Predictive Controller can adapt quite well because we can model this latency in the system.
最優(yōu)解求解器
以上闡述了智駕MPC應(yīng)用的整體思路和架構(gòu)凯砍。但是到算法層面箱硕,如何得到最優(yōu)解是最核心的。當(dāng)然對(duì)于工程應(yīng)用悟衩,可以選擇第三方最優(yōu)化求解器剧罩,當(dāng)前這是一個(gè)非線性規(guī)劃問題
Ipopt
關(guān)于Cppad::ipopt算法核心可見Interior Point OPTimizer 內(nèi)點(diǎn)法
Ipopt is the tool we'll be using to optimize the control inputs [δ1?,a1?,…,δN?1?,aN?1?]. It's able to find locally optimal values (non-linear problem!) while keeping the constraints set directly to the actuators and the constraints defined by the vehicle model. Ipopt requires we give it the jacobians and hessians directly - it does not compute them for us. Hence, we need to either manually compute them or have a library do this for us. Luckily, there is a library called CppAD which does exactly this.
CppAD
CppAD is a library we'll use for automatic differentiation. By using CppAD we don't have to manually compute derivatives, which is tedious and prone to error.
Given a C++ algorithm that computes function values, CppAD generates an algorithm that computes corresponding derivative values (of arbitrary order using either forward or reverse mode).
我把CppAD理解為基于Ipopt的應(yīng)用。
More Learning:
Use Ipopt to Solve a Nonlinear Programming Problem
Nonlinear Programming Using CppAD and Ipopt: Example and Test
IPOPT和CppAD簡(jiǎn)介
參考文獻(xiàn):
1.Udacity無人駕駛課程
2.https://blog.csdn.net/qq_42258099/article/details/95353986