コード例 #1
0
ファイル: brain.py プロジェクト: diederikvkrieken/Asjemenao
def load_config(sysargs):
    """
    Load configuration file and combine this with command line arguments
    """
    if len(sysargs) < 2:
        print_usage("Specification of robot IP and starting behavior is mandatory!")
        sys.exit()
    option_dict, args = parse_args(sysargs)
    if len(args) >= 1:
        config_file = args[0]
        configparse.parse_config(config_file, option_dict) #does not overwrite existing arguments in option_dict
    try:
        check_options(option_dict)
    except Exception as e:
        print_usage("Failed to load valid configuration!")
        print e
        sys.exit()

    replace_placeholders(option_dict)
    return option_dict
コード例 #2
0
def load_config(sysargs):
    """
    Load configuration file and combine this with command line arguments
    """
    if len(sysargs) < 2:
        print_usage("Specification of robot IP and starting behavior is mandatory!")
        sys.exit()
    option_dict, args = parse_args(sysargs)
    if len(args) >= 1:
        config_file = args[0]
        configparse.parse_config(config_file, option_dict) #does not overwrite existing arguments in option_dict
    try:
        check_options(option_dict)
    except Exception as e:
        print_usage("Failed to load valid configuration!")
        print e
        sys.exit()

    replace_placeholders(option_dict)
    return option_dict
コード例 #3
0
def load_config(sysargs):
    """
    Load configuration file and combine this with command line arguments
    """
    if len(sysargs) < 2:
        sys.exit()
    option_dict, args = parse_args(sysargs)

    if len(args) >= 1:
        config_file = args[0]
        configparse.parse_config(
            config_file,
            option_dict)  #does not overwrite existing arguments in option_dict

    try:
        check_options(option_dict)
    except Exception as e:
        print e
        sys.exit()

    return option_dict
コード例 #4
0
    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")
    if not (update_frequency_s and robot_ip and controller_ip and
        controller_port_s and video_source_name):
コード例 #5
0
    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])
            postcondition_read = True
        if (variable == "exceptions"):
            exceptions.append(option_dict.option_dict[section][variable])
            exception_read = True
    if (variable == "description"):
        descriptions.append(option_dict.option_dict[section][variable])
        description_read = True
コード例 #6
0
    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"))
    if not (update_frequency_s and robot_ip and controller_ip and
コード例 #7
0
    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])
            postcondition_read = True
        if (variable == "exceptions"):
            exceptions.append(option_dict.option_dict[section][variable])
            exception_read = True
    if (variable == "description"):
        descriptions.append(option_dict.option_dict[section][variable])
        description_read = True