Add bind() method to MjModel and MjData.

This method allows users to bind a spec to a model or data object, making it less verbose to access its arrays.

PiperOrigin-RevId: 699952211
Change-Id: I6b71a88d5a6968bc0f902bd49db7c568b46a4dfb
This commit is contained in:
Alessio Quaglino
2024-11-25 05:53:03 -08:00
committed by Copybara-Service
parent 13b6055098
commit c6ba8f27fd
6 changed files with 75 additions and 17 deletions
+3 -3
View File
@@ -457,9 +457,9 @@
"pos_x = []\n",
"pos_y = []\n",
"geoms = arena.worldbody.find_all(mj.mjtObj.mjOBJ_GEOM)\n",
"torsos_data = [data.geom(geom.name) for geom in geoms if 'torso' in geom.name]\n",
"torsos_model = [model.geom(geom.name) for geom in geoms if 'torso' in geom.name]\n",
"actuators = [data.actuator(actuator.name) for actuator in arena.actuators]\n",
"torsos_data = [data.bind(geom) for geom in geoms if 'torso' in geom.name]\n",
"torsos_model = [model.bind(geom) for geom in geoms if 'torso' in geom.name]\n",
"actuators = [data.bind(actuator) for actuator in arena.actuators]\n",
"\n",
"# Control signal frequency, phase, amplitude.\n",
"freq = 5\n",