Skip to content

Commit 56cfba9

Browse files
authored
Merge branch 'google-deepmind:main' into musculoskeletal_dog_creation
2 parents 863b1e2 + 4d356d3 commit 56cfba9

10 files changed

Lines changed: 76 additions & 31 deletions

File tree

dm_control/mjcf/physics_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ def test_write_to_ipos(self):
484484
second = physics.bind(entity2)
485485

486486
# Initially both bodies should be 'simple' and 'sameframe'
487-
self.assertEqual(first.simple, 1)
487+
self.assertEqual(first.simple, 2)
488488
self.assertEqual(first.sameframe, 1)
489-
self.assertEqual(second.simple, 1)
489+
self.assertEqual(second.simple, 2)
490490
self.assertEqual(second.sameframe, 1)
491491

492492
# Assigning to `ipos` should disable 'simple' and 'sameframe' only for that
@@ -495,7 +495,7 @@ def test_write_to_ipos(self):
495495
first.ipos = new_ipos
496496
self.assertEqual(first.simple, 0)
497497
self.assertEqual(first.sameframe, 0)
498-
self.assertEqual(second.simple, 1)
498+
self.assertEqual(second.simple, 2)
499499
self.assertEqual(second.sameframe, 1)
500500
# `xipos` should reflect the new position.
501501
np.testing.assert_array_equal(first.xipos, new_ipos)
@@ -518,9 +518,9 @@ def test_write_to_iquat(self):
518518
second = physics.bind(entity2)
519519

520520
# Initially both bodies should be 'simple' and 'sameframe'
521-
self.assertEqual(first.simple, 1)
521+
self.assertEqual(first.simple, 2)
522522
self.assertEqual(first.sameframe, 1)
523-
self.assertEqual(second.simple, 1)
523+
self.assertEqual(second.simple, 2)
524524
self.assertEqual(second.sameframe, 1)
525525

526526
# Assigning to `iquat` should disable 'simple' and 'sameframe' only for that
@@ -529,7 +529,7 @@ def test_write_to_iquat(self):
529529
first.iquat = new_iquat
530530
self.assertEqual(first.simple, 0)
531531
self.assertEqual(first.sameframe, 0)
532-
self.assertEqual(second.simple, 1)
532+
self.assertEqual(second.simple, 2)
533533
self.assertEqual(second.sameframe, 1)
534534
# `ximat` should reflect the new quaternion.
535535
np.testing.assert_allclose(first.ximat, self.quat2mat(new_iquat))

dm_control/mujoco/engine.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
Contexts = collections.namedtuple('Contexts', ['gl', 'mujoco'])
6363
Selected = collections.namedtuple(
64-
'Selected', ['body', 'geom', 'skin', 'world_position'])
64+
'Selected', ['body', 'geom', 'flex', 'skin', 'world_position'])
6565
NamedIndexStructs = collections.namedtuple(
6666
'NamedIndexStructs', ['model', 'data'])
6767
Pose = collections.namedtuple(
@@ -937,12 +937,14 @@ def select(self, cursor_position):
937937
cursor_x, cursor_y = cursor_position
938938
pos = np.empty(3, np.double)
939939
geom_id_arr = np.intc([-1])
940+
flex_id_arr = np.intc([-1])
940941
skin_id_arr = np.intc([-1])
941942
body_id = mujoco.mjv_select(self._physics.model.ptr, self._physics.data.ptr,
942943
self._scene_option.ptr, aspect_ratio, cursor_x,
943944
cursor_y, self._scene.ptr, pos, geom_id_arr,
944-
skin_id_arr)
945+
flex_id_arr, skin_id_arr)
945946
[geom_id] = geom_id_arr
947+
[flex_id] = flex_id_arr
946948
[skin_id] = skin_id_arr
947949

948950
# Validate IDs
@@ -954,6 +956,10 @@ def select(self, cursor_position):
954956
assert 0 <= geom_id < self._physics.model.ngeom
955957
else:
956958
geom_id = None
959+
if flex_id != -1:
960+
assert 0 <= flex_id < self._physics.model.nflex
961+
else:
962+
flex_id = None
957963
if skin_id != -1:
958964
assert 0 <= skin_id < self._physics.model.nskin
959965
else:
@@ -963,7 +969,12 @@ def select(self, cursor_position):
963969
pos = None
964970

965971
return Selected(
966-
body=body_id, geom=geom_id, skin=skin_id, world_position=pos)
972+
body=body_id,
973+
geom=geom_id,
974+
flex=flex_id,
975+
skin=skin_id,
976+
world_position=pos,
977+
)
967978

968979

969980
class MovableCamera(Camera):

dm_control/mujoco/testing/image_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def compute_rms(image1, image2):
203203
return np.sqrt(float(sum_of_squares) / abs_diff.size)
204204

205205

206-
def assert_images_close(expected, actual, tolerance=10.):
206+
def assert_images_close(expected, actual, tolerance=23.5):
207207
"""Tests whether two images are almost equal.
208208
209209
Args:

dm_control/mujoco/tutorial.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"\"\"\")\n",
9494
"\n",
9595
"print('Installing dm_control...')\n",
96-
"!pip install -q dm_control\u003e=1.0.14\n",
96+
"!pip install -q dm_control\u003e=1.0.15\n",
9797
"\n",
9898
"# Configure dm_control to use the EGL rendering backend (requires GPU)\n",
9999
"%env MUJOCO_GL=egl\n",

dm_control/viewer/gui/base_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
_EPSILON = 1e-7
3434

3535

36-
@mock.patch(base.__name__ + '.time')
36+
@mock.patch.object(base, 'time')
3737
class DoubleClickDetectorTest(absltest.TestCase):
3838

3939
def setUp(self):

dm_control/viewer/renderer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ def raycast(self, viewport, screen_pos):
494494
viewport_pos = viewport.screen_to_inverse_viewport(screen_pos)
495495
grab_world_pos = np.empty(3, dtype=np.double)
496496
selected_geom_id_arr = np.intc([-1])
497+
selected_flex_id_arr = np.intc([-1])
497498
selected_skin_id_arr = np.intc([-1])
498499
selected_body_id = mujoco.mjv_select(
499500
self._model.ptr,
@@ -505,9 +506,14 @@ def raycast(self, viewport, screen_pos):
505506
self._scene.ptr,
506507
grab_world_pos,
507508
selected_geom_id_arr,
509+
selected_flex_id_arr,
508510
selected_skin_id_arr,
509511
)
510-
del selected_geom_id_arr, selected_skin_id_arr # Unused.
512+
del (
513+
selected_geom_id_arr,
514+
selected_skin_id_arr,
515+
selected_flex_id_arr,
516+
) # Unused.
511517
if selected_body_id < 0:
512518
selected_body_id = _INVALID_BODY_INDEX
513519
grab_world_pos = None

dm_control/viewer/renderer_test.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,25 @@ def initialize_camera(self, enable):
422422

423423
def test_raycast_mapping_geom_to_body_id(self):
424424
def build_mjv_select(mock_body_id, mock_geom_id, mock_position):
425+
425426
def mock_select(
426-
m, d, vopt, aspectratio, relx, rely, scn, selpnt, geomid, skinid):
427-
del m, d, vopt, aspectratio, relx, rely, scn, skinid # Unused.
427+
m,
428+
d,
429+
vopt,
430+
aspectratio,
431+
relx,
432+
rely,
433+
scn,
434+
selpnt,
435+
geomid,
436+
flexid,
437+
skinid,
438+
):
439+
del m, d, vopt, aspectratio, relx, rely, scn, flexid, skinid # Unused.
428440
selpnt[:] = mock_position
429441
geomid[:] = mock_geom_id
430442
return mock_body_id
443+
431444
return mock_select
432445

433446
geom_id = 0
@@ -444,9 +457,11 @@ def mock_select(
444457
np.testing.assert_array_equal(hit_world_pos, world_pos)
445458

446459
def test_raycast_hitting_empty_space(self):
460+
447461
def mock_select(
448-
m, d, vopt, aspectratio, relx, rely, scn, selpnt, geomid, skinid):
449-
del (m, d, vopt, aspectratio, relx, rely, scn, selpnt, geomid,
462+
m, d, vopt, aspectratio, relx, rely, scn, selpnt, geomid, flexid, skinid
463+
):
464+
del (m, d, vopt, aspectratio, relx, rely, scn, selpnt, geomid, flexid,
450465
skinid) # Unused.
451466
mock_body_id = -1 # Nothing selected.
452467
return mock_body_id
@@ -459,13 +474,26 @@ def mock_select(
459474

460475
def test_raycast_maps_coordinates_to_viewport_space(self):
461476
def build_mjv_select(expected_aspect_ratio, expected_viewport_pos):
477+
462478
def mock_select(
463-
m, d, vopt, aspectratio, relx, rely, scn, selpnt, geomid, skinid):
464-
del m, d, vopt, scn, selpnt, geomid, skinid # Unused.
479+
m,
480+
d,
481+
vopt,
482+
aspectratio,
483+
relx,
484+
rely,
485+
scn,
486+
selpnt,
487+
geomid,
488+
flexid,
489+
skinid,
490+
):
491+
del m, d, vopt, scn, selpnt, geomid, flexid, skinid # Unused.
465492
self.assertEqual(expected_aspect_ratio, aspectratio)
466493
np.testing.assert_array_equal(expected_viewport_pos, [relx, rely])
467494
mock_body_id = 0
468495
return mock_body_id
496+
469497
return mock_select
470498

471499
viewport_pos = [.5, .5]

requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
absl-py==1.4.0
1+
absl-py==2.0.0
22
dm-env==1.6
33
dm-tree==0.1.8
44
glfw==1.12.0
5-
h5py==3.9.0
5+
h5py==3.10.0
66
labmaze==1.0.6
77
lxml==4.9.3
88
mock==5.1.0
9-
mujoco==2.3.7
9+
mujoco==3.0.0
1010
nose==1.3.7
1111
nose-xunitmp==0.4.1
1212
numpy==1.24.4; python_version == '3.8'
13-
numpy==1.25.1; python_version >= '3.9'
14-
Pillow==10.0.0
13+
numpy==1.26.1; python_version >= '3.9'
14+
Pillow==10.1.0
1515
protobuf==3.19.4 # TensorFlow requires protobuf<3.20 (b/182876485)
1616
pyopengl==3.1.7
17-
pyparsing==3.1.0
17+
pyparsing==3.1.1
1818
requests==2.31.0
1919
scipy==1.10.1; python_version == '3.8'
20-
scipy==1.11.1; python_version >= '3.9'
21-
setuptools==68.0.0
22-
tqdm==4.65.0
20+
scipy==1.11.3; python_version >= '3.9'
21+
setuptools==68.2.2
22+
tqdm==4.66.0

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def is_excluded(s):
173173

174174
setup(
175175
name='dm_control',
176-
version='1.0.14',
176+
version='1.0.15',
177177
description='Continuous control environments and MuJoCo Python bindings.',
178178
long_description="""
179179
# `dm_control`: DeepMind Infrastructure for Physics-Based Simulation.
@@ -201,7 +201,7 @@ def is_excluded(s):
201201
'glfw',
202202
'labmaze',
203203
'lxml',
204-
'mujoco >= 2.3.7',
204+
'mujoco >= 3.0.0',
205205
'numpy >= 1.9.0',
206206
'protobuf >= 3.19.4', # TensorFlow requires protobuf<3.20 (b/182876485)
207207
'pyopengl >= 3.1.4',

tutorial.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"\"\"\")\n",
9494
"\n",
9595
"print('Installing dm_control...')\n",
96-
"!pip install -q dm_control\u003e=1.0.14\n",
96+
"!pip install -q dm_control\u003e=1.0.15\n",
9797
"\n",
9898
"# Configure dm_control to use the EGL rendering backend (requires GPU)\n",
9999
"%env MUJOCO_GL=egl\n",

0 commit comments

Comments
 (0)