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) andalso 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 allPoint_d
where d is: (dimension of a single robot point) * (number of robots)- Parameters:
scene (
Scene
) – the scene of the roadmapmetric (
Metric
) – Metric to usenearest_neighbors_class (
NearestNeighbors
orNone
) – 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 pointq (
Point_d
) – second pointcheck_if_valid (
bool
) – check if edge is valid before adding itweight (
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:
- Returns:
the given point if point was added successfully, otherwise returns None on failure.
- Return type:
- 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:
- 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.
- 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