pyrobosim.utils.polygon.sample_from_polygon
- pyrobosim.utils.polygon.sample_from_polygon(polygon: Polygon, max_tries: int = 100) tuple[float | None, float | None]
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 polygon from which to sample
max_tries – Maximum tries for sampling.
- Returns:
Sampled pose contained within the polygon. If no pose could be found, returns (None, None)