예제 #1
0
    def __init__(self, settings_f):
        """
        Setup field of fire metrics based on settings read in from file.
        """
        ##pass setting to the test bench api
        settings_dict = tba.load_settings(settings_f)

        ## Optional test bench settings
        self.show_3d = settings_dict.get("show_3d", False)
        horizontal_divs = settings_dict.get("horizontal_divs", 720)
        self.up_direction = settings_dict.get("up_direction",
                                              np.array([0, 1.0, 0]))
        self.ground = settings_dict.get("ground", np.array([0, 1.0, 0]))

        ## Set up some constant parameters
        self.hor_sweep = np.linspace(0, 2 * pi, horizontal_divs)

        ## How many rays are considered contiguous - 3degrees of arc
        self.contiguous = int(ceil(3 * horizontal_divs / 360.0))
        self.incr_elev = 2 * pi / 720.0

        ## Get the data for the weapon.
        fof_data = tba.get_data(parts_of_interest)["Weapon_Station_Remote"]

        ## Get a weapon object.  API will enforce there is only one.
        wep_name = fof_data.keys()[0]
        self.weapon = Weapon_Station(wep_name, fof_data)

        ## Specify the classes of objects we want geometry for and load them in.
        class_set = tba.get_all_geom_set(
        ) - tba.geom_sets["never_exterior_classes"]
        surface = tba.load_geometry(class_set, single_file=True)

        ## Make a binary space partition to speed up intersection calculations
        self.nodes = np.vstack((surface['x'], surface['y'], surface['z'])).T
        self.tris = surface['tris']
        self.b_tree = BSP_Tree(self.nodes, self.tris)
        self.b_tree.generate_tree()

        ## Set up result storage.
        self.traverse_results = []
예제 #2
0
    def __init__(self, settings_f):
        """
        Setup field of fire metrics based on settings read in from file.
        """
        ##pass setting to the test bench api
        settings_dict = tba.load_settings(settings_f)

        ## Optional test bench settings
        self.show_3d = settings_dict.get("show_3d", False)
        horizontal_divs = settings_dict.get("horizontal_divs", 720)
        self.up_direction = settings_dict.get("up_direction", np.array([0, 1.0, 0]))
        self.ground = settings_dict.get("ground", np.array([0, 1.0, 0]))

        ## Set up some constant parameters
        self.hor_sweep = np.linspace(0, 2 * pi, horizontal_divs)

        ## How many rays are considered contiguous - 3degrees of arc
        self.contiguous = int(ceil(3 * horizontal_divs / 360.0))
        self.incr_elev = 2 * pi / 720.0

        ## Get the data for the weapon.
        fof_data = tba.get_data(parts_of_interest)["Weapon_Station_Remote"]

        ## Get a weapon object.  API will enforce there is only one.
        wep_name = fof_data.keys()[0]
        self.weapon = Weapon_Station(wep_name, fof_data)

        ## Specify the classes of objects we want geometry for and load them in.
        class_set = tba.get_all_geom_set() - tba.geom_sets["never_exterior_classes"]
        surface = tba.load_geometry(class_set, single_file=True)

        ## Make a binary space partition to speed up intersection calculations
        self.nodes = np.vstack((surface['x'], surface['y'], surface['z'])).T
        self.tris = surface['tris']
        self.b_tree = BSP_Tree(self.nodes, self.tris)
        self.b_tree.generate_tree()

        ## Set up result storage.
        self.traverse_results = []
예제 #3
0
                                     weight='weight',
                                     heuristic=a_star_heuristic)
        # Don't plot the final exit point; that's for internal bookkeeping. We care more about
        # what edge the soldier stepped on right before exiting.
        coord_lists = zip(*path_to_exit)
        
        ax.plot(coord_lists[1], coord_lists[0], linewidth=3, alpha=0.3)
        ax.plot(exit_pt[1], exit_pt[0], marker="^", color='r')

    save_folder = os.path.join("results", settings["run_id"], str(settings["voxel_size"]))
    plt.savefig(os.path.join(save_folder, "troop_exit_paths.png"))

if __name__ == "__main__":
    # User specified settings from separate file
    from rpl.tools.api import test_bench_api as tba
    SETTINGS = tba.load_settings("settings.js")

    ## Set up logging
    logging.info("\n"+50*"_"+'\ntest bench started\n'+50*"_")

    # Value references numpy; can't be read from json
    SETTINGS["unwalkable_value"] = np.inf

    # Load in vehicle occupied voxels file in order to locate the door points
    vox_veh_folder = r"voxelated_models/vehicles/{}/{}".format(SETTINGS["run_id"],
                                                               SETTINGS["voxel_size"])
    vox_veh_file = "voxels_{}_vox{}".format(SETTINGS["run_id"], SETTINGS["voxel_size"])
    veh_vox = data_io.load_array(vox_veh_folder, vox_veh_file, multi_array=True)

    #### Standalone egress testing mode requires a few dummy points that will depend on the
    # assembly chosen. These apply to the Ricardo master assembly as of Nov 11, 2013.
예제 #4
0
    def __init__(self, settings_f):
        """
        Setup vision metrics based on settings read in from file.
        """
        ##pass setting to the test bench api
        settings_dict = tba.load_settings(settings_f)

        ## Optional test bench settings
        self.show_3d = settings_dict.get("show_3d", False)
        horizontal_divs = settings_dict.get("horizontal_divs", 720)
        self.focal_length_multiplier = settings_dict.get(
            "focal_length_multiplier", 1.5)
        self.far_dist = settings_dict.get("far_dist", 20.0)
        self.up_direction = settings_dict.get("up_direction",
                                              np.array([0, 1.0, 0]))
        self.fore_direction = settings_dict.get("fore_direction",
                                                np.array([0, 0, -1.0]))
        self.ground = settings_dict.get("ground", np.array([0, 1.0, 0]))

        ## Set up some constant parameters
        self.hor_sweep = np.linspace(0, 2 * pi, horizontal_divs)
        self.target_points_horizon = np.zeros(horizontal_divs, np.uint32)

        ## Get a dictionary of parts and properties form the api (periscopes, manikins, screens)
        fov_data = tba.get_data(parts_of_interest)

        ## Get Periscope objects for any that are found
        self.periscopes = [
            Vision_Device(p, fov_data["Periscope"])
            for p in fov_data["Periscope"]
        ]

        ## Get Manikin objects for the vehicle occupants that have vision requirements
        m_data = fov_data["Manikin"]

        req_roles = ["driver", "vehicle_commander", "troop_commander"]

        vis_roles = lambda m: m_data[m]["properties"]["vehicle_role"
                                                      ] in req_roles
        self.manikins = [
            Manikin(m, fov_data["Manikin"]) for m in m_data if vis_roles(m)
        ]

        ## Need exactly one of each
        roles = [m.vehicle_role for m in self.manikins]
        if len(set(roles)) != len(req_roles):
            msg = "Didn't get 1 of each vehicle_role={} instead got={}".format(
                req_roles, roles)
            raise ValueError(msg)

        ## Specify the classes of objects we want geometry for.
        class_set = tba.get_all_geom_set(
        ) - tba.geom_sets["never_exterior_classes"]

        ## And load them all as an effective single file
        surface = tba.load_geometry(class_set, single_file=True)

        ## Make a binary space partition to speed up intersection calculations
        self.nodes = np.vstack((surface['x'], surface['y'], surface['z'])).T
        self.tris = surface['tris']
        self.b_tree = BSP_Tree(self.nodes, self.tris)
        self.b_tree.generate_tree()

        ## TODO this won't cope with unusual orientations
        ## determine orientation of the vehicle given the direction up and forward
        fore = np.dot(self.nodes, self.fore_direction).min()
        fore = np.min(surface["z"])
        self.side_direction = np.cross(self.up_direction, self.fore_direction)
        side_array = np.dot(self.nodes, self.side_direction)

        self.z_ground = np.dot(self.ground, self.up_direction)

        center = (side_array.min() + side_array.max()) / 2.0
        center = (np.min(surface["x"]) + np.max(surface["x"])) * 0.5
        ## Find the vehicle origin (point on ground at front on centerline)
        self.veh_origin = np.array([center, self.z_ground, fore])
        logging.info("Vehicle origin is at {}".format(self.veh_origin))
        self.tran_veh = translate(self.veh_origin)

        self.fore_aft = [None] * len(self.periscopes)
        self.uplook = np.array([-1000.0] * len(self.periscopes))

        self.hit = []

        self.hor_fans = []
예제 #5
0
    res = True if litter_collision_count < max_coll_allowed else False

    logging.info("Litter collisions: {:.2%}".format(
        float(litter_collision_count) / float(litter_vox_count)))
    logging.info(
        "Test bench TB036 completed. Vehicle has room for litter: {}".format(
            res))
    return res


if __name__ == "__main__":
    #############

    # Initialize API with settings
    SETTINGS = tba.load_settings("settings.js")

    # Value references numpy; can't be read from json
    SETTINGS["unwalkable_value"] = np.inf

    #######
    #  Call test bench api to obtain desired information
    assembly = Assembly_Info(SETTINGS)

    #######
    #  Voxelize the vehicle and return all information
    # Save the voxelated model of the vehicle (sans door and other excluded parts)

    vox_veh_folder = r"voxelated_models/vehicles/{}/{}".format(
        SETTINGS["run_id"], SETTINGS["voxel_size"])
예제 #6
0
파일: fov.py 프로젝트: hitej/meta-core
    def __init__(self, settings_f):
        """
        Setup vision metrics based on settings read in from file.
        """
        ##pass setting to the test bench api
        settings_dict = tba.load_settings(settings_f)

        ## Optional test bench settings
        self.show_3d = settings_dict.get("show_3d", False)
        horizontal_divs = settings_dict.get("horizontal_divs", 720)
        self.focal_length_multiplier = settings_dict.get("focal_length_multiplier", 1.5)
        self.far_dist = settings_dict.get("far_dist", 20.0)
        self.up_direction = settings_dict.get("up_direction", np.array([0, 1.0, 0]))
        self.fore_direction = settings_dict.get("fore_direction", np.array([0, 0, -1.0]))
        self.ground = settings_dict.get("ground", np.array([0, 1.0, 0]))

        ## Set up some constant parameters
        self.hor_sweep = np.linspace(0, 2 * pi, horizontal_divs)
        self.target_points_horizon = np.zeros(horizontal_divs, np.uint32)

        ## Get a dictionary of parts and properties form the api (periscopes, manikins, screens)
        fov_data = tba.get_data(parts_of_interest)

        ## Get Periscope objects for any that are found
        self.periscopes = [Vision_Device(p, fov_data["Periscope"]) for p in fov_data["Periscope"]]

        ## Get Manikin objects for the vehicle occupants that have vision requirements
        m_data = fov_data["Manikin"]

        req_roles = ["driver", "vehicle_commander", "troop_commander"]

        vis_roles = lambda m: m_data[m]["properties"]["vehicle_role"] in req_roles
        self.manikins = [Manikin(m, fov_data["Manikin"]) for m in m_data if vis_roles(m)]

        ## Need exactly one of each
        roles = [m.vehicle_role for m in self.manikins]
        if len(set(roles)) != len(req_roles):
            msg = "Didn't get 1 of each vehicle_role={} instead got={}".format(req_roles, roles)
            raise ValueError(msg)

        ## Specify the classes of objects we want geometry for.
        class_set = tba.get_all_geom_set() - tba.geom_sets["never_exterior_classes"]

        ## And load them all as an effective single file
        surface = tba.load_geometry(class_set, single_file=True)

        ## Make a binary space partition to speed up intersection calculations
        self.nodes = np.vstack((surface["x"], surface["y"], surface["z"])).T
        self.tris = surface["tris"]
        self.b_tree = BSP_Tree(self.nodes, self.tris)
        self.b_tree.generate_tree()

        ## TODO this won't cope with unusual orientations
        ## determine orientation of the vehicle given the direction up and forward
        fore = np.dot(self.nodes, self.fore_direction).min()
        fore = np.min(surface["z"])
        self.side_direction = np.cross(self.up_direction, self.fore_direction)
        side_array = np.dot(self.nodes, self.side_direction)

        self.z_ground = np.dot(self.ground, self.up_direction)

        center = (side_array.min() + side_array.max()) / 2.0
        center = (np.min(surface["x"]) + np.max(surface["x"])) * 0.5
        ## Find the vehicle origin (point on ground at front on centerline)
        self.veh_origin = np.array([center, self.z_ground, fore])
        logging.info("Vehicle origin is at {}".format(self.veh_origin))
        self.tran_veh = translate(self.veh_origin)

        self.fore_aft = [None] * len(self.periscopes)
        self.uplook = np.array([-1000.0] * len(self.periscopes))

        self.hit = []

        self.hor_fans = []
예제 #7
0
        # Build up the voxel_data
        logging.debug("Sampling component: {}".format(key))
        ## Default mask is 1 for anything not in an identified set
        surf_mask = 1
        for mask, geo_set in voxel_masks.items():
            if veh_surf['part_class'] in geo_set:
                surf_mask |= mask

        voxel_data = find_occupied_voxels(veh_surf, surf_mask, voxel_data)

    return voxel_data


if __name__ == "__main__":
    from rpl.tools.api import test_bench_api as tb_api
    SETTINGS = tb_api.load_settings("settings.js")

    DOORS = {'Hatch_Assembly_Rear_Ramp', 'Hatch_Assembly_Personnel_Door'}
    HATCHES = {'Hatch_Assembly_Driver_Commander', 'Hatch_Assembly_Cargo'}
    HULLS = {
        "Hull_Assembly_Parametric", 'Hull_Assembly_Example_With_Connector'
    }
    MANIKINS = {"Manikin"}
    # Special labels applied to specific types of voxels
    VOXEL_LABELS = {2: HULLS, 4: DOORS, 8: HATCHES, 16: MANIKINS}

    vehicle_surfs = tb_api.load_geometry(tb_api.get_all_geom_set() - MANIKINS,
                                         single_file=False)

    # Modify node coords so object aligns with cartesian axes of occ voxel grid, +z=up
    # Vector to rotate around is cross product of current z axis and sfc normal
예제 #8
0
        "Plotting approach angles: writing image to file {} in {}.".format(
            img_file_name, current_dir))

    plt.savefig(img_file_name, dpi=100)

    logging.info("Finished plotting approach angles")

    plt.clf()


def plot_tracks(track_points, track_outline):
    """
    plots the convex hull created by the track geometry
    """
    for simplex in track_outline.simplices:
        plt.plot(track_points[simplex, 0],
                 track_points[simplex, 1],
                 'k-',
                 linewidth=0.5,
                 alpha=0.7)


if __name__ == "__main__":
    ## Executes the transportability test bench.

    logging.info("\n" + 50 * "_" + "\ntest bench started\n" + 50 * "_")

    settings_file = r"settings.js"
    settings_dict = tba.load_settings(settings_file)
    vehicle_metrics = Vehicle_Metrics(settings_dict)
    logging.info("Test bench completed\n" + 50 * "_")
예제 #9
0


if __name__ == "__main__":
    #############
    # User specified settings from separate file
    with open(r"settings.js", "r") as f:
        SETTINGS = json.load(f)

    ## Set up logging
    logging.info("\n"+50*"_"+'\nTest bench started\n'+50*"_")
    # Uncaught exceptions and assertions should write error to log
    sys.excepthook = excepthook

    # Initialize API with settings
    tba.load_settings(SETTINGS)
    logging.debug("Data loader API initialized")

    phi = 0.0
    assembly = Assembly_Info()

    geo = {}
    for t in hatch_types:
        geo.update(tba.load_geometry({t}))

    show3d = False
    if show3d:
        from mayavi import mlab
        from itertools import cycle
        hatch_colors = cycle([(.8, .4, .4),
                              (.4, .8, .4),
예제 #10
0
    plt.suptitle("Approach angles", horizontalalignment='right', verticalalignment='top')

    img_file_name = "Approach_angles.png"
    current_dir = os.getcwd()
    logging.info("Plotting approach angles: writing image to file {} in {}.".format(
        img_file_name, current_dir))

    plt.savefig(img_file_name, dpi=100)

    logging.info("Finished plotting approach angles")

    plt.clf()


def plot_tracks(track_points, track_outline):
    """
    plots the convex hull created by the track geometry
    """
    for simplex in track_outline.simplices:
        plt.plot(track_points[simplex, 0], track_points[simplex, 1], 'k-', linewidth=0.5, alpha=0.7)


if __name__ == "__main__":
    ## Executes the transportability test bench.

    logging.info("\n" + 50 * "_" + "\ntest bench started\n" + 50 * "_")

    settings_file = r"settings.js"
    settings_dict = tba.load_settings(settings_file)
    vehicle_metrics = Vehicle_Metrics(settings_dict)
    logging.info("Test bench completed\n" + 50 * "_")