Carla 模拟器中的 XMLSchemaChildrenValidationError (Python 3.7)
XMLSchemaChildrenValidationError in Carla simulator (Python 3.7)
我一直在尝试在 Carla 0.9.5 中使用带有 openscenario 文件的场景运行器(使用 Python 3.7):
python scenario_runner.py --openscenario openscenario_file.xosc
我不断收到以下错误:
Traceback (most recent call last):
File "scenario_runner.py", line 413, in <module>
SCENARIORUNNER.run(ARGUMENTS)
File "scenario_runner.py", line 224, in run
self.run_openscenario(args)
File "scenario_runner.py", line 311, in run_openscenario
config = OpenScenarioConfiguration(args.openscenario)
File "C:\scenario_runner-0.9.5.1\srunner\tools\openscenario_parser.py", line 37, in __init__
self._validate_openscenario_configuration()
File "C:\scenario_runner-0.9.5.1\srunner\tools\openscenario_parser.py", line 58, in _validate_openscenario_configuration
xsd.validate(self.xml_tree)
File "C:\Python\Python37\site-packages\xmlschema\validators\schema.py", line 1269, in validate
raise error
xmlschema.validators.exceptions.XMLSchemaChildrenValidationError: failed validating <Element 'Event' at 0x000002621BDF6458> with XsdGroup(model='sequence', occurs=[1, 1]):
Reason: Unexpected child with tag 'Conditions' at position 2. Tag 'StartConditions' expected.
Schema:
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Action">
<xsd:complexType>
<xsd:choice>
<xsd:element name="Global" type="OSCGlobalAction" />
<xsd:element name="UserDefined" type="OSCUserDefinedAction" />
<xsd:element name="Private" type="OSCPrivateAction" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="StartConditions">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="ConditionGroup" type="OSCConditionGroup" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
...
...
</xsd:complexType>
Instance:
<Event name="MyLaneChangeLeftEvent" priority="overwrite">
<Action name="MyLaneChangeLeftAction">
<Private>
<Lateral>
<LaneChange>
<Dynamics shape="sinusoidal" time="5" />
<Target>
<Relative object="$owner" value="1" />
</Target>
</LaneChange>
</Lateral>
</Private>
</Action>
<Conditions>
<Start>
<ConditionGroup>
<Condition delay="0" edge="rising" name="MyStartCondition1">
<ByEntity>
<TriggeringEntities rule="any">
<Entity name="$owner" />
...
...
</Event>
Path: /OpenSCENARIO/Storyboard/Story/Act/Sequence/Maneuver/Event
我对 python 和 carla 很陌生。我查找了此类错误,但是找不到任何有用的信息,有什么想法吗?据我了解,子元素 "Conditions" 似乎是无效的子元素,但我不确定为什么。
错误很明显
Unexpected child with tag 'Conditions' at position 2. Tag 'StartConditions' expected.
验证器看到一个 <Conditions>
元素,其中预期 <StartConditions>
。
您的架构显示 "after 1..N occurrences of <Action>
there must be a <StartConditions>
":
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Action">
<xsd:complexType>
<xsd:choice>
<xsd:element name="Global" type="OSCGlobalAction" />
<xsd:element name="UserDefined" type="OSCUserDefinedAction" />
<xsd:element name="Private" type="OSCPrivateAction" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="StartConditions">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="ConditionGroup" type="OSCConditionGroup" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
这就是您的 XML 所做的:
<Event name="MyLaneChangeLeftEvent" priority="overwrite">
<Action name="MyLaneChangeLeftAction"> <!-- position 1 -->
<!-- ... -->
</Action>
<Conditions> <!-- position 2 -->
<!-- ... -->
</Conditions>
</Event>
解决方案是更新您的 XML 以匹配架构,或者更新您的架构以匹配 XML。
我一直在尝试在 Carla 0.9.5 中使用带有 openscenario 文件的场景运行器(使用 Python 3.7):
python scenario_runner.py --openscenario openscenario_file.xosc
我不断收到以下错误:
Traceback (most recent call last):
File "scenario_runner.py", line 413, in <module>
SCENARIORUNNER.run(ARGUMENTS)
File "scenario_runner.py", line 224, in run
self.run_openscenario(args)
File "scenario_runner.py", line 311, in run_openscenario
config = OpenScenarioConfiguration(args.openscenario)
File "C:\scenario_runner-0.9.5.1\srunner\tools\openscenario_parser.py", line 37, in __init__
self._validate_openscenario_configuration()
File "C:\scenario_runner-0.9.5.1\srunner\tools\openscenario_parser.py", line 58, in _validate_openscenario_configuration
xsd.validate(self.xml_tree)
File "C:\Python\Python37\site-packages\xmlschema\validators\schema.py", line 1269, in validate
raise error
xmlschema.validators.exceptions.XMLSchemaChildrenValidationError: failed validating <Element 'Event' at 0x000002621BDF6458> with XsdGroup(model='sequence', occurs=[1, 1]):
Reason: Unexpected child with tag 'Conditions' at position 2. Tag 'StartConditions' expected.
Schema:
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Action">
<xsd:complexType>
<xsd:choice>
<xsd:element name="Global" type="OSCGlobalAction" />
<xsd:element name="UserDefined" type="OSCUserDefinedAction" />
<xsd:element name="Private" type="OSCPrivateAction" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="StartConditions">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="ConditionGroup" type="OSCConditionGroup" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
...
...
</xsd:complexType>
Instance:
<Event name="MyLaneChangeLeftEvent" priority="overwrite">
<Action name="MyLaneChangeLeftAction">
<Private>
<Lateral>
<LaneChange>
<Dynamics shape="sinusoidal" time="5" />
<Target>
<Relative object="$owner" value="1" />
</Target>
</LaneChange>
</Lateral>
</Private>
</Action>
<Conditions>
<Start>
<ConditionGroup>
<Condition delay="0" edge="rising" name="MyStartCondition1">
<ByEntity>
<TriggeringEntities rule="any">
<Entity name="$owner" />
...
...
</Event>
Path: /OpenSCENARIO/Storyboard/Story/Act/Sequence/Maneuver/Event
我对 python 和 carla 很陌生。我查找了此类错误,但是找不到任何有用的信息,有什么想法吗?据我了解,子元素 "Conditions" 似乎是无效的子元素,但我不确定为什么。
错误很明显
Unexpected child with tag 'Conditions' at position 2. Tag 'StartConditions' expected.
验证器看到一个 <Conditions>
元素,其中预期 <StartConditions>
。
您的架构显示 "after 1..N occurrences of <Action>
there must be a <StartConditions>
":
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Action">
<xsd:complexType>
<xsd:choice>
<xsd:element name="Global" type="OSCGlobalAction" />
<xsd:element name="UserDefined" type="OSCUserDefinedAction" />
<xsd:element name="Private" type="OSCPrivateAction" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="StartConditions">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="ConditionGroup" type="OSCConditionGroup" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
这就是您的 XML 所做的:
<Event name="MyLaneChangeLeftEvent" priority="overwrite">
<Action name="MyLaneChangeLeftAction"> <!-- position 1 -->
<!-- ... -->
</Action>
<Conditions> <!-- position 2 -->
<!-- ... -->
</Conditions>
</Event>
解决方案是更新您的 XML 以匹配架构,或者更新您的架构以匹配 XML。