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
This commit is contained in:
Andrea Gesmundo
2025-01-13 05:40:56 -08:00
committed by Copybara-Service
parent d4ca66a47b
commit 1c32b5d2dd
+3 -12
View File
@@ -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": {