Skip to content

Commit

Permalink
mjSpec tutorial backwards compatibility with the latest MuJoCo release.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 690747714
Change-Id: Ib8894a1dc2a68e30a110e773c77fbd2baee87efd
  • Loading branch information
quagla authored and copybara-github committed Oct 28, 2024
1 parent d01fb81 commit f1d4b23
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions python/mjspec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"render(model)\n",
"\n",
"# Change the mjSpec, re-compile and re-render\n",
"geoms = spec.worldbody.find_all('geom')\n",
"geoms = spec.worldbody.find_all(mj.mjtObj.mjOBJ_GEOM)\n",
"geoms[0].name = 'blue_box'\n",
"geoms[0].rgba = [0, 0, 1, 1]\n",
"geoms[1].name = 'yellow_sphere'\n",
Expand Down Expand Up @@ -392,7 +392,11 @@
"#@title Six Creatures on a floor.{vertical-output: true}\n",
"\n",
"arena = mj.MjSpec()\n",
"arena.compiler.degree = False # Use radians.\n",
"\n",
"if hasattr(arena, 'compiler'):\n",
" arena.compiler.degree = False # MuJoCo dev (next release).\n",
"else:\n",
" arena.degree = False # MuJoCo release\n",
"\n",
"# Make arena with textured floor.\n",
"chequered = arena.add_texture(\n",
Expand Down Expand Up @@ -452,7 +456,7 @@
"video = []\n",
"pos_x = []\n",
"pos_y = []\n",
"geoms = arena.worldbody.find_all(\"geom\")\n",
"geoms = arena.worldbody.find_all(mj.mjtObj.mjOBJ_GEOM)\n",
"torsos = [geom.id for geom in geoms if 'torso' in geom.name]\n",
"actuators = [actuator.id for actuator in arena.actuators]\n",
"\n",
Expand Down Expand Up @@ -703,7 +707,11 @@
"\n",
"spec = mj.MjSpec.from_file(humanoid_file)\n",
"franka = mj.MjSpec.from_file(franka_file)\n",
"spec.compiler.degree = False # This has no effect on the humanoid as it does not contain angles\n",
"\n",
"if hasattr(spec, 'compiler'):\n",
" spec.compiler.degree = False # MuJoCo dev (next release).\n",
"else:\n",
" spec.degree = False # MuJoCo release\n",
"\n",
"# Replace right arm with frame\n",
"arm_right = spec.find_body('upper_arm_right')\n",
Expand Down Expand Up @@ -805,15 +813,18 @@
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [
"sJFuNetilv4m"
],
"gpuClass": "premium",
"private_outputs": true
},
"gpuClass": "premium",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f1d4b23

Please sign in to comment.