driving.Path
Planned vehicle path
Description
The driving.Path
object represents a vehicle path composed of
a sequence of path segments. These segments can be either driving.DubinsPathSegment
objects or driving.ReedsSheppPathSegment
objects and are stored in the PathSegments
property of driving.Path
.
To check the validity of the path against a vehicleCostmap
object, use the checkPathValidity
function. To interpolate poses along the length of the
path, use the interpolate
function.
Creation
To create a driving.Path
object, use the plan
function, specifying a pathPlannerRRT
object as input.
Properties
StartPose
— Initial pose of vehicle
[x, y, Θ]
vector
This property is read-only.
Initial pose of the vehicle, specified as an [x, y, Θ] vector. x and y are in world units, such as meters. Θ is in degrees.
GoalPose
— Goal pose of vehicle
[x, y, Θ]
vector
This property is read-only.
Goal pose of the vehicle, specified as an [x, y, Θ] vector. x and y are in world units, such as meters. Θ is in degrees.
PathSegments
— Segments along path
array of driving.DubinsPathSegment
objects | array of driving.ReedsSheppPathSegment
objects
This property is read-only.
Segments along the path, specified as an array of driving.DubinsPathSegment
objects or driving.ReedsSheppPathSegment
objects.
Length
— Length of path
positive real scalar
This property is read-only.
Length of the path, in world units, specified as a positive real scalar.
Object Functions
interpolate | Interpolate poses along planned vehicle path |
plot | Plot planned vehicle path |
Examples
Plan Path and Check Its Validity
Plan a vehicle path through a parking lot by using the optimal rapidly exploring random tree (RRT*) algorithm. Check that the path is valid, and then plot the transition poses along the path.
Load a costmap of a parking lot. Plot the costmap to see the parking lot and inflated areas for the vehicle to avoid.
data = load('parkingLotCostmap.mat');
costmap = data.parkingLotCostmap;
plot(costmap)
Define start and goal poses for the vehicle as [x, y, Θ] vectors. World units for the (x,y) locations are in meters. World units for the Θ orientation angles are in degrees.
startPose = [4, 4, 90]; % [meters, meters, degrees]
goalPose = [30, 13, 0];
Use a pathPlannerRRT
object to plan a path from the start pose to the goal pose.
planner = pathPlannerRRT(costmap); refPath = plan(planner,startPose,goalPose);
Check that the path is valid.
isPathValid = checkPathValidity(refPath,costmap)
isPathValid = logical
1
Interpolate the transition poses along the path.
transitionPoses = interpolate(refPath);
Plot the planned path and the transition poses on the costmap.
hold on plot(refPath,'DisplayName','Planned Path') scatter(transitionPoses(:,1),transitionPoses(:,2),[],'filled', ... 'DisplayName','Transition Poses') hold off
Plan Path and Interpolate Along Path
Plan a vehicle path through a parking lot by using the rapidly exploring random tree (RRT*) algorithm. Interpolate the poses of the vehicle at points along the path.
Load a costmap of a parking lot. Plot the costmap to see the parking lot and inflated areas for the vehicle to avoid.
data = load('parkingLotCostmap.mat');
costmap = data.parkingLotCostmap;
plot(costmap)
Define start and goal poses for the vehicle as [
x, y, Θ]
vectors. World units for the (x,y) locations are in meters. World units for the Θ orientation angles are in degrees.
startPose = [4, 4, 90]; % [meters, meters, degrees]
goalPose = [30, 13, 0];
Use a pathPlannerRRT
object to plan a path from the start pose to the goal pose.
planner = pathPlannerRRT(costmap); refPath = plan(planner,startPose,goalPose);
Interpolate the vehicle poses every 1 meter along the entire path.
lengths = 0 : 1 : refPath.Length; poses = interpolate(refPath,lengths);
Plot the interpolated poses on the costmap.
plot(costmap) hold on scatter(poses(:,1),poses(:,2),'DisplayName','Interpolated Poses') hold off
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2018aR2018b: connectingPoses
function and driving.Path
object properties KeyPoses
and NumSegments
are not recommended
The connectingPoses
function and the KeyPoses
and
NumSegments
properties of the driving.Path
object are not recommended. Instead, use the interpolate
function, which returns key poses, connecting poses,
transition poses, and direction changes. The KeyPoses
and
NumSegments
properties are no longer relevant.
KeyPoses
, NumSegments
, and
connectingPoses
will be removed in a future release.
In R2018a, connectingPoses
enabled you to obtain intermediate
poses either along the entire path or along the path segments that are between key
poses (as specified by KeyPoses
). Using the
interpolate
function, you can now obtain intermediate poses
at any specified point along the path. The interpolate
function
also provides transition poses at which changes in direction occur.
Remove all instances of KeyPoses
and
NumSegments
and replace all instances of
connectingPoses
with interpolate
.
The table shows typical usages of connectingPoses
and how
to update your code to use interpolate
instead. Here,
path
is a driving.Path
object returned
by pathPlannerRRT
.
Discouraged Usage | Recommended Replacement |
---|---|
poses = connectingPoses(path); |
poses = interpolate(path); |
segID = 1; posesSegment = connectingPoses(path,segID); |
step = 0.1; samples = 0 : step : path.PathSegments(1).Length; segmentPoses = interpolate(path,samples); |
See Also
Functions
Objects
Topics
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)