Ejemplo n.º 1
0
 def test_embodied_teacher(self):
     agents = ['youbot_noplugin', 'pioneer2dx_noplugin', 'pr2_noplugin']
     with open(os.path.join(social_bot.get_model_dir(), "agent_cfg.json"),
               'r') as cfg_file:
         agent_cfgs = json.load(cfg_file)
     for agent_type in agents:
         for use_image_obs in [True, False]:
             agent_cfg = agent_cfgs[agent_type]
             test_tasks = [GoalTask, KickingBallTask]
             if agent_cfg['camera_sensor'] == '' and use_image_obs:
                 continue
             logging.info("Testing Case: Agent " + agent_type + ", Task " +
                          str(test_tasks) + ", UseImage: " +
                          str(use_image_obs))
             env = EmbodiedTeacher(with_language=True,
                                   use_image_observation=use_image_obs,
                                   image_with_internal_states=True,
                                   agent_type=agent_type,
                                   tasks=test_tasks,
                                   demo_by_human=False)
             step_cnt = 0
             last_done_time = time.time()
             while step_cnt < 100 and (time.time() - last_done_time) < 5:
                 actions = env._control_space.sample()
                 actions = dict(control=actions, sentence="hello")
                 teacher_actions = env._teacher_control_space.sample()
                 actions = OrderedDict(learner=actions,
                                       teacher=teacher_actions)
                 env.step(actions)
                 step_cnt += 1
             step_per_sec = step_cnt / (time.time() - last_done_time)
             logging.info("Test Passed, FPS: " + str(step_per_sec))
             env.close()
             gazebo.close()
Ejemplo n.º 2
0
    def test_pr2(self):
        for use_internal_states_only in [True, False]:
            env = Pr2Gripper(world_config=PR2_WORLD_SETTING + [
                "//sensor[@type='camera']<>visualize=true",
                "//camera//format=R8G8B8",
            ],
                             max_steps=100,
                             use_internal_states_only=use_internal_states_only)

            env.run(render=False)
            env.close()
            gazebo.close()
Ejemplo n.º 3
0
 def test_play_ground(self):
     with_language = True
     with_agent_language = False
     agents = [
         'pioneer2dx_noplugin', 'pr2_noplugin', 'icub', 'icub_with_hands',
         'youbot_noplugin'
     ]
     with open(os.path.join(social_bot.get_model_dir(), "agent_cfg.json"),
               'r') as cfg_file:
         agent_cfgs = json.load(cfg_file)
     tasks = [GoalTask, KickingBallTask, Reaching3D, PickAndPlace, Stack]
     for task in tasks:
         for agent_type in task.compatible_agents:
             for with_language in [True, False]:
                 for use_image_obs in [True, False]:
                     for image_with_internal_states in [True, False]:
                         agent_cfg = agent_cfgs[agent_type]
                         test_tasks = [task]
                         if agent_type.find('icub') != -1:
                             test_tasks.append(ICubAuxiliaryTask)
                         if agent_cfg[
                                 'camera_sensor'] == '' and use_image_obs:
                             continue
                         logging.info("Testing Case: Agent " + agent_type +
                                      ", Task " + str(test_tasks) +
                                      ", UseImage: " + str(use_image_obs))
                         env = PlayGround(
                             with_language=with_language,
                             with_agent_language=with_agent_language,
                             use_image_observation=use_image_obs,
                             image_with_internal_states=
                             image_with_internal_states,
                             agent_type=agent_type,
                             tasks=test_tasks)
                         step_cnt = 0
                         last_done_time = time.time()
                         while step_cnt < 100 and (time.time() -
                                                   last_done_time) < 5:
                             actions = env._control_space.sample()
                             if with_agent_language:
                                 actions = dict(control=actions,
                                                sentence="hello")
                             env.step(actions)
                             step_cnt += 1
                         step_per_sec = step_cnt / (time.time() -
                                                    last_done_time)
                         logging.info("Test Passed, FPS: " +
                                      str(step_per_sec))
                         env.close()
                         gazebo.close()
Ejemplo n.º 4
0
 def run(self):
     port = os.environ.get('PYGAZEBO_PORT', 11345)
     env = SimpleNavigationLanguage(port=port + self.env_id + 1)
     env.reset()
     for _ in range(500):
         control = [
             random.random() * 0.2 - 0.1,
             random.random() * 0.2 - 0.1
         ]
         obs, reward, done, info = env.step(
             dict(control=control, sentence="hello"))
         if done:
             env.reset()
     env.close()
     gazebo.close()
     self.ok.value = 1
Ejemplo n.º 5
0
 def close(self):
     super().close()
     gazebo.close()