丰浩网站建设中心,济南装修公司口碑最好的是哪家,乐清建站公司,江苏交通厅门户网站建设工程使用编程创建驾驶场景。
1.使用Driving scenario Designer 交互方式创建驾驶场景
2.导出matalb function
3.修正这个函数#xff0c;创建原始场景的变体。
4.调用这个函数#xff0c;生成drivingScenario object。
5.在simulink中仿真#xff0c;导入这个objcet 创建原始场景的变体。
4.调用这个函数生成drivingScenario object。
5.在simulink中仿真导入这个objcet 使用Scenario Reader 模块 在APP中创建场景。
drivingScenarioDesigner(LeftTurnScenarioNoSensors.mat)
点击导出MATLAB Function 生成了下图的函数 function [scenario, egoVehicle] LeftTurnScenarioNoSensors()
% createDrivingScenario Returns the drivingScenario defined in the Designer% Generated by MATLAB(R) 9.13 (R2022b) and Automated Driving Toolbox 3.6 (R2022b).
% Generated on: 21-Aug-2023 22:30:51% Construct a drivingScenario object.构建结构体对象
scenario drivingScenario;% Add all road segments
roadCenters [150 24.2 0;134.3 24.7 0;54 24.2 0];
laneSpecification lanespec([2 2]);
road(scenario, roadCenters, Lanes, laneSpecification, Name, Road);roadCenters [105 75 0;105.2 54.5 0;105 -20 0];
laneSpecification lanespec([2 2]);
road(scenario, roadCenters, Lanes, laneSpecification, Name, Road1);% Add the ego vehicle
egoVehicle vehicle(scenario, ...ClassID, 1, ...Position, [56 19 0], ...% 初始位置Mesh, driving.scenario.carMesh, ...% 车的形状Name, egoVehicle);
waypoints [56 19 0;135 19 0];
speed 10;
smoothTrajectory(egoVehicle, waypoints, speed);% Add the non-ego actors
otherVehicle vehicle(scenario, ...ClassID, 1, ...Position, [103 73 0], ...Mesh, driving.scenario.carMesh, ...Name, otherVehicle);
waypoints [103 73 0;102.8 34.3 0;114.3 22.4 0;148.1 22.4 0];
speed [11;10;10;11];
yaw [-90;-90;0;0];
smoothTrajectory(otherVehicle, waypoints, speed, Yaw, yaw);
运行这个函数会返回道路场景、车以及车上传感器所采集的信息。
修改函数创建场景变体。
上边代码相当于给你个代码壳子你可以往里填充。一个常见的变体是测试主车以不同的速度行驶。在上边代码中ego车的车速是10 m/s。为了生成不同的速度你可以在上述代码中添加接口。
1添加输入变量。 2在平滑轨迹中替换了speed. (3)还可以考虑
修改路和车道的参数。修改轨迹或者车辆初始位置修改车辆参数。
4调用你修改的这个函数 可以看到确实是20m/s 没修改之前的场景 10m/sVS 修改之后的场景20m/s
主车跟左拐车没有相遇。 注意如果你的主车有传感器你要使用这个命令去打开app
drivingScenarioDesigner(scenario,sensors).
注意更改classId ,car是1truck是2。
在simulink中导入场景
使用Scenario Reader 模块。
关于Simulink中如何使用 可以通过一个简单的例子来学会。
首先输入Scenario Reader,依次选择 最后加个小wifi 炫酷的鸟瞰图。这个场景过于简单所以不炫酷。 回到lattice 首先运行的是这个函数。 首先看一下车道中心线 主车和五辆车
function [scenario, egoVehicle] drivingScenarioTrafficExample()
% createDrivingScenario Returns the drivingScenario defined in the Designer% Generated by MATLAB(R) 9.9 (R2020b) and Automated Driving Toolbox 3.2 (R2020b).
% Generated on: 28-Apr-2020 15:04:44% Construct a drivingScenario object.
scenario drivingScenario;% 创建一个drivingScenario对象% Add all road segments
roadCenters [0 50 0;150 50 0;300 75 0;310 75 0;400 0 0;300 -50 0;290 -50 0;0 -50 0;0 -50 0];
laneSpecification lanespec(4);% 四个车道
road(scenario, roadCenters, Lanes, laneSpecification, Name, Road);% Add the ego vehicle
egoVehicle vehicle(scenario, ...ClassID, 1, ...Position, [10.7 51.4 0], ...Name, Car);% Add the non-ego actors
car1 vehicle(scenario, ...ClassID, 1, ...Position, [34.7 49.3 0], ...Name, Car1);
waypoints [34.7 49.3 0;60.1 48.2 0;84.2 47.9 0;119 49.3 0;148.1 51.4 0;189.6 58.7 0;230.6 68 0;272.6 74.7 0;301.4 77.5 0;316.7 76.8 0;332.4 75.2 0;348.9 72.2 0;366.2 65.1 0;379.6 55.6 0];
speed [10;10;10;10;10;10;10;10;10;10;10;10;10;10];
trajectory(car1, waypoints, speed);car2 vehicle(scenario, ...ClassID, 1, ...Position, [17.6 46.7 0], ...Name, Car2);
waypoints [17.6 46.7 0;43.4 45.5 0;71.3 43.8 0;102.3 43.5 0;123.5 45.5 0;143.6 47.4 0;162.4 50 0;198.5 61 0;241.1 70.1 0;272.3 74.1 0;292 76.6 0;312.8 77.2 0;350.3 75.2 0;362.5 70.4 0;375.9 63.3 0;390.7 49.9 0;401.3 33 0];
speed [9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9];
trajectory(car2, waypoints, speed);car3 vehicle(scenario, ...ClassID, 1, ...Position, [62.6 51.9 0], ...Name, Car3);
waypoints [62.6 51.9 0;87.4 51.3 0;117.7 52.2 0;147.6 55 0;174.9 59.7 0;203.3 65.8 0;265 69.7 0;288.3 73.1 0;314.5 73.1 0;334.9 70.8 0;360 59.9 0];
speed [6;6;6;6;6;6;6;6;6;6;6];
trajectory(car3, waypoints, speed);car4 vehicle(scenario, ...ClassID, 1, ...Position, [101.7 41.1 0], ...Name, Car4);
waypoints [101.7 41.1 0;124.6 42 0;148.5 43.9 0;171.9 48.2 0;197.1 52.8 0;222.3 58.5 0;252.4 64.4 0;281.4 68.5 0;307.7 69.5 0;329.9 68.2 0;352.7 62.8 0];
speed [7;7;7;7;7;7;7;7;7;7;7];
trajectory(car4, waypoints, speed);car5 vehicle(scenario, ...ClassID, 1, ...Position, [251.3 75.6 0], ...Name, Car5);
waypoints [251.3 75.6 0;255.7 76.7 0];
speed [0.01;0.01];
trajectory(car5, waypoints, speed);
车辆的参数
carLen 4.7; % in meters carWidth 1.8; % in meters rearAxleRatio .25;
画出这个场景 构造参考路径
结构体referencePathFrenet。这个结构题可以给出沿着路径长度的状态。
找到匹配点提供坐标系转换。
waypoints [0 50; 150 50; 300 75; 310 75; 400 0; 300 -50; 290 -50; 0 -50]; % in meters refPath referencePathFrenet(waypoints);
这两个代码生成了这个结构体 这六列是什么x,y, 使用show函数show出来这里就不求甚解了。
ax show(refPath); axis(ax,equal); xlabel(X); ylabel(Y); 详细阅读 referencePathFrenet
给wayPoints (x,y)或者x,y,theta--》平滑修补成连续曲线。 查询路径上最接近全局状态的点插值坐标系转换‘ 全局状态是[x,y,theta,kappa,speed,accel]