Initializes a new `Stack` task. Args: arena: `composer.Entity` instance. arm: `robot_base.RobotArm` instance. hand: `robot_base.RobotHand` instance. num_bricks: The total number of bricks; must be between 2 and 6. target_height: The target number of bricks in the s
(self,
arena,
arm,
hand,
num_bricks,
target_height,
moveable_base,
randomize_order,
obs_settings,
workspace,
control_timestep)
| 182 | """Build a stack of Duplo bricks.""" |
| 183 | |
| 184 | def __init__(self, |
| 185 | arena, |
| 186 | arm, |
| 187 | hand, |
| 188 | num_bricks, |
| 189 | target_height, |
| 190 | moveable_base, |
| 191 | randomize_order, |
| 192 | obs_settings, |
| 193 | workspace, |
| 194 | control_timestep): |
| 195 | """Initializes a new `Stack` task. |
| 196 | |
| 197 | Args: |
| 198 | arena: `composer.Entity` instance. |
| 199 | arm: `robot_base.RobotArm` instance. |
| 200 | hand: `robot_base.RobotHand` instance. |
| 201 | num_bricks: The total number of bricks; must be between 2 and 6. |
| 202 | target_height: The target number of bricks in the stack in order to get |
| 203 | maximum reward. Must be between 2 and `num_bricks`. |
| 204 | moveable_base: Boolean specifying whether or not the bottom brick should |
| 205 | be moveable. |
| 206 | randomize_order: Boolean specifying whether to randomize the desired order |
| 207 | of bricks in the stack at the start of each episode. |
| 208 | obs_settings: `observations.ObservationSettings` instance. |
| 209 | workspace: A `_BrickWorkspace` instance. |
| 210 | control_timestep: Float specifying the control timestep in seconds. |
| 211 | |
| 212 | Raises: |
| 213 | ValueError: If `num_bricks` is not between 2 and 6, or if |
| 214 | `target_height` is not between 2 and `num_bricks - 1`. |
| 215 | """ |
| 216 | if not 2 <= target_height <= num_bricks: |
| 217 | raise ValueError('`target_height` must be between 2 and {}, got {}.' |
| 218 | .format(num_bricks, target_height)) |
| 219 | |
| 220 | super().__init__( |
| 221 | arena=arena, |
| 222 | arm=arm, |
| 223 | hand=hand, |
| 224 | num_bricks=num_bricks, |
| 225 | obs_settings=obs_settings, |
| 226 | workspace=workspace, |
| 227 | control_timestep=control_timestep) |
| 228 | |
| 229 | self._moveable_base = moveable_base |
| 230 | self._randomize_order = randomize_order |
| 231 | self._target_height = target_height |
| 232 | self._prop_bbox = workspace.prop_bbox |
| 233 | |
| 234 | # Shuffled at the start of each episode if `randomize_order` is True. |
| 235 | self._desired_order = np.arange(target_height) |
| 236 | |
| 237 | # In the random order case, create a `prop_pose` observable that informs the |
| 238 | # agent of the desired order. |
| 239 | if randomize_order: |
| 240 | desired_order_observable = observable.Generic(self._get_desired_order) |
| 241 | desired_order_observable.configure(**obs_settings.prop_pose._asdict()) |