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 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 PRM planner
- Parameters:
env_map (Env) – environment map where the planning will take place
robot_radius (float) – robot body modeled as circle with given radius
n_sample (int) – number of samples
n_knn (int) – number of edges
max_edge_len (float) – max edge length
- rr#
- obstacle_list#
- n_sample = 500#
- n_knn = 10#
- max_edge_len = 30.0#
- planning(start_pose: list[float], goal_pose: list[float], rng: Any | None = None, show_animation: bool = True) tuple[list[float], list[float]] | None[source]#
A star path search
- 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))