Discrete (Grid-based) planners

Planner

Plans in

Discrete/Continuous

Obstacle avoidance

Bug2

\(\mathbb{R}^2\)

discrete

yes

DistanceTransformPlanner

\(\mathbb{R}^2\)

discrete

yes

DstarPlanner

\(\mathbb{R}^2\)

discrete

yes

Distance transform planner

class roboticstoolbox.mobile.DistanceTransformPlanner(occgrid=None, metric='euclidean', **kwargs)[source]

Bases: PlannerBase

Distance transform path planner

Parameters:
  • occgrid (BinaryOccGrid or ndarray(h,w)) – occupancy grid

  • metric (str optional) – distane metric, one of: “euclidean” [default], “manhattan”

  • kwargs – common planner options, see PlannerBase

Feature

Capability

Plan

\(\mathbb{R}^2\), discrete

Obstacle avoidance

Yes, occupancy grid

Curvature

Discontinuous

Motion

Omnidirectional

Creates a planner that finds the path between two points in the 2D grid using omnidirectional motion and avoiding occupied cells. The path comprises a set of 4- or -way connected points in adjacent cells. Also known as the wavefront, grassfire or brushfire planning algorithm.

The map is described by a 2D occupancy occgrid whose elements are zero if traversable of nonzero if untraversable, ie. an obstacle.

The cells are assumed to be unit squares. Crossing the cell horizontally or vertically is a travel distance of 1, and for the Euclidean distance measure, the crossing the cell diagonally is a distance of \(\sqrt{2}\).

Example:

>>> from roboticstoolbox import DistanceTransformPlanner
>>> import numpy as np
>>> simplegrid = np.zeros((6, 6));
>>> simplegrid[2:5, 3:5] = 1
>>> dx = DistanceTransformPlanner(simplegrid, goal=(1, 1), distance="manhattan");
>>> dx.plan()
>>> path = dx.query(start=(5, 4))
>>> print(path.T)
[[5 5 5 4 3 2 1]
 [4 3 2 1 1 1 1]]

Warning

The distance planner is iterative and implemented in Python, will be slow for very large occupancy grids.

Author:

Peter Corke

Seealso:

plan() query() PlannerBase

property metric

Get the distance metric

Returns:

Get the metric, either “euclidean” or “manhattan”

Return type:

str

property distancemap

Get the distance map

Returns:

distance map

Return type:

ndarray(h,w)

The 2D array, the same size as the passed occupancy grid, has elements equal to nan if they contain an obstacle, otherwise the minimum obstacle-free distance to the goal using the particular distance metric.

plan(goal=None, animate=False, summary=False)[source]

Plan path using distance transform

Parameters:

goal (array_like(2), optional) – goal position \((x, y)\), defaults to previously set value

Compute the distance transform for all non-obstacle cells, which is the minimum obstacle-free distance to the goal using the particular distance metric.

Seealso:

query()

next(position)[source]

Find next point on the path

Parameters:

position (array_like(2)) – current robot position

Raises:

RuntimeError – no plan has been computed

Returns:

next robot position

Return type:

ndarray(2)

Return the robot position that is one step closer to the goal. Called by query() to find a path from start to goal.

Seealso:

plan() query()

plot_3d(path=None, ls=None)[source]

Plot path on 3D cost surface

Parameters:
  • path (ndarray(N,2), optional) – robot path, defaults to None

  • ls (dict, optional) – dictionary of Matplotlib linestyle options, defaults to None

Returns:

Matplotlib 3D axes

Return type:

Axes

Creates a 3D plot showing distance from the goal as a cost surface. Overlays the path if given.

Warning

The visualization is poor because of Matplotlib’s poor hidden line/surface handling.

property goal

Set/get goal point or configuration (superclass)

Getter:

Return goal pointor configuration

Return type:

ndarray(2) or ndarray(3)

Setter:

Set goal point or configuration

Param:

array_like(2) or array_like(3)

The goal is either a point \((x, y)\) or a configuration \((x, y, \theta)\).

Seealso:

goal()

isoccupied(p)

Test if point is occupied (superclass)

Parameters:

p (array_like(2)) – world coordinate (x, y)

Returns:

occupancy status of corresponding grid cell

Return type:

bool

The world coordinate is transformed and the status of the occupancy grid cell is returned. If the point lies outside the bounds of the occupancy grid return True (obstacle)

If there is no occupancy grid this function always returns False (free).

Seealso:

occgrid() validate_endpoint() BinaryOccGrid.isoccupied()

property occgrid

Occupancy grid

Returns:

occupancy grid used for planning

Return type:

OccGrid or subclass or None

Returns the occupancy grid that was optionally inflated at constructor time.

Seealso:

validate_endpoint() isoccupied()

plot(path=None, line=None, line_r=None, configspace=False, unwrap=True, direction=None, background=True, path_marker=None, path_marker_reverse=None, start_marker=None, goal_marker=None, start_vehicle=None, goal_vehicle=None, start=None, goal=None, ax=None, block=None, bgargs={}, **unused)

Plot vehicle path (superclass)

Parameters:
  • path ((N, 2) or ndarray(N, 3)) – path, defaults to None

  • direction (array_like(N), optional) – travel direction associated with each point on path, is either >0 or <0, defaults to None

  • line (sequence of dict of arguments for plot) – line style for forward motion, default is striped yellow on black

  • line_r (sequence of dict of arguments for plot) – line style for reverse motion, default is striped red on black

  • configspace (bool, optional) – plot the path in 3D configuration space, input must be 3xN. Start and goal style will be given by qstart_marker and qgoal_marker, defaults to False

  • unwrap (bool, optional) – for configuration space plot unwrap \(\theta\) so there are no discontinuities at \(\pm \pi\), defaults to True

  • background (bool, optional) – plot occupancy grid if present, default True

  • start_marker (dict, optional) – style for marking start point

  • goal_marker (dict, optional) – style for marking goal point

  • start_vehicle (dict) – style for vehicle animation object at start configuration

  • goal_vehicle (dict) – style for vehicle animation object at goal configuration

  • start (array_like(2) or array_like(3), optional) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set

  • goal (array_like(2) or array_like(3), optional) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set

  • bgargs (dict, optional) – arguments passed to plot_bg(), defaults to None

  • ax (matplotlib axes) – axes to plot into

  • block (bool, optional) – block after displaying the plot

Plots the start and goal location/pose if they are specified by start or goal or were set by the object constructor or plan or query method.

If the start and goal have length 2, planning in \(\mathbb{R}^2\), then markers are drawn using styles specified by start_marker and end_marker which are dicts using Matplotlib keywords, for example:

planner.plot(path, start=dict(marker='s', color='b'))

If the start and goal have length 3, planning in \(\SE{2}\), and configspace is False, then direction-indicating markers are used to display start and goal configuration. These are also given as dicts but have two items: 'shape' which is the shape of the polygonal marker and is either 'triangle' or 'car'. The second item 'args' is passed to base.plot_poly() and Matplotlib and could have values such as filled=True or color.

If configspace is False then a 3D plot is created and the start and goal are indicated by Matplotlib markers specified by the dicts start_marker and end_marker

Default values are provided for all markers:

  • the start point is a circle

  • the goal point is a star

  • the start vehicle style is a VehiclePolygon(shape='car') as an unfilled outline

  • the goal vehicle style is a VehiclePolygon(shape='car') as a transparent filled shape

If background is True then the background of the plot is either or both of:

  • the occupancy grid

  • the distance field of the planner

Additional arguments bgargs can be passed through to plot_bg()

If path is specified it has one column per point and either 2 or 3 rows:

  • 2 rows describes motion in the \(xy\)-plane and a 2D plot is created

  • 3 rows describes motion in the \(xy\theta\)-configuration space. By default only the \(xy\)-plane is plotted unless configspace is True in which case motion in \(xy\theta\)-configuration space is shown as a 3D plot.

If the planner supports bi-directional motion then the direction option gives the direction for each point on the path.

Forward motion segments are drawn using style information from line while reverse motion segments are drawn using style information from line_r. These are each a sequence of dicts of Matplotlib plot options which can draw an arbitrary number of lines on top of each other. The default:

line = (
        {color:'black', linewidth:4},
        {color:'yellow', linewidth:3, dashes:(5,5)}
    )

will draw a blackline of width 4 with a dashed yellow line of width 3 plotted on top, giving a line of alternating black and yellow dashes.

Seealso:

plot_bg() base.plot_poly()

plot_bg(distance=None, cmap='gray', ax=None, inflated=True, colorbar=True, block=None, **unused)

Plot background (superclass)

Parameters:
  • distance (ndarray(N,M), optional) – override distance field, defaults to None

  • cmap (str or Colormap, optional) – Specify a colormap for the distance field, defaults to ‘gray’

Displays the background which is either the occupancy grid or a distance field. The distance field encodes the distance of a point from the goal, small distance is dark, a large distance is bright.

If the planner has an occupancy grid then that will be displayed with:
  • free cells in white

  • occupied cells in red

  • inflated occupied cells in pink

If distance is provided, or the planner has a distancemap attribute the the distance field will be used as the background and obstacle cells (actual or inflated) will be shown in red. A colorbar is added.

query(start=None, goal=None, dtype=None, next=True, animate=False, movie=None)

Find a path from start to goal using planner (superclass)

Parameters:
  • start (array_like(), optional) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value specified to constructor

  • goal (array_like(), optional) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value specified to constructor

  • dtype (str, optional) – data type for point coordinates, defaults to None

  • next (bool, optional) – invoke next() method of class, defaults to True

  • animate (bool, optional) – show the vehicle path, defaults to False

Returns:

path from start to goal, one point \((x, y)\) or configuration \((x, y, \theta)\) per row

Return type:

ndarray(N,2) or ndarray(N,3)

Find a path from start to goal using a previously computed plan.

This is a generic method that works for any planner (\(\mathbb{R}^2\) or \(\SE{2}\)) that can incrementally determine the next point on the path. The method performs the following steps:

  • Validate start and goal

  • If animate, visualize the environment using plot()

  • Iterate on the class’s next() method until the goal is achieved, and if animate plot points.

Seealso:

next() plan()

property start

Set/get start point or configuration (superclass)

Getter:

Return start point or configuration

Return type:

ndarray(2) or ndarray(3)

Setter:

Set start point or configuration

Param:

array_like(2) or array_like(3)

The start is either a point \((x, y)\) or a configuration \((x, y, \theta)\).

Seealso:

goal()

validate_endpoint(p, dtype=None)

Validate start or goal point

Parameters:
  • p (array_like(2)) – the point

  • dtype (str, optional) – data type for point coordinates, defaults to None

Raises:

ValueError – point is inside obstacle

Returns:

point as a NumPy array of specified dtype

Return type:

ndarray(2)

The coordinate is tested to be a free cell in the occupancy grid.

Seealso:

isoccupied() occgrid()

property verbose

Get verbosity

Returns:

verbosity

Return type:

bool

If verbosity print more diagnostic messages to the planner’s message channel.

D* planner

class roboticstoolbox.mobile.DstarPlanner(costmap=None, **kwargs)[source]

Bases: PlannerBase

D* path planner

Parameters:
  • costmap (OccGrid or ndarray(w,h)) – traversability costmap

  • kwargs – common planner options, see PlannerBase

Feature

Capability

Plan

\(\mathbb{R}^2\), discrete

Obstacle avoidance

Yes, occupancy grid

Curvature

Discontinuous

Motion

Omnidirectional

Creates a planner that finds the minimum-cost path between two points in the plane using omnidirectional motion. The path comprises a set of 8-way connected points in adjacent cells.

The map is described by a 2D costmap whose elements indicate the cost of traversing that cell. The cost of diagonal traverse is \(\sqrt{2}\) the value of the cell. An infinite cost indicates an untraversable cell or obstacle.

Example:

>>> from roboticstoolbox import DstarPlanner
>>> import numpy as np
>>> costmap = np.ones((6, 6));
>>> costmap[2:5, 3:5] = 10
>>> ds = DstarPlanner(costmap, goal=(1, 1));
>>> ds.plan()
>>> path, status = ds.query(start=(5, 4))
>>> print(path.T)
[[5 5 5 4 3 2 1]
 [4 3 2 1 1 1 1]]
>>> print(status)
_DstarStatus(cost=np.float64(6.414213562373095))
Thanks:

based on D* grid planning included from Python Robotics

Seealso:

PlannerBase

plan(goal=None, animate=False, progress=True, summary=False)[source]

Plan D* path

Parameters:
  • goal (array_like(2), optional) – goal position \((x, y)\), defaults to previously set value

  • animate (bool, optional) – animate the planning algorithm iterations, defaults to False

  • progress (bool, optional) – show progress bar, defaults to True

Compute the minimum-cost obstacle-free distance to the goal from all points in the grid.

property nexpand

Number of node expansions

Returns:

number of expansions

Return type:

int

This number will increase during initial planning, and also if replanning is invoked during the query().

query(start, sensor=None, animate=False, verbose=False)[source]

Find path with replanning

Parameters:
  • start (array_like(2)) – start position \((x,y)\)

  • sensor (callable, optional) – sensor function, defaults to None

  • animate (bool, optional) – animate the motion of the robot, defaults to False

  • verbose (bool, optional) – display detailed diagnostic information about D* operations, defaults to False

Returns:

path from start to goal, one point \((x, y)\) per row

Return type:

ndarray(N,2)

If sensor is None then the plan determined by the plan phase is used unaltered.

If sensor is not None it must be callable, and is called at each step of the path with the current robot coordintes:

sensor((x, y))

and mimics the behaviour of a simple sensor onboard the robot which can dynamically change the costmap. The function return a list (0 or more) of 3-tuples (x, y, newcost) which are the coordinates of cells and their cost. If the cost has changed this will trigger D* incremental replanning. In this case the value returned by nexpand() will increase, according to the severity of the replanning.

Seealso:

plan()

__str__()

Compact representation of the planner

Returns:

pretty printed representation

Return type:

str

property goal

Set/get goal point or configuration (superclass)

Getter:

Return goal pointor configuration

Return type:

ndarray(2) or ndarray(3)

Setter:

Set goal point or configuration

Param:

array_like(2) or array_like(3)

The goal is either a point \((x, y)\) or a configuration \((x, y, \theta)\).

Seealso:

goal()

property occgrid

Occupancy grid

Returns:

occupancy grid used for planning

Return type:

OccGrid or subclass or None

Returns the occupancy grid that was optionally inflated at constructor time.

Seealso:

validate_endpoint() isoccupied()

plot(path=None, line=None, line_r=None, configspace=False, unwrap=True, direction=None, background=True, path_marker=None, path_marker_reverse=None, start_marker=None, goal_marker=None, start_vehicle=None, goal_vehicle=None, start=None, goal=None, ax=None, block=None, bgargs={}, **unused)

Plot vehicle path (superclass)

Parameters:
  • path ((N, 2) or ndarray(N, 3)) – path, defaults to None

  • direction (array_like(N), optional) – travel direction associated with each point on path, is either >0 or <0, defaults to None

  • line (sequence of dict of arguments for plot) – line style for forward motion, default is striped yellow on black

  • line_r (sequence of dict of arguments for plot) – line style for reverse motion, default is striped red on black

  • configspace (bool, optional) – plot the path in 3D configuration space, input must be 3xN. Start and goal style will be given by qstart_marker and qgoal_marker, defaults to False

  • unwrap (bool, optional) – for configuration space plot unwrap \(\theta\) so there are no discontinuities at \(\pm \pi\), defaults to True

  • background (bool, optional) – plot occupancy grid if present, default True

  • start_marker (dict, optional) – style for marking start point

  • goal_marker (dict, optional) – style for marking goal point

  • start_vehicle (dict) – style for vehicle animation object at start configuration

  • goal_vehicle (dict) – style for vehicle animation object at goal configuration

  • start (array_like(2) or array_like(3), optional) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set

  • goal (array_like(2) or array_like(3), optional) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set

  • bgargs (dict, optional) – arguments passed to plot_bg(), defaults to None

  • ax (matplotlib axes) – axes to plot into

  • block (bool, optional) – block after displaying the plot

Plots the start and goal location/pose if they are specified by start or goal or were set by the object constructor or plan or query method.

If the start and goal have length 2, planning in \(\mathbb{R}^2\), then markers are drawn using styles specified by start_marker and end_marker which are dicts using Matplotlib keywords, for example:

planner.plot(path, start=dict(marker='s', color='b'))

If the start and goal have length 3, planning in \(\SE{2}\), and configspace is False, then direction-indicating markers are used to display start and goal configuration. These are also given as dicts but have two items: 'shape' which is the shape of the polygonal marker and is either 'triangle' or 'car'. The second item 'args' is passed to base.plot_poly() and Matplotlib and could have values such as filled=True or color.

If configspace is False then a 3D plot is created and the start and goal are indicated by Matplotlib markers specified by the dicts start_marker and end_marker

Default values are provided for all markers:

  • the start point is a circle

  • the goal point is a star

  • the start vehicle style is a VehiclePolygon(shape='car') as an unfilled outline

  • the goal vehicle style is a VehiclePolygon(shape='car') as a transparent filled shape

If background is True then the background of the plot is either or both of:

  • the occupancy grid

  • the distance field of the planner

Additional arguments bgargs can be passed through to plot_bg()

If path is specified it has one column per point and either 2 or 3 rows:

  • 2 rows describes motion in the \(xy\)-plane and a 2D plot is created

  • 3 rows describes motion in the \(xy\theta\)-configuration space. By default only the \(xy\)-plane is plotted unless configspace is True in which case motion in \(xy\theta\)-configuration space is shown as a 3D plot.

If the planner supports bi-directional motion then the direction option gives the direction for each point on the path.

Forward motion segments are drawn using style information from line while reverse motion segments are drawn using style information from line_r. These are each a sequence of dicts of Matplotlib plot options which can draw an arbitrary number of lines on top of each other. The default:

line = (
        {color:'black', linewidth:4},
        {color:'yellow', linewidth:3, dashes:(5,5)}
    )

will draw a blackline of width 4 with a dashed yellow line of width 3 plotted on top, giving a line of alternating black and yellow dashes.

Seealso:

plot_bg() base.plot_poly()

plot_bg(distance=None, cmap='gray', ax=None, inflated=True, colorbar=True, block=None, **unused)

Plot background (superclass)

Parameters:
  • distance (ndarray(N,M), optional) – override distance field, defaults to None

  • cmap (str or Colormap, optional) – Specify a colormap for the distance field, defaults to ‘gray’

Displays the background which is either the occupancy grid or a distance field. The distance field encodes the distance of a point from the goal, small distance is dark, a large distance is bright.

If the planner has an occupancy grid then that will be displayed with:
  • free cells in white

  • occupied cells in red

  • inflated occupied cells in pink

If distance is provided, or the planner has a distancemap attribute the the distance field will be used as the background and obstacle cells (actual or inflated) will be shown in red. A colorbar is added.

property start

Set/get start point or configuration (superclass)

Getter:

Return start point or configuration

Return type:

ndarray(2) or ndarray(3)

Setter:

Set start point or configuration

Param:

array_like(2) or array_like(3)

The start is either a point \((x, y)\) or a configuration \((x, y, \theta)\).

Seealso:

goal()

validate_endpoint(p, dtype=None)

Validate start or goal point

Parameters:
  • p (array_like(2)) – the point

  • dtype (str, optional) – data type for point coordinates, defaults to None

Raises:

ValueError – point is inside obstacle

Returns:

point as a NumPy array of specified dtype

Return type:

ndarray(2)

The coordinate is tested to be a free cell in the occupancy grid.

Seealso:

isoccupied() occgrid()

property verbose

Get verbosity

Returns:

verbosity

Return type:

bool

If verbosity print more diagnostic messages to the planner’s message channel.

Lattice planner

class roboticstoolbox.mobile.LatticePlanner(costs=None, root=(0, 0, 0), **kwargs)[source]

Bases: PlannerBase

Lattice planner

Parameters:
  • costs (array_like(3), optional) – cost for straight, left-turn, right-turn, defaults to \((1, \pi/2, \pi/2)\)

  • root (array_like(3), optional) – configuration of root node, defaults to (0,0,0)

  • kwargs – arguments passed to PlannerBase constructor

Feature

Capability

Plan

\(\SE{2}\)

Obstacle avoidance

Yes, occupancy grid

Curvature

Discontinuous

Motion

Forwards only

The lattice planner incrementally builds a graph from the root vertex, at each iteration adding three edges to the graph:

code

direction

‘S’

straight ahead

‘L’

turn left

‘R’

turn right

If the configuration is already in the graph, the edge connects to that existing vertex. The vertex is named after the sequence of moves required to reach it from the root. This means, that any configuration, ie. \((x, y, \theta)\) can be reached by multiple paths and potentially have multiple names. The first name assigned to a vertex is permanent and is not overriden.

If an occupancy grid exists and the configuration is an obstacle, then the vertex is not added.

The path through the lattice is found using A* graph search, and costs changes the weighting for path costs at query time.

Example:

>>> from roboticstoolbox import LatticePlanner
>>> import numpy as np
>>> lattice = LatticePlanner();
>>> lattice.plan(iterations=6)
>>> path, status = lattice.query(start=(0, 0, 0), goal=(1, 2, np.pi/2))
>>> print(path.T)
[[0.     1.     1.    ]
 [0.     1.     2.    ]
 [0.     1.5708 1.5708]]
>>> print(status)
LatticeStatus(cost=2.5707963267948966, segments=['L', 'S'], edges=[Edge{[0] -- [0L], cost=1.571}, Edge{[0L] -- [0LS], cost=1}])
Seealso:

plan() query() PlannerBase

plan(iterations=None, verbose=False, summary=False)[source]

Create a lattice plan

Parameters:
  • iterations (int, optional) – number of iterations, defaults to None

  • verbose (bool, optional) – show frontier and added vertices/edges at each iteration, defaults to False

If an occupancy grid exists the if iterations is None the area of the grid will be completely filled.

Seealso:

query()

query(start, goal)[source]

Find a path through the lattice

Parameters:
  • start (array_like(3), optional) – start configuration \((x, y, \theta)\)

  • goal (array_like(3), optional) – goal configuration \((x, y, \theta)\)

Returns:

path and status

Return type:

ndarray(N,3), namedtuple

The returned status value has elements:

Element

Description

cost

path cost

segments

a list containing the type of each path segment as a single letter code: either “L”, “R” or “S” for left turn, right turn or straight line respectively.

edges

successive edges of the graph LatticeEdge type

Seealso:

plan()

plot(path=None, **kwargs)[source]

Plot vehicle path (superclass)

Parameters:
  • path ((N, 2) or ndarray(N, 3)) – path, defaults to None

  • direction (array_like(N), optional) – travel direction associated with each point on path, is either >0 or <0, defaults to None

  • line (sequence of dict of arguments for plot) – line style for forward motion, default is striped yellow on black

  • line_r (sequence of dict of arguments for plot) – line style for reverse motion, default is striped red on black

  • configspace (bool, optional) – plot the path in 3D configuration space, input must be 3xN. Start and goal style will be given by qstart_marker and qgoal_marker, defaults to False

  • unwrap (bool, optional) – for configuration space plot unwrap \(\theta\) so there are no discontinuities at \(\pm \pi\), defaults to True

  • background (bool, optional) – plot occupancy grid if present, default True

  • start_marker (dict, optional) – style for marking start point

  • goal_marker (dict, optional) – style for marking goal point

  • start_vehicle (dict) – style for vehicle animation object at start configuration

  • goal_vehicle (dict) – style for vehicle animation object at goal configuration

  • start (array_like(2) or array_like(3), optional) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set

  • goal (array_like(2) or array_like(3), optional) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set

  • bgargs (dict, optional) – arguments passed to plot_bg(), defaults to None

  • ax (matplotlib axes) – axes to plot into

  • block (bool, optional) – block after displaying the plot

Plots the start and goal location/pose if they are specified by start or goal or were set by the object constructor or plan or query method.

If the start and goal have length 2, planning in \(\mathbb{R}^2\), then markers are drawn using styles specified by start_marker and end_marker which are dicts using Matplotlib keywords, for example:

planner.plot(path, start=dict(marker='s', color='b'))

If the start and goal have length 3, planning in \(\SE{2}\), and configspace is False, then direction-indicating markers are used to display start and goal configuration. These are also given as dicts but have two items: 'shape' which is the shape of the polygonal marker and is either 'triangle' or 'car'. The second item 'args' is passed to base.plot_poly() and Matplotlib and could have values such as filled=True or color.

If configspace is False then a 3D plot is created and the start and goal are indicated by Matplotlib markers specified by the dicts start_marker and end_marker

Default values are provided for all markers:

  • the start point is a circle

  • the goal point is a star

  • the start vehicle style is a VehiclePolygon(shape='car') as an unfilled outline

  • the goal vehicle style is a VehiclePolygon(shape='car') as a transparent filled shape

If background is True then the background of the plot is either or both of:

  • the occupancy grid

  • the distance field of the planner

Additional arguments bgargs can be passed through to plot_bg()

If path is specified it has one column per point and either 2 or 3 rows:

  • 2 rows describes motion in the \(xy\)-plane and a 2D plot is created

  • 3 rows describes motion in the \(xy\theta\)-configuration space. By default only the \(xy\)-plane is plotted unless configspace is True in which case motion in \(xy\theta\)-configuration space is shown as a 3D plot.

If the planner supports bi-directional motion then the direction option gives the direction for each point on the path.

Forward motion segments are drawn using style information from line while reverse motion segments are drawn using style information from line_r. These are each a sequence of dicts of Matplotlib plot options which can draw an arbitrary number of lines on top of each other. The default:

line = (
        {color:'black', linewidth:4},
        {color:'yellow', linewidth:3, dashes:(5,5)}
    )

will draw a blackline of width 4 with a dashed yellow line of width 3 plotted on top, giving a line of alternating black and yellow dashes.

Seealso:

plot_bg() base.plot_poly()

property goal

Set/get goal point or configuration (superclass)

Getter:

Return goal pointor configuration

Return type:

ndarray(2) or ndarray(3)

Setter:

Set goal point or configuration

Param:

array_like(2) or array_like(3)

The goal is either a point \((x, y)\) or a configuration \((x, y, \theta)\).

Seealso:

goal()

property occgrid

Occupancy grid

Returns:

occupancy grid used for planning

Return type:

OccGrid or subclass or None

Returns the occupancy grid that was optionally inflated at constructor time.

Seealso:

validate_endpoint() isoccupied()

property start

Set/get start point or configuration (superclass)

Getter:

Return start point or configuration

Return type:

ndarray(2) or ndarray(3)

Setter:

Set start point or configuration

Param:

array_like(2) or array_like(3)

The start is either a point \((x, y)\) or a configuration \((x, y, \theta)\).

Seealso:

goal()

validate_endpoint(p, dtype=None)

Validate start or goal point

Parameters:
  • p (array_like(2)) – the point

  • dtype (str, optional) – data type for point coordinates, defaults to None

Raises:

ValueError – point is inside obstacle

Returns:

point as a NumPy array of specified dtype

Return type:

ndarray(2)

The coordinate is tested to be a free cell in the occupancy grid.

Seealso:

isoccupied() occgrid()

property verbose

Get verbosity

Returns:

verbosity

Return type:

bool

If verbosity print more diagnostic messages to the planner’s message channel.