提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
文章: Distributed model predictive control for heterogeneous vehicle platoons under unidirectional topologies
作者: Zheng, Yang, Shengbo Eben Li, Keqiang Li, Francesco Borrelli, and J. Karl Hedrick.
Journal: IEEE Transactions on Control Systems Technology 25, no. 3 (2017): 899-910.
一、pandas是什么?
示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。
二、源码分析
1.初始参数设定
文章中设置一辆领航车与七辆跟随车,跟随车的参数在文件PlatoonParameter.mat
中。PlatoonParameter.mat
中包含时间长度(10)、采样间隔(Time_step=0.1
)、总步数(Num_step=100
)、异构车辆的数量(7)、各个车的内部参数(质量、车轮半径、惯性滞后常数、摩擦系数、传动效率、空气阻力、物理约束等)、重力加速度等。
载入PlatoonParameter.mat
:
clc;clear;close all;
load PlatoonParameter.mat % This set of parameters was used in the paper
领航车辆参数初始化,理想车距设定为20,参数为位置、速度、加速度:
% Leading vehicle
d = 20; % Desired spacing
a0 = zeros(Num_step,1);
v0 = zeros(Num_step,1);
x0 = zeros(Num_step,1);
跟随车辆初始化,参数为位置、速度、扭矩、理想扭矩以及性能指标和优化器停止标志:
%% Initial Virables
Postion = zeros(Num_step,Num_veh); % postion of each vehicle;
Velocity = zeros(Num_step,Num_veh); % velocity of each vehicle;
Torque = zeros(Num_step,Num_veh); % Braking or Tracking Torque of each vehicle;
U = zeros(Num_step,Num_veh); % Desired Braking or Tracking Torque of each vehicle;
Cost = zeros(Num_step,Num_veh); % Cost function
Exitflg = zeros(Num_step,Num_veh); % Stop flag - solvers
领航车辆按预期的速度行驶,跟随车辆初始情况设定:
% Transient process of leader, which is given in advance
v0(1) = 20;
a0(1/Tim_step+1:2/Tim_step) = 2;
for i = 2:Num_step
v0(i) = v0(i-1)+a0(i)*Tim_step;
x0(i) = x0(i-1)+v0(i)*Tim_step;
end
% Zero initial error for the followers
for i = 1:Num_veh
Postion(1,i) = x0(1)-i*d;
Velocity(1,i) = 20;
Torque(1,i) = (Mass(i)*g*f + Ca(i)*Velocity(1,i)^2)*R(i)/Eta;
end
2.算法流程
本文采用分布式预测控制算法,预测时域Np = 20
。对于每一步的滚动优化,基于上一时刻的预测进行当前的优化:
% Distributed MPC assumed state
Np = 20; % Predictive horizon
Pa = zeros(Np,Num_veh); % Assumed postion of each vehicle;
Va = zeros(Np,Num_veh); % Assumed velocity of each vehicle;
ua = zeros(Np,Num_veh); % Assumed Braking or Tracking Torque input of each vehicle;
Pa_next = zeros(Np+1,Num_veh); % 1(0): Assumed postion of each vehicle at the newt time step;
Va_next = zeros(Np+1,Num_veh); % Assumed velocity of each vehicle at the newt time step;
ua_next = zeros(Np+1,Num_veh); % Assumed Braking or Tracking Torque of each vehicle at the newt time step;
首个时刻初始化,第一个坐标代表时刻,第二个坐标代表车辆编号:
% Initialzie the assumed state for the first computation: constant speed
for i = 1:Num_veh
ua(:,i) = Torque(1,i);
Pa(1,i) = Postion(1,i); % The first point should be interpreted as k = 0 (current state)
Va(1,i) = Velocity(1,i);
Ta(1,i) = Torque(1,i);
for j = 1:Np
[Pa(j+1,i),Va(j+1,i),Ta(j+1,i)] = VehicleDynamic(ua(j,i),Tim_step,Pa(j,i),Va(j,i),Ta(j,i),Mass(i),R(i),g,f,Eta,Ca(i),Tao(i));
end
end
tol_opt = 1e-5;
options = optimset('Display','off','TolFun', tol_opt, 'MaxIter', 2000,...
'LargeScale', 'off', 'RelLineSrchBnd', [], 'RelLineSrchBndDuration', 1);
从第二个时刻开始,对每一步进行优化,程序中?
代表车辆编号:
Vehicle_Type = [Mass(?),R(?),g,f,Eta,Ca(?),Tao(?)]; % the vehicle parameters : Mass,R,g,f,Eta,Ca,Tao,
X0 = [Postion(i-1,?),Velocity(i-1,?),Torque(i-1,?)]; % the vehicle variable in the last time
Pd = zeros(Np+1,1); Vd = zeros(Np+1,1);
Xdes = [Pd,Vd];
Xa = [Pa(:,?),Va(:,?)];
Xnfa = [Pa(:,?) - d, Va(:,?)];
u0 = ua(:,?);
A = [];b = []; Aeq = []; beq = [];
lb = Torquebound(2,1)*ones(Np,1); ub = Torquebound(2,2)*ones(Np,1);
Pnp = Xnfa(end,1); Vnp = Xnfa(end,2);
Xend(i,?) = Pnp; Vend(i,?) = Vnp; Tnp = (Ca(?)*Vnp.^2 + Mass(?)*g*f)/Eta*R(?);
% MPC - subporblem for vehicle ?
[u, Cost(i,?), Exitflg(i,?), output] = fmincon(@(u) Costfunction( Np, Tim_step, X0 ,u, Vehicle_Type,Q,Xdes,R,F,Xa,G,Xnfa), ...
u0, A, b, Aeq, beq, lb, ub, @(u) Nonlinearconstraints(Np, Tim_step, X0, u, Vehicle_Type,Pnp,Vnp,Tnp),options);
将序列u
的第一个值作用到系统中,更新状态:
% state involves one step
U(i,?) = u(1);
[Postion(i,?),Velocity(i,?),Torque(i,?)] = VehicleDynamic(U(i,?),Tim_step,Postion(i-1,?),Velocity(i-1,?),Torque(i-1,?),Mass(?),R(?),g,f,Eta,Ca(?),Tao(?));
根据对优化问题求解得到的u
更新下个时刻的控制估计ua
,ua
前Np-1
个值对应于u
的后Np-1
个结果;对于ua
的最后一个元素由预期设定的方式决定,即与当前时刻的终端的最优速度
v
∗
(
N
p
)
v^*(Np)
v∗(Np)有关;得到ua
的控制序列之后,可以对下个时刻的Pa
和Va
的预测序列。
% Update assumed state
Temp = zeros(Np+1,3);
Temp(1,:) = [Postion(i,?),Velocity(i,?),Torque(i,?)];
ua(1:Np-1,?) = u(2:Np);
for j = 1:Np-1
[Temp(j+1,1),Temp(j+1,2),Temp(j+1,3)] = VehicleDynamic(ua(j,?),Tim_step,Temp(j,1),Temp(j,2),Temp(j,3),Mass(?),R(?),g,f,Eta,Ca(?),Tao(?));
end
ua(Np,?) = (Ca(?)*Temp(Np,2).^2 + Mass(?)*g*f)/Eta*R(?);
[Temp(Np+1,1),Temp(Np+1,2),Temp(Np+1,3)] = VehicleDynamic(ua(Np,?),Tim_step,Temp(Np,1),Temp(Np,2),Temp(Np,3),Mass(?),R(?),g,f,Eta,Ca(?),Tao(?));
Pa_next(:,2) = Temp(:,1);
Va_next(:,2) = Temp(:,2);
%% Update assumed data
Pa = Pa_next;
Va = Va_next;
其中,fmincon()
用于寻找非线性约束最小值,将序列u
的第一个值作用到系统中,更新状态;同时
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。