示例#1
0
 def render(self):
     SawyerEnv.render(self)
示例#2
0
    @property
    def action_space(self):
        return FlatGoalEnv.action_space(self)

    def render(self):
        SawyerEnv.render(self)

    def log_diagnostics(self, paths, prefix=''):
        reach_rew = [path["env_infos"]['reachRew'] for path in paths]
        pick_rew = [path["env_infos"]['pickRew'][-1] for path in paths]
        place_rew = [path["env_infos"]['placeRew'] for path in paths]
        reach_dist = [path["env_infos"]['reachDist'] for path in paths]
        placing_dist = [path["env_infos"]['placingDist'] for path in paths]

        logger.logkv(prefix + 'AverageReachReward', np.mean(reach_rew))
        logger.logkv(prefix + 'AveragePickReward', np.mean(pick_rew))
        logger.logkv(prefix + 'AveragePlaceReward', np.mean(place_rew))
        logger.logkv(prefix + 'AverageReachDistance', np.mean(reach_dist))
        logger.logkv(prefix + 'AveragePlaceDistance', np.mean(placing_dist))


if __name__ == "__main__":
    env = SawyerPickAndPlaceEnv()
    while True:
        task = env.sample_tasks(1)[0]
        env.set_task(task)
        env.reset()
        for _ in range(500):
            SawyerEnv.render(env)
            _, reward, _, _ = env.step(
                env.action_space.sample())  # take a random action