Experiment 6 Autonomous Driving Modeling and Simulation

【Purpose】

  1. Understand Matlab/Simulink software environment, familiar with Simulink modeling steps;
  2. Understand the basic principles of vehicle motion control, learn simple vehicle motion control modeling and simulation;
  3. Understand the basic process of autonomous driving modeling and the application characteristics of typical ADAS system models.
  4. Understand the functions related to automatic driving, and understand the functions and uses of automatic driving functions.

【Experimental nature】

Confirmatory experiment.

【Experimental Requirements】

Matlab2020+ software.

【Experimental content】

  1. Operate Matlab software and learn to carry out Simulink graphical modeling.
  2. Debug the vehicle motion control model.
  3. Learn a typical ADAS system and analyze its functional module composition.
  4. Call the automatic driving function to simulate the automatic driving scene.

【Experimental steps】

1. Vehicle motion control modeling learning

(1) The opened vehicle longitudinal motion control model, as shown in the figure below:

 

Open the Simulink toolbox (namely "Library Browser"), find the graphic symbols in the model in the toolbox, and learn how to use the model library in the toolbox.

Run the above model, view and save the running results, select two screenshots of the running results and paste them in the area below.

Module (oscilloscope) name:   scope2          

       Module (oscilloscope) name:   scope3          

 

        2. Advanced driver assistance system ( ADAS ) modeling learning

  Expand the automatic driving toolbox, you can find that there are many cases that come with Matlab, choose one to open, and analyze its composition and execution process.

3. Autopilot scene practice

(1) Simulate a car moving on an S-shaped road

Enter the following command in the Matlab command line window, and complete the code comments (written by hand) in the right column of the table:

s=drivingScenario;

roadCenters=[-35,20,0;-20,-20,0;0,0,0;20,20,0;35,-20,0];

lm=[laneMarking('Solid','Color','w'); ...

laneMarking('Dashed','Color','y');...

laneMarking('Dashed','Color','y');...

laneMarking('Solid','Color','w')];

ls=lanespec(3,'Marking',lm);

road(s, roadCenters, 'Lanes', ls);

car=vehicle(s, 'ClassID',1,'Position',[-35,20,0]);

waypoints=[-35,20,0;-20,-20,0; 0,0,0;20,20,0; 35,-20,0];

speed=10;

trajectory(car, waypoints, speed);

plot(s);

while advance(s)

   lbdry=laneBoundaries(car);

end

%Define the driving scene

% set the road center

%Set lane markings

% set the lane specification

% Add roads to the driving scene

% Add stationary vehicles in the driving scene

% Add sports vehicles in the driving scene

%Set vehicle waypoint

% set speed

%Create vehicle track

%Draw the driving scene

% simulation loop starts

% show vehicle boundaries

% simulation ended

 

attitude:

ActorID: Actor ID

Position: participant position (unit m)

Velocity: speed (unit m/s)

Roll: roll angle (degrees)

Pitch: pitch angle (degrees)

Yaw: yaw angle (degrees)

AngularVelocity: angular velocity (degrees/s)

The running result is shown in the figure below:

 

(2) Simulate stationary vehicles and moving vehicles driving on the road.

Enter the following command in the Matlab command line window, and complete the code comments (written by hand) in the right column of the table:

s=drivingScenario;

roadCenters=[0,0; 10,0; 53,-20];

road(s, roadCenters, 'Lanes', lanespec(2));

stationaryCar=vehicle(s, 'Position',[25,-5.5,0], 'Yaw',-22);

passingCar=vehicle(s);

waypoints=[1,-1.5; 16.4,-2.5; 17.4,-2.8; 23.8,-2; 25,-2.5; 50,-16];

speed=5;

trajectory(passingCar, waypoints, speed);

plot(s, 'Waypoints', 'on');

rec=record(s);

rec(1).ActorPoses(2);

rec(end).ActorPoses(2);

ans

%while advance(s)

%   pause(0.01);

%end

%poses=actorPoses(s);

%定义驾驶场景

%设置道路中心

%在驾驶场景中添加道路

%在驾驶场景中添加静止车辆

%在驾驶场景中添加运动车辆

%设置车辆航路点

%设置车速

%创建车辆轨迹

%绘制驾驶场景

%运行场景并记录

%显示车辆模拟开始姿态

%显示车辆模拟结束姿态

%姿态结构

%仿真循环开始

%停顿时间

%仿真结束

%获取交通参与者姿态

姿态:

ActorID:参与者标识

Position:参与者位置(单位m)

Velocity:速度(单位m/s)

Roll:横滚角(度)

Pitch:俯仰角(度)

Yaw:偏航角(度)

AngularVelocity:角速度(度/s)

 

  运行结果如下图所

 

 

4、停车场路径规划

  1. 停车场停车路径规划(基于碰撞的路径规划)

Matlab安装目录中搜索 parkingLotCostmap.mat 文件所在路径,并将该目录在Matlab地址栏中打开(设为当前路径)

 

在Matlab命令行窗口输入以下命令,在表格右列补充完善代码注释(手工书写):

data = load('parkingLotCostmap.mat');

costmap = data.parkingLotCostmap;

figure;                                                          

plot(costmap);                                                                      

vehicleDims = vehicleDimensions(4.5, 1.7);                               

numCircles = 3;                                                                              

ccConfig = inflationCollisionChecker(vehicleDims, numCircles);

costmap.CollisionChecker = ccConfig;                                         

figure;                                                                                             

plot(costmap);                                                                               

startPose = [11, 10, 0];                                                                  

goalPose = [31.5, 17, 90];                                                             

planner = pathPlannerRRT(costmap);                                         

refPath = plan(planner, startPose, goalPose);                             

hold on;                                                                                          

plot(refPath);                                                                                 

%加载停车场文件

%下载车辆成本图

%设置图形窗口

%绘制车辆成本图

%设置车辆尺寸

%圆圈数

%检测碰撞

%重新配置成本图

%设置图形窗口

%绘制车辆成本图

%设置初始姿态

%设置目的姿态

%绘制车辆成本图

%设置初始姿态

%设置目的姿态

%创建路径规划器

%路径规划

%保存图形

%绘制路径规划

运行结果如下图所示:

 

  1. 驶出停车场路径规划(验证路径规划)

Matlab安装目录中搜索 parkingLotCostmap.mat 文件所在路径,并将该目录在Matlab地址栏中打开(设为当前路径)。

在Matlab命令行窗口输入以下命令,在表格右列补充完善代码注释(手工书写):

data = load('parkingLotCostmap.mat');  

costmap = data.parkingLotCostmap;

plot(costmap);        

startPose = [4,4,90];

goalPose = [70,35,0];

planner = pathPlannerRRT(costmap);

refPath = plan(planner, startPose, goalPose);

isPathValid = checkPathValidity(refPath,costmap);

transitionPoses = interpolate(refPath); 

hold on;                                              

plot(refPath,'DisplayName','Planned Path'); 

scatter(transitionPoses(:,1),transitionPoses(:,2),[],'filled',

'DisplayName','过渡姿态');

%加载停车场文件

%下载车辆成本图

%绘制车辆成本图

%设置初始姿态

%设置目的姿态

%创建路径规划器

%路径规划

%保存图形

%绘制路径规划

%绘制过渡姿态

运行结果如下图所示:

 

Guess you like

Origin blog.csdn.net/m0_59054762/article/details/130788216
Recommended