Compute nonzero default mass value only if geom is not in the default section.

Fixes #561.

PiperOrigin-RevId: 486604407
Change-Id: Ie62578808f96f0de3a2353c6bc4cc8bd3ae3afbc
This commit is contained in:
Alessio Quaglino
2022-11-07 02:17:58 -08:00
committed by Copybara-Service
parent 36b30e4500
commit fc24097b92
2 changed files with 29 additions and 1 deletions
+25
View File
@@ -684,6 +684,31 @@ TEST_F(XMLWriterTest, OverwritesDensity) {
mj_deleteModel(model);
}
TEST_F(XMLWriterTest, SaveDefaultMass) {
static constexpr char xml[] = R"(
<mujoco>
<asset>
<mesh name="example"
vertex="0 0 0 1 0 0 0 1 0 0 0 1"
face="2 0 3 0 1 3 1 2 3 0 2 1" />
</asset>
<default class="main">
<geom type="mesh" mass="1"/>
</default>
<worldbody>
<body>
<geom mesh="example" size=".1 .2 .3"/>
</body>
</worldbody>
</mujoco>
)";
mjModel* model = LoadModelFromString(xml);
EXPECT_THAT(model, NotNull());
std::string content = SaveAndReadXml(model);
EXPECT_THAT(content, HasSubstr("mass=\"1\""));
mj_deleteModel(model);
}
TEST_F(XMLWriterTest, UsesTwoSpaces) {
static constexpr char xml[] = R"(
<mujoco>