目录
💥1 概述
📚2 运行结果
🎉3 参考文献
👨💻4 Matlab代码
💥1 概述
在本项目中,我们将自动驾驶挑战限制在一维范围内,自动驾驶者的目标是在避免碰撞的同时达到设定速度。
从结果中,我们得出结论,ACC是成功的。在ACC算法下工作的自我车辆适当地应用其最大加速度以避免被追尾。避免碰撞后,可以看到它正试图达到100m/s的设定点,但仅限于前车的位置。
总之,此ACC算法在选择最佳操作之前模拟所有操作的性能。在此模拟期间,算法假设其他代理将在接下来的 N 个时间步长中承诺其速度,并评估 N 个时间步的所有可能操作的状态。一旦通过简单的运动学方程计算出状态,就可以通过沿每个动作的轨迹应用成本函数来评估动作的性能。然后选择与最佳性能(即最低成本)相关的操作。
📚2 运行结果
主函数部分代码:
%% Adaptive Cruise Control System % Define the sample time, |Ts|, and simulation duration, |T|, in seconds close all;clear; Ts = 0.05; T = 50; %Define human driver's freq & amplitude of acccel HA=2; HF=0.4; %Radians %% % Specify the linear model for ego car. G_ego = tf(1,[0.5,1,0]); %% vref=21;L_RDis=7;L_Vel=26.8;R_RDis=20;R_Vel=30; % Specify the initial position and velocity for the two vehicles. x0_lead = 80; % initial position for lead car (m) v0_lead = 30; % initial velocity for lead car (m/s) x0_ego = 20; % initial position for ego car (m) v0_ego = 30; % initial velocity for ego car (m/s) x0_rear = 14; % initial position for rear car (m) v0_rear = 30; % initial velocity for rear car (m/s) %% % Specify the driver-set velocity in m/s. v_set = 100; %% Simulation Analysis % Run the simulation. sim('ACCsystem.slx') %% figure(1);subplot(211); yyaxis left plot(Lv);hold on plot(Ev); plot(Rv); grid on; title(['Vehicle Velocities: Vref= ',num2str(v_set) ]) xlabel('Time') ylabel('Velocity (m/s)') yyaxis right plot(Ea); hold off ylabel('Ego Acceleration') legend('Lead','Ego','Rear','Ego-Accerlation') %% Plot Relative Distances subplot(212) plot(Ep.Time,Lp.Data-Ep.Data);hold on yline(0); plot(Ep.Time,Rp.Data-Ep.Data); hold off title('Relative Lead/Rear Distances from Ego') xlabel('Time(s)') ylabel('Relative distance (m)') legend('Lead Vehicle Offset','Ego Vehicle','Rear Vehicle offset') %% Circular Plot %X,V,A X=[Lp.Data';Ep.Data';Rp.Data']; V=[Lv.Data';Ev.Data';Rv.Data']; A=[La.Data';Ea.Data';Ra.Data']; N=3; %Number of Players Nh = 2; %Number of Humans iH = [1,3]; %Position of Humans R = 1000; %Radius of Circle eV=0.05; K=T/Ts; %Video initialization myVideo = VideoWriter('ACC_Demo'); %open video file myVideo.FrameRate = 10; %can adjust this, 5 - 10 works well for me open(myVideo) dW = N*pi/(eV*N); XC = @( x ) R*sin( x/dW ); YC = @( x ) R*cos( x/dW ); COLORS = { [0 0.4470 0.7410], [0.8500 0.3250 0.0980], [0.9290 0.6940 0.1250],... [0.4940 0.1840 0.5560], [0.4660 0.6740 0.1880], [0.3010 0.7450 0.9330],... [0.6350 0.0780 0.1840] }; NAMES = {'Trajectories', 'Accelerations', 'Distance between Agents', 'Velocities'}; XLAB = {'','Time(s)','Time(s)','Time(s)'}; YLAB = {'','Acceleration (m/s^2)','Distance (m)','Velocity (m/s)'}; figure('Name','Animation','NumberTitle','off','WindowState','maximized') for k = 1:4 ax(k) = subplot(2,2,k); title( NAMES{k} ); xlabel( XLAB{k} ); ylabel( YLAB{k} ); hold on grid on grid minor end
🎉3 参考文献
[1]戴旭彬,孙涛,夏维.基于MPC的自适应巡航算法改进研究[J].机电工程,2018,35(06):644-648+657.
部分理论引用网络文献,若有侵权联系博主删除。