18
18
from __future__ import division
19
19
from __future__ import print_function
20
20
21
+ import unittest
22
+
21
23
# Internal dependencies.
22
24
23
25
from absl .testing import absltest
24
26
from absl .testing import parameterized
25
27
28
+ from dm_control import render
26
29
from dm_control .mujoco import engine
27
30
from dm_control .mujoco import wrapper
28
31
from dm_control .mujoco .testing import assets
@@ -63,12 +66,14 @@ def _assert_attributes_equal(self, actual_obj, expected_obj, attr_to_compare):
63
66
raise AssertionError ("Attribute '{}' differs from expected value. {}"
64
67
"" .format (name , e .message ))
65
68
69
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
66
70
@parameterized .parameters (0 , 'cart' , u'cart' )
67
71
def testCameraIndexing (self , camera_id ):
68
72
height , width = 480 , 640
69
73
_ = engine .Camera (
70
74
self ._physics , height , width , camera_id = camera_id )
71
75
76
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
72
77
def testDepthRender (self ):
73
78
plane_and_box = """
74
79
<mujoco>
@@ -86,6 +91,7 @@ def testDepthRender(self):
86
91
# Furthest pixels should be 3m away (depth is orthographic)
87
92
np .testing .assert_approx_equal (pixels .max (), 3.0 , 3 )
88
93
94
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
89
95
def testTextOverlay (self ):
90
96
height , width = 480 , 640
91
97
overlay = engine .TextOverlay (title = 'Title' , body = 'Body' , style = 'big' ,
@@ -97,6 +103,7 @@ def testTextOverlay(self):
97
103
self .assertFalse (np .all (no_overlay == with_overlay ),
98
104
msg = 'Images are identical with and without text overlay.' )
99
105
106
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
100
107
def testSceneOption (self ):
101
108
height , width = 480 , 640
102
109
scene_option = wrapper .MjvOption ()
@@ -115,6 +122,7 @@ def testSceneOption(self):
115
122
((0.5 , 0.1 ), (0 , 0 )), # ground
116
123
((0.9 , 0.9 ), (None , None )), # sky
117
124
)
125
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
118
126
def testCameraSelection (self , coordinates , expected_selection ):
119
127
height , width = 480 , 640
120
128
camera = engine .Camera (self ._physics , height , width , camera_id = 0 )
@@ -127,6 +135,7 @@ def testCameraSelection(self, coordinates, expected_selection):
127
135
selected = camera .select (coordinates )
128
136
self .assertEqual (expected_selection , selected [:2 ])
129
137
138
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
130
139
def testMovableCameraSetGetPose (self ):
131
140
height , width = 240 , 320
132
141
@@ -154,6 +163,7 @@ def testMovableCameraSetGetPose(self):
154
163
155
164
self .assertFalse (np .all (image == camera .render ()))
156
165
166
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
157
167
def testRenderExceptions (self ):
158
168
max_width = self ._physics .model .vis .global_ .offwidth
159
169
max_height = self ._physics .model .vis .global_ .offheight
@@ -167,6 +177,7 @@ def testRenderExceptions(self):
167
177
with self .assertRaisesRegexp (ValueError , 'camera_id' ):
168
178
self ._physics .render (max_height , max_width , camera_id = - 2 )
169
179
180
+ @unittest .skipIf (render .DISABLED , reason = render .DISABLED_MESSAGE )
170
181
def testPhysicsRenderMethod (self ):
171
182
height , width = 240 , 320
172
183
image = self ._physics .render (height = height , width = width )
0 commit comments