Closed hartikainen closed 2 weeks ago
I would say this is more of a feature request than a bug. With the current design, you can't set defaults, create a geom, change the defaults, and expect that they propagate. Defaults are used once to create the geom and then only kept for deciding which attributes to write explicitly when saving an XML. Maybe a solution is to keep track if a default has been used and if so return an error when changing any of its attributes? Any better ideas?
Perhaps I misunderstand how the defaults work, but it was surprising to me that the contype="1" conaffinity="1"
values get written to the geom
element only when I manually change the geom's default values (and not when I haven't touched the default values; see the note and assert after the first compile()
call above). I'll need to play around with this a bit more to understand what the semantics are before I can comment on what the good solution here would be.
Yes, I think this is basically a documentation issue. When using mjSpec
, defaults are applied once, when creating the element. I will add a clarifying note.
Intro
Hi!
I use MuJoCo for robotic manipulation.
My setup
MuJoCo:
API: Python
OS:
What's happening? What did you expect?
Modifying
MjSpec
element's default values doesn't take effect as I would expect. For example, modifying the defaultcontype
value of an element that doesn't havecontype
explicitly defined, I would expect the default'scontype
value to take precedence. However, what I see is thatMjSpec
directly assigns thecontype
value to the element and thus the defaultcontype
is not taken into account.See the test case below for reproduction.
Steps for reproduction
(This could be dropped directly into specs_test.py.)
This one fails with:
As I didn't modify the
con{type,affinity}
values forgeom
directly, I'd expected them to not be set (note how they're set only if I modify the default values) and thus the default values to take precedence. Here, however, they're both set to1
explicitly and thedefault
values get ignored.Minimal model for reproduction
See above.
Code required for reproduction
See above.
Confirmations