From 9a7f4a768aff625e539f8c50c39ae6a99a7272b5 Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Mon, 6 Feb 2023 05:51:37 -0800 Subject: [PATCH] Remove control plugin API. This is a rollback of f937ffd93326b2964e33689b0dc6024124776a9e. PiperOrigin-RevId: 507456400 Change-Id: I2026510e6065eb440c0c899fcc5a2cc8ff5afd49 --- doc/includes/references.h | 1 - include/mujoco/mjplugin.h | 1 - introspect/enums.py | 1 - src/engine/engine_forward.c | 27 +++------------------------ unity/Runtime/Bindings/MjBindings.cs | 1 - 5 files changed, 3 insertions(+), 28 deletions(-) diff --git a/doc/includes/references.h b/doc/includes/references.h index 36eacea6..0fd7e965 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -1154,7 +1154,6 @@ typedef enum mjtPluginCapabilityBit_ { mjPLUGIN_ACTUATOR = 1<<0, mjPLUGIN_SENSOR = 1<<1, mjPLUGIN_PASSIVE = 1<<2, - mjPLUGIN_CONTROL = 1<<3, } mjtPluginCapabilityBit; struct mjpPlugin_ { const char* name; // globally unique name identifying the plugin diff --git a/include/mujoco/mjplugin.h b/include/mujoco/mjplugin.h index 0448a71f..315438ed 100644 --- a/include/mujoco/mjplugin.h +++ b/include/mujoco/mjplugin.h @@ -24,7 +24,6 @@ typedef enum mjtPluginCapabilityBit_ { mjPLUGIN_ACTUATOR = 1<<0, mjPLUGIN_SENSOR = 1<<1, mjPLUGIN_PASSIVE = 1<<2, - mjPLUGIN_CONTROL = 1<<3, } mjtPluginCapabilityBit; struct mjpPlugin_ { diff --git a/introspect/enums.py b/introspect/enums.py index 1d6ef75b..f8269715 100755 --- a/introspect/enums.py +++ b/introspect/enums.py @@ -558,7 +558,6 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjPLUGIN_ACTUATOR', 1), ('mjPLUGIN_SENSOR', 2), ('mjPLUGIN_PASSIVE', 4), - ('mjPLUGIN_CONTROL', 8), ]), )), ('mjtGridPos', diff --git a/src/engine/engine_forward.c b/src/engine/engine_forward.c index 34cbaef9..fd214e2a 100644 --- a/src/engine/engine_forward.c +++ b/src/engine/engine_forward.c @@ -775,30 +775,9 @@ void mj_forwardSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor) } // acceleration-dependent - if (!mjDISABLED(mjDSBL_ACTUATION)) { - // call legacy control callback if specified - if (mjcb_control) { - mjcb_control(m, d); - } - - // handle control plugins - if (m->nplugin) { - const int nslot = mjp_pluginCount(); - for (int i=0; inplugin; i++) { - const int slot = m->plugin[i]; - const mjpPlugin* plugin = mjp_getPluginAtSlotUnsafe(slot, nslot); - if (!plugin) { - mju_error_i("invalid plugin slot: %d", slot); - } - if (plugin->capabilityflags & mjPLUGIN_CONTROL) { - if (!plugin->compute) { - mju_error_i("`compute` is a null function pointer for plugin at slot %d", slot); - } - plugin->compute(m, d, i, mjPLUGIN_CONTROL); - } - } - } -} + if (mjcb_control && !mjDISABLED(mjDSBL_ACTUATION)) { + mjcb_control(m, d); + } mj_fwdActuation(m, d); mj_fwdAcceleration(m, d); diff --git a/unity/Runtime/Bindings/MjBindings.cs b/unity/Runtime/Bindings/MjBindings.cs index ffff4ea8..8a563066 100644 --- a/unity/Runtime/Bindings/MjBindings.cs +++ b/unity/Runtime/Bindings/MjBindings.cs @@ -365,7 +365,6 @@ public enum mjtPluginCapabilityBit : int{ mjPLUGIN_ACTUATOR = 1, mjPLUGIN_SENSOR = 2, mjPLUGIN_PASSIVE = 4, - mjPLUGIN_CONTROL = 8, } public enum mjtGridPos : int{ mjGRID_TOPLEFT = 0,