def _reach(obs_settings, use_site): """Configure and instantiate a `Reach` task. Args: obs_settings: An `observations.ObservationSettings` instance. use_site: Boolean, if True then the target will be a fixed site, otherwise it will be a moveable Duplo brick. Returns: An instance of `reach.Reach`. """ arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) if use_site: workspace = _SITE_WORKSPACE prop = None else: workspace = _DUPLO_WORKSPACE prop = props.Duplo(observable_options=observations.make_options( obs_settings, observations.FREEPROP_OBSERVABLES)) task = Reach(arena=arena, arm=arm, hand=hand, prop=prop, obs_settings=obs_settings, workspace=workspace, control_timestep=constants.CONTROL_TIMESTEP) return task
def _reassemble(obs_settings, num_bricks, randomize_initial_order, randomize_desired_order): """Configure and instantiate a `Reassemble` task. Args: obs_settings: `observations.ObservationSettings` instance. num_bricks: The total number of bricks; must be between 2 and 6. randomize_initial_order: Boolean specifying whether to randomize the initial order of bricks in the stack at the start of each episode. randomize_desired_order: Boolean specifying whether to independently randomize the desired order of bricks in the stack at the start of each episode. By default the desired order will be the reverse of the initial order, with the exception of the base brick which is always the same as in the initial order since it is welded in place. Returns: An instance of `Reassemble`. """ arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) return Reassemble(arena=arena, arm=arm, hand=hand, num_bricks=num_bricks, randomize_initial_order=randomize_initial_order, randomize_desired_order=randomize_desired_order, obs_settings=obs_settings, workspace=_WORKSPACE, control_timestep=constants.CONTROL_TIMESTEP)
def _reach(obs_settings, use_site, evalenv=False): """Configure and instantiate a `Reach` task. Args: obs_settings: An `observations.ObservationSettings` instance. use_site: Boolean, if True then the target will be a fixed site, otherwise it will be a moveable Duplo brick. Returns: An instance of `reach.Reach`. """ arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) if use_site: workspace = _SITE_WORKSPACE prop = None else: workspace = _DUPLO_WORKSPACE prop = props.Duplo(observable_options=observations.make_options( obs_settings, observations.FREEPROP_OBSERVABLES)) env_randomizer = EnvRandomizer() table_col_tag = random.choice(list(env_randomizer.table_tags.values())) table_env_col_tag = random.choice( list(env_randomizer.table_eval_tags.values())) sky_col_tag = random.choice(list(env_randomizer.sky_tags.values())) if evalenv: task = ReachEval(arena=arena, arm=arm, hand=hand, prop=prop, obs_settings=obs_settings, workspace=workspace, control_timestep=constants.CONTROL_TIMESTEP, table_col_tag=table_env_col_tag) else: task = Reach(arena=arena, arm=arm, hand=hand, prop=prop, obs_settings=obs_settings, workspace=workspace, control_timestep=constants.CONTROL_TIMESTEP, table_col_tag=table_col_tag, sky_col_tag=sky_col_tag) mod_id = str(table_col_tag) + str(sky_col_tag) + str( random.randint(10, 1000)) return task, mod_id
def _lift(obs_settings, prop_name): """Configure and instantiate a Lift task. Args: obs_settings: `observations.ObservationSettings` instance. prop_name: The name of the prop to be lifted. Must be either 'duplo' or 'box'. Returns: An instance of `lift.Lift`. Raises: ValueError: If `prop_name` is neither 'duplo' nor 'box'. """ arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) if prop_name == 'duplo': workspace = _DUPLO_WORKSPACE prop = _DuploWithVertexSites( observable_options=observations.make_options( obs_settings, observations.FREEPROP_OBSERVABLES)) elif prop_name == 'box': workspace = _BOX_WORKSPACE # NB: The box is intentionally too large to pick up with a pinch grip. prop = _BoxWithVertexSites( size=[_BOX_SIZE] * 3, observable_options=observations.make_options( obs_settings, observations.FREEPROP_OBSERVABLES)) prop.geom.mass = _BOX_MASS else: raise ValueError('`prop_name` must be either \'duplo\' or \'box\'.') task = Lift(arena=arena, arm=arm, hand=hand, prop=prop, workspace=workspace, obs_settings=obs_settings, control_timestep=constants.CONTROL_TIMESTEP) return task
def _push(obs_settings): """Configure and instantiate a `Push` task. Args: obs_settings: An `observations.ObservationSettings` instance. Returns: An instance of `push.Push`. """ arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) workspace = _DUPLO_WORKSPACE prop = props.Duplo(observable_options=observations.make_options( obs_settings, observations.FREEPROP_OBSERVABLES)) task = Push(arena=arena, arm=arm, hand=hand, prop=prop, obs_settings=obs_settings, workspace=workspace, control_timestep=constants.CONTROL_TIMESTEP) return task
def _place(obs_settings, cradle_prop_name): """Configure and instantiate a Place task. Args: obs_settings: `observations.ObservationSettings` instance. cradle_prop_name: The name of the prop onto which the Duplo brick must be placed. Must be either 'duplo' or 'cradle'. Returns: An instance of `Place`. Raises: ValueError: If `prop_name` is neither 'duplo' nor 'cradle'. """ arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) prop = props.Duplo(observable_options=observations.make_options( obs_settings, observations.FREEPROP_OBSERVABLES)) if cradle_prop_name == 'duplo': cradle = props.Duplo() elif cradle_prop_name == 'cradle': cradle = SphereCradle() else: raise ValueError( '`cradle_prop_name` must be either \'duplo\' or \'cradle\'.') task = Place(arena=arena, arm=arm, hand=hand, prop=prop, obs_settings=obs_settings, workspace=_WORKSPACE, control_timestep=constants.CONTROL_TIMESTEP, cradle=cradle) return task
def _stack(obs_settings, num_bricks, moveable_base, randomize_order, target_height=None): """Configure and instantiate a Stack task. Args: obs_settings: `observations.ObservationSettings` instance. num_bricks: The total number of bricks; must be between 2 and 6. moveable_base: Boolean specifying whether or not the bottom brick should be moveable. randomize_order: Boolean specifying whether to randomize the desired order of bricks in the stack at the start of each episode. target_height: The target number of bricks in the stack in order to get maximum reward. Must be between 2 and `num_bricks`. Defaults to `num_bricks`. Returns: An instance of `Stack`. """ if target_height is None: target_height = num_bricks arena = arenas.Standard() arm = robots.make_arm(obs_settings=obs_settings) hand = robots.make_hand(obs_settings=obs_settings) return Stack(arena=arena, arm=arm, hand=hand, num_bricks=num_bricks, target_height=target_height, moveable_base=moveable_base, randomize_order=randomize_order, obs_settings=obs_settings, workspace=_WORKSPACE, control_timestep=constants.CONTROL_TIMESTEP)