exportWaypointsPlan
Description
Examples
Plan Coverage Path for Defined Region
This example shows how to plan a coverage path for a region in local coordinates and compares the results of using the exhaustive solver with the results of using the minimum traversal solver.
Define the vertices for a coverage space.
area = [5 8.75; 5 27.5; 17.5 22.5; 25 31.25; 35 31.25; 30 20; 15 6.25];
Because vertices define a concave polygon and the coverage planner requires convex polygons, decompose the polygon into convex polygons. Then create a coverage space with the polygons from decomposition.
polygons = coverageDecomposition(area); cs = uavCoverageSpace(Polygons=polygons);
Define the takeoff and landing positions at [0 0 0]
and [32.25 37.25 0]
, respectively. Then show the coverage space and plot the takeoff and landing positions.
takeoff = [0 0 0]; landing = [32.25 37.25 0]; show(cs); exampleHelperPlotTakeoffLandingLegend(takeoff,landing)
Create a coverage planner with the exhaustive solver algorithm and another coverage planner with a minimum traversal solver algorithm. Because Polygon 2
is closer to the takeoff position, set the visiting sequence of the solver parameters such that we traverse Polygon 2
first.
cpeExh = uavCoveragePlanner(cs,Solver="Exhaustive"); cpMin = uavCoveragePlanner(cs,Solver="MinTraversal"); cpeExh.SolverParameters.VisitingSequence = [2 1]; cpMin.SolverParameters.VisitingSequence = [2 1];
Plan with both solver algorithms using the same takeoff and landing positions.
[wptsExh,solnExh] = plan(cpeExh,takeoff,landing); [wptsMin,solnMin] = plan(cpMin,takeoff,landing);
Show the planned path for both the exhaustive and the minimum traversal algorithms.
figure
show(cs);
title("Exhaustive Solver Algorithm")
exampleHelperPlotTakeoffLandingLegend(takeoff,landing,wptsExh)
figure
show(cs);
title("Minimum Traversal Solver Algorithm")
exampleHelperPlotTakeoffLandingLegend(takeoff,landing,wptsMin)
Export the waypoints from the minimum traversal solver to a .waypoints
file with the reference frame set to north-east-down.
exportWaypointsPlan(cpMin,solnMin,"coveragepath.waypoints",ReferenceFrame="NED")
Input Arguments
planner
— Coverage path planner
uavCoveragePlanner
object
Coverage path planner, specified as a uavCoveragePlanner
object.
solninfo
— Solution information
structure
Solution plan, specified as a structure containing these fields:
VisitingSequence
— N-element row vector denoting the order of visitation of polygons, where N is the total number of polygons in the coverage space. For example,[2 1 3]
specifies that the UAV should visit polygon 2 first, polygon 1 second, and polygon 3 last.SweepPattern
— N-element row vector of integers denoting the sweep pattern for each polygon, where N is the total number of polygons in the coverage space. Each element is an integer in the range [1, 4] that indicates a sweep pattern:1
— Forward sweep pattern2
— Counter-clockwise sweep pattern3
— Reverse sweep pattern4
— Reverse counter-clockwise sweep pattern
For example,
[3 1 2]
specifies that the UAV should use the reverse sweep pattern for polygon 1, the forward sweep pattern for polygon 2, and the counter-clockwise sweep pattern for polygon 3.TransitionCost
— Euclidean distance cost for transitioning between polygons including takeoff and landing distance.Takeoff
— Takeoff location, specified as a three-element row vector in LLA format.Landing
— Takeoff location, specified as a three-element row vector in LLA format.
Use the plan
function
to get this structure.
filename
— File name to export information to
character vector | string scalar
File name to export information to, specified as a character vector or string
scalar. Specify the format of the file by ending the character vector or string scalar
with either ".txt"
or ".waypoints"
. For more
information, see MAVLink File
Formats.
Example: "waypointfile.txt"
Data Types: char
| string
frame
— Reference frame to export waypoints to
"ENU"
(default) | "NED"
Reference frame to export waypoints to, specified as either "ENU"
for east-north-up or "NED"
for north-east-down.
Data Types: char
| string
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Generating code containing the exportWaypointsPlan
requires you to enable dynamic memory allocation. For more information about enabling dynamic memory allocation, see Set Dynamic Memory Allocation Threshold (MATLAB Coder).
Deploying to embedded real time (ERT) targets is not supported.
Version History
Introduced in R2023aR2023b: Code generation support with dynamic memory allocation
exportWaypointsPlan
now supports code generation with dynamic memory allocation enabled. For more information about enabling dynamic memory allocation, see Set Dynamic Memory Allocation Threshold (MATLAB Coder).
Deploying to embedded real time (ERT) targets is not supported.
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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)