google-deepmind / google-deepmind/mujoco
Default class name missing when the spec attached to a parent without a suffix and prefix
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
### Intro
Hi!
I am Senior Software Engineer at Apptronik.
### My setup
Linux/MacOS, Mujoco C++, Mujoco 3.3.4
### What's happening? What did you expect?
When the child spec has a default class and it is attached to a parent class without using any suffix and prefix, the default class doesn't have any name. This results in an incompatible xml file.
### Steps for reproduction
1. Run the code below
2. Try loading the saved XML in the mujoco simulation application or using API.
### Minimal model for reproduction
This it the XML produced by my script
```XML
```
### Code required for reproduction
```
#include
using namespace std;
int main(){
mjSpec* spec = mj_makeSpec();
mjsBody* body = mjs_findBody(spec, "world");
mjsBody* body2 = mjs_addBody(body, nullptr);
mjsElement* frame = mjs_addFrame(mjs_findBody(spec, "world"), NULL)->element;
mjsDefault* def = mjs_addDefault(spec, "class", nullptr);
mjSpec* specA = mj_makeSpec();
mjsBody* bodyA = mjs_findBody(specA, "world");
mjsBody* bodyA2 = mjs_addBody(bodyA, nullptr);
mjsDefault* defA2 = mjs_addDefault(spec, "lol", nullptr);
mjs_attach(frame, bodyA2->element, "", "");
mj_compile(spec, nullptr);
char error[1024];
mj_saveXML(spec, "test.xml", error, sizeof(error));
return 0;
}
```
### Confirmations
- [x] I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting.
- [x] I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before.
Contributor guide
Assessment
This issue has not been assessed yet.