From 1eb6fc22854af71f70744e31265eaf2e1bbb2c59 Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Wed, 25 Sep 2024 02:55:05 -0700 Subject: [PATCH] Disallow using elasticity and edge constraints at the same time. Fixes #2084. PiperOrigin-RevId: 678614880 Change-Id: I44eead3dc4edf82d725a3063b927a421c660721a --- src/user/user_mesh.cc | 3 +++ src/xml/xml_native_reader.cc | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/user/user_mesh.cc b/src/user/user_mesh.cc index cb1d5c0a..d03fc42b 100644 --- a/src/user/user_mesh.cc +++ b/src/user/user_mesh.cc @@ -2896,6 +2896,9 @@ void mjCFlex::Compile(const mjVFS* vfs) { // compute elasticity if (young > 0) { + if (poisson < 0 || poisson >= 0.5) { + throw mjCError(this, "Poisson ratio must be in [0, 0.5)"); + } stiffness.assign(21*nelem, 0); for (unsigned int t = 0; t < nelem; t++) { if (dim==2) { diff --git a/src/xml/xml_native_reader.cc b/src/xml/xml_native_reader.cc index d5813799..5fcaf155 100644 --- a/src/xml/xml_native_reader.cc +++ b/src/xml/xml_native_reader.cc @@ -2694,6 +2694,11 @@ void mjXReader::OneFlexcomp(XMLElement* elem, mjsBody* body, const mjVFS* vfs) { ReadAttr(elasticity, "thickness", 1, &dflex.thickness, text); } + // check errors + if (elasticity && fcomp.equality) { + throw mjXError(elem, "elasticity and edge constraints cannot both be present"); + } + // contact XMLElement* cont = FirstChildElement(elem, "contact"); if (cont) {