def get_vertical(self): """ Return a vector corresponding to the up vector in the vehicle. Determined from calculated metrics file. Normalize it to unit length to be safe. """ if self._up_vector is None: try: self._up_vector, _, _ = tba.get_up_vector() logging.debug("Used up vector based on ComputedValues.xml from GME assembly") except ValueError: wrn = """ WARNING: Requires a known vector pointing up. Hard-coded value is (0,1,0), implying that the up direction lies along y axis. """ self._up_vector = np.array([0, 1, 0]) logging.warning(wrn) self._up_vector /= np.linalg.norm(self._up_vector) return self._up_vector
def get_vertical(self): """ Return a vector corresponding to the up vector in the vehicle. Determined from calculated metrics file. Normalize it to unit length to be safe. """ if self._up_vector is None: try: self._up_vector, _, _ = tba.get_up_vector() logging.debug( "Used up vector based on ComputedValues.xml from GME assembly" ) except ValueError: wrn = """ WARNING: Requires a known vector pointing up. Hard-coded value is (0,1,0), implying that the up direction lies along y axis. """ self._up_vector = np.array([0, 1, 0]) logging.warning(wrn) self._up_vector /= np.linalg.norm(self._up_vector) return self._up_vector
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)