def test_behavior_from_yaml():
    map_file = os.getcwd() + '/test/building_crowdsim/config_test.yaml'
    yaml_parse = BuildingYamlParse(map_file)
    crowd_sim_yaml = yaml_parse.crowd_sim_config

    behavior_file = BehaviorFile()
    if 'states' in crowd_sim_yaml:
        for state in crowd_sim_yaml['states']:
            cur_state = BehaviorState()
            cur_state.load_from_yaml(state)
            behavior_file.sub_elements.append(cur_state)
    if 'transitions' in crowd_sim_yaml:
        for transition in crowd_sim_yaml['transitions']:
            cur_transition = StateTransition()
            cur_transition.load_from_yaml(transition)
            behavior_file.sub_elements.append(cur_transition)
    if 'goal_sets' in crowd_sim_yaml:
        for goal_set in crowd_sim_yaml['goal_sets']:
            cur_goal_set = GoalSet()
            cur_goal_set.load_from_yaml(goal_set, yaml_parse.get_human_goals())
            behavior_file.sub_elements.append(cur_goal_set)

    behavior_file_root = behavior_file.output_xml_element()
    util.pretty_xml(behavior_file_root, '\t', '\n')
    ET.dump(behavior_file_root)
def test_scene_from_yaml():
    map_file = os.getcwd() + '/test/building_crowdsim/config_test.yaml'
    yaml_parse = BuildingYamlParse(map_file)
    crowd_sim_yaml = yaml_parse.crowd_sim_config

    scene_file = SceneFile()
    scene_file.add_spatial_query()
    scene_file.add_common()
    if 'obstacle_set' in crowd_sim_yaml:
        obstacle_set = ObstacleSet()
        obstacle_set.load_from_yaml(crowd_sim_yaml['obstacle_set'])
        scene_file.sub_elements.append(obstacle_set)
    if 'agent_profiles' in crowd_sim_yaml:
        for item in crowd_sim_yaml['agent_profiles']:
            cur_profile = AgentProfile()
            cur_profile.load_from_yaml(item)
            scene_file.sub_elements.append(cur_profile)
    if 'agent_groups' in crowd_sim_yaml:
        for item in crowd_sim_yaml['agent_groups']:
            cur_group = AgentGroup()
            cur_group.load_from_yaml(item)
            scene_file.sub_elements.append(cur_group)

    scene_file_root = scene_file.output_xml_element()
    util.pretty_xml(scene_file_root, '\t', '\n')
    ET.dump(scene_file_root)
def test_plugin_from_yaml():
    map_file = os.getcwd() + '/test/building_crowdsim/config_test.yaml'
    yaml_parse = yaml_parse = BuildingYamlParse(map_file)
    crowd_sim_yaml = yaml_parse.crowd_sim_config

    plugin_file = Plugin()
    plugin_file.load_from_yaml(crowd_sim_yaml)
    plugin_file_root = plugin_file.output_xml_element()
    util.pretty_xml(plugin_file_root, '\t', '\n')
    ET.dump(plugin_file_root)
Example #4
0
def navmesh_main(map_file, output_dir):
    if not os.path.exists(map_file):
        raise ValueError('Map path not exist!')

    if not os.path.exists(output_dir):
        print("Creating output folder path: ", output_dir)
        os.makedirs(output_dir)

    # parse the yaml file
    yaml_parse = BuildingYamlParse(map_file)

    for level_name in yaml_parse.levels_name:
        # navmesh output
        navmesh_output_file = output_dir + '/' + level_name + "_navmesh.nav"
        level_with_human_lanes = yaml_parse.levels_with_human_lanes[level_name]
        navmesh_output(level_name, level_with_human_lanes, navmesh_output_file)
def configfile_main(map_file, output_dir, world_file_to_be_inserted):
    if not os.path.exists(map_file):
        raise ValueError('Map path not exist!: ' + map_file)

    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
        print("Create output dir for:", output_dir)

    if not os.path.exists(world_file_to_be_inserted):
        world_file_to_be_inserted = ""

    yaml_parse = BuildingYamlParse(map_file)
    configfile_generator = ConfigFileGenerator(yaml_parse)
    configfile_generator.generate_behavior_file(output_dir)
    configfile_generator.generate_scene_file(output_dir)
    configfile_generator.insert_plugin_into_world_file(
        world_file_to_be_inserted)
def navmesh_main(map_file, output_dir):
    if not os.path.exists(map_file):
        raise ValueError('Map path not exist!')

    if not os.path.exists(output_dir):
        print("Creating output folder path: ", output_dir)
        os.makedirs(output_dir)

    # parse the yaml file
    try:
        yaml_parse = BuildingYamlParse(map_file)
    except ValueError as e:
        print('crowdsim unable to parse, not attempting to proceed')
        return

    for level_name in yaml_parse.levels_name:
        # navmesh output
        navmesh_output_file = output_dir + '/' + level_name + "_navmesh.nav"
        level_with_human_lanes = yaml_parse.levels_with_human_lanes[level_name]
        navmesh_output(level_name, level_with_human_lanes, navmesh_output_file)