Gazebo resources: Tutorials | Q&A | Documentation | Blog

SDFormat Spec "Required" Values

I’m new to Gazebo and SDFormat and I’m trying to use the spec to understand what’s needed for minimal SDF files. So I go to double-check the question “does a link require a collision geometry?” and the answer seems to be

<collision> Element
   Required: *

I thought from context of other elements, * means “optional, but many such tags are allowed.” But then I find <state> and that does not seem to be correct.

In trying to figure out what it means I also stumbled on <road> -> <point> which is Required: +

http://sdformat.org/spec?ver=1.7&elem=world#road_point

I don’t want to belabor the point for <collision> which is easy enough to find out from other sources, just wanted to flag this quirk in case the non-numeric values for Required: are something weird and unintended going on in the backend or informative values that might be included in the Tree Key.

I found a key to interpreting these symbols buried into SDF’s API documentation. Here’s what it says:

  • 0: Not required.
  • 1: Exactly one element is required.
  • +: One or more elements are required.
  • *: Zero or more elements are required.

I ticketed an issue about making this information more easily available.

I believe the intention of * and + is to follow the pattern from regex, which is widely used. But I agree that it feels weird to use them without mentioning what they mean.

Thanks! Makes sense.

I believe the intention of * and + is to follow the pattern from regex, which is widely used.

Yeah, maybe it reads naturally to people who are coming at robotics code and simulation from the programming side instead of from the hardware/physics/other simulation side. I’ve still not yet internalized regex :sweat_smile:

1 Like