自动驾驶之十字路口
发布时间
阅读量:
阅读量
% 生成自动驾驶车辆的十字路口
% 完美擦肩而过
% copyright by liwei 2021年10月9日14:37:48
%% 添加十字道路
s = drivingScenario;
roadCenters = [0,0;100,0];
% 从坐标(0,0)到坐标(100,0)
roadWidth = 16;
road(s, roadCenters, roadWidth,'Lanes',lanespec(2));
% 创建双车道线
roadCenters = [50,-50;50,50];
road(s, roadCenters, roadWidth,'Lanes',lanespec(2));
% 创建双车道线
%% 添加车辆
v1_col = vehicle(s); % 纵向道路添加一辆车
waypoints_1_col = [0,-2;95,-2];% 中心点从(0,0)跑到(100,2)
speed = 30; % m/s
v2_col = vehicle(s); % 纵向再添加一辆车
waypoints_2_col = [15,-2;95,-2];
trajectory(v1_col,waypoints_1_col,speed);
trajectory(v2_col,waypoints_2_col,speed);
v1_row = vehicle(s); % 横向道路添加一辆车
waypoints_1_row = [48,38;48,-50];% 从(50,50)到(-50,50)
trajectory(v1_row,waypoints_1_row,speed);
v2_row = vehicle(s); % 横向道路再添加一辆车
waypoints_2_row = [48,53;48,-50];% 从(50,50)到(-50,50)
trajectory(v2_row,waypoints_2_row,speed);
%% 画图
plot(s)
while advance(s)
pause(0.04)
end
全部评论 (0)
还没有任何评论哟~
