Warn when a non-rigid flex has no constraints or passive forces.
Add a warning in user_model.cc if a flex is not rigid and has no edge equality constraints or passive forces (edge stiffness, edge damping, or vertex damping). Such flexes would not affect the simulation. A test case is added to verify the warning. PiperOrigin-RevId: 889215981 Change-Id: I481128e1456921b632719547c676d201fdfbe931
This commit is contained in:
committed by
Copybara-Service
parent
fd3ce4fe92
commit
c49bc7c7c0
@@ -3538,6 +3538,12 @@ void mjCModel::CopyObjects(mjModel* m) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pfl->rigid && m->flex_edgeequality[i] == 0 &&
|
||||||
|
!pfl->edgestiffness && !pfl->edgedamping && !pfl->damping) {
|
||||||
|
mju_warning("flex '%s' is not rigid and has no equality constraints "
|
||||||
|
"or passive forces", pfl->name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// copy bvh data (flex aabb computed dynamically in mjData)
|
// copy bvh data (flex aabb computed dynamically in mjData)
|
||||||
if (pfl->tree.Nbvh()) {
|
if (pfl->tree.Nbvh()) {
|
||||||
memcpy(m->bvh_child + 2*bvh_adr, pfl->tree.Child().data(), 2*pfl->tree.Nbvh()*sizeof(int));
|
memcpy(m->bvh_child + 2*bvh_adr, pfl->tree.Child().data(), 2*pfl->tree.Nbvh()*sizeof(int));
|
||||||
|
|||||||
@@ -991,5 +991,22 @@ TEST_F(UserFlexTest, FlexAttachConstraintPreserved) {
|
|||||||
mj_deleteVFS(vfs.get());
|
mj_deleteVFS(vfs.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(UserFlexTest, FlexNoConstraintsWarning) {
|
||||||
|
static constexpr char xml[] = R"(
|
||||||
|
<mujoco>
|
||||||
|
<worldbody>
|
||||||
|
<flexcomp name="test" type="grid" count="4 4 1" spacing=".2 .2 .2"
|
||||||
|
dim="2" radius=".1"/>
|
||||||
|
</worldbody>
|
||||||
|
</mujoco>
|
||||||
|
)";
|
||||||
|
std::array<char, 1024> error;
|
||||||
|
mjModel* m = LoadModelFromString(xml, error.data(), error.size());
|
||||||
|
ASSERT_THAT(m, NotNull()) << error.data();
|
||||||
|
EXPECT_THAT(error.data(),
|
||||||
|
HasSubstr("no equality constraints or passive forces"));
|
||||||
|
mj_deleteModel(m);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace mujoco
|
} // namespace mujoco
|
||||||
|
|||||||
Reference in New Issue
Block a user