-
Notifications
You must be signed in to change notification settings - Fork 745
Expand file tree
/
Copy pathfloors_test.py
More file actions
50 lines (38 loc) · 1.65 KB
/
floors_test.py
File metadata and controls
50 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright 2019 The dm_control Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Tests for locomotion.arenas.floors."""
from absl.testing import absltest
from dm_control import mjcf
from dm_control.locomotion.arenas import floors
import numpy as np
class FloorsTest(absltest.TestCase):
def test_can_compile_mjcf(self):
arena = floors.Floor()
mjcf.Physics.from_mjcf_model(arena.mjcf_model)
def test_size(self):
floor_size = (12.9, 27.1)
arena = floors.Floor(size=floor_size)
self.assertEqual(tuple(arena.ground_geoms[0].size[:2]), floor_size)
def test_top_camera(self):
floor_width, floor_height = 12.9, 27.1
arena = floors.Floor(size=[floor_width, floor_height])
self.assertGreater(arena._top_camera_y_padding_factor, 1)
np.testing.assert_array_equal(arena._top_camera.quat, (1, 0, 0, 0))
expected_camera_y = floor_height * arena._top_camera_y_padding_factor
np.testing.assert_allclose(
np.tan(np.deg2rad(arena._top_camera.fovy / 2)),
expected_camera_y / arena._top_camera.pos[2])
if __name__ == '__main__':
absltest.main()