gazebosim / gazebosim/sdformat
Flattening process for nested models modifies unintended elements
- Dominant language
- C++
- Stars
- 216
- Forks
- 125
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 14
Description
## Environment
* Source or binary build? source, `sdf9` & `sdf10`
## Description
During the flattening process of an included model, if an element value or attribute has the same value as an element name that requires a name replacement with the `::` deliminator then the value of the unintended element or attribute will be changed as well. For example,
```xml
1
...
box::1
...
```
This happens in the `replace_all` calls in `addNestedModel`: https://github.com/ignitionrobotics/sdformat/blob/1a0544467c3a33d2f7b9b71e05f40a1c893bc7ab/src/parser.cc#L1358-L1373
And for this particular example, will lead to `Error [Param.cc:319] Invalid boolean value` from `readXml` since the value of `` is now `box::1` (i.e., `_xml->GetText()` is `box::1`): https://github.com/ignitionrobotics/sdformat/blob/1a0544467c3a33d2f7b9b71e05f40a1c893bc7ab/src/parser.cc#L944
The logic needs to be addressed so that unintended elements/attributes are not modified.
## Steps to reproduce
1. Clone https://github.com/jennuine/sdf-flatten-bug
2. In a terminal, `export SDF_PATH=/path/to/repo/sdf-flatten-bug`
3. In a the same terminal, `ign sdf -k /path/to/repo/sdf-flatten-bug/include_model.sdf`
## Output
For the example provided above
```bash
Error [Param.cc:319] Invalid boolean value
Error [parser.cc:525] parse as sdf version 1.7 failed, should try to parse as old deprecated format
Error: Error reading element
Error: Error reading element
Error: Unable to parse sdf element[sdf]
Error: A model must have at least one link.
Error: A model must have at least one link.
Error: FrameAttachedToGraph error, Non-LINK vertex with name [__model__] is disconnected; it should have 1 outgoing edge in MODEL attached_to graph.
Error: Graph with __model__ scope has sink vertex named [__model__] when starting from vertex with name [__model__], which is not permitted.
Error: Failed to load a world.
```
Contributor guide
Assessment
This issue has not been assessed yet.