メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

plot

R2026a

ドライビング シナリオをプロット

説明

plot(scenario) は、ドライビング シナリオ scenario の真上から見た、正規直交パースペクティブで 3-D プロットを作成します。

例

plot(scenario,Name,Value) は、1 つ以上の名前と値のペアを使用してオプションを指定します。たとえば、これらのオプションを使用して、道路の中心とアクターのウェイポイントをプロット上に表示できます。

例

例

すべて折りたたむ

シナリオのワールド座標で指定された 8 の字形の道路を含むドライビング シナリオを作成します。シナリオのワールド座標を、自車座標系に変換します。

空のドライビング シナリオを作成します。

scenario = drivingScenario;

8 の字形の道路をシナリオに追加します。シナリオを表示します。

roadCenters = [0  0  1
             20 -20  1
             20  20  1
            -20 -20  1
            -20  20  1
              0   0  1];

roadWidth = 3;
bankAngle = [0 15 15 -15 -15 0];
road(scenario,roadCenters,roadWidth,bankAngle);
plot(scenario)

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 4 objects of type patch, line.

自車をシナリオに追加します。車両をワールド座標 (20, -20) に配置して、向きを -15 度のヨー角に設定します。

ego = actor(scenario,'ClassID',1,'Position',[20 -20 0],'Yaw',-15);
Warning: Class ID 1 is not supported for an actor. The drivingScenario object created a vehicle instead. ClassID of actor must be one of these values: 3 (Bicycle), 4 (Pedestrian), 5 (Jersey Barrier), or 6 (Guardrail).

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 5 objects of type patch, line.

関数 roadBoundaries を使用して、道路の境界を自車座標で取得します。自車を入力引数として指定します。

rbEgo1 = roadBoundaries(ego);

結果を鳥瞰図プロット上に表示します。

bep = birdsEyePlot;
lbp = laneBoundaryPlotter(bep,'DisplayName','Road');
plotLaneBoundary(lbp,rbEgo1)

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains an object of type line. This object represents Road.

関数 roadBoundaries を使用して、道路の境界をワールド座標で取得します。シナリオを入力引数として指定します。

rbScenario = roadBoundaries(scenario);

関数 driving.scenario.roadBoundariesToEgo を使用して、道路の境界を自車座標で取得します。

rbEgo2 = driving.scenario.roadBoundariesToEgo(rbScenario,ego);

道路の境界を鳥瞰図プロット上に表示します。

bep = birdsEyePlot;
lbp = laneBoundaryPlotter(bep,'DisplayName','Road boundaries');
plotLaneBoundary(lbp,{rbEgo2})

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains an object of type line. This object represents Road boundaries.

1 つの曲線道路、2 つの直線道路、2 つのアクター (車と自転車) が含まれたドライビング シナリオを作成します。どちらのアクターも 60 秒間道路に沿って移動します。

ドライビング シナリオ オブジェクトを作成します。

scenario = drivingScenario('SampleTime',0.1','StopTime',60);

半径 800 メートルの円弧に従う道路中心点を使用して、曲線道路を作成します。円弧は 0 度から開始して 90 度で終了し、5 度のインクリメントでサンプリングされます。

angs = [0:5:90]';
R = 800;
roadcenters = R*[cosd(angs) sind(angs) zeros(size(angs))];
roadwidth = 10;
cr = road(scenario,roadcenters,roadwidth);

両端の道路中央点を使用して、既定の幅をもつ 2 本の直線道路を追加します。最初の直線道路の両エッジに障壁を追加します。

roadcenters = [700 0 0; 100 0 0];
sr1 = road(scenario,roadcenters);
barrier(scenario,sr1)
barrier(scenario,sr1,'RoadEdge','left')
roadcenters = [400 400 0; 0 0 0];
road(scenario,roadcenters);

道路の境界を取得します。

rbdry = roadBoundaries(scenario);

車と自転車をシナリオに追加します。1 つ目の直線道路の最初の位置に車を配置します。

car = vehicle(scenario,'ClassID',1,'Position',[700 0 0], ...
    'Length',3,'Width',2,'Height',1.6);

道路を進んだ先に自転車を配置します。

bicycle = actor(scenario,'ClassID',3,'Position',[706 376 0]', ...
    'Length',2,'Width',0.45,'Height',1.5);

シナリオをプロットします。

plot(scenario,'Centerline','on','RoadCenters','on');
title('Scenario');

Figure contains an axes object. The axes object with title Scenario, xlabel X (m), ylabel Y (m) contains 1221 objects of type patch, line.

アクターの姿勢とプロファイルを表示します。

allActorPoses = actorPoses(scenario)
allActorPoses=242×1 struct array with fields:
    ActorID
    Position
    Velocity
    Roll
    Pitch
    Yaw
    AngularVelocity

allActorProfiles = actorProfiles(scenario)
allActorProfiles=242×1 struct array with fields:
    ActorID
    ClassID
    Length
    Width
    Height
    OriginOffset
    MeshVertices
    MeshFaces
    RCSPattern
    RCSAzimuthAngles
    RCSElevationAngles

このシナリオには障壁があり、各障壁セグメントがアクターと見なされているため、関数 actorPoses および関数 actorProfiles は、すべての静止アクターと非静止アクターの姿勢を返します。車両や二輪車など非静止アクターの姿勢とプロファイルのみを取得するには、まず scenario.Actors.ActorID プロパティを使用して、それらの対応するアクター ID を取得します。

movableActorIDs = [scenario.Actors.ActorID];

次に、それらの ID を使用して、非静止アクターの姿勢とプロファイルのみをフィルター処理します。

movableActorPoseIndices = ismember([allActorPoses.ActorID],movableActorIDs);

movableActorPoses = allActorPoses(movableActorPoseIndices)
movableActorPoses=2×1 struct array with fields:
    ActorID
    Position
    Velocity
    Roll
    Pitch
    Yaw
    AngularVelocity

movableActorProfiles = allActorProfiles(movableActorPoseIndices)
movableActorProfiles=2×1 struct array with fields:
    ActorID
    ClassID
    Length
    Width
    Height
    OriginOffset
    MeshVertices
    MeshFaces
    RCSPattern
    RCSAzimuthAngles
    RCSElevationAngles

R2024b 以降

ドライビング シナリオ オブジェクトを作成します。

scenario1 = drivingScenario(StopTime=1.25);

ドライビング シナリオに道路と車線のセグメントを追加します。

laneSpecification = lanespec(2,Width=5);
roadCenters = [27 24 0; 
              27 -3 0;
              47 16 0];
road(scenario1,roadCenters,Lanes=laneSpecification);

車両のパラメーターをそのウェイポイントおよび相対速度値と共に指定します。

egoCar1 = vehicle(scenario1,ClassID=1,Position=[22 19 0], ...
    PlotColor=[0.494 0.184 0.556],Name="Car1",Length=10,FrontOverhang=1.8);
waypoints = [22 19 0; 
            19 13 0; 
            19 6 0; 
            20 2 0; 
            33 -6 0; 
            48 10 0];
speed = 25;

前車軸をステアリングの基準にして車両の軌跡を作成します。

trajectory(egoCar1,waypoints,speed,ReferenceSteerPosition="front-axle")

別のドライビング シナリオ オブジェクトを作成します。

scenario2 = drivingScenario(StopTime=1.25);

ドライビング シナリオに、前のドライビング シナリオに追加したものと同じ道路と車線のセグメントを追加します。

road(scenario2,roadCenters,Lanes=laneSpecification);

前のドライビング シナリオに追加したものと同じ車両のパラメーターを、そのウェイポイントおよび相対速度値と共に指定します。

egoCar2 = vehicle(scenario2,ClassID=1,Position=[22 19 0], ...
    PlotColor=[0.466 0.674 0.188],Name="Car2",Length=10,FrontOverhang=1.8);

既定の後車軸をステアリングの基準にして車両の軌跡を作成します。

trajectory(egoCar2,waypoints,speed)

シナリオのプロットとシミュレーションを行い、前車軸と後車軸の軌跡を表示します。最初のサブプロットに、前車軸のステアリングを基準にして作成される後車軸の破線の軌跡が含まれていることを観察します。

fig = figure(Visible="on"); % Ensure the figure is visible
axesWidth  = 0.35;          % Relative width of each axes
axesHeight = 0.8;           % Relative height of each axes
margin     = 0.1;           % Margin from left/right and between axes

% Calculate axes positions of each subplot for equal spacing
pos1 = [margin 0.1 axesWidth axesHeight];
pos2 = [1-(margin+axesWidth) 0.1 axesWidth axesHeight];

% Specify title to the first axes in the figure
ax1 = axes(fig,Position=pos1);
title(ax1,"Trajectory with Front-Axle Steering")

% Specify title to the second axes in the figure
ax2 = axes(fig,Position=pos2);
title(ax2,"Trajectory with Rear-Axle Steering")

% Plot and simulate the scenarios
plot(scenario1,Waypoints="on",RoadCenters="on",ShowRearAxle="on",Parent=ax1)
plot(scenario2,Waypoints="on",RoadCenters="on",ShowRearAxle="on",Parent=ax2)
while advance(scenario1) && advance(scenario2)
    pause(0.1)
end

Figure contains 2 axes objects. Axes object 1 with title Trajectory with Front-Axle Steering, xlabel X (m), ylabel Y (m) contains 10 objects of type patch, line, quiver. One or more of the lines displays its values using only markers Axes object 2 with title Trajectory with Rear-Axle Steering, xlabel X (m), ylabel Y (m) contains 7 objects of type patch, line. One or more of the lines displays its values using only markers

入力引数

すべて折りたたむ

ドライビング シナリオ。drivingScenario オブジェクトとして指定します。

名前と値の引数

すべて折りたたむ

オプションの引数のペアを Name1=Value1,...,NameN=ValueN として指定します。ここで、Name は引数名で、Value は対応する値です。名前と値の引数は他の引数の後に指定しなければなりませんが、ペアの順序は重要ではありません。

R2021a より前では、コンマを使用して名前と値をそれぞれ区切り、Name を引用符で囲みます。

例: plot(sc,'Centerline','on','RoadCenters','on') は、各道路セグメントのセンター ラインと道路の中心を表示します。

プロットの描画に使用する座標軸。'Parent' と Axes オブジェクトで構成されるコンマ区切りのペアとして指定します。Parent を指定しない場合は、新しい Figure が作成されます。

道路のセンター ラインを表示します。'Centerline' と 'off' または 'on' で構成されるコンマ区切りのペアとして指定します。センター ラインは各道路セグメントの中央に従います。交差点や道路の分岐などの領域では、センター ラインは不連続になります。

道路の中心を表示します。'RoadCenters' と 'off' または 'on' で構成されるコンマ区切りのペアとして指定します。道路の中心は、プロットに表示される道路を定義します。

アクターのウェイポイントを表示します。'Waypoints' と 'off' または 'on' で構成されるコンマ区切りのペアとして指定します。ウェイポイントはアクターの軌跡を定義します。

直方体の代わりにアクターのメッシュを表示します。'Meshes' と 'off' または 'on' で構成されるコンマ区切りのペアとして指定します。

周囲にインジケーターを描画するアクター。'ActorIndicators' と ActorID の整数ベクトルで構成されるコンマ区切りのペアとして指定します。ドライビング シナリオ プロットは、指定した ActorID 値をもつアクターの周囲に円を描画します。円はそれぞれ、囲んでいるアクターと同じ色になります。円はセンサーのカバレッジ領域ではありません。

この名前と値のペアを使用して、複数の車両を含むドライビング シナリオで自車を強調表示します。

駐車場のエッジ番号を表示します。'ParkingLotEdges' と 'off' または 'on' で構成されるコンマ区切りのペアとして指定します。エッジ番号の順序は、各駐車場で定義されている頂点の順序に基づきます。

R2024b 以降

後車軸の軌跡を表示します。"off" または "on" として指定します。

ShowRearAxle を "on" に設定すると、plot 関数は前車軸と後車軸の両方の軌跡を表示します。前車軸の軌跡は各ウェイポイントを通る実線で、後車軸の軌跡は各ウェイポイントにおける車両の進行方位を矢印で表す破線です。詳細については、前車軸のステアリングを使用した長い車両の軌跡の作成の例を参照してください。

メモ

名前と値の引数 ShowRearAxle を使用するには、前車軸のステアリングを使用した車両の軌跡がドライビング シナリオに含まれていなければなりません。

ヒント

  • 任意のプロットを回転するには、Figure ウィンドウで、[ビュー] 、 [カメラ ツール バー] を選択します。

バージョン履歴

R2017a で導入

すべて展開する