Example #1
0
def ant_run_gaps():
    walker = ant.Ant()

    # Build a corridor-shaped arena with gaps, where the sizes of the gaps and
    # platforms are uniformly randomized.
    arena = corr_arenas.GapsCorridor(
        platform_length=distributions.Uniform(1.25, 2.5),  # (0.3, 2.5)
        gap_length=distributions.Uniform(0.3, 0.7),  # (0.5, 1.25)
        corridor_width=10,
        corridor_length=250)

    # Build a task that rewards the agent for running down the corridor at a
    # specific velocity.
    task = corr_tasks.RunThroughCorridor(walker=walker,
                                         arena=arena,
                                         walker_spawn_position=(1.0, 0, 0),
                                         stand_height=0.2,
                                         contact_termination=False,
                                         physics_timestep=_PHYSICS_TIMESTEP,
                                         control_timestep=_CONTROL_TIMESTEP)

    # (Chongyi Zheng): redefine reward function
    # task.get_reward = _ant_get_reward.__get__(task, task.get_reward)

    return composer.Environment(time_limit=30,
                                task=task,
                                strip_singleton_obs_buffer_dim=True)
Example #2
0
def ant_run_walls():
    walker = ant.Ant()

    arena = corr_arenas.WallsCorridor(wall_gap=4.,
                                      wall_width=distributions.Uniform(1, 7),
                                      wall_height=3.0,
                                      corridor_width=10,
                                      corridor_length=250,
                                      include_initial_padding=False)

    task = corr_tasks.RunThroughCorridor(walker=walker,
                                         arena=arena,
                                         walker_spawn_position=(0.5, 0, 0),
                                         walker_spawn_rotation=0,
                                         stand_height=0.2,
                                         contact_termination=False,
                                         physics_timestep=_PHYSICS_TIMESTEP,
                                         control_timestep=_CONTROL_TIMESTEP)

    # (Chongyi Zheng): redefine reward function
    # task.get_reward = _ant_get_reward.__get__(task, task.get_reward)

    return composer.Environment(time_limit=30,
                                task=task,
                                strip_singleton_obs_buffer_dim=True)
Example #3
0
def ant_run(random_state=None):
    walker = ant.Ant()
    arena = corr_arenas.EmptyCorridor()
    task = corr_tasks.RunThroughCorridor(walker=walker,
                                         arena=arena,
                                         walker_spawn_position=(5, 0, 0),
                                         walker_spawn_rotation=0,
                                         physics_timestep=_PHYSICS_TIMESTEP,
                                         control_timestep=_CONTROL_TIMESTEP)

    return composer.Environment(time_limit=30,
                                task=task,
                                random_state=random_state,
                                strip_singleton_obs_buffer_dim=True)
Example #4
0
def ant_run_long():
    walker = ant.Ant()
    arena = corr_arenas.EmptyCorridor(corridor_length=250,
                                      visible_side_planes=False)
    task = corr_tasks.RunThroughCorridor(walker=walker,
                                         arena=arena,
                                         walker_spawn_position=(1, 0, 0),
                                         walker_spawn_rotation=0,
                                         stand_height=0.2,
                                         contact_termination=False,
                                         physics_timestep=_PHYSICS_TIMESTEP,
                                         control_timestep=_CONTROL_TIMESTEP)

    # (Chongyi Zheng): redefine reward function
    # task.get_reward = _ant_get_reward.__get__(task, task.get_reward)

    return composer.Environment(time_limit=30,
                                task=task,
                                strip_singleton_obs_buffer_dim=True)
Example #5
0
def ant_escape_bowl(random_state=None):
    walker = ant.Ant()

    # Build a bowl-shaped arena.
    arena = bowl.Bowl(ground_size=(15., 15.),
                      hfield_size=(30, 30, 5),
                      terrain_smoothness=0.15,
                      terrain_bump_scale=2.0)

    # Build a task that rewards the agent for being far from the origin.
    task = escape.Escape(walker=walker,
                         arena=arena,
                         walker_spawn_position=(0, 0, 1.5),
                         physics_timestep=_PHYSICS_TIMESTEP,
                         control_timestep=_CONTROL_TIMESTEP)

    return composer.Environment(
        time_limit=30,  # 20
        task=task,
        random_state=random_state,
        strip_singleton_obs_buffer_dim=True)
Example #6
0
def ant_run_walls(random_state=None):
    walker = ant.Ant()

    arena = corr_arenas.WallsCorridor(wall_gap=4.,
                                      wall_width=distributions.Uniform(1, 7),
                                      wall_height=3.0,
                                      corridor_width=10,
                                      corridor_length=100,
                                      include_initial_padding=False)

    task = corr_tasks.RunThroughCorridor(walker=walker,
                                         arena=arena,
                                         walker_spawn_position=(0.5, 0, 0),
                                         walker_spawn_rotation=0,
                                         physics_timestep=_PHYSICS_TIMESTEP,
                                         control_timestep=_CONTROL_TIMESTEP)

    return composer.Environment(time_limit=30,
                                task=task,
                                random_state=random_state,
                                strip_singleton_obs_buffer_dim=True)
Example #7
0
def ant_run_gaps(random_state=None):
    walker = ant.Ant()

    # Build a corridor-shaped arena with gaps, where the sizes of the gaps and
    # platforms are uniformly randomized.
    arena = corr_arenas.GapsCorridor(
        platform_length=distributions.Uniform(1.25, 2.5),  # (0.3, 2.5)
        gap_length=distributions.Uniform(0.3, 0.7),  # (0.5, 1.25)
        corridor_width=10,
        corridor_length=250)

    # Build a task that rewards the agent for running down the corridor at a
    # specific velocity.
    task = corr_tasks.RunThroughCorridor(walker=walker,
                                         arena=arena,
                                         walker_spawn_position=(1.0, 0, 0),
                                         target_velocity=3.0,
                                         physics_timestep=_PHYSICS_TIMESTEP,
                                         control_timestep=_CONTROL_TIMESTEP)

    return composer.Environment(time_limit=30,
                                task=task,
                                random_state=random_state,
                                strip_singleton_obs_buffer_dim=True)
Example #8
0
 def test_proprioception(self):
     walker = ant.Ant()
     for item in walker.observables.proprioception:
         self.assertIsInstance(item, observable_base.Observable)
Example #9
0
 def test_set_name(self):
     name = 'fred'
     walker = ant.Ant(name=name)
     self.assertEqual(walker.mjcf_model.model, name)
Example #10
0
 def test_get_element_tuple_property(self, name):
     attribute_value = getattr(ant.Ant(), name)
     self.assertNotEmpty(attribute_value)
     for item in attribute_value:
         self.assertIsInstance(item, mjcf.Element)
Example #11
0
 def test_get_element_property(self, name):
     attribute_value = getattr(ant.Ant(), name)
     self.assertIsInstance(attribute_value, mjcf.Element)