Main Content

interpolate

パスに沿って点を内挿

R2019b 以降

説明

interpolate(path,numStates) は、いくつかの状態をパスに挿入し、パス内ですべての点の分布が一様となるようにします。この関数では、パス内の既存の状態がすべて保持されます。numStates の値は、パス内の既存の状態の数以上でなければなりません。

すべて折りたたむ

Dubins 空間で、複数のウェイポイントに基づいて navPath オブジェクトを作成します。

dubinsSpace = stateSpaceDubins([0 25; 0 25; -pi pi])
dubinsSpace = 
  stateSpaceDubins with properties:

   SE2 Properties
                 Name: 'SE2 Dubins'
          StateBounds: [3x2 double]
    NumStateVariables: 3

   Dubins Vehicle Properties
     MinTurningRadius: 1

pathobj = navPath(dubinsSpace)
pathobj = 
  navPath with properties:

      StateSpace: [1x1 stateSpaceDubins]
          States: [0x3 double]
       NumStates: 0
    MaxNumStates: Inf

waypoints = [8 10 pi/2;
             7 14 pi/4;
             10 17 pi/2;
             10 10 -pi];
append(pathobj,waypoints)

ちょうど 250 個の点が含まれるよう、そのパスに内挿を行います。

interpolate(pathobj,250)

内挿されたパスと元のウェイポイントを可視化します。

figure
grid on
axis equal
hold on
plot(pathobj.States(:,1),pathobj.States(:,2),".b")
plot(waypoints(:,1),waypoints(:,2),"*r","MarkerSize",10)

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers

パスの長さを計算します。

len = pathLength(pathobj);
disp("Path length = " + num2str(len))
Path length = 19.4722

都市ブロックの 3 次元占有マップをワークスペースに読み込みます。セルを障害物なしとして見なすしきい値を指定します。

mapData = load("dMapCityBlock.mat");
omap = mapData.omap;
omap.FreeThreshold = 0.5;

占有マップをインフレートして、障害物の周囲の安全な動作のためにバッファー ゾーンを追加します。

inflate(omap,1)

状態変数の範囲を指定して SE(3) 状態空間オブジェクトを作成します。

ss = stateSpaceSE3([0 220;0 220;0 100;inf inf;inf inf;inf inf;inf inf]);

SE(3) 状態空間で、複数のウェイポイントに基づいて navPath オブジェクトを作成します。

path = navPath(ss);
waypoints = [40 180 15 0.7 0.2 0 0.1;
             55 120 20 0.6 0.2 0 0.1;
             100 100 25 0.5 0.2 0 0.1;
             130 90 30 0.4 0 0.1 0.6;
             150 33 35 0.3 0 0.1 0.6];
append(path,waypoints)

ちょうど 250 個の点が含まれるよう、そのパスに内挿を行います。

interpolate(path,250)

内挿されたパスと元のウェイポイントを可視化します。

show(omap)
axis equal
view([-10 55])
hold on
% Start state
scatter3(waypoints(1,1),waypoints(1,2),waypoints(1,3),"g","filled")
% Goal state
scatter3(waypoints(end,1),waypoints(end,2),waypoints(end,3),"r","filled")
% Intermediate waypoints
scatter3(waypoints(2:end-1,1),waypoints(2:end-1,2), ...
         waypoints(2:end-1,3),"y","filled")
% Path
plot3(path.States(:,1),path.States(:,2),path.States(:,3), ...
      "r-",LineWidth=2)

Figure contains an axes object. The axes object with title Occupancy Map, xlabel X [meters], ylabel Y [meters] contains 5 objects of type patch, scatter, line.

パスの長さを計算します。

len = pathLength(path);
disp("Path length = " + num2str(len))
Path length = 204.1797

入力引数

すべて折りたたむ

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

パスに挿入される状態の数。非負の整数として指定します。その値は、パス内の既存の状態の数以上でなければなりません。

データ型: double

拡張機能

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

バージョン履歴

R2019b で導入

参考

オブジェクト

関数