def get_hatches(self): # Fetch data, then convert to objects for t in hatch_types: # Get data for all hatches of this type, then create Hatch objs for all hatches of # that type in the vehicle (eg 2 cargo hatches) # TODO: Note [t] indexing and order of looping; we're only querying one hatch type at # a time (due to chamfer/articulation angle difference) hatch_type_data = tba.get_data(get_parts_of_interest(t))[t] for hatch_name in hatch_type_data: self.hatches.append(pinf.Hatch_Info(hatch_type_data[hatch_name], hatch_name))
def __init__(self, settings_dict): self.settings_dict = settings_dict self.desired_params = tba.get_data(get_parts_of_interest()) self._up_vector = None self._tr_mat = None self._vehicle_stl = None self._litter_stl = None self._doors_xyz = None self.voxel_data = None
def __init__(self): self.parts_found = tba.get_data(get_parts_of_interest()) self.hatches = {} self.get_hatches() # Determine the connectivity of parts self.conn = self.get_connectivity() # Load in spring and tbar data & connect each to the appropriate hatch self.get_axial_springs() self.get_torsion_bars() # After assembly initialization, run sanity check assert len(self.hatches) > 0, "No hatches were found in this assembly."
def __init__(self): # get doors, get actuators. Initialize objects and connect. # Manually specified vertical distance from hinge center to ground in SETTINGS[ # 'dist_to_ground'. According to mayavi, heights are 1.76m and 1.07 m, respectively. self.parts_found = tba.get_data(get_parts_of_interest()) # Determine the connectivity of parts self.conn = self.get_connectivity() self.ramps = {} self.get_ramps() # Load in actuator data & connect each to the appropriate ramp self.get_actuators() # After assembly initialization, run sanity check assert len(self.ramps) > 0, "No ramps found in this assembly"
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 = []
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 = []
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 = []
def __init__(self, settings): """ Setup vehicle metrics based on settings read in from file. """ ## Essential test bench settings self.output_json_file = settings["output_json_file"] ##testbench specific settings transport_dimensions = settings["transport_dimensions"] self.up_direction = settings.get("up_direction", np.array([0, 1.0, 0])) self.fore_direction = settings.get("fore_direction", np.array([0, 0, 1.0])) self.ground = settings.get("ground", np.array([0, 1.0, 0])) self.curb_mass = tba.get_veh_mass() self.cent_grav = tba.get_veh_cg() try: self.up_direction, self.ground_plane, _ = tba.get_up_vector() except: self.up_direction = settings.get("up_direction", np.array([0, 1.0, 0])) trans_data = tba.get_data(parts_of_interest) ## Define dictionaries for each lifting and tie down class self.eye_weld = {} self.eye_bolt = {} self.ring_hoist = {} self.d_ring = {} self.dbar_weld = {} self.dbar_bolt = {} self.dbar_eye = {} self.pintle = {} self.cleat = {} self.eye_weld = trans_data[ "Eye_Welded"] # TODO: does this crash on empty list? self.eye_bolt = trans_data["Eye_Bolted"] self.ring_hoist = trans_data["Ring_Hoist"] self.d_ring = trans_data["D_Ring_Lashing"] self.pintle = trans_data["Pintle_Tow"] self.cleat = trans_data["Cleat_Mooring"] self.dbar_weld = trans_data["Drawbar_Welded"] self.dbar_bolt = trans_data["Drawbar_Bolted"] self.dbar_eye = trans_data["Drawbar_Eyebolt"] ## Define set of classes to get geometry for all_class_set = tba.get_all_geom_set() ## Class sets and geometry for approach angles class_set = all_class_set - tba.geom_sets["never_exterior_classes"] - \ {"Roadwheel", "Trailing_Arm_Hydropneumatic_Rh", "Trailing_Arm_Hydropneumatic_Lh", "Track", "Sprocket_And_Carrier_Drive", "Wheel_Idler"} surface = tba.load_geometry(class_set, single_file=True) self.surface_coords = np.vstack( [surface["x"], surface["y"], surface["z"]]).T wheel_set = {"Roadwheel", "Sprocket_And_Carrier_Drive", "Wheel_Idler"} wheels = tba.load_geometry(wheel_set, single_file=True) track_set = {"Track"} track = tba.load_geometry(track_set, single_file=True) ## Class set and geometry for container fitting trans_class_set = all_class_set trans_geom = tba.load_geometry(trans_class_set, single_file=True) ## Class sets and geometry for lift eyes and tie_downs lift_set = {"Eye_Welded"} tie_down_set = {"Ring_Hoist"} lift_geom = tba.load_geometry(lift_set, single_file=True) tie_down_geom = tba.load_geometry(tie_down_set, single_file=True) self.trans_dict = vehicle_fit(surface, self.up_direction, self.fore_direction, transport_dimensions) self.trans_dict["Lifting_Metrics"] = self.lifting_metrics() self.trans_dict["Tie_Down_Metrics"] = self.tie_down_metrics() self.trans_dict["Approach_Angles"] = approach_angles( surface, wheels, track) pintle_count = len(self.pintle) cleat_count = len(self.cleat) tow_count = len(self.eye_bolt) + len(self.eye_weld) + len(self.dbar_bolt) + \ len(self.dbar_eye) + len(self.dbar_weld) + len(self.pintle) lift_count = len(self.eye_bolt) + len(self.eye_weld) self.trans_dict["Count_for_components_in_towing_class"] = tow_count self.trans_dict["Count_for_components_in_lifting_class"] = lift_count self.trans_dict["Count_for_components_in_pintle_class"] = pintle_count self.trans_dict["Count_for_components_in_mooring_class"] = cleat_count plot_vehicle(trans_geom, transport_dimensions) plot_lift_tie_down(trans_geom, lift_geom, tie_down_geom) tba.write_results(self.trans_dict)
def __init__(self, settings): """ Setup vehicle metrics based on settings read in from file. """ ## Essential test bench settings self.output_json_file = settings["output_json_file"] ##testbench specific settings transport_dimensions = settings["transport_dimensions"] self.up_direction = settings.get("up_direction", np.array([0, 1.0, 0])) self.fore_direction = settings.get("fore_direction", np.array([0, 0, 1.0])) self.ground = settings.get("ground", np.array([0, 1.0, 0])) self.curb_mass = tba.get_veh_mass() self.cent_grav = tba.get_veh_cg() try: self.up_direction, self.ground_plane, _ = tba.get_up_vector() except: self.up_direction = settings.get("up_direction", np.array([0, 1.0, 0])) trans_data = tba.get_data(parts_of_interest) ## Define dictionaries for each lifting and tie down class self.eye_weld = {} self.eye_bolt = {} self.ring_hoist = {} self.d_ring = {} self.dbar_weld = {} self.dbar_bolt = {} self.dbar_eye = {} self.pintle = {} self.cleat = {} self.eye_weld = trans_data["Eye_Welded"] # TODO: does this crash on empty list? self.eye_bolt = trans_data["Eye_Bolted"] self.ring_hoist = trans_data["Ring_Hoist"] self.d_ring = trans_data["D_Ring_Lashing"] self.pintle = trans_data["Pintle_Tow"] self.cleat = trans_data["Cleat_Mooring"] self.dbar_weld = trans_data["Drawbar_Welded"] self.dbar_bolt = trans_data["Drawbar_Bolted"] self.dbar_eye = trans_data["Drawbar_Eyebolt"] ## Define set of classes to get geometry for all_class_set = tba.get_all_geom_set() ## Class sets and geometry for approach angles class_set = all_class_set - tba.geom_sets["never_exterior_classes"] - \ {"Roadwheel", "Trailing_Arm_Hydropneumatic_Rh", "Trailing_Arm_Hydropneumatic_Lh", "Track", "Sprocket_And_Carrier_Drive", "Wheel_Idler"} surface = tba.load_geometry(class_set, single_file=True) self.surface_coords = np.vstack([surface["x"], surface["y"], surface["z"]]).T wheel_set = {"Roadwheel", "Sprocket_And_Carrier_Drive", "Wheel_Idler"} wheels = tba.load_geometry(wheel_set, single_file=True) track_set = {"Track"} track = tba.load_geometry(track_set, single_file=True) ## Class set and geometry for container fitting trans_class_set = all_class_set trans_geom = tba.load_geometry(trans_class_set, single_file=True) ## Class sets and geometry for lift eyes and tie_downs lift_set = {"Eye_Welded"} tie_down_set = {"Ring_Hoist"} lift_geom = tba.load_geometry(lift_set, single_file=True) tie_down_geom = tba.load_geometry(tie_down_set, single_file=True) self.trans_dict = vehicle_fit(surface, self.up_direction, self.fore_direction, transport_dimensions) self.trans_dict["Lifting_Metrics"] = self.lifting_metrics() self.trans_dict["Tie_Down_Metrics"] = self.tie_down_metrics() self.trans_dict["Approach_Angles"] = approach_angles(surface, wheels, track) pintle_count = len(self.pintle) cleat_count = len(self.cleat) tow_count = len(self.eye_bolt) + len(self.eye_weld) + len(self.dbar_bolt) + \ len(self.dbar_eye) + len(self.dbar_weld) + len(self.pintle) lift_count = len(self.eye_bolt) + len(self.eye_weld) self.trans_dict["Count_for_components_in_towing_class"] = tow_count self.trans_dict["Count_for_components_in_lifting_class"] = lift_count self.trans_dict["Count_for_components_in_pintle_class"] = pintle_count self.trans_dict["Count_for_components_in_mooring_class"] = cleat_count plot_vehicle(trans_geom, transport_dimensions) plot_lift_tie_down(trans_geom, lift_geom, tie_down_geom) tba.write_results(self.trans_dict)