Example #1
0
 def define_program_options(self, params):
     params.add_flag('verbose', help='Instances all configuration')        
     config = get_rs2b_config()
     classes = config.get_classes() 
     examples = ', '.join(classes)
     helps = 'Only print one type of objects (%s)' % examples,
     params.add_string('type', help=helps, default=None)
    def go(self):
        options = self.get_options()
        rate = options.rate
        boot_config = get_boot_config()
        rs2b_config = get_rs2b_config()

        for c in options.config:
            boot_config.load(c)
            rs2b_config.load(c)

        id_robot = options.robot
        robot = boot_config.robots.instance(id_robot)

        rest = robot.get_spec().get_commands().get_default_value()
        robot.set_commands(rest, 'rest')

        try:
            for key in getKeys(timeout=0):
                if key == 'q':
                    break
                if key in moveBindings.keys():
                    u = np.array(moveBindings[key])
                else:
                    u = rest
                robot.set_commands(u, 'teleop')
                time.sleep(rate)


#         except Exception as e:
#             # print str(e)

        finally:
            robot.set_commands(rest, 'rest')
    def go(self):
        options = self.get_options()
        rate = options.rate
        boot_config = get_boot_config()
        rs2b_config = get_rs2b_config()
        
        for c in options.config:
            boot_config.load(c)
            rs2b_config.load(c)
            
        id_robot = options.robot
        robot = boot_config.robots.instance(id_robot)
        
        rest = robot.get_spec().get_commands().get_default_value()
        robot.set_commands(rest, 'rest')
        
        try: 
            for key in getKeys(timeout=0):
                if key == 'q':
                    break
                if key in moveBindings.keys():
                    u = np.array(moveBindings[key])
                else:
                    u = rest
                robot.set_commands(u, 'teleop')
                time.sleep(rate)
#         except Exception as e:
#             # print str(e)
            
        finally:
            robot.set_commands(rest, 'rest')
def do_convert_job2(id_robot,
                    id_robot_res,
                    id_explog, id_stream, id_episode,
                    filename):
    
    rs2b_config = get_rs2b_config()
    boot_config = get_boot_config()
    
    """
        id_robot: original robot must be a ROSRobot
    """
    
    if os.path.exists(filename):
        msg = 'Output file exists: %s\n' % friendly_path(filename)
        msg += 'Delete to force recreating the log.'
        logger.info(msg)
        return
    
    explog = rs2b_config.explogs.instance(id_explog)
    robot = boot_config.robots.instance(id_robot)
    orig_robot = robot.get_inner_components()[-1]

    if not isinstance(orig_robot, ROSRobot):
        msg = 'Expected ROSRobot, got %s' % describe_type(robot)
        raise ValueError(msg)
    
    orig_robot.read_from_log(explog)
    id_environment = explog.get_id_environment()
    write_robot_observations(id_stream, filename, id_robot_res,
                             robot, id_episode, id_environment)
   def define_jobs_context(self, context):
       options = self.get_options()
       boot_root = options.boot_root
       rs2b_config = get_rs2b_config()
       boot_config = get_boot_config()
       data_central = DataCentral(boot_root)
       id_robot = options.id_robot
       id_robot_res = options.id_robot_res
       id_explog = options.id_explog
       id_stream = '%s%s' % (options.id_episode_prefix, id_explog)
       id_episode = id_stream
       id_agent = None
       
       # make sure we have them
       boot_config.robots[id_robot]
       rs2b_config.explogs[id_explog]
 
       ds = data_central.get_dir_structure()
       filename = ds.get_explog_filename(id_robot=id_robot_res,
                                         id_agent=id_agent,
                                         id_stream=id_stream)
     
       return context.comp_config(do_convert_job2,
                           id_robot=id_robot,
                           id_robot_res=id_robot_res,
                           id_explog=id_explog, id_stream=id_stream,
                           id_episode=id_episode,
                           filename=filename) 
Example #6
0
    def define_jobs_context(self, context):     

        id_explog = self.get_options().id_explog
        rs2b_config = get_rs2b_config()
        log = rs2b_config.explogs.instance(id_explog)
        if not isinstance(log, ExpLogFromYaml):
            self.info('Skipping log %r because not raw log.' % id_explog)
            return
        
        jobs_video_servo_multi(context, id_explog)
 def define_jobs_context(self, context):
     options = self.get_options()
     
     rs2b_config = get_rs2b_config()
     
     self.info('explogs: %s' % options.explogs)
     self.info('robots: %s' % options.robots)
     explogs = rs2b_config.explogs.expand_names(options.explogs)
     robots = rs2b_config.explogs.expand_names(options.robots)
 
     
     s = iterate_context_explogs_and_robots(context, explogs, robots)
     for c, id_explog, id_robot in s:
         c.subtask(MakeVideosBootData, id_robot=id_robot, id_explog=id_explog,
                   add_job_prefix='', add_outdir='')
Example #8
0
    def initial_setup(self):        
        rs2b_config = get_rs2b_config()
        rs2b_config.load(rs2b_config.get_default_dir())

        if self.options.config != '':
            GlobalConfig.global_load_dir(self.options.config)
 def from_yaml(obs_adapters):
     config = get_rs2b_config()
     adapters = [config.obs_adapters.instance_smarter(x)[1] 
                 for x in obs_adapters]
     return SensorJoin(adapters)
Example #10
0
 def go(self):
     options = self.get_options()        
     config = get_rs2b_config()
     config.print_summary(sys.stdout, instance=options.verbose,
                          only_type=options.type)
 def from_yaml(obs_adapter, cmd_adapter, **other):
     config = get_rs2b_config()
     _, obs_adapter = config.obs_adapters.instance_smarter(obs_adapter)
     _, cmd_adapter = config.cmd_adapters.instance_smarter(cmd_adapter)
     return ROSRobotAdapter(obs_adapter, cmd_adapter, **other)