def create_signal_proto(x, y, heading):
    # mkz vehicle configuration

    center_x = x + g_front_to_center * math.cos(heading)
    center_y = y + g_front_to_center * math.sin(heading)

    map_signal = map_signal_pb2.Signal()

    map_signal.id.id = "%2.5f_%2.5f" % (center_x, center_y)

    map_signal.type = map_signal_pb2.Signal.MIX_3_VERTICAL

    # left subsignal
    left_subsignal = map_signal.subsignal.add()
    left_x = center_x + g_left_to_center * math.cos(heading + math.pi / 2.0)
    left_y = center_y + g_left_to_center * math.sin(heading + math.pi / 2.0)
    left_subsignal.id.id = "%2.5f_%2.5f" % (left_x, left_y)
    left_subsignal.type = map_signal_pb2.Subsignal.CIRCLE
    left_subsignal.location.x = left_x
    left_subsignal.location.y = left_y
    left_subsignal.location.z = 5.0

    stopline = map_signal.stop_line.add()
    stopline.CopyFrom(create_stop_line(center_x, center_y, heading))

    if g_args.extend_to_neighbor_lane:
        # add stop line on left lane
        left_shift_x = center_x + g_lane_width * math.cos(heading +
                                                          math.pi / 2.0)
        left_shift_y = center_y + g_lane_width * math.sin(heading +
                                                          math.pi / 2.0)
        stopline = map_signal.stop_line.add()
        stopline.CopyFrom(create_stop_line(left_shift_x, left_shift_y,
                                           heading))

        # add stop line on right lane
        right_shift_x = center_x + g_lane_width * math.cos(heading -
                                                           math.pi / 2.0)
        right_shift_y = center_y + g_lane_width * math.sin(heading -
                                                           math.pi / 2.0)
        stopline = map_signal.stop_line.add()
        stopline.CopyFrom(
            create_stop_line(right_shift_x, right_shift_y, heading))

    return map_signal
Example #2
0
if len(sys.argv) < 3:
    print('Usage: %s [map_file] [signal_file]' % sys.argv[0])
    sys.exit(0)

map_file = sys.argv[1]
signal_file = sys.argv[2]

with open(map_file, 'r') as fmap:
    map_data = fmap.read()
    map = map_pb2.Map()
    text_format.Parse(map_data, map)

with open(signal_file, 'r') as fsignal:
    signal_data = fsignal.read()
    signal = map_signal_pb2.Signal()
    text_format.Parse(signal_data, signal)

lanes = {}
lanes_map = {}
for lane in map.lane:
    lane_points = []
    lanes_map[lane.id.id] = lane
    for segment in lane.central_curve.segment:
        for point in segment.line_segment.point:
            lane_points.append((point.x, point.y))
    lane_string = LineString(lane_points)
    lanes[lane.id.id] = lane_string

lines = {}
for stop_line in signal.stop_line: