Module boundary

commonocean_dc.boundary.boundary.create_waters_boundary_obstacle(scenario: Scenario, method='triangulation', return_scenario_obstacle=True, **kwargs)[source]

Creates the waters boundary for the given scenario.

Parameters:
  • scenario – the input scenario to be triangulated

  • method – waters boundary creation method: triangulation - Delaunay triangulation, aligned_triangulation - axis-aligned triangles using GPC polygon strips, obb_rectangles - OBB rectangles on the waters border (default: triangulation)

  • return_scenario_obstacle – additionally create a commonwaters StaticObstacle for the waters boundary

  • kwargs – settings of the method

Returns:

[optional: StaticObstacle representing the waters boundary,] ShapeGroup with the collision checker objects

Available methods:

-triangulation

Delaunay triangulation

-aligned_triangulation

Divides the polygons representing the waters boundary into axis-aligned tiles and triangulates the tiles separately into the triangles having one side parallel to the other axis (in order to reduce the number of candidate triangles for collision checks).

Settings:

axis - 0: Use vertical tiles, 1: Use horizontal tiles, ‘auto’: Use horizontal tiles if width<height.

boundary_margin - Size of margin for the calculation of scenario corners.

-obb_rectangles

In contrast to triangulation, this method creates a set of oriented rectangles that separates the waters and the waters boundary. To compute the set, we first compute the union of all waters in the waters network and then extract the inner and outer contours of the resulting polygon. Afterwards, we create an oriented rectangle for each line segment of the inner and outer contours. The oriented rectangles symmetrically overapproximate each line segment. In this way, we can reduce the false positive rate at waters forks and merges.

Settings:

width: Width of the generated rectangles. Default: 1e-5.

Example:

create_waters_boundary_obstacle(scenario, method = ‘aligned_triangulation’, axis=’auto’)

commonocean_dc.boundary.boundary.create_waters_polygons(scenario: Scenario, method='lane_polygons', **kwargs)[source]

Creates a ShapeGroup with collision checker polygons representing the waters.

Parameters:
  • scenario – the input scenario for the creation of waters polygons

  • method – waters polygons creation method: lane_polygons - lane polygons, waters_polygons - waters polygons, whole_polygon - whole polygon, whole_polygon_tiled - whole polygon subdivided into tiles (default: lane_polygons)

  • kwargs – settings of the method

Returns:

ShapeGroup with the collision checker polygons

Available methods:

-lane_polygons

Creates lane polygons for the given scenario. Optionally uses Douglas-Peucker resampling and buffering of the polygons.

Settings:

resample - use Douglas-Peucker resampling. 0 - no resampling, 1 - enable resampling.

resample_tolerance_distance - tolerance distance for the resampling (default: 2e-5).

buffer - use polygon buffering. 0 - no buffering, 1 - enable buffering. The Boost Geometry library, mitre joins and flat ends are used for the buffering.

buf_width - buffer width by which the resulting polygons should be enlarged (default: 5e-5).

triangulate - True: triangles will be generated for the interior of each lane polygon using GPC Polygon strips, False: two triangles will be created for each lane polygon from its AABB bounding box.

-waters_polygons

Creates waters polygons for the given scenario. Optionally uses Douglas-Peucker resampling and buffering of the polygons.

Settings:

resample - use Douglas-Peucker resampling. 0 - no resampling, 1 - enable resampling.

resample_tolerance_distance - tolerance distance for the resampling (default: 2e-5).

buffer - use polygon buffering. 0 - no buffering, 1 - enable buffering. The Boost Geometry library, mitre joins and flat ends are used for the buffering.

buf_width - buffer width by which the resulting polygons should be enlarged (default: 5e-5).

triangulate - True: triangles will be generated for the interior of each waters polygon using GPC Polygon strips, False: two triangles will be created for each waters polygon from its AABB bounding box.

-whole_polygon

Creates large polygon(s), possibly with holes, representing the waters network for the given scenario.

Settings:

triangulate - True: triangles will be generated for the interior of each resulting polygon using GPC Polygon strips, False: two triangles will be created for each resulting polygon from its AABB bounding box.

-whole_polygon_tiled

Creates large polygon(s), possibly with holes, representing the scenario waters network. After that, tiles the polygon(s) into uniform rectangular grid cells. For the creation of polygon tiles, the uniform grid cells used are enlarged by epsilon to avoid any gaps between the generated polygon tiles.

Settings:

max_cell_width - maximal grid cell width.

max_cell_height - maximal grid cell height.

triangulate - True: triangles will be generated for the interior of each resulting polygon using GPC Polygon strips, False: two triangles will be created for each resulting polygon from its AABB bounding box.

Example:

create_waters_polygons(scenario, method = ‘lane_polygons’, resample=1, buffer=1, triangulate=True)

commonocean_dc.boundary.boundary.create_shallow_polygons(scenario: Scenario, method='lane_polygons', **kwargs)[source]
commonocean_dc.boundary.boundary.overlapping_shallow_waters(scenario: Scenario, method_waters='lane_polygons', method_shallow='lane_polygons', **kwargs)[source]
commonocean_dc.boundary.boundary.has_enough_depth(scenario: Scenario, main_obj=None, standard_depth=15, method='lane_polygons', **kwargs)[source]

Function that checks if a certain trajectory or dynamic obstacle is compatible with the depth of the environment path. It can be called with a simple trajectory (and a manually chosen depth, as the trajectory calls does not have its own depth) or even with a proper dynamic obstacle object and its own depth. Remember that the Waterways themselves have infinite depth.

Parameters:
  • scenario – the input scenario to be considered

  • main_obj – object to be tested (can be a trajectory or even a dynamic obstacle)

  • standard_depth – standard depth to be compared to, in case the main object does not have an intrinsic value (if it is not an obstacle)

  • method – method used to construct the shallows polygons

  • kwargs – extra standard arguments used in the construction of the shallow polygons

Returns:

flag (bool) indicating if the depth is safe for that path, [entire shallow polygon or shallow that collided, collision main object]

Available methods:

  • lane_polygons

  • whole_polygon

  • whole_polygon_tiled

Example:

has_enough_depth(scenario, trajectory, standard_depth = 25, method = ‘lane_polygons’)