MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / __init__

Method __init__

dm_control/manipulation/bricks.py:83–162  ·  view source on GitHub ↗
(self,
               arena,
               arm,
               hand,
               num_bricks,
               obs_settings,
               workspace,
               control_timestep)

Source from the content-addressed store, hash-verified

81 """Common components of brick tasks."""
82
83 def __init__(self,
84 arena,
85 arm,
86 hand,
87 num_bricks,
88 obs_settings,
89 workspace,
90 control_timestep):
91 if not 2 <= num_bricks <= 6:
92 raise ValueError('`num_bricks` must be between 2 and 6, got {}.'
93 .format(num_bricks))
94
95 if num_bricks > 3:
96 # The default values computed by MuJoCo's compiler are too small if there
97 # are more than three stacked bricks, since each stacked pair generates
98 # a large number of contacts. The values below are sufficient for up to
99 # 6 stacked bricks.
100 # TODO(b/78331644): It may be useful to log the size of `physics.model`
101 # and `physics.data` after compilation to gauge the
102 # impact of these changes on MuJoCo's memory footprint.
103 arena.mjcf_model.size.nconmax = 400
104 arena.mjcf_model.size.njmax = 1200
105
106 self._arena = arena
107 self._arm = arm
108 self._hand = hand
109 self._arm.attach(self._hand)
110 self._arena.attach_offset(self._arm, offset=workspace.arm_offset)
111 self.control_timestep = control_timestep
112
113 # Add custom camera observable.
114 self._task_observables = cameras.add_camera_observables(
115 arena, obs_settings, cameras.FRONT_CLOSE)
116
117 color_sequence = iter(_COLOR_VALUES)
118 brick_obs_options = observations.make_options(
119 obs_settings, observations.FREEPROP_OBSERVABLES)
120
121 bricks = []
122 brick_frames = []
123 goal_hint_bricks = []
124 for _ in range(num_bricks):
125 color = next(color_sequence)
126 brick = props.Duplo(color=color,
127 observable_options=brick_obs_options)
128 brick_frames.append(arena.add_free_entity(brick))
129 bricks.append(brick)
130
131 # Translucent, contactless brick with no observables. These are used to
132 # provide a visual hint representing the goal state for each task.
133 hint_brick = props.Duplo(color=color)
134 _hintify(hint_brick, alpha=_HINT_ALPHA)
135 arena.attach(hint_brick)
136 goal_hint_bricks.append(hint_brick)
137
138 self._bricks = bricks
139 self._brick_frames = brick_frames
140 self._goal_hint_bricks = goal_hint_bricks

Callers

nothing calls this directly

Calls 4

_hintifyFunction · 0.85
attach_offsetMethod · 0.80
add_free_entityMethod · 0.80
attachMethod · 0.45

Tested by

no test coverage detected