google-research

Форк
0
81 строка · 2.9 Кб
1
# coding=utf-8
2
# Copyright 2024 The Google Research Authors.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
"""A collection of MuJoCo-based Reinforcement Learning environments.
17

18
The suite provides a similar API to the original dm_control suite.
19
Users can configure the distractions on top of the original tasks. The suite is
20
targeted for loading environments directly with similar configurations as those
21
used in the original paper. Each distraction wrapper can be used independently
22
though.
23
"""
24
import numpy as np
25

26
DIFFICULTY_SCALE = dict(easy=0.1, medium=0.2, hard=0.3)
27
DIFFICULTY_NUM_VIDEOS = dict(easy=4, medium=8, hard=None)
28
DEFAULT_BACKGROUND_PATH = "$HOME/davis/"
29

30

31
def get_color_kwargs(scale, dynamic):
32
  max_delta = scale
33
  step_std = 0.03 * scale if dynamic else 0.0
34
  return dict(max_delta=max_delta, step_std=step_std)
35

36

37
def get_camera_kwargs(domain_name, scale, dynamic):
38
  assert domain_name in ['reacher', 'cartpole', 'finger', 'cheetah',
39
                         'ball_in_cup', 'walker', 'humanoid']
40
  assert scale >= 0.0
41
  assert scale <= 1.0
42
  return dict(
43
      vertical_delta=np.pi / 2 * scale,
44
      horizontal_delta=np.pi / 2 * scale,
45
      # Limit camera to -90 / 90 degree rolls.
46
      roll_delta=np.pi / 2. * scale,
47
      vel_std=.1 * scale if dynamic else 0.,
48
      max_vel=.4 * scale if dynamic else 0.,
49
      roll_std=np.pi / 300 * scale if dynamic else 0.,
50
      max_roll_vel=np.pi / 50 * scale if dynamic else 0.,
51
      max_zoom_in_percent=.5 * scale,
52
      max_zoom_out_percent=1.5 * scale,
53
      limit_to_upper_quadrant='reacher' not in domain_name,
54
  )
55

56

57
def get_background_kwargs(domain_name,
58
                          num_videos,
59
                          dynamic,
60
                          dataset_path,
61
                          dataset_videos=None,
62
                          shuffle=False,
63
                          video_alpha=1.0):
64
  assert domain_name in ['reacher', 'cartpole', 'finger', 'cheetah',
65
                         'ball_in_cup', 'walker', 'humanoid']
66
  if domain_name == 'reacher':
67
    ground_plane_alpha = 0.0
68
  elif domain_name in ['walker', 'cheetah']:
69
    ground_plane_alpha = 1.0
70
  else:
71
    ground_plane_alpha = 0.3
72

73
  return dict(
74
      num_videos=num_videos,
75
      video_alpha=video_alpha,
76
      ground_plane_alpha=ground_plane_alpha,
77
      dynamic=dynamic,
78
      dataset_path=dataset_path,
79
      dataset_videos=dataset_videos,
80
      shuffle_buffer_size=100 if shuffle else None,
81
  )
82

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.