def _edit_new_task(self): task_file = input('What task would you like to edit?\n') if len(task_file) > 3 and task_file[-3:] != '.py': task_file += '.py' try: task_class = name_to_task_class(task_file) except: print('There was no task named: %s. ' 'Would you like to create it?' % task_file) inp = input() if inp == 'y': self._create_python_file(task_file) task_class = name_to_task_class(task_file) else: print('Pick a defined task in that case...') task_class, task_file = self._edit_new_task() return task_class, task_file
def reload_python(self): try: task_class = name_to_task_class(self.task_file) except Exception as e: print_fail('The python file could not be loaded!') traceback.print_exc() return None, None self.task = task_class(self.pr, self.robot) # task constructor self.scene.load(self.task)
from gym.envs.registration import register import rlbench.backend.task as task import os from rlbench.utils import name_to_task_class from rlbench.gym.rlbench_env import RLBenchEnv TASKS = [ t for t in os.listdir(task.TASKS_PATH) if t != '__init__.py' and t.endswith('.py') ] for task_file in TASKS: task_name = task_file.split('.py')[0] task_class = name_to_task_class(task_name) register(id='%s-state-v0' % task_name, entry_point='rlbench.gym:RLBenchEnv', kwargs={ 'task_class': task_class, 'observation_mode': 'state' }) register(id='%s-vision-v0' % task_name, entry_point='rlbench.gym:RLBenchEnv', kwargs={ 'task_class': task_class, 'observation_mode': 'vision' }) register(id='%s-visiondepth-v0' % task_name, entry_point='rlbench.gym:RLBenchEnv', kwargs={ 'task_class': task_class, 'observation_mode': 'visiondepth',