メインコンテンツ

plotTrajectory

軌跡プロッターで一連の軌跡をプロットする

説明

plotTrajectory(trajPlotter,trajCoordList) は、軌跡プロッターを介して、trajCoordList で指定された軌跡をシアター プロット上にプロットします。

すべて折りたたむ

3 つの軌跡の座標を定義します。

coordinates1 = [(1:10)' (2:11)' (11:-1:2)'];
coordinates2 = coordinates1 + 1;
coordinates3 = coordinates1 + 2;

theaterPlot オブジェクトを作成し、視点角度を設定して、trajectoryPlotter オブジェクトを作成します。

tp = theaterPlot;
view(14,50)
trajPlotter = trajectoryPlotter(tp,DisplayName="Trajectories");

3 つの軌跡をプロットします。

plotTrajectory(trajPlotter,{coordinates1,coordinates2,coordinates3})

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

この例では、軌跡上のプラットフォーム移動のアニメーションを作成する方法を説明します。

まず、trackingScenario を作成して軌跡のウェイポイントを追加します。

ts = trackingScenario;
height = 100;
d = 1;
wayPoints = [ ...
    -30   -25   height;
    -30    25-d height;
    -30+d  25   height;
    -10-d  25   height;
    -10    25-d height;
    -10   -25+d height;
    -10+d -25   height;
    10-d -25   height;
    10   -25+d height;
    10    25-d height;
    10+d  25   height;
    30-d  25   height;
    30    25-d height;
    30   -25+d height;
    30   -25   height];

各ウェイポイントの時間を指定します。

elapsedTime = linspace(0,10,size(wayPoints,1));

次に、トラッキング シナリオでプラットフォームを作成し、trajectory メソッドを使用して軌跡情報を追加します。

target = platform(ts);
traj = waypointTrajectory('Waypoints',wayPoints,'TimeOfArrival',elapsedTime);
target.Trajectory = traj;

トラッキング シナリオを記録してプラットフォームの軌跡を取得します。

r = record(ts);
pposes = [r(:).Poses];
pposition = vertcat(pposes.Position);

シアター プロットを作成して記録した軌跡を表示します。

tp = theaterPlot('XLim',[-40 40],'YLim',[-40 40]);
trajPlotter = trajectoryPlotter(tp,'DisplayName','Trajectory');
plotTrajectory(trajPlotter,{pposition})

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

platformPlotter を使用してアニメーション化します。

restart(ts);
trajPlotter = platformPlotter(tp,'DisplayName','Platform');

while advance(ts)
    p = pose(target,'true');
    plotPlatform(trajPlotter, p.Position);
    pause(0.1)
    
end

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Trajectory, Platform.

このアニメーションは、生成されたすべてのプロットをループ処理します。

入力引数

すべて折りたたむ

軌跡プロッター。trajectoryPlotter オブジェクトとして指定します。

表示する軌跡の座標。N 要素の cell 配列として指定します。ここで、N は軌跡の数です。軌跡を表す各 cell 要素には M 行 3 列の行列が含まれます。ここで、M は軌跡内の点の数です。異なる cell 内の行列には異なる行数を含めることができます。各行列の 1 列目、2 列目、3 列目は、対応する軌跡の x 座標、y 座標、および z 座標に対応します。

例: coordList = {[1 2 3; 4 5 6; 7,8,9];[4 2 1; 4 3 1];[4 4 4; 3 1 2; 9 9 9; 1 0 2]} は 3 つの異なる軌跡を指定します。

バージョン履歴

R2018b で導入