def set_planning_conf(config): """change planning config based on navi config""" planning_conf = planning_config_pb2.PlanningConfig() proto_utils.get_pb_from_file(PLANNING_CONF_FILE, planning_conf) planner_type = config.get('PlanningConf', 'planner_type') if planner_type == "EM": planning_conf.planner_type = planning_config_pb2.PlanningConfig.EM if planner_type == "LATTICE": planning_conf.planner_type = planning_config_pb2.PlanningConfig.LATTICE if planner_type == "NAVI": planning_conf.planner_type = planning_config_pb2.PlanningConfig.NAVI proto_utils.write_pb_to_text_file(planning_conf, PLANNING_CONF_FILE)
def parse_file(self, filename): value = self.instance() if not proto_utils.get_pb_from_file(filename, value): print("Failed to parse file %s" % filename) return None else: return value
def set_hmi_conf(config): """change hmi conf file based on navi config file""" hmi_conf = hmi_config_pb2.HMIConfig() proto_utils.get_pb_from_file(HMI_CONF_FILE, hmi_conf) perception = config.get('PerceptionConf', 'perception') navi_mode = hmi_conf.modes["Navigation"] if 'navigation_camera' in navi_mode.live_modules: navi_mode.live_modules.remove('navigation_camera') if 'navigation_perception' in navi_mode.live_modules: navi_mode.live_modules.remove('navigation_perception') if 'mobileye' in navi_mode.live_modules: navi_mode.live_modules.remove('mobileye') if 'third_party_perception' in navi_mode.live_modules: navi_mode.live_modules.remove('third_party_perception') if 'velodyne' in navi_mode.live_modules: navi_mode.live_modules.remove('velodyne') if 'perception' in navi_mode.live_modules: navi_mode.live_modules.remove('perception') if perception == "CAMERA": if 'navigation_camera' not in navi_mode.live_modules: navi_mode.live_modules.insert(0, 'navigation_camera') if 'navigation_perception' not in navi_mode.live_modules: navi_mode.live_modules.insert(0, 'navigation_perception') if perception == "MOBILEYE": if 'mobileye' not in navi_mode.live_modules: navi_mode.live_modules.insert(0, 'mobileye') if 'third_party_perception' not in navi_mode.live_modules: navi_mode.live_modules.insert(0, 'third_party_perception') if perception == "VELODYNE64": if 'velodyne' not in navi_mode.live_modules: navi_mode.live_modules.insert(0, 'velodyne') if 'perception' not in navi_mode.live_modules: navi_mode.live_modules.insert(0, 'perception') hmi_conf.modes["Navigation"].CopyFrom(navi_mode) proto_utils.write_pb_to_text_file(hmi_conf, HMI_CONF_FILE)
def run(gmap_key, map_file, utm_zone): """ read and process map file """ map_pb = map_pb2.Map() proto_utils.get_pb_from_file(map_file, map_pb) left_boundaries = [] right_boundaries = [] center_lat = None center_lon = None for lane in map_pb.lane: for curve in lane.left_boundary.curve.segment: if curve.HasField('line_segment'): left_boundary = [] for p in curve.line_segment.point: point = {} lat, lng = utm2latlon(p.x, p.y, utm_zone) if center_lat is None: center_lat = lat if center_lon is None: center_lon = lng point['lat'] = lat point['lng'] = lng left_boundary.append(point) left_boundaries.append(left_boundary) for curve in lane.right_boundary.curve.segment: if curve.HasField('line_segment'): right_boundary = [] for p in curve.line_segment.point: point = {} lat, lng = utm2latlon(p.x, p.y, utm_zone) point['lat'] = lat point['lng'] = lng right_boundary.append(point) right_boundaries.append(right_boundary) html = generate(gmap_key, left_boundaries, right_boundaries, center_lat, center_lon) with open('gmap.html', 'w') as file: file.write(html)
last_point = p cur_len += delta_diff return prediction if __name__ == '__main__': parser = argparse.ArgumentParser( description="extend prediction trajectory") parser.add_argument("prediction", action="store", type=str, help="set the prediction file") parser.add_argument("-p", "--period", action="store", type=float, default=10.0, help="set the prediction period") parser.add_argument("-d", "--distance", action="store", type=float, default=70.0, help="set the prediction distance") args = parser.parse_args() prediction_data = proto_utils.get_pb_from_file(args.prediction, PredictionObstacles()) extended_prediction = extend_prediction(prediction_data, args.distance, args.period) print(extended_prediction)
def load(self, map_file_name): res = proto_utils.get_pb_from_file(map_file_name, self.map_pb) return res is not None
def load_map_data(map_file): map_pb = map_pb2.Map() proto_utils.get_pb_from_file(map_file, map_pb) return map_pb