資源簡介
實現仿真兩輛車輛之間互相追逐,并以自我車輛為主體,跟蹤另外一輛車的相對位置。
代碼片段和文件信息
s?=?drivingScenario;
v1?=?vehicle(s‘Position‘[?6?0?0]‘Velocity‘[-3??0?0]‘Yaw‘?180);
v2?=?vehicle(s‘Position‘[?0?10?0]‘Velocity‘[?0?-4?0]‘Yaw‘-90);
plot(s);%p1
set(gcf‘Name‘‘Scenario?Plot‘)
xlim([-20?20]);
ylim([-20?20]);
ap?=?actorPoses(s);
v2TargetPoses?=?targetPoses(v2);
chasePlot(v2)%p2
set(gcf‘Name‘‘Chase?Plot‘)
v1.Yaw?=?135;
updatePlots(s);%p3
s?=?drivingScenario;
roadCenters?=?...
????[??0??40??49??50?100??50??49?40?-40?-49?-50?-100??-50??-49??-40????0
?????-50?-50?-50?-50???0??50??50?50??50??50??50????0??-50??-50??-50??-50
???????0???0?.45?.45?.45?.45?.45??0???0?.45?.45??.45??.45??.45????0????0]‘;
bankAngles?=?...
????[??0???0???9???9???9???9???9??0???0???9???9????9????9????9????0????0];
road(s?roadCenters?bankAngles?‘lanes‘?lanespec(2));
plot(s);%p4
rb?=?roadBoundaries(s);
figure
outerBoundary?=?rb{1};
innerBoundary?=?rb{2};
plot3(innerBoundary(:1)innerBoundary(:2)innerBoundary(:3)‘r‘?...
??????outerBoundary(:1)outerBoundary(:2)outerBoundary(:3)‘g‘)
axis?equal
egoCar?=?vehicle(s‘Position‘[80?-40?.45]‘Yaw‘30);
figure
rb?=?roadBoundaries(egoCar);
outerBoundary?=?rb{1};
innerBoundary?=?rb{2};
plot3(innerBoundary(:1)innerBoundary(:2)innerBoundary(:3)‘r‘?...
??????outerBoundary(:1)outerBoundary(:2)outerBoundary(:3)‘g‘)
axis?equal
?
chasePlot(egoCar);%p5
fastCar?=?vehicle(s);
d?=?2.7/2;
h?=?.45/2;
roadOffset?=?[?0??0??0??0??d??0??0??0??0??0??0?-d??0??0??0??0
??????????????-d?-d?-d?-d??0??d??d??d??d??d??d??0?-d?-d?-d?-d
???????????????0??0??h??h??h??h??h??0??0??h??h??h??h??h??0??0]‘;
rWayPoints?=?roadCenters?+?roadOffset;
lWayPoints?=?roadCenters?-?roadOffset;
%?loop?around?the?track?four?times
rWayPoints?=?[repmat(rWayPoints(1:end-1:)51);?rWay
- 上一篇:sumo與matlab的聯合開發
- 下一篇:gmd分解,即幾何均值分解
評論
共有 條評論