Add worldbody assertions in attach tests.

This clarifies the difference between attaching a full spec, which converts the worldbody to a frame, and attaching a specific body (or frame).

PiperOrigin-RevId: 721297010
Change-Id: Iff87fe99b81746e6ab3a189a3057b274d3c9a939
This commit is contained in:
Alessio Quaglino
2025-01-30 01:34:59 -08:00
committed by Copybara-Service
parent e0664b1bb8
commit 904b49848f
+6
View File
@@ -966,6 +966,7 @@ class SpecsTest(absltest.TestCase):
child1.assets = {'cube1.obj': 'cube1_content'}
body1 = child1.worldbody.add_body()
self.assertIs(body1, site.attach_body(body1, prefix='_'))
self.assertIsNotNone(child1.worldbody)
body1.pos = [1, 1, 1]
model1 = parent.compile()
self.assertIsNotNone(model1)
@@ -979,6 +980,7 @@ class SpecsTest(absltest.TestCase):
child2.assets = {'cube2.obj': 'cube2_content'}
body2 = child2.worldbody.add_body(name='body')
self.assertIsNotNone(parent.attach(child2, site=site, prefix='child2-'))
self.assertIsNone(child2.worldbody)
body2.pos = [-1, -1, -1]
model2 = parent.compile()
self.assertIsNotNone(model2)
@@ -995,6 +997,7 @@ class SpecsTest(absltest.TestCase):
child3.assets = {'cube3.obj': 'cube3_content'}
body3 = child3.worldbody.add_body(name='body')
self.assertIsNotNone(parent.attach(child3, site='site', prefix='child3-'))
self.assertIsNone(child3.worldbody)
body3.pos = [-2, -2, -2]
model3 = parent.compile()
self.assertIsNotNone(model3)
@@ -1032,6 +1035,7 @@ class SpecsTest(absltest.TestCase):
child1.assets = {'cube1.obj': 'cube1_content'}
body1 = child1.worldbody.add_body()
self.assertIs(body1, frame.attach_body(body1, prefix='_'))
self.assertIsNotNone(child1.worldbody)
body1.pos = [1, 1, 1]
model1 = parent.compile()
self.assertIsNotNone(model1)
@@ -1045,6 +1049,7 @@ class SpecsTest(absltest.TestCase):
child2.assets = {'cube2.obj': 'cube2_content'}
body2 = child2.worldbody.add_body(name='body')
self.assertIsNotNone(parent.attach(child2, frame=frame, prefix='child-'))
self.assertIsNone(child2.worldbody)
body2.pos = [-1, -1, -1]
model2 = parent.compile()
self.assertIsNotNone(model2)
@@ -1061,6 +1066,7 @@ class SpecsTest(absltest.TestCase):
child3.assets = {'cube2.obj': 'new_cube2_content'}
body3 = child3.worldbody.add_body(name='body')
self.assertIsNotNone(parent.attach(child3, frame='frame', prefix='child3-'))
self.assertIsNone(child3.worldbody)
body3.pos = [-2, -2, -2]
model3 = parent.compile()
self.assertIsNotNone(model3)