gazebosim/sdformat

Enforce required elements

开放

#1,002 创建于 2022年4月22日

 (2 条评论) (0 个反应) (0 位负责人)C++ (122 个派生)auto 404
documentationhelp wanted

仓库指标

星标
 (216 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

The "required" field of the spec accepts 5 different values. They're not documented very prominently (#496 ), but there's a definition for them here:

https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/include/sdf/Element.hh#L109-L113

Current enforcement

Looking through the code, I found some places that make use of them:

  1. Deprecated elements (-1) issue errors:

    https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/src/parser.cc#L1491-L1495

  2. Elements that must have exactly 1 or must have at least one + issue errors:

    https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/src/parser.cc#L1504-L1509 https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/src/parser.cc#L1903

But that 's only part of it.

Missing enforcement

Should these also cause errors (they're all currently valid according to ign sdf -k)?


More than one element when it should have exactly one (1):

<?xml version="1.0" ?>
<sdf version="1.6">
<world name="banana">
<audio>
  <device>a</device>
  <device>b</device>
</audio>
</world>
</sdf>

The difference between 0 and * should be clarified in the documentation and also in the enforcement. I assume that the existence of * implies that 0 means "either none or one". In that case, this should be an error:

<?xml version="1.0" ?>
<sdf version="1.6">
<world name="banana">
<wind></wind>
<wind></wind>
</world>
</sdf>

贡献者指南