irsim.lib.path_planners.probabilistic_road_map#

Probabilistic Road Map (PRM) Planner

author: Atsushi Sakai (@Atsushi_twi)

adapted by: Reinis Cimurs

Classes#

Node

Node class for dijkstra search

PRMPlanner

Initialize PRM planner

Module Contents#

class irsim.lib.path_planners.probabilistic_road_map.Node(x, y, cost, parent_index)[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, robot_radius, n_sample=500, n_knn=10, max_edge_len=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, goal_pose, rng=None, show_animation=True)[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, y, rr)[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, sy, gx, gy)[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, sample_y)[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, sy, gx, gy, road_map, sample_x, sample_y, show_animation)[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, sample_x, sample_y)[source]#
sample_points(sx, sy, gx, gy, rng)[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))