Discrete (Grid-based) planners
Planner |
Plans in |
Discrete/Continuous |
Obstacle avoidance |
|---|---|---|---|
\(\mathbb{R}^2\) |
discrete |
yes |
|
\(\mathbb{R}^2\) |
discrete |
yes |
|
\(\mathbb{R}^2\) |
discrete |
yes |
|
\(\SE{2}\) |
discrete |
yes |
Distance transform planner
- class DistanceTransformPlanner(occgrid=None, metric='euclidean', *, distance=None, **kwargs)[source]
Bases:
PlannerBaseDistance transform path planner
- Parameters:
occgrid (
BinaryOccupancyGrid|ndarray|None) – occupancy gridmetric (
str) – distance metric, one of: “euclidean” [default], “manhattan” (“cityblock” is a synonym)kwargs (
Any) – common planner options, seePlannerBase
- Raises:
ValueError –
metricis not recognised, ormetricanddistanceare both given and are different
Deprecated since version 1.5.0:
distanceis deprecated, usemetric. It was never an argument (it was silently ignored), but code printed in the book uses it.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 8-way connected points in adjacent cells. Also known as the wavefront, grassfire or brushfire planning algorithm.
The map is described by a 2D occupancy
occgridwhose elements are zero if traversable or nonzero if untraversable, ie. an obstacle.Positions, paths and distances are in world units. Crossing a cell horizontally or vertically travels one
cellsize; a diagonal travels \(\sqrt{2}\) times that distance. Endpoints are rounded to cell centres.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), metric="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
See also
- property metric: str
Get the distance metric
- Returns:
the metric, either “euclidean” or “manhattan”
- property distancemap: ndarray | None
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.
- __str__()[source]
Compact representation of the planner
- Return type:
- Returns:
the base class description, the metric and whether a distance map has been computed
- plan(goal: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | None = None, animate: bool | None = None, summary: bool = False) None[source]
Plan path using distance transform
- Parameters:
goal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],None]) – goal position \((x, y)\), defaults to previously set valueanimate (
bool|None) – show the iterations of the algorithm, defaults to the planner’sanimatesummary (
bool) – print the number of iterations and of unreachable cells, defaults to False
- Raises:
ValueError – no goal is given here or to the constructor, or there is no occupancy grid
- Return type:
Compute the distance transform for all non-obstacle cells, which is the minimum obstacle-free distance to the goal using the particular distance metric.
See also
- query(start: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | None = None, goal: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | None = None, dtype: Any = None, animate: bool | None = None, movie: str | tuple[str, float] | None = None, *, next: bool | None = None) ndarray[source]
Find a path from start to goal using the distance map
- Parameters:
start (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],None]) – start position \((x, y)\), defaults to value specified to constructorgoal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],None]) – goal position \((x, y)\), defaults to value specified to constructordtype (
Any) – data type of the returned path, defaults to int for unit cells at (0, 0), otherwise floatanimate (
bool|None) – show the vehicle path, defaults to the planner’sanimatemovie (
str|tuple[str,float] |None) – save the animation as a movie file, filename or tuple (filename, frame interval), defaults to the planner’smovie. Impliesanimate.
- Raises:
ValueError – there is no start point
RuntimeError – no plan has been computed
NoPathError – the goal cannot be reached from
start
- Returns:
path from start to goal, one point \((x, y)\) per row
- Return type:
Repeatedly steps to the neighbouring cell with the lowest distance until the goal is reached.
Deprecated since version 1.5.0:
nextwas accepted but had no effect.See also
- next(position: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]]) ndarray | None[source]
Find next point on the path
- Parameters:
position (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]]]) – current robot position in world coordinates- Raises:
RuntimeError – no plan has been computed
NoPathError – there is no neighbouring cell with a finite distance
- Returns:
next robot position, None if the next point is the goal
- Return type:
Return the robot position that is one step closer to the goal. Called by
query()to find a path from start to goal.
- plot_3d(path: ndarray | None = None, path_style: dict[str, Any] | None = None, block: bool | None = True, *, ls: dict[str, Any] | None = None) Any[source]
Plot path on 3D cost surface
- Parameters:
path (
ndarray|None) – robot path, one point per row, defaults to Nonepath_style (
dict[str,Any] |None) – dictionary of Matplotlib line options for the path, defaults to Noneblock (
bool|None) –Noneleaves showing the figure to the environment (noplt.showcall),Falseshows it and returns at once,Trueshows it and waits until it is closed; ignored by notebook backends, defaults to True
- Raises:
ValueError – no plan has been computed
- Returns:
Matplotlib 3D axes
- Return type:
Creates a 3D plot showing distance from the goal as a cost surface. Overlays the path if given.
Deprecated since version 1.5.0:
lsis deprecated, usepath_style.Warning
The visualization is poor because of Matplotlib’s poor hidden line/surface handling.
- property animate: bool
Get or set animation of the planner’s operation
- Getter:
True if planners that can animate will do so
- Setter:
Set the default for methods that take an
animateargument
A movie file given to the constructor also implies animation.
See also
- animation_end() None
End an animation, closing the movie file if there is one
See also
- Return type:
- animation_frame(pause: float = 0.05) None
Show the current state of the animation
- Parameters:
pause (
float) – time to pause for the display to update, defaults to 0.05 s- Return type:
Updates the display and adds a frame to the movie, if there is one.
See also
- animation_start(animate: bool | None = None, movie: str | tuple[str, float] | None = None, draw: Callable[[], Any] | None = None) bool
Begin an animation
- Parameters:
- Return type:
- Returns:
True if the caller should animate
The planner decides what is drawn and when, this helper owns the pacing and recording. If animating,
drawis called, then the movie file if any is opened on the current figure. The caller then callsanimation_frame()after updating its artists, andanimation_end()when done.A
movieimplies animation.See also
- property goal: ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Set/get goal point or configuration (superclass)
- Getter:
Return goal point or configuration, None if not set
- Setter:
Set goal point or configuration, None is ignored
- Raises:
ValueError – (setter) not of length
ndims, or inside an obstacle
The goal is either a point \((x, y)\) or a configuration \((x, y, \theta)\).
See also
- isoccupied(p: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]]) bool
Test if point is occupied (superclass)
- Parameters:
p (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]]]) – world coordinate (x, y), or configuration (x, y, :math:` heta`)- Return type:
- Returns:
occupancy status of corresponding grid cell
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).
See also
occgrid()validate_endpoint()isoccupied
- property movie: str | tuple[str, float] | None
Get or set the movie file for the animation
- Getter:
filename, or tuple (filename, frame interval), None for no movie
- Setter:
Set the default movie file, None for no movie
- property occgrid: BinaryOccupancyGrid | None
Occupancy grid
- Returns:
occupancy grid used for planning, None if there is none
Returns the occupancy grid that was optionally inflated at constructor time.
See also
- plot(path: NDArray | None = None, path_style: dict[str, Any] | Sequence[dict[str, Any]] | None = None, path_reverse_style: dict[str, Any] | Sequence[dict[str, Any]] | None = None, configspace: bool = False, unwrap: bool = True, direction: ArrayLike | None = None, background: bool = True, path_marker: dict[str, Any] | Sequence[dict[str, Any]] | None = None, path_marker_reverse: dict[str, Any] | Sequence[dict[str, Any]] | None = None, start_style: dict[str, Any] | None = None, goal_style: dict[str, Any] | None = None, start_vehicle_style: dict[str, Any] | None = None, goal_vehicle_style: dict[str, Any] | None = None, start: ArrayLike2 | ArrayLike3 | None = None, goal: ArrayLike2 | ArrayLike3 | None = None, ax: Axes | None = None, block: bool | None = None, bgargs: dict[str, Any] | None = None, *, line: dict[str, Any] | Sequence[dict[str, Any]] | None = None, line_r: dict[str, Any] | Sequence[dict[str, Any]] | None = None, start_marker: dict[str, Any] | None = None, goal_marker: dict[str, Any] | None = None, start_vehicle: dict[str, Any] | None = None, goal_vehicle: dict[str, Any] | None = None, labels: bool = False, label_style: dict[str, Any] | None = None, labelvalues: bool = False, inflated: bool | None = None, colorbar: bool | dict[str, Any] | None = None, colorbar_style: dict[str, Any] | None = None, cmap: str | None = None, **unused: Any) Axes
Plot vehicle path (superclass)
- Parameters:
path (
ndarray|None) – path, one point per row, defaults to Nonepath_style (
dict[str,Any] |Sequence[dict[str,Any]] |None) – style for forward motion, one dict of Matplotlib line options or a sequence of them drawn on top of each other, defaults toPATH_STYLE, a dashed yellow line on blackpath_reverse_style (
dict[str,Any] |Sequence[dict[str,Any]] |None) – style for reverse motion, aspath_style, defaults toPATH_REVERSE_STYLE, a dashed red line on blackconfigspace (
bool) – plot path in configuration space, defaults to Falseunwrap (
bool) – for configuration space plot unwrap \(\theta\) so there are no discontinuities at \(\pm \pi\), defaults to Truedirection (
ndarray|Sequence[float] |None) – travel direction associated with each point on path, either >0 or <0, defaults to None (all forward)background (
bool) – plot occupancy grid if present, default Truestart_style (
dict[str,Any] |None) – Matplotlib options for the start point, merged overSTART_STYLEgoal_style (
dict[str,Any] |None) – Matplotlib options for the goal point, merged overGOAL_STYLEstart_vehicle_style (
dict[str,Any] |None) – options for the vehicle drawn at the start configuration, merged overSTART_VEHICLE_STYLEgoal_vehicle_style (
dict[str,Any] |None) – options for the vehicle drawn at the goal configuration, merged overGOAL_VEHICLE_STYLEstart (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously setgoal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set. The planner’s own goal is not changed.ax (
Axes|None) – axes to plot into, defaults to a new axesblock (
bool|None) –Noneleaves showing the figure to the environment (noplt.showcall),Falseshows it and returns at once,Trueshows it and waits until it is closed; ignored by notebook backends, defaults to Nonebgargs (
dict[str,Any] |None) – arguments passed toplot_bg(), defaults to Nonelabels (
bool) – write the distance value in each cell of the distance field, defaults to False. Useful for small grids, seeplot_bg().label_style (
dict[str,Any] |None) – Matplotlib text options forlabelslabelvalues (
bool) – deprecated, uselabelsinflated (
bool|None) – show the inflated obstacles, passed toplot_bg()colorbar (
bool|dict[str,Any] |None) – show a colorbar for the distance field, passed toplot_bg()colorbar_style (
dict[str,Any] |None) – options for the colorbar, passed toplot_bg()cmap (
str|None) – colormap for the distance field, passed toplot_bg()path_marker (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_stylepath_marker_reverse (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_reverse_styleline (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_styleline_r (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_reverse_stylestart_marker (
dict[str,Any] |None) – deprecated, usestart_stylegoal_marker (
dict[str,Any] |None) – deprecated, usegoal_stylestart_vehicle (
dict[str,Any] |None) – deprecated, usestart_vehicle_stylegoal_vehicle (
dict[str,Any] |None) – deprecated, usegoal_vehicle_style
- Raises:
ValueError –
configspaceis True but the path is not in configuration space- Return type:
- Returns:
the axes plotted into
Plots the start and goal location/pose if they are specified by
startorgoalor were set by the object constructor orplanorquerymethod.If the
startandgoalhave length 2, planning in \(\mathbb{R}^2\), then markers are drawn using styles specified bystart_styleandgoal_style, which are dicts using Matplotlib keywords, for example:planner.plot(path, start_style=dict(marker='s', color='b'))
If the
startandgoalhave length 3, planning in \(\SE{2}\), andconfigspaceis False, then the start and goal configuration are displayed as a vehicle, usingstart_vehicle_styleandgoal_vehicle_style.If
configspaceis True then a 3D plot is created and the start and goal are indicated by Matplotlib markers specified by the dictsstart_styleandgoal_style.Default values are provided for all styles:
the start point is a circle
the goal point is a star
the start vehicle style is a
VehiclePolygon(shape='car')as an unfilled outlinethe goal vehicle style is a
VehiclePolygon(shape='car')as a transparent filled shape
If
backgroundis True then the background of the plot is either or both of:the occupancy grid
the distance field of the planner
Additional arguments
bgargscan be passed through toplot_bg()If
pathis 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
configspaceis 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
directionoption gives the direction for each point on the path.Forward motion segments are drawn using the layers of
path_stylewhile reverse motion segments are drawn usingpath_reverse_style. These are each one dict, or a sequence of dicts, of Matplotlib plot options which can draw an arbitrary number of lines on top of each other. The default:path_style = ( {color:'black', linewidth:4}, {color:'yellow', linewidth:3, dashes:(5,5)} )
will draw a black line of width 4 with a dashed yellow line of width 3 plotted on top, giving a line of alternating black and yellow dashes. A style given by the caller replaces these layers.
Deprecated since version 1.5.0: The arguments
line,line_r,path_marker,path_marker_reverse,start_marker,goal_marker,start_vehicleandgoal_vehicleare deprecated, usepath_style,path_reverse_style,start_style,goal_style,start_vehicle_styleandgoal_vehicle_style.path_markerandpath_marker_reversewere accepted but had no effect.See also
plot_bg()plot_polyNote
Unknown keyword arguments are ignored, with a
DeprecationWarning, as they were silently by RTB 1.4.4 and earlier.Deprecated since version 1.5.0:
labelvaluesis deprecated, uselabels. It is the name used in the book, where it had no effect.Changed in version 1.5.0:
block=Falseshows the figure without waiting, as documented. It used to do nothing, the same asNone.
- plot_bg(distance: NDArray | None = None, cmap: str = 'gray', ax: Axes | None = None, inflated: bool = True, colorbar: bool | dict[str, Any] = True, block: bool | None = None, colorbar_style: dict[str, Any] | None = None, labels: bool = False, label_style: dict[str, Any] | None = None, labelvalues: bool = False, **unused: Any) None
Plot background (superclass)
- Parameters:
distance (
ndarray|None) – override distance field, defaults to None. The array is not modified.cmap (
str) – Specify a colormap for the distance field, defaults to ‘gray’ax (
Axes|None) – axes to plot into, defaults to the current axesinflated (
bool) – show the inflated obstacles, defaults to Truecolorbar (
bool|dict[str,Any]) – show a colorbar for the distance field, defaults to Trueblock (
bool|None) –Noneleaves showing the figure to the environment (noplt.showcall),Falseshows it and returns at once,Trueshows it and waits until it is closed; ignored by notebook backends, defaults to Nonecolorbar_style (
dict[str,Any] |None) – options for the colorbar, passed tomatplotlib.figure.Figure.colorbar(), defaults to None. The label defaults to “Distance”.labels (
bool) – write the value in each cell of the distance field, defaults to Falselabelvalues (
bool) – deprecated, uselabelslabel_style (
dict[str,Any] |None) – Matplotlib text options for the values, merged over red, centeredfontsize8 text, as in the book, with a thin white outline (path_effects) so that it is legible on any gray. The axes are set to show every cell whole.
- Return type:
Deprecated since version 1.5.0: Giving a dict as
colorbaris deprecated, usecolorbar=Truewithcolorbar_style.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 distance field will be used as the background and obstacle cells (actual or inflated) will be shown in red. A colorbar is added.
Note
Unknown keyword arguments are ignored, with a
DeprecationWarning, as they were silently by RTB 1.4.4 and earlier.Deprecated since version 1.5.0:
labelvaluesis deprecated, uselabels. It is the name used in the book, where it had no effect.
- property start: ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Set/get start point or configuration (superclass)
- Getter:
Return start point or configuration, None if not set
- Setter:
Set start point or configuration, None is ignored
- Raises:
ValueError – (setter) not of length
ndims, or inside an obstacle
The start is either a point \((x, y)\) or a configuration \((x, y, \theta)\).
See also
- validate_endpoint(p: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None, dtype: Any = None) ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Validate start or goal point
- Parameters:
- Raises:
ValueError – point is of the wrong length, or is inside an obstacle
- Return type:
ndarray[Tuple[Literal[2]],dtype[floating]] |ndarray[Tuple[Literal[3]],dtype[floating]] |None- Returns:
point as a NumPy array of specified dtype, None if
pis None
The coordinate is tested to be a free cell in the occupancy grid.
See also
- validate_start_goal(start: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None = None, goal: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None = None, dtype: Any = None) None
Validate and store the start and goal
- Parameters:
start (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to the value already setgoal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to the value already setdtype (
Any) – data type for the coordinates, defaults to None
- Raises:
ValueError –
startorgoalis of the wrong length or is inside an obstacle- Return type:
Each given value is tested against the planner’s dimensionality and the occupancy grid, and then stored as
startorgoal. A value of None leaves the existing value unchanged. If either is invalid neither is stored.See also
D* planner
- class DstarPlanner(costmap=None, **kwargs)[source]
Bases:
PlannerBaseD* path planner
- Parameters:
costmap (
ndarray|OccupancyGrid|None) – traversability costmapkwargs (
Any) – common planner options, seePlannerBase
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
costmapwhose elements indicate the cost per world unit. The cost of a step is the mean of the two cell costs multiplied by the distance between their centres. An infinite cost indicates an untraversable cell or obstacle. Endpoints and returned paths are in world coordinates; endpoints are rounded to cell centres.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
See also
- plan(goal: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | None = None, animate: bool | None = None, progress: bool = True, summary: bool = False) None[source]
Plan D* path
- Parameters:
goal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],None]) – goal position \((x, y)\), defaults to previously set valueanimate (
bool|None) – deprecated, animating the planning is not implementedprogress (
bool) – deprecated, has no effectsummary (
bool) – print the number of insertions, defaults to False
- Return type:
Deprecated since version 1.5.0:
animateandprogresswere accepted but had no effect.Compute the minimum-cost obstacle-free distance to the goal from all points in the grid.
- property nexpand: int
Number of node expansions
- Returns:
number of expansions
This number will increase during initial planning, and also if replanning is invoked during the
query().
- query(start: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]], sensor: Callable[[...], Any] | None = None, animate: bool | None = None, verbose: bool = False, movie: str | tuple[str, float] | None = None) tuple[ndarray, DstarStatus][source]
Find path with replanning
- Parameters:
start (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]]]) – start position \((x,y)\)sensor (
Callable[...,Any] |None) – sensor function, defaults to Noneanimate (
bool|None) – animate the motion of the robot, defaults to the planner’sanimatemovie (
str|tuple[str,float] |None) – save the animation as a movie file, filename or tuple (filename, frame interval), defaults to the planner’smovie. Impliesanimate.verbose (
bool) – display detailed diagnostic information about D* operations, defaults to False
- Returns:
path from start to goal, one point \((x, y)\) per row
- Return type:
If
sensoris None then the plan determined by theplanphase is used unaltered.If
sensoris not None it must be callable, and is called at each step of the path with the current robot coordinates in world units: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 world coordinates of cells and their cost per world unit. 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.See also
- __str__()
Compact representation of the planner
- Returns:
pretty printed representation
- Return type:
- property animate: bool
Get or set animation of the planner’s operation
- Getter:
True if planners that can animate will do so
- Setter:
Set the default for methods that take an
animateargument
A movie file given to the constructor also implies animation.
See also
- animation_end() None
End an animation, closing the movie file if there is one
See also
- Return type:
- animation_frame(pause: float = 0.05) None
Show the current state of the animation
- Parameters:
pause (
float) – time to pause for the display to update, defaults to 0.05 s- Return type:
Updates the display and adds a frame to the movie, if there is one.
See also
- animation_start(animate: bool | None = None, movie: str | tuple[str, float] | None = None, draw: Callable[[], Any] | None = None) bool
Begin an animation
- Parameters:
- Return type:
- Returns:
True if the caller should animate
The planner decides what is drawn and when, this helper owns the pacing and recording. If animating,
drawis called, then the movie file if any is opened on the current figure. The caller then callsanimation_frame()after updating its artists, andanimation_end()when done.A
movieimplies animation.See also
- property goal: ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Set/get goal point or configuration (superclass)
- Getter:
Return goal point or configuration, None if not set
- Setter:
Set goal point or configuration, None is ignored
- Raises:
ValueError – (setter) not of length
ndims, or inside an obstacle
The goal is either a point \((x, y)\) or a configuration \((x, y, \theta)\).
See also
- property movie: str | tuple[str, float] | None
Get or set the movie file for the animation
- Getter:
filename, or tuple (filename, frame interval), None for no movie
- Setter:
Set the default movie file, None for no movie
- property occgrid: BinaryOccupancyGrid | None
Occupancy grid
- Returns:
occupancy grid used for planning, None if there is none
Returns the occupancy grid that was optionally inflated at constructor time.
See also
- plot(path: NDArray | None = None, path_style: dict[str, Any] | Sequence[dict[str, Any]] | None = None, path_reverse_style: dict[str, Any] | Sequence[dict[str, Any]] | None = None, configspace: bool = False, unwrap: bool = True, direction: ArrayLike | None = None, background: bool = True, path_marker: dict[str, Any] | Sequence[dict[str, Any]] | None = None, path_marker_reverse: dict[str, Any] | Sequence[dict[str, Any]] | None = None, start_style: dict[str, Any] | None = None, goal_style: dict[str, Any] | None = None, start_vehicle_style: dict[str, Any] | None = None, goal_vehicle_style: dict[str, Any] | None = None, start: ArrayLike2 | ArrayLike3 | None = None, goal: ArrayLike2 | ArrayLike3 | None = None, ax: Axes | None = None, block: bool | None = None, bgargs: dict[str, Any] | None = None, *, line: dict[str, Any] | Sequence[dict[str, Any]] | None = None, line_r: dict[str, Any] | Sequence[dict[str, Any]] | None = None, start_marker: dict[str, Any] | None = None, goal_marker: dict[str, Any] | None = None, start_vehicle: dict[str, Any] | None = None, goal_vehicle: dict[str, Any] | None = None, labels: bool = False, label_style: dict[str, Any] | None = None, labelvalues: bool = False, inflated: bool | None = None, colorbar: bool | dict[str, Any] | None = None, colorbar_style: dict[str, Any] | None = None, cmap: str | None = None, **unused: Any) Axes
Plot vehicle path (superclass)
- Parameters:
path (
ndarray|None) – path, one point per row, defaults to Nonepath_style (
dict[str,Any] |Sequence[dict[str,Any]] |None) – style for forward motion, one dict of Matplotlib line options or a sequence of them drawn on top of each other, defaults toPATH_STYLE, a dashed yellow line on blackpath_reverse_style (
dict[str,Any] |Sequence[dict[str,Any]] |None) – style for reverse motion, aspath_style, defaults toPATH_REVERSE_STYLE, a dashed red line on blackconfigspace (
bool) – plot path in configuration space, defaults to Falseunwrap (
bool) – for configuration space plot unwrap \(\theta\) so there are no discontinuities at \(\pm \pi\), defaults to Truedirection (
ndarray|Sequence[float] |None) – travel direction associated with each point on path, either >0 or <0, defaults to None (all forward)background (
bool) – plot occupancy grid if present, default Truestart_style (
dict[str,Any] |None) – Matplotlib options for the start point, merged overSTART_STYLEgoal_style (
dict[str,Any] |None) – Matplotlib options for the goal point, merged overGOAL_STYLEstart_vehicle_style (
dict[str,Any] |None) – options for the vehicle drawn at the start configuration, merged overSTART_VEHICLE_STYLEgoal_vehicle_style (
dict[str,Any] |None) – options for the vehicle drawn at the goal configuration, merged overGOAL_VEHICLE_STYLEstart (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously setgoal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set. The planner’s own goal is not changed.ax (
Axes|None) – axes to plot into, defaults to a new axesblock (
bool|None) –Noneleaves showing the figure to the environment (noplt.showcall),Falseshows it and returns at once,Trueshows it and waits until it is closed; ignored by notebook backends, defaults to Nonebgargs (
dict[str,Any] |None) – arguments passed toplot_bg(), defaults to Nonelabels (
bool) – write the distance value in each cell of the distance field, defaults to False. Useful for small grids, seeplot_bg().label_style (
dict[str,Any] |None) – Matplotlib text options forlabelslabelvalues (
bool) – deprecated, uselabelsinflated (
bool|None) – show the inflated obstacles, passed toplot_bg()colorbar (
bool|dict[str,Any] |None) – show a colorbar for the distance field, passed toplot_bg()colorbar_style (
dict[str,Any] |None) – options for the colorbar, passed toplot_bg()cmap (
str|None) – colormap for the distance field, passed toplot_bg()path_marker (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_stylepath_marker_reverse (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_reverse_styleline (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_styleline_r (
dict[str,Any] |Sequence[dict[str,Any]] |None) – deprecated, usepath_reverse_stylestart_marker (
dict[str,Any] |None) – deprecated, usestart_stylegoal_marker (
dict[str,Any] |None) – deprecated, usegoal_stylestart_vehicle (
dict[str,Any] |None) – deprecated, usestart_vehicle_stylegoal_vehicle (
dict[str,Any] |None) – deprecated, usegoal_vehicle_style
- Raises:
ValueError –
configspaceis True but the path is not in configuration space- Return type:
- Returns:
the axes plotted into
Plots the start and goal location/pose if they are specified by
startorgoalor were set by the object constructor orplanorquerymethod.If the
startandgoalhave length 2, planning in \(\mathbb{R}^2\), then markers are drawn using styles specified bystart_styleandgoal_style, which are dicts using Matplotlib keywords, for example:planner.plot(path, start_style=dict(marker='s', color='b'))
If the
startandgoalhave length 3, planning in \(\SE{2}\), andconfigspaceis False, then the start and goal configuration are displayed as a vehicle, usingstart_vehicle_styleandgoal_vehicle_style.If
configspaceis True then a 3D plot is created and the start and goal are indicated by Matplotlib markers specified by the dictsstart_styleandgoal_style.Default values are provided for all styles:
the start point is a circle
the goal point is a star
the start vehicle style is a
VehiclePolygon(shape='car')as an unfilled outlinethe goal vehicle style is a
VehiclePolygon(shape='car')as a transparent filled shape
If
backgroundis True then the background of the plot is either or both of:the occupancy grid
the distance field of the planner
Additional arguments
bgargscan be passed through toplot_bg()If
pathis 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
configspaceis 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
directionoption gives the direction for each point on the path.Forward motion segments are drawn using the layers of
path_stylewhile reverse motion segments are drawn usingpath_reverse_style. These are each one dict, or a sequence of dicts, of Matplotlib plot options which can draw an arbitrary number of lines on top of each other. The default:path_style = ( {color:'black', linewidth:4}, {color:'yellow', linewidth:3, dashes:(5,5)} )
will draw a black line of width 4 with a dashed yellow line of width 3 plotted on top, giving a line of alternating black and yellow dashes. A style given by the caller replaces these layers.
Deprecated since version 1.5.0: The arguments
line,line_r,path_marker,path_marker_reverse,start_marker,goal_marker,start_vehicleandgoal_vehicleare deprecated, usepath_style,path_reverse_style,start_style,goal_style,start_vehicle_styleandgoal_vehicle_style.path_markerandpath_marker_reversewere accepted but had no effect.See also
plot_bg()plot_polyNote
Unknown keyword arguments are ignored, with a
DeprecationWarning, as they were silently by RTB 1.4.4 and earlier.Deprecated since version 1.5.0:
labelvaluesis deprecated, uselabels. It is the name used in the book, where it had no effect.Changed in version 1.5.0:
block=Falseshows the figure without waiting, as documented. It used to do nothing, the same asNone.
- plot_bg(distance: NDArray | None = None, cmap: str = 'gray', ax: Axes | None = None, inflated: bool = True, colorbar: bool | dict[str, Any] = True, block: bool | None = None, colorbar_style: dict[str, Any] | None = None, labels: bool = False, label_style: dict[str, Any] | None = None, labelvalues: bool = False, **unused: Any) None
Plot background (superclass)
- Parameters:
distance (
ndarray|None) – override distance field, defaults to None. The array is not modified.cmap (
str) – Specify a colormap for the distance field, defaults to ‘gray’ax (
Axes|None) – axes to plot into, defaults to the current axesinflated (
bool) – show the inflated obstacles, defaults to Truecolorbar (
bool|dict[str,Any]) – show a colorbar for the distance field, defaults to Trueblock (
bool|None) –Noneleaves showing the figure to the environment (noplt.showcall),Falseshows it and returns at once,Trueshows it and waits until it is closed; ignored by notebook backends, defaults to Nonecolorbar_style (
dict[str,Any] |None) – options for the colorbar, passed tomatplotlib.figure.Figure.colorbar(), defaults to None. The label defaults to “Distance”.labels (
bool) – write the value in each cell of the distance field, defaults to Falselabelvalues (
bool) – deprecated, uselabelslabel_style (
dict[str,Any] |None) – Matplotlib text options for the values, merged over red, centeredfontsize8 text, as in the book, with a thin white outline (path_effects) so that it is legible on any gray. The axes are set to show every cell whole.
- Return type:
Deprecated since version 1.5.0: Giving a dict as
colorbaris deprecated, usecolorbar=Truewithcolorbar_style.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 distance field will be used as the background and obstacle cells (actual or inflated) will be shown in red. A colorbar is added.
Note
Unknown keyword arguments are ignored, with a
DeprecationWarning, as they were silently by RTB 1.4.4 and earlier.Deprecated since version 1.5.0:
labelvaluesis deprecated, uselabels. It is the name used in the book, where it had no effect.
- property start: ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Set/get start point or configuration (superclass)
- Getter:
Return start point or configuration, None if not set
- Setter:
Set start point or configuration, None is ignored
- Raises:
ValueError – (setter) not of length
ndims, or inside an obstacle
The start is either a point \((x, y)\) or a configuration \((x, y, \theta)\).
See also
- validate_endpoint(p: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None, dtype: Any = None) ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Validate start or goal point
- Parameters:
- Raises:
ValueError – point is of the wrong length, or is inside an obstacle
- Return type:
ndarray[Tuple[Literal[2]],dtype[floating]] |ndarray[Tuple[Literal[3]],dtype[floating]] |None- Returns:
point as a NumPy array of specified dtype, None if
pis None
The coordinate is tested to be a free cell in the occupancy grid.
See also
- validate_start_goal(start: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None = None, goal: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None = None, dtype: Any = None) None
Validate and store the start and goal
- Parameters:
start (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to the value already setgoal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to the value already setdtype (
Any) – data type for the coordinates, defaults to None
- Raises:
ValueError –
startorgoalis of the wrong length or is inside an obstacle- Return type:
Each given value is tested against the planner’s dimensionality and the occupancy grid, and then stored as
startorgoal. A value of None leaves the existing value unchanged. If either is invalid neither is stored.See also
Lattice planner
- class LatticePlanner(costs=None, root=(0, 0, 0), **kwargs)[source]
Bases:
PlannerBaseLattice planner
- Parameters:
costs (
Union[List[float],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – cost for straight, left-turn, right-turn, defaults to \((1, \pi/2, \pi/2)\)root (
Union[List[float],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]]]) – configuration of root node, defaults to (0,0,0)kwargs (
Any) – arguments passed toPlannerBaseconstructor
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 overridden.
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
costschanges 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=[LatticeEdge{[0] -> [0L], cost=1.571}, LatticeEdge{[0L] -> [0LS], cost=1}])
See also
- plan(iterations: int | None = None, verbose: bool = False, summary: bool = False) None[source]
Create a lattice plan
- Parameters:
- Return type:
If an occupancy grid exists the if
iterationsis None the area of the grid will be completely filled.Note
A spatial index can only be built after the last iteration: adding a vertex invalidates it. Automatic indexing is deferred because pgraph 1.0.0 can reject lattice angles just below zero: wrapping them rounds to the upper boundary of its periodic k-d tree. The unindexed nearest-vertex search remains valid. See
examples/benchmark_roadmap.pyfor a comparison on completed roadmaps, including index-construction failures.See also
- query(start: List[float] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]], goal: List[float] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]]) tuple[ndarray, LatticeStatus][source]
Find a path through the lattice
- Parameters:
- Returns:
path and status
- Return type:
The returned status value has elements:
Element
Description
costpath cost
segmentsa 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.
edgessuccessive edges of the graph
LatticeEdgetypeSee also
- plot(path: ndarray | None = None, **kwargs: Any) None[source]
Plot vehicle path (superclass)
- Parameters:
path (
ndarray|None) – path, one point per row, defaults to Nonepath_style – style for forward motion, one dict of Matplotlib line options or a sequence of them drawn on top of each other, defaults to
PATH_STYLE, a dashed yellow line on blackpath_reverse_style – style for reverse motion, as
path_style, defaults toPATH_REVERSE_STYLE, a dashed red line on blackconfigspace – plot path in configuration space, defaults to False
unwrap – for configuration space plot unwrap \(\theta\) so there are no discontinuities at \(\pm \pi\), defaults to True
direction (array_like(N)) – travel direction associated with each point on path, either >0 or <0, defaults to None (all forward)
background – plot occupancy grid if present, default True
start_style – Matplotlib options for the start point, merged over
START_STYLEgoal_style – Matplotlib options for the goal point, merged over
GOAL_STYLEstart_vehicle_style – options for the vehicle drawn at the start configuration, merged over
START_VEHICLE_STYLEgoal_vehicle_style – options for the vehicle drawn at the goal configuration, merged over
GOAL_VEHICLE_STYLEstart – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set
goal – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to value previously set. The planner’s own goal is not changed.
ax – axes to plot into, defaults to a new axes
block –
Noneleaves showing the figure to the environment (noplt.showcall),Falseshows it and returns at once,Trueshows it and waits until it is closed; ignored by notebook backends, defaults to Nonebgargs – arguments passed to
plot_bg(), defaults to Nonelabels – write the distance value in each cell of the distance field, defaults to False. Useful for small grids, see
plot_bg().label_style – Matplotlib text options for
labelslabelvalues – deprecated, use
labelsinflated – show the inflated obstacles, passed to
plot_bg()colorbar – show a colorbar for the distance field, passed to
plot_bg()colorbar_style – options for the colorbar, passed to
plot_bg()cmap – colormap for the distance field, passed to
plot_bg()path_marker – deprecated, use
path_stylepath_marker_reverse – deprecated, use
path_reverse_styleline – deprecated, use
path_styleline_r – deprecated, use
path_reverse_stylestart_marker – deprecated, use
start_stylegoal_marker – deprecated, use
goal_stylestart_vehicle – deprecated, use
start_vehicle_stylegoal_vehicle – deprecated, use
goal_vehicle_style
- Raises:
ValueError –
configspaceis True but the path is not in configuration space- Return type:
- Returns:
the axes plotted into
Plots the start and goal location/pose if they are specified by
startorgoalor were set by the object constructor orplanorquerymethod.If the
startandgoalhave length 2, planning in \(\mathbb{R}^2\), then markers are drawn using styles specified bystart_styleandgoal_style, which are dicts using Matplotlib keywords, for example:planner.plot(path, start_style=dict(marker='s', color='b'))
If the
startandgoalhave length 3, planning in \(\SE{2}\), andconfigspaceis False, then the start and goal configuration are displayed as a vehicle, usingstart_vehicle_styleandgoal_vehicle_style.If
configspaceis True then a 3D plot is created and the start and goal are indicated by Matplotlib markers specified by the dictsstart_styleandgoal_style.Default values are provided for all styles:
the start point is a circle
the goal point is a star
the start vehicle style is a
VehiclePolygon(shape='car')as an unfilled outlinethe goal vehicle style is a
VehiclePolygon(shape='car')as a transparent filled shape
If
backgroundis True then the background of the plot is either or both of:the occupancy grid
the distance field of the planner
Additional arguments
bgargscan be passed through toplot_bg()If
pathis 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
configspaceis 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
directionoption gives the direction for each point on the path.Forward motion segments are drawn using the layers of
path_stylewhile reverse motion segments are drawn usingpath_reverse_style. These are each one dict, or a sequence of dicts, of Matplotlib plot options which can draw an arbitrary number of lines on top of each other. The default:path_style = ( {color:'black', linewidth:4}, {color:'yellow', linewidth:3, dashes:(5,5)} )
will draw a black line of width 4 with a dashed yellow line of width 3 plotted on top, giving a line of alternating black and yellow dashes. A style given by the caller replaces these layers.
Deprecated since version 1.5.0: The arguments
line,line_r,path_marker,path_marker_reverse,start_marker,goal_marker,start_vehicleandgoal_vehicleare deprecated, usepath_style,path_reverse_style,start_style,goal_style,start_vehicle_styleandgoal_vehicle_style.path_markerandpath_marker_reversewere accepted but had no effect.See also
plot_bg()plot_polyNote
Unknown keyword arguments are ignored, with a
DeprecationWarning, as they were silently by RTB 1.4.4 and earlier.Deprecated since version 1.5.0:
labelvaluesis deprecated, uselabels. It is the name used in the book, where it had no effect.Changed in version 1.5.0:
block=Falseshows the figure without waiting, as documented. It used to do nothing, the same asNone.
- property animate: bool
Get or set animation of the planner’s operation
- Getter:
True if planners that can animate will do so
- Setter:
Set the default for methods that take an
animateargument
A movie file given to the constructor also implies animation.
See also
- animation_end() None
End an animation, closing the movie file if there is one
See also
- Return type:
- animation_frame(pause: float = 0.05) None
Show the current state of the animation
- Parameters:
pause (
float) – time to pause for the display to update, defaults to 0.05 s- Return type:
Updates the display and adds a frame to the movie, if there is one.
See also
- animation_start(animate: bool | None = None, movie: str | tuple[str, float] | None = None, draw: Callable[[], Any] | None = None) bool
Begin an animation
- Parameters:
- Return type:
- Returns:
True if the caller should animate
The planner decides what is drawn and when, this helper owns the pacing and recording. If animating,
drawis called, then the movie file if any is opened on the current figure. The caller then callsanimation_frame()after updating its artists, andanimation_end()when done.A
movieimplies animation.See also
- property goal: ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Set/get goal point or configuration (superclass)
- Getter:
Return goal point or configuration, None if not set
- Setter:
Set goal point or configuration, None is ignored
- Raises:
ValueError – (setter) not of length
ndims, or inside an obstacle
The goal is either a point \((x, y)\) or a configuration \((x, y, \theta)\).
See also
- property movie: str | tuple[str, float] | None
Get or set the movie file for the animation
- Getter:
filename, or tuple (filename, frame interval), None for no movie
- Setter:
Set the default movie file, None for no movie
- property occgrid: BinaryOccupancyGrid | None
Occupancy grid
- Returns:
occupancy grid used for planning, None if there is none
Returns the occupancy grid that was optionally inflated at constructor time.
See also
- property start: ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Set/get start point or configuration (superclass)
- Getter:
Return start point or configuration, None if not set
- Setter:
Set start point or configuration, None is ignored
- Raises:
ValueError – (setter) not of length
ndims, or inside an obstacle
The start is either a point \((x, y)\) or a configuration \((x, y, \theta)\).
See also
- validate_endpoint(p: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None, dtype: Any = None) ndarray[Tuple[Literal[2]], dtype[floating]] | ndarray[Tuple[Literal[3]], dtype[floating]] | None
Validate start or goal point
- Parameters:
- Raises:
ValueError – point is of the wrong length, or is inside an obstacle
- Return type:
ndarray[Tuple[Literal[2]],dtype[floating]] |ndarray[Tuple[Literal[3]],dtype[floating]] |None- Returns:
point as a NumPy array of specified dtype, None if
pis None
The coordinate is tested to be a free cell in the occupancy grid.
See also
- validate_start_goal(start: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None = None, goal: List[float] | Tuple[float, float] | ndarray[Tuple[Literal[2]], dtype[floating]] | Tuple[float, float, float] | ndarray[Tuple[Literal[3]], dtype[floating]] | None = None, dtype: Any = None) None
Validate and store the start and goal
- Parameters:
start (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – start position \((x, y)\) or configuration \((x, y, \theta)\), defaults to the value already setgoal (
Union[List[float],Tuple[float,float],ndarray[Tuple[Literal[2]],dtype[floating]],Tuple[float,float,float],ndarray[Tuple[Literal[3]],dtype[floating]],None]) – goal position \((x, y)\) or configuration \((x, y, \theta)\), defaults to the value already setdtype (
Any) – data type for the coordinates, defaults to None
- Raises:
ValueError –
startorgoalis of the wrong length or is inside an obstacle- Return type:
Each given value is tested against the planner’s dimensionality and the occupancy grid, and then stored as
startorgoal. A value of None leaves the existing value unchanged. If either is invalid neither is stored.See also