def setUp(self):
        params = configparse.ParameterDict()
        params.add_option('speech_controller', 'modules', '')

        self.SC = speechcontroller.SpeechController(params)
        self.test_socket = util.testsocket.TestSocket()
        self.SC.receive_sockets = [self.test_socket]
Exemple #2
0
def parse_args(sysargs):
    """
    Parse command line arguments
    """
    optlist, args = getopt.getopt(sysargs[1:], 'hb:', 
        ['nao_ip=','no_nao','pioneer_ip=','no_pioneer','nao_port=','pioneer_port=',
        'kinect_ip=','communicator_port=','speech_port=','starting_behavior=','brain_speed=',
        'log=','log-level=','log-file=','log-format=','help','profile'])
    print optlist, args
    option_dict = configparse.ParameterDict()
    logger = None
    logger_format = None
    logger_filename = None
    logger_level = None
    for opt, value in optlist:
        if opt in ("-h", "--help"):
            print_usage()
            sys.exit()
        elif opt in ("--nao_ip"):
            option_dict.add_option('body', 'number_of_naos', 1)
            option_dict.add_option('body', 'nao_ip_0', value)
        elif opt in ("--no_nao"):
            option_dict.add_option('body', 'number_of_naos', 0)
        elif opt in ("--pioneer_ip"):
            option_dict.add_option('body', 'number_of_pioneers', 1)
            option_dict.add_option('body', 'pioneer_ip_0', value)
        elif opt in ("--no_pioneer"):
            option_dict.add_option('body', 'number_of_pioneers', 0)
        elif opt in ("--nao_port"):
            option_dict.add_option('body', 'nao_port_0', value)
        elif opt in ("--pioneer_port"):
            option_dict.add_option('body', 'pioneer_port_0', value)
        elif opt in ("--kinect_ip"):
            option_dict.add_option('body', 'kinect_ip', value)
        elif opt in ("--communicator_port"):
            option_dict.add_option('vision_controller', 'communicator_port', value)
        elif opt in ("--speech_port"):
            option_dict.add_option('speech_controller', 'speech_port', value)
        elif opt in ("-b", "--starting_behavior"):
            option_dict.add_option('general', 'starting_behavior', value)
        elif opt in ("--brain_speed"):
            option_dict.add_option('general', 'brain_speed', value)
        elif opt in ("--log"):
            logger = logging.getLogger(value)
        elif opt in ("--log-level"):
            logger_level = value
        elif opt in ("--log-file"):
            logger_filename = value
        elif opt in ("--log-format"):
            logger_format = value
        elif opt in ("--profile"):
            global profile
            profile = True
        else:
            print_usage("unhandled option: " + opt + " " + value)


    setup_logging(logger, logger_format, logger_filename, logger_level)
    return option_dict, args
Exemple #3
0
 def testSingleton(self):
     param_dict = configparse.ParameterDict()
     param_dict.add_option('body','number_of_naos', '1')
     param_dict.add_option('body','number_of_pioneers', '1')
     param_dict.add_option('body','nao_ip_0', '000.000.000')
     param_dict.add_option('body','nao_port_0', '0')
     param_dict.add_option('body','pioneer_ip_0', '000.000.000')
     param_dict.add_option('body','pioneer_port_0', '0')        
    def setUp(self):
        params = configparse.ParameterDict()
        params.add_option('general', 'robot_ip', '129.125.178.227')
        params.add_option('general', 'starting_behavior', 'followMe')
        params.add_option('vision_controller', 'video_source_name', 'test')
        params.add_option('body', 'number_of_naos', '0')
        params.add_option('body', 'number_of_pioneers', '0')

        self.brain = brain.Brain(params)
Exemple #5
0
 def setUp(self):
     if not hasattr(self, "random_seed"):
         random.seed()
         self.random_seed = True
     self.testport = random.randint(49152, 65535)
     self.communicator = communicator.Communicator(port=self.testport)
     self.params = configparse.ParameterDict()
     self.params.add_option('vision_controller', 'video_source_name',
                            'webcam')
     self.TestCommand = 'this is a command to start xterm'
    def test_speech_recog_update(self):
        params = configparse.ParameterDict()
        self.test_socket = util.testsocket.TestSocket()
        self.si.speechcontroller.receive_sockets = [self.test_socket] 
        message = 'I want a tequila from the kitchen'
        self.test_socket.set_data(message)
        self.si.add_to_memory(self.si.speechcontroller.update())

        obs = self.mem.get_last_observation('voice_command')
        self.assertEqual(obs[1]['message'], message)
Exemple #7
0
 def setUp(self):
     if not hasattr(self, "random_seed"):
         random.seed()
         self.random_seed = True
     self.communicatorPort = random.randint(49152, 65535)
     config_dict = configparse.ParameterDict()
     config_dict.add_option("vision_controller", "start_port", "50000")
     config_dict.add_option("vision_controller", "end_port", "52000")
     config_dict.add_option("vision_controller", "communicator_port",
                            self.communicatorPort)
     self.config = config_dict
     self.controller = visioncontroller.VisionController()
     self.controller.set_config(self.config)
    def setUp(self):
        params = configparse.ParameterDict()
        self.IP = '192.168.0.1'
        params.add_option('general', 'robot_ip', self.IP )
        params.add_option('vision_controller', 'video_source_name', 'test')

        params.add_option('general', 'starting_behavior', 'test1')
        params.add_option('speech_controller', 'modules', '') #no speech modules, we'll add a test socket later on 
        params.add_option('speech_controller', 'start_speech', 'true') #no speech modules, we'll add a test socket later on 

        params.add_option('body','number_of_naos','0')
        params.add_option('body','number_of_pioneers','0')
        self.mem = memory.Memory()
        self.mem.clear()
        self.si = sensorintegrator.SensorIntegrator(params)
Exemple #9
0
def parse_args(sysargs):
    """
    Parse command line arguments
    """
    optlist, args = getopt.getopt(sysargs[1:], 'hb:', [
        'nao_ip=', 'no_nao', 'pioneer_ip=', 'no_pioneer', 'nao_port=',
        'pioneer_port=', 'kinect_ip=', 'communicator_port=', 'speech_port=',
        'starting_behavior=', 'brain_speed=', 'log=', 'log-level=',
        'log-file=', 'log-format=', 'help', 'profile'
    ])
    print optlist, args
    option_dict = configparse.ParameterDict()

    for opt, value in optlist:
        if opt in ("-h", "--help"):
            sys.exit()
        elif opt in ("--feature"):
            option_dict.add_option('feature', 'features', value)
        elif opt in ("--communicator_port"):
            option_dict.add_option('vision_controller', 'communicator_port',
                                   value)

    return option_dict, args
    files = os.listdir(beh_path)
    for filename in files:
        if (behaviorname == filename[0:len(behaviorname)]):
            if (filename[len(behaviorname)] == '_'):
                if (filename[len(behaviorname) + 1] != 'x' and filename[-3:] == '.py'):
                    imports.append("import " + filename[:-3])

    return imports


#start generating:
print "generating behavior classes..."


#read all information about the behaviors:
option_dict = configparse.ParameterDict()
names = []
postconditions = []
exceptions = []
descriptions = []
conf_location = os.path.abspath(os.environ['BORG'] + '/brain/src/config/behaviors_config')

configparse.parse_config(conf_location, option_dict)
for section in option_dict.option_dict.keys():
    names.append(section)
    exception_read = False
    postcondition_read = False
    description_read = False
    for variable in option_dict.option_dict[section]:
        if (variable == "postcondition"):
            postconditions.append(option_dict.option_dict[section][variable])
Exemple #11
0
    print "Configuration file is a mandatory arguments, and should contain"
    print "the right options:"
    print ""
    print "Usage: ", sys.argv[0], " config file"
    print ""
    print "Config file should contain: controller_ip, surfdetect (port nr), "
    print "update_frequency, and video_source_name"
    print "Where videosource = [nao] (other sources to be implemented...)"

if __name__ == "__main__":
    print os.path.abspath(os.path.dirname(__file__)+'/../../data/training_img')    
    if len(sys.argv) < 2:
        usage()
        exit()

    config_dict = configparse.ParameterDict()
    configparse.parse_config(sys.argv[1], config_dict)
    vsec = "vision_controller" #section in config_dict
    gsec = "general"
    module_name = "surfdetect"
    modules = config_dict.get_option(vsec, "modules")
    if module_name not in modules.split():
        print "not using", module_name
        exit()

    update_frequency_s = config_dict.get_option(vsec, "update_frequency")
    robot_ip = config_dict.get_option(gsec, "robot_ip")
    controller_ip = config_dict.get_option(vsec, "controller_ip")
    controller_port_s = config_dict.get_option(vsec, module_name)
    video_source_name = config_dict.get_option(vsec, "video_source_name")
    training_dir = os.path.join( os.path.abspath(os.environ['BORG']) , config_dict.get_option(vsec, "training_dir"))