Official rules for individual OSI fields are defined in the *.proto
files of
OSI.
The first step to using and editing rules is to extract them from the proto files with rules2yml.py
.
It has the following options:
usage: python3 rules2yml.py [-h] [--dir DIR] [--full-osi]
Export the rules of *.proto files into the *.yml format so it can be used by
the validator.
options:
-h, --help show this help message and exit
--dir DIR, -d DIR Name of the directory where the yml rules will be stored.
--full-osi, -f Add is_set rule to all fields that do not contain it already.
The following example command will generate the yml rule files in a folder rules
and add the is_set
rule to every OSI field that does not have this rule anyways.
This will result in a rule base to check for a full interface.
python3 rules2yml.py --dir rules --full-osi
The resulting yml rule files can be freely edited and are explained in the following in more detail.
Below you can see an example of the osi_detectedlane.yml rule file for
osi_detectedlane.proto without the --full-osi
option.
DetectedLane:
header:
CandidateLane:
probability:
- is_greater_than_or_equal_to: 0
- is_less_than_or_equal_to: 1
classification:
DetectedLaneBoundary:
header:
boundary_line:
position:
Each root at the top level represent a root message type
DetectedLane
or DetectedLaneBoundary
. The children of each root
message represent its fields if they are not camel-case. For example
header
is a field of DetectedLane
or header
and
boundary_line
are fields of DetectedLaneBoundary
.
CandidateLane
is a submessage of the message DetectedLane
. Each
field has a sequence
(starting with an hyphen -
) of rules that
apply to that specific field. For example the probability of the message
CandidateLane
is between 0 and 1.
The rules can either be with or without any parameters.
is_greater_than_or_equal_to: 0.0
is_equal: 1
In the case a rule has a parameter, it is written as a
mapping ( a scalar followed by a colon ":").
What comes after the colon depends on the rule used. For instance, the
rule is_greater_than_or_equal_to
accept a double.
The available rules and their usage are explained in the osi-validator
class
osi_rules_implementations.
See also examples for available rules which can be defined in *.yml
files below:
is_set:
is_greater_than: 1
is_greater_than_or_equal_to: 1
is_less_than_or_equal_to: 10
is_less_than: 2
is_equal: 1
is_different: 2
is_globally_unique:
refers_to: Lane
is_iso_country_code:
first_element: {is_equal: 0.13, is_greater_than: 0.13}
last_element: {is_equal: 0.13, is_greater_than: 0.13}
check_if: [{is_equal: 2, is_greater_than: 3, target: this.y}, {do_check: {is_equal: 1, is_less_than: 3}}]