pyrobosim.utils.polygon.sample_from_polygon

pyrobosim.utils.polygon.sample_from_polygon(polygon, max_tries=100)

Samples a valid (x, y) tuple that is inside a Shapely polygon. This is done using rejection sampling, in which we sample from the x-y bounds of the polygon and check whether the point is inside the (potentially more complex) polygon geometry.

Parameters:
  • polygon (shapely.geometry.Polygon) – Shapely polygon from which to sample

  • max_tries (float) – Maximum tries for sampling.

Returns:

Sampled pose contained within the polygon. If no pose could be found, returns (None, None)

Return type:

(float, float)