Roadmap

class discopygal.solvers_infra.roadmap.Roadmap(scene: Scene, metric: Metric, nearest_neighbors_class: NearestNeighbors, sampler: Sampler | None = None, robots: List[Robot] | None = None, is_directed: bool = False)
A class that represents a roadmap, which has the roadmap graph (points and edges between them) and
also includes collision detection that ables to check valid points and edges, ability to add points and edges.
All points in roadmap graph are from type Point_d
This means they are all Point_d where d is: (dimension of a single robot point) * (number of robots)
Parameters:
  • scene (Scene) – the scene of the roadmap

  • metric (Metric) – Metric to use

  • nearest_neighbors_class (NearestNeighbors or None) – a nearest neighbors algorithm. Pass a class, not an object! A new nearest_neighbors instance will be created.

  • sampler (Sampler) – sampling algorithm/method.

  • robots – robots for which we built the roadmap for

  • is_directed – Is the roadmap graph directed or not

add_edge(p, q, check_if_valid=True, weight=None, **extra_args_for_edge)

Get two vertices p, q and try to connect them. If we cannot connect them - return False.

Parameters:
  • p (Point_d) – first point

  • q (Point_d) – second point

  • check_if_valid (bool) – check if edge is valid before adding it

  • weight (float) – Weight of the edge (if given None the weight will be the distance according to the metric)

  • extra_args_for_edge (dict) – extra data added to the edge (can be accessed by self.edges[p, q][<key>])

Returns:

True if edge was added successfully

Return type:

bool

add_point(point, check_if_valid=True, **extra_args_for_point)

Try to add a point to the roadmap. If point is invalid - return None.

Parameters:
  • point (Point_d or Point_2) – point to add

  • check_if_valid (bool) – check if point is valid before adding it

  • extra_args_for_point (dict) – extra data added to the node of the point (can be accessed by self.points[<point>][<key>])

Returns:

the given point if point was added successfully, otherwise returns None on failure.

Return type:

Point_d

add_sampled_point()

Sample a random point and try to add it to the roadmap. On success return the added point, otherwise return None.

Returns:

The added point

Return type:

Point_d

property edges

Return a list of all edges in the roadmap

Returns:

list of edges

is_edge_valid(p, q)

Get two points in the configuration space and decide if they can be connected - i.e. all continuous points from the the source to the dest are collision free.

Parameters:
Returns:

Can they be connected

Return type:

bool

is_point_valid(point)

Is a given point valid on roadmap (no collisions)

Parameters:

point (Point_d) – point to check

Returns:

True/False

Return type:

bool

property points

Return a list of all landmarks (points) in the roadmap

Returns:

list of landmarks

Return type:

List[<Point_d>]

sample_free_point()

Sample a free random point in configuration space Dimension is 2*robots_num

Returns:

Sampled free point

Return type:

Point_d