irsim.lib.path_planners.probabilistic_road_map#
Probabilistic Road Map (PRM) Planner
author: Atsushi Sakai (@Atsushi_twi)
adapted by: Reinis Cimurs
Classes#
Node class for dijkstra search |
|
Initialize the PRM planner. |
Module Contents#
- class irsim.lib.path_planners.probabilistic_road_map.Node(x: float, y: float, cost: float, parent_index: int)[source]#
Node class for dijkstra search
Initialize Node
- Parameters:
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.Map, robot_radius: float, n_sample: int = 500, n_knn: int = 10, max_edge_len: float = 30.0)[source]#
Initialize the PRM planner.
- Parameters:
env_map (Map) β Environment map where planning takes place.
robot_radius (float) β Robot radius modeled as a circle.
n_sample (int) β Number of sampled points.
n_knn (int) β Number of nearest neighbors per node.
max_edge_len (float) β Maximum allowed edge length.
- rr#
- obstacle_list#
- 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[source]#
Plan a path from start to goal using the PRM method.
- Parameters:
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
- Returns:
xy position array of the final path
- Return type:
(np.array)
- check_node(x: float, y: float, rr: float) bool[source]#
Check positon for a collision
- Parameters:
x (float) β x value of the position
y (float) β y value of the position
- Returns:
True if there is a collision. False otherwise
- Return type:
(bool)
- is_collision(sx: float, sy: float, gx: float, gy: float) bool[source]#
Check if line between points is acceptable - within edge limits and free of collisions
- Parameters:
sx (float) β start x position
sy (float) β start y position
gx (float) β goal x position
gy (float) β goal y position
- Returns:
True if node is not acceptable. False otherwise
- Return type:
result (bool)
- generate_road_map(sample_x: list[float], sample_y: list[float]) list[list[int]][source]#
Road map generation
- Parameters:
sample_x (List) β [m] x positions of sampled points
sample_y (List) β [m] y positions of sampled points
- Returns:
list of edge ids
- Return type:
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[source]#
- Parameters:
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]
- Returns:
Two lists of path coordinates ([x1, x2, β¦], [y1, y2, β¦]), empty list when no path was found
- Return type:
(tuple(list, list))
- static plot_road_map(road_map: list[list[int]], sample_x: list[float], sample_y: list[float]) None[source]#
- sample_points(sx: float, sy: float, gx: float, gy: float, rng: Any | None) tuple[list[float], list[float]][source]#
Generate sample points
- Parameters:
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
- Returns:
sample positions
- Return type:
sample (tuple (list, list))