From 8d84b5f693972a521c8bf613e4a7764bf1c0f297 Mon Sep 17 00:00:00 2001 From: Kyle Bayes Date: Mon, 14 Oct 2024 09:18:14 -0700 Subject: [PATCH] Disable hfields for collision sensors. PiperOrigin-RevId: 685730321 Change-Id: Ib1d4a90b7b31ca388e018076a274e25c40409080 --- doc/changelog.rst | 2 ++ src/user/user_objects.cc | 6 ++++++ src/user/user_objects.h | 1 + test/engine/testdata/sensor/fromto_convex.xml | 8 -------- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index a1c02d8d..c4e1507f 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -31,6 +31,8 @@ Bug fixes ^^^^^^^^^ - Fixed a bug where ``actuator_force`` was not set in MJX (:github:issue:`2068`). - Fixed bug where MJX data tendon fields were incorrect after calling ``mjx.put_data``. +- The compiler now returns an error if height fields are used with :ref:`collision sensors` as they + are not yet supported. Version 3.2.3 (Sep 16, 2024) diff --git a/src/user/user_objects.cc b/src/user/user_objects.cc index 4293fb02..1df87fd8 100644 --- a/src/user/user_objects.cc +++ b/src/user/user_objects.cc @@ -6399,6 +6399,12 @@ void mjCSensor::Compile(void) { throw mjCError(this, "1st body/geom must be different from 2nd body/geom"); } + // height fields are not necessarily convex and are not yet supported + if (static_cast(obj)->Type() == mjGEOM_HFIELD || + static_cast(ref)->Type() == mjGEOM_HFIELD) { + throw mjCError(this, "height fields are not supported in geom distance sensors"); + } + // set needstage = mjSTAGE_POS; if (type==mjSENS_GEOMDIST) { diff --git a/src/user/user_objects.h b/src/user/user_objects.h index f7723b2b..08aca2f8 100644 --- a/src/user/user_objects.h +++ b/src/user/user_objects.h @@ -530,6 +530,7 @@ class mjCGeom : public mjCGeom_, private mjsGeom { void SetInertia(void); // compute and set geom inertia bool IsVisual(void) const { return visual_; } void SetNotVisual(void) { visual_ = false; } + mjtGeom Type() const { return type; } // Compute all coefs modeling the interaction with the surrounding fluid. void SetFluidCoefs(void); diff --git a/test/engine/testdata/sensor/fromto_convex.xml b/test/engine/testdata/sensor/fromto_convex.xml index e46deceb..4a83f5e5 100644 --- a/test/engine/testdata/sensor/fromto_convex.xml +++ b/test/engine/testdata/sensor/fromto_convex.xml @@ -61,23 +61,15 @@ - - - - - - - -