From e20ab6c96f2d89370d54e3024eaf80bb337a1421 Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Thu, 16 Mar 2023 12:05:03 -0700 Subject: [PATCH] Add a number of missing struct fields to Python bindings. It is quite possible that there are a few other fields still missing since we currently do not yet have automated testing of struct field existence. Fixes #747. PiperOrigin-RevId: 517189048 Change-Id: I7c1d95e700eaea05aaa3cde1fd05e1a259553117 --- doc/changelog.rst | 3 ++- python/mujoco/structs.cc | 7 +++++++ python/mujoco/structs.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index e911fb2c..a09dc375 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -48,9 +48,10 @@ Python bindings - Fixed IPython history corruption when using ``launch_repl``. The ``launch_repl`` function now provides seamless continuation of an IPython interactive shell session, and is no longer considered experimental feature. -- Remove ``efc_`` fields from joint indexers. Since the introduction of arena memory, these fields now have dynamic +- Removed ``efc_`` fields from joint indexers. Since the introduction of arena memory, these fields now have dynamic sizes that change between time steps depending on the number of active constraints, breaking strict correspondence between joints and ``efc_`` rows. +- Added a number of missing fields to the bindings of ``mjVisual`` and ``mjvPerturb`` structs. Simulate ^^^^^^^^ diff --git a/python/mujoco/structs.cc b/python/mujoco/structs.cc index c10a29b6..5bdc6e16 100644 --- a/python/mujoco/structs.cc +++ b/python/mujoco/structs.cc @@ -983,6 +983,7 @@ MjvPerturbWrapper::MjWrapper() }()), X(refpos), X(refquat), + X(refselpos), X(localpos) {} #undef X @@ -1299,8 +1300,11 @@ PYBIND11_MODULE(_structs, m) { #define X(var) mjVisualGlobal.def_readwrite(#var, &raw::MjVisualGlobal::var) X(fovy); X(ipd); + X(azimuth); + X(elevation); X(linewidth); X(glow); + X(realtime); X(offwidth); X(offheight); #undef X @@ -1966,11 +1970,14 @@ This is useful for example when the MJB is not available as a file on disk.)")); X(skinselect); X(active); X(active2); + X(localmass); + X(scale); #undef X #define X(var) DefinePyArray(mjvPerturb, #var, &MjvPerturbWrapper::var) X(refpos); X(refquat); + X(refselpos); X(localpos); #undef X diff --git a/python/mujoco/structs.h b/python/mujoco/structs.h index 3e80f1e7..3b208f57 100644 --- a/python/mujoco/structs.h +++ b/python/mujoco/structs.h @@ -611,6 +611,7 @@ class MjWrapper : public WrapperBase { #define X(var) py_array_or_tuple_t var X(refpos); X(refquat); + X(refselpos); X(localpos); #undef X };