Main Content

interpolate

伝播関数ステップ サイズに基づいてパスを内挿

R2021b 以降

説明

interpolate(pathObj) は、制御パス pathObjStatePropagator プロパティにある nav.StatePropagator オブジェクトの ControlStepSize プロパティに基づいてパスを評価し、すべての中間点を制御パスに追加します。

すべて折りたたむ

状態と状態伝播関数パラメーターの設定

三項マップ行列を読み込み、occupancyMap オブジェクトを作成します。

load("exampleMaps","ternaryMap")
map = occupancyMap(ternaryMap,10);

マップを使用して、二輪の運動学モデルの状態伝播関数を作成します。

propagator = mobileRobotPropagator(Environment=map);

マップのワールドの範囲に基づき、状態空間の状態の範囲を設定します。

propagator.StateSpace.StateBounds(1:2,:) = [map.XWorldLimits; 
                                            map.YWorldLimits];

パスの計画

状態伝播関数からパス プランナーを作成します。

planner = plannerControlRRT(propagator);

開始状態とゴール状態を指定します。

start = [10 15 0];
goal  = [40 30 0];

状態間のパスを計画します。結果を再現できるように、計画を行う前に乱数発生器をリセットします。

rng("default")
path = plan(planner,start,goal);

制御パスの総経過期間をチェックします。

pathDuration(path)
ans = 102.4000

伝播関数の制御ステップ サイズまでのパスを内挿します。

interpolate(path)

パスを可視化します。

figure
show(map)
hold on
plot(start(1),start(2),"rx")
plot(goal(1),goal(2),"go")
plot(path.States(:,1),path.States(:,2),"b")
hold off

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 4 objects of type image, line. One or more of the lines displays its values using only markers

リターン パスの計画

前のパス位置の終点から開始点に戻る 2 番目のパスを計画します。

path2 = plan(planner,path.States(end,:),start);

2 番目のパスの総経過期間をチェックします。

pathDuration(path2)
ans = 100.3000

パスを可視化します。

figure
show(map)
hold on
plot(start(1),start(2),"rx")
plot(goal(1),goal(2),"go")
plot(path2.States(:,1),path2.States(:,2),"m")
hold off

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 4 objects of type image, line. One or more of the lines displays its values using only markers

パスの組み合わせ

2 番目のパスから動作のシーケンスを抽出します。

states = path2.States(2:end,:);
controls = path2.Controls;
targets = path2.TargetStates;
durations = path2.Durations;

このシーケンスを最初のパスの最後に追加します。

append(path,states,controls,targets,durations)

元のパスに新しいセグメントを内挿します。

interpolate(path)

最後のパスの総経過期間をチェックします。

pathDuration(path)
ans = 102.4000

パスを可視化します。

figure
show(map)
hold on
plot(start(1),start(2),"rx")
plot(goal(1),goal(2),"go")
plot(path.States(:,1),path.States(:,2),"b")
hold off

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 4 objects of type image, line. One or more of the lines displays its values using only markers

入力引数

すべて折りたたむ

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

データ型: double

バージョン履歴

R2021b で導入