Skip to content

Commit

Permalink
Add worldbody assertions in attach tests.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
quagla authored and copybara-github committed Jan 30, 2025
1 parent e0664b1 commit 904b498
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/mujoco/specs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ def test_attach_to_site(self):
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)
Expand All @@ -979,6 +980,7 @@ def test_attach_to_site(self):
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)
Expand All @@ -995,6 +997,7 @@ def test_attach_to_site(self):
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)
Expand Down Expand Up @@ -1032,6 +1035,7 @@ def test_attach_to_frame(self):
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)
Expand All @@ -1045,6 +1049,7 @@ def test_attach_to_frame(self):
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)
Expand All @@ -1061,6 +1066,7 @@ def test_attach_to_frame(self):
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)
Expand Down

0 comments on commit 904b498

Please sign in to comment.