Main Content

interpolate

Interpolate poses along path segment

Description

poses = interpolate(pathSeg) interpolates along the path segment at the transitions between motion types.

poses = interpolate(pathSeg,lengths) interpolates along the path segment at the specified lengths along the path. Transitions between motion types are always included.

example

[poses,directions] = interpolate(___) also returns the direction of motion along the path for each section as a vector of 1s (forward) and –1s (reverse) using the previous inputs.

Examples

collapse all

Create a dubinsConnection object.

dubConnObj = dubinsConnection;

Define start and goal poses as [x y theta] vectors.

startPose = [0 0 0];
goalPose = [1 1 pi];

Calculate a valid path segment to connect the poses.

[pathSegObj,pathCosts] = connect(dubConnObj,startPose,goalPose);

Show the generated path.

show(pathSegObj{1})

Figure contains an axes object. The axes object contains 12 objects of type line, scatter. These objects represent Path, Heading, Start Position, Goal Position.

Interpolate poses along the path. Get a pose every 0.2 meters, including the transitions between turns.

length = pathSegObj{1}.Length;
poses = interpolate(pathSegObj{1},0:0.2:length)
poses = 32×3

         0         0         0
    0.1987   -0.0199    6.0832
    0.3894   -0.0789    5.8832
    0.5646   -0.1747    5.6832
    0.7174   -0.3033    5.4832
    0.8309   -0.4436    5.3024
    0.8418   -0.4595    5.3216
    0.9718   -0.6110    5.5216
    1.1293   -0.7337    5.7216
    1.3081   -0.8226    5.9216
      ⋮

Use the quiver function to plot these poses.

quiver(poses(:,1),poses(:,2),cos(poses(:,3)),sin(poses(:,3)),0.5)

Figure contains an axes object. The axes object contains an object of type quiver.

Input Arguments

collapse all

Path segment, specified as a dubinsPathSegment or reedsSheppPathSegment object.

Lengths along path to interpolate at, specified as a positive numeric vector. For example, specify [0:0.1:pathSegObj{1}.Length] to interpolate at every 0.1 meters along the path. Transitions between motion types are always included.

Output Arguments

collapse all

This property is read-only.

Interpolated poses along the path segment, specified as an [x, y, Θ] matrix. Each row of the matrix corresponds to a different interpolated pose along the path.

x and y are in meters. Θ is in radians.

Directions of motion for each segment of the interpolated path, specified as a vector of 1s (forward) and –1s (reverse).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2019b