irsim.lib.path_planners.probabilistic_road_map#

Probabilistic Road Map (PRM) Planner.

Collision precedence:
  1. Grid lookup when env_map.grid is not None; if occupied, collision.

2. When the grid reports free or is unavailable, Shapely vs. obstacle_list. (Grid and obstacle_list are combined when both are present.)

author: Atsushi Sakai (@Atsushi_twi)

adapted by: Reinis Cimurs

Classes#

Node

Node class for dijkstra search

PRMPlanner

Initialize the PRM planner.

Module Contents#

class irsim.lib.path_planners.probabilistic_road_map.Node(x: float, y: float, cost: float, parent_index: int)[源代码]#

Node class for dijkstra search

Initialize Node

参数:
  • x (float) -- x position of the node

  • y (float) -- y position of the node

  • cost (float) -- heuristic cost of the node

  • parent_index (int) -- Nodes parent index

x#
y#
cost#
parent_index#
class irsim.lib.path_planners.probabilistic_road_map.PRMPlanner(env_map: irsim.world.map.EnvGridMap, robot_radius: float, n_sample: int = 500, n_knn: int = 10, max_edge_len: float = 30.0)[源代码]#

Initialize the PRM planner.

参数:
  • env_map -- Environment map (any EnvGridMap compatible object).

  • robot_radius -- Robot radius modeled as a circle.

  • n_sample -- Number of sampled points.

  • n_knn -- Number of nearest neighbors per node.

  • max_edge_len -- Maximum allowed edge length.

rr#
obstacle_list#
min_x#
min_y#
max_x#
max_y#
n_sample = 500#
n_knn = 10#
max_edge_len = 30.0#
planning(start_pose: numpy.ndarray, goal_pose: numpy.ndarray, rng: Any | None = None, show_animation: bool = True) tuple[list[float], list[float]] | None[源代码]#

Plan a path from start to goal using the PRM method.

参数:
  • start_pose (np.array) -- start pose [x,y]

  • goal_pose (np.array) -- goal pose [x,y]

  • rng (Optional) -- Random generator

  • show_animation (bool) -- If true, shows the animation of planning process

返回:

xy position array of the final path

返回类型:

(np.array)

check_node(x: float, y: float, rr: float) bool[源代码]#

Check position for a collision.

参数:
  • x -- World x coordinate.

  • y -- World y coordinate.

  • rr -- Robot radius for the check.

返回:

True if a collision is detected.

is_collision(sx: float, sy: float, gx: float, gy: float) bool[源代码]#

Check if line between points is acceptable - within edge limits and free of collisions

参数:
  • sx (float) -- start x position

  • sy (float) -- start y position

  • gx (float) -- goal x position

  • gy (float) -- goal y position

返回:

True if node is not acceptable. False otherwise

返回类型:

result (bool)

generate_road_map(sample_x: list[float], sample_y: list[float]) list[list[int]][源代码]#

Road map generation

参数:
  • sample_x (List) -- [m] x positions of sampled points

  • sample_y (List) -- [m] y positions of sampled points

返回:

list of edge ids

返回类型:

road_map (List)

static dijkstra_planning(sx: float, sy: float, gx: float, gy: float, road_map: list[list[int]], sample_x: list[float], sample_y: list[float], show_animation: bool) tuple[list[float], list[float]] | None[源代码]#
参数:
  • sx (float) -- start x position [m]

  • sy (float) -- start y position [m]

  • gx (float) -- goal x position [m]

  • gy (float) -- goal y position [m]

  • road_map (list) -- list of edge ids

  • sample_x (float) -- ??? [m]

  • sample_y (float) -- ??? [m]

返回:

Two lists of path coordinates ([x1, x2, ...], [y1, y2, ...]), empty list when no path was found

返回类型:

(tuple(list, list))

static plot_road_map(road_map: list[list[int]], sample_x: list[float], sample_y: list[float]) None[源代码]#
sample_points(sx: float, sy: float, gx: float, gy: float, rng: Any | None) tuple[list[float], list[float]][源代码]#

Generate sample points

参数:
  • sx (float) -- start x position [m]

  • sy (float) -- start y position [m]

  • gx (float) -- goal x position [m]

  • gy (float) -- goal y position [m]

  • rng -- Random generator

返回:

sample positions

返回类型:

sample (tuple (list, list))