Specifications for plotting heading angle

Since R2023b

## Syntax

`````` spec = plannerLineSpec.heading``````
`````` spec = plannerLineSpec.heading(Name=Value)``````
``[spec,structData] = plannerLineSpec.heading(___)``

## Description

example

``` ``` spec = plannerLineSpec.heading``` specifies default color, line, and marker properties for plotting heading angle.```

example

``` ``` spec = plannerLineSpec.heading(Name=Value)``` specifies new values for the color, line, and marker properties by using one or more name-value arguments.```
``` `[spec,structData] = plannerLineSpec.heading(___)` returns the properties and their values as a structure using any combination of inputs from the previous syntaxes.```

## Examples

collapse all

Set the random number seed to ensure repeatability.

`rng(100,"twister")`

Load a probability occupancy grid into the MATLAB® workspace.

`load("exampleMaps.mat","simpleMap")`

Create an occupancy map from the input occupancy grid.

`map = occupancyMap(simpleMap);`

Define the lower and upper limits of the state space variables `x`, `y`, and `theta` from the occupancy map.

```x = map.XWorldLimits; y = map.YWorldLimits; theta = [-pi pi];```

Display the occupancy map.

```figure show(map) hold on```

Specify the start state and the goal state for path planning.

```start = [2 5 0]; goal = [22 22 0];```

Plot Start and Goal States

Use the `plannerLineSpec.start` and `plannerLineSpec.goal` functions to plot the start and goal states, respectively.

```plot(start(1),start(2),plannerLineSpec.start{:}) plot(goal(1),goal(2),plannerLineSpec.goal{:})```

Configure PRM Path Planner

Create a state space SE(2) object using the specified state space variables.

`stateSpace = stateSpaceSE2([x; y; theta]);`

Check the validity of the states in the input state space by using a state validator. Set the validation distance to 0.01.

```stateValidator = validatorOccupancyMap(stateSpace,Map=map); stateValidator.ValidationDistance = 0.01;```

Configure the PRM path planner.

`planner = plannerPRM(stateSpace,stateValidator);`

Find the generic states (or nodes) from the network graph.

```digraphObj = graphData(planner); nodes = table2array(digraphObj.Nodes);```

Find the search tree from the network graph.

```edges = table2array(digraphObj.Edges); edgeLine = []; for i = 1:size(edges,1) state1 = nodes(edges(i,1),:); state2 = nodes(edges(i,2),:); edgeLine = [edgeLine; state1(1:2); state2(1:2); NaN NaN]; end```

Plot Search Tree and Generic States

Use the `plannerLineSpec.tree` function to plot the search tree.

`plot(edgeLine(:,1),edgeLine(:,2),plannerLineSpec.tree{:})`

Use the `plannerLineSpec.state` function to plot the generic states. Set the size of the marker for plotting the generic states to 3.

```gstate = plannerLineSpec.state(MarkerSize=3); plot(nodes(:,1),nodes(:,2),gstate{:})```

Find Path Between Two States and Heading Angle

Compute the path between the start point and the goal point.

`[path,info] = plan(planner,start,goal);`

Compute the heading angle from the XY-points to the path.

```inpath=[path.States(:,1) path.States(:,2)]; heading = headingFromXY(inpath);```

Plot Computed Path and Heading Angle

Use the `plannerLineSpec.path` and `plannerLineSpec.heading` functions to plot the computed path and the heading angle, respectively. Modify the line color for plotting the heading angle to `cyan`.

```if info.IsPathFound plot(path.States(:,1),path.States(:,2),plannerLineSpec.path{:}) headingplot = plannerLineSpec.heading(Color="cyan"); quiver(path.States(:,1),path.States(:,2),cos(heading),sin(heading),0.2,headingplot{:}) else disp("Path not found") end legend(Position=[0.82 0.1 0.15 0.15])```

## Input Arguments

collapse all

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: `plannerLineSpec.heading(Color="Red")`

Line color, specified as one of these values:

• RGB triplet — Specify the intensities of the red, green, and blue components of the color as a three-element vector in the order `[R G B]`. Each intensity must be in the range [0, 1]. For example, you can specify a shade of pink as ```[1 0.5 0.8]```.

• Character vector or string scalar — Specify the hexadecimal color code, color name, or short name of the color.

For more information on the types of color values and how to specify them, see Specify Plot Colors.

Line style, specified as one of these values:

• `"-"` — For a solid line. This is the default.

• `"--"` — For a dashed line.

• `":"` — For a dotted line.

• `"-."` — For a dash-dotted line.

• `"none"` — For no line.

Line width, specified as a positive numeric scalar.

Marker symbol, specified as one of the values listed in this table.

MarkerDescriptionResulting Marker
`"o"` Circle

`"+"` Plus sign

`"*"` Asterisk

`"."` Point

`"x"` Cross

`"_"` Horizontal line

`"|"` Vertical line

`"square"` Square

`"diamond"` Diamond

`"^"` Upward-pointing triangle

`"v"` Downward-pointing triangle

`">"` Right-pointing triangle

`"<"` Left-pointing triangle

`"pentagram"` Pentagram

`"hexagram"` Hexagram

`"none"` No markersNot applicable

Marker size, specified as a positive numeric scalar.

Marker outline color, specified as one of these values:

• RGB triplet — Specify the intensities of the red, green, and blue components of the color as a three-element vector in the order `[R G B]`. Each intensity must be in the range [0, 1]. For example, you can specify a shade of pink as ```[1 0.5 0.8]```.

• Character vector or string scalar — Specify the hexadecimal color code, color name, or short name of the color.

For more information on the types of color values and how to specify them, see Specify Plot Colors.

Marker fill color, specified as one of these values:

• RGB triplet — Specify the intensities of the red, green, and blue components of the color as a three-element vector in the order `[R G B]`. Each intensity must be in the range [0, 1]. For example, you can specify a shade of pink as ```[1 0.5 0.8]```.

• Character vector or string scalar — Specify the hexadecimal color code, color name, or short name of the color.

For more information on the types of color values and how to specify them, see Specify Plot Colors.

Label to include in the legend, specified as a character vector or string scalar.

## Output Arguments

collapse all

Color, line, and marker specifications for plotting the heading angle, returned as a cell array of size 1-by-16.

Data Types: `cell`

Specifications for the plot, returned as a structure with fields `Color`, `LineStyle`, `LineWidth`, `Marker`, `MarkerSize`, `MarkerEdgecolor`, `MarkerFaceColor`, and `DisplayName`. Each field contains the value specified to the corresponding name-value argument.

Data Types: `struct`

## Version History

Introduced in R2023b