Skip to content

xodr_signal_list is [] and not None - if check bug #81

@PatrickPromitzer

Description

@PatrickPromitzer

Describe the bug
In the file qc_openscenario/checks/reference_checker/resolvable_signal_id_in_traffic_signal_state_action.py Line 55

xodr_signal_list = checker_data.xodr_root.findall(".//signal")
if xodr_signal_list is None:
    ....

was used.
The problem is that the xml package will give back an empty list if no values are found, and not None.
This makes the if statement always false.

To Reproduce
Steps to reproduce the behavior:

  1. install the packages
pip install asam-qc-baselib
pip install asam-qc-openscenarioxml

2.) Save this script and fill out the file_path

from qc_baselib import Configuration, Result
from qc_openscenario.checks.models import CheckerData
from qc_openscenario.checks import reference_checker
from qc_openscenario.checks import utils
from qc_openscenario import constants


def main():
    file_path = "path/to/openSCENARIO.xosc"

    config = Configuration()
    result = Result()
    checker_data = CheckerData(
        xml_file_path=file_path,
        input_file_xml_root=None,
        config=config,
        result=result,
        schema_version="1.0.0",
        xodr_root=None
    )

    result.register_checker_bundle(
        name=constants.BUNDLE_NAME,
        description="OpenScenario checker bundle",
        version=constants.BUNDLE_VERSION,
        summary="",
    )
    result.set_result_version(version=constants.BUNDLE_VERSION)

    checker = reference_checker.resolvable_signal_id_in_traffic_signal_state_action

    result.register_checker(
        checker_bundle_name=constants.BUNDLE_NAME,
        checker_id=checker.CHECKER_ID,
        description=checker.CHECKER_DESCRIPTION,
    )

    # Register the associated rule using the rule UID
    result.register_rule_by_uid(
        checker_bundle_name=constants.BUNDLE_NAME,
        checker_id=checker.CHECKER_ID,
        rule_uid=checker.RULE_UID,
    )

    checker_data.input_file_xml_root = utils.get_root_without_default_namespace(checker_data.xml_file_path)
    checker_data.xodr_root = checker_data.input_file_xml_root
    checker.check_rule(checker_data = checker_data)

if __name__ == "__main__":
    main()

Go to debug mode (or add a print) and check the value xodr_signal_list in
qc_openscenario/checks/reference_checker/resolvable_signal_id_in_traffic_signal_state_action.py

  1. Expected behavior
    The code should go in the
if xodr_signal_list is None:

statement if no signals are present in the openDRIVE file.

Screenshots

Image

Desktop (please complete the following information):

  • OS: Windows 11

Additional context
The bug exist in multiple instances in the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    isType:BugAn issue that contains contradictions or errors in the standard.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions