Main Content

interpolate

参照パス上の指定された弧の長さを内挿

R2020b 以降

説明

pathPoints = interpolate(refPath,arclengths) は、参照パス上の指定された弧の長さを内挿し、パス上の内挿点をグローバル座標で返します。

すべて折りたたむ

一連のウェイポイントから参照パスを生成します。

waypoints = [0 0; 50 20; 100 0; 150 10];
refPath = referencePathFrenet(waypoints);

この参照パスから trajectoryGeneratorFrenet オブジェクトを作成します。

connector = trajectoryGeneratorFrenet(refPath);

パスの原点と、パスに沿って 30 メートルのポイントとの間の 5 秒の軌跡を、フレネ状態として生成します。

initCartState = refPath.SegmentParameters(1,:);
initFrenetState = global2frenet(refPath,initCartState);
termFrenetState = initFrenetState + [30 zeros(1,5)];
frenetTraj = connect(connector,initFrenetState,termFrenetState,5);

この軌跡をグローバル状態に変換します。

globalTraj = frenet2global(refPath,frenetTraj.Trajectory);

この参照パスと軌跡を表示します。

show(refPath);
axis equal
hold on
plot(globalTraj(:,1),globalTraj(:,2),'b')

グローバル点を指定し、参照パス上の最近傍点を求めます。

globalPoints = waypoints(2:end,:) + [20 -50];
nearestPathPoint = closestPoint(refPath,globalPoints);

グローバル点と、参照パス上の最近傍点を表示します。

plot(globalPoints(:,1),globalPoints(:,2),'r*','MarkerSize',10)
plot(nearestPathPoint(:,1),nearestPathPoint(:,2),'b*','MarkerSize',10)

参照パスに沿った最初の 2 つの最近傍点の間の弧の長さを内挿します。

arclengths = linspace(nearestPathPoint(1,6),nearestPathPoint(2,6),10);
pathStates = interpolate(refPath,arclengths);

内挿されたパス上の点を表示します。

plot(pathStates(:,1),pathStates(:,2),'g')
legend(["Waypoints","Reference Path","Trajectory to 30m",...
        "Global Points","Closest Points","Interpolated Path Points"])

Figure contains an axes object. The axes object contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent Waypoints, Reference Path, Trajectory to 30m, Global Points, Closest Points, Interpolated Path Points.

入力引数

すべて折りたたむ

参照パス。referencePathFrenet オブジェクトとして指定します。

参照パスに沿った距離。N 要素ベクトルとして指定します。N は点をサンプリングする弧の長さの数です。各距離はメートル単位です。

出力引数

すべて折りたたむ

参照パス上の点。行の形式が [x y theta kappa dkappa s] である N 行 6 列の数値行列として返されます。ここで次のようになっています。

  • x y および theta — グローバル座標で表された SE(2) の状態 (x と y はメートル単位、theta はラジアン単位)

  • kappa — 曲率 (半径の逆数、m-1 単位)

  • dkappa — 弧の長さに対する曲率の微分 (m-2 単位)

  • s — 弧の長さ (パスの原点からパスに沿った距離、メートル単位)

N は参照パスに沿ってサンプリングされた点の数です。

拡張機能

C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。

バージョン履歴

R2020b で導入