From 1c32b5d2dd02842e532e80319c42705ae44ce920 Mon Sep 17 00:00:00 2001 From: Andrea Gesmundo Date: Mon, 13 Jan 2025 05:40:56 -0800 Subject: [PATCH] Fix attach logic. Replace .attach() with .attach_body() where a body is passed as a first argument instead of a spec that is expected by .attach(). +Fix typo. PiperOrigin-RevId: 714933134 Change-Id: Idb242fbef0fe164075826c01d4e1995c7d4ae565 --- python/mjspec.ipynb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/python/mjspec.ipynb b/python/mjspec.ipynb index c1e1fbf9..2f09d3cf 100644 --- a/python/mjspec.ipynb +++ b/python/mjspec.ipynb @@ -372,7 +372,7 @@ " theta = 2 * i * np.pi / num_legs\n", " hip_pos = BODY_RADIUS * np.array([np.cos(theta), np.sin(theta), 0])\n", " hip_site = spec.worldbody.add_site(pos=hip_pos, euler=[0, 0, theta])\n", - " hip_site.attach(leg.spec.find_body('thigh'), '', '-' + str(i))\n", + " hip_site.attach_body(leg.spec.find_body('thigh'), '', '-' + str(i))\n", "\n", " return spec" ] @@ -428,7 +428,7 @@ " spawn_pos = (xpos.flat[i], ypos.flat[i], zpos.flat[i])\n", " spawn_site = arena.worldbody.add_site(pos=spawn_pos, group=3)\n", " # Attach to the arena at the spawn sites, with a free joint.\n", - " spawn_body = spawn_site.attach(spec.worldbody, '', '-' + str(i))\n", + " spawn_body = spawn_site.attach_body(spec.worldbody, '', '-' + str(i))\n", " spawn_body.add_freejoint()\n", "\n", "# Instantiate the physics and render.\n", @@ -654,7 +654,7 @@ "id": "owcmKeuSzQRy" }, "source": [ - "We wish to remove the arms and replace them with the legs. This can be done by first storing the arm positions into frames attaches to the torso. Then we can detach the arms and self-attach the legs into the frames." + "We wish to remove the arms and replace them with the legs. This can be done by first storing the arm positions into frames attached to the torso. Then we can detach the arms and self-attach the legs into the frames." ] }, { @@ -807,15 +807,6 @@ "model = spec.compile()\n", "render(model, height=400)" ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "id": "pyy2q_mSVAX1" - }, - "outputs": [], - "source": [] } ], "metadata": {