freneticlib.executors.road_validator

Note

Note, the code in this module code is an adaptation of the file code_pipeline/validation.py as provided by the CPS-Tool-Competition repository. https://github.com/sbft-cps-tool-competition/cps-tool-competition

It has been licensed under the GNU General Public License. Thus, this file is also made available under GPL.

Module Contents

Classes

RoadValidator

Performs several checks to assert the road is valid.

Functions

find_circle(p1, p2, p3)

Returns the center and radius of the circle passing the given 3 points.

min_radius(x[, w])

Finds the smallest curvature radius within the road.

freneticlib.executors.road_validator.find_circle(p1, p2, p3)[source]

Returns the center and radius of the circle passing the given 3 points. In case the 3 points form a line, returns (None, infinity).

freneticlib.executors.road_validator.min_radius(x, w=5)[source]

Finds the smallest curvature radius within the road.

class freneticlib.executors.road_validator.RoadValidator(map_size: int = 200, road_min_length: float = 20)[source]

Bases: object

Performs several checks to assert the road is valid.

This means that the road has to be inside a square map, cannot contain too sharp turns or be self-intersecting, or have a certain minimum length, etc.

Parameters:
  • map_size (int) – The side length of the map.

  • road_min_length (float) – The minimum length of the road.

is_valid(test: freneticlib.core.core.TestIndividual, executor) Tuple[bool, str][source]

Perform the checks.

Specifically: - road has an acceptable number of points - road is not self-intersecting - the road polygon is inside the map - the road meets the self.road_min_length - the road is not too sharp

Returns:

A boolean indicating the validity and a string explanation of which check failed

Return type:

(Tuple[bool,str])

_is_too_sharp(the_test, TSHD_RADIUS=47) bool[source]

Checks if the road is not too sharp.

Parameters:
  • the_test – The road (in cartesian coordinates) to be evaluated

  • TSHD_RADIUS (float) – The maximum acceptable radius.

Returns:

Whether the road sharpness is acceptable.

Return type:

(bool)