Initializes a new `Reach` task. Args: arena: `composer.Entity` instance. arm: `robot_base.RobotArm` instance. hand: `robot_base.RobotHand` instance. prop: `composer.Entity` instance specifying the prop to reach to, or None in which case the target is a fixed site
(
self, arena, arm, hand, prop, obs_settings, workspace, control_timestep)
| 65 | """Bring the hand close to a target prop or site.""" |
| 66 | |
| 67 | def __init__( |
| 68 | self, arena, arm, hand, prop, obs_settings, workspace, control_timestep): |
| 69 | """Initializes a new `Reach` task. |
| 70 | |
| 71 | Args: |
| 72 | arena: `composer.Entity` instance. |
| 73 | arm: `robot_base.RobotArm` instance. |
| 74 | hand: `robot_base.RobotHand` instance. |
| 75 | prop: `composer.Entity` instance specifying the prop to reach to, or None |
| 76 | in which case the target is a fixed site whose position is specified by |
| 77 | the workspace. |
| 78 | obs_settings: `observations.ObservationSettings` instance. |
| 79 | workspace: `_ReachWorkspace` specifying the placement of the prop and TCP. |
| 80 | control_timestep: Float specifying the control timestep in seconds. |
| 81 | """ |
| 82 | self._arena = arena |
| 83 | self._arm = arm |
| 84 | self._hand = hand |
| 85 | self._arm.attach(self._hand) |
| 86 | self._arena.attach_offset(self._arm, offset=workspace.arm_offset) |
| 87 | self.control_timestep = control_timestep |
| 88 | self._tcp_initializer = initializers.ToolCenterPointInitializer( |
| 89 | self._hand, self._arm, |
| 90 | position=distributions.Uniform(*workspace.tcp_bbox), |
| 91 | quaternion=workspaces.DOWN_QUATERNION) |
| 92 | |
| 93 | # Add custom camera observable. |
| 94 | self._task_observables = cameras.add_camera_observables( |
| 95 | arena, obs_settings, cameras.FRONT_CLOSE) |
| 96 | |
| 97 | target_pos_distribution = distributions.Uniform(*workspace.target_bbox) |
| 98 | self._prop = prop |
| 99 | if prop: |
| 100 | # The prop itself is used to visualize the target location. |
| 101 | self._make_target_site(parent_entity=prop, visible=False) |
| 102 | self._target = self._arena.add_free_entity(prop) |
| 103 | self._prop_placer = initializers.PropPlacer( |
| 104 | props=[prop], |
| 105 | position=target_pos_distribution, |
| 106 | quaternion=workspaces.uniform_z_rotation, |
| 107 | settle_physics=True) |
| 108 | else: |
| 109 | self._target = self._make_target_site(parent_entity=arena, visible=True) |
| 110 | self._target_placer = target_pos_distribution |
| 111 | |
| 112 | obs = observable.MJCFFeature('pos', self._target) |
| 113 | obs.configure(**obs_settings.prop_pose._asdict()) |
| 114 | self._task_observables['target_position'] = obs |
| 115 | |
| 116 | # Add sites for visualizing the prop and target bounding boxes. |
| 117 | workspaces.add_bbox_site( |
| 118 | body=self.root_entity.mjcf_model.worldbody, |
| 119 | lower=workspace.tcp_bbox.lower, upper=workspace.tcp_bbox.upper, |
| 120 | rgba=constants.GREEN, name='tcp_spawn_area') |
| 121 | workspaces.add_bbox_site( |
| 122 | body=self.root_entity.mjcf_model.worldbody, |
| 123 | lower=workspace.target_bbox.lower, upper=workspace.target_bbox.upper, |
| 124 | rgba=constants.BLUE, name='target_spawn_area') |
nothing calls this directly
no test coverage detected