Exemplo n.º 1
0
    def rebuild_centerline(self):
        '''rebuild centerline and save data'''
        save_path_shapely = self.save_path + '/' + self.city + '_shapely'
        save_path_array = self.save_path + '/' + self.city + '_array'
        try:
            f = open(save_path_shapely, 'rb')
            line_set_shapely = pickle.load(f)
            f.close()

            f = open(save_path_array, 'rb')
            line_set_array = pickle.load(f)
            f.close()
        except:
            am = ArgoverseMap()
            line_set_shapely = {}
            line_set_array = {}
            centerline_ind = am.build_centerline_index()[
                self.city]  # 生成全部centerline
            for ctlID, ctlinfo in centerline_ind.items():
                line_set_shapely[ctlID] = LineString(ctlinfo.centerline)
                line_set_array[ctlID] = ctlinfo.centerline
            # 保存
            f = open(save_path_shapely, 'wb')
            pickle.dump(line_set_shapely, f)
            f.close()

            f = open(save_path_array, 'wb')
            pickle.dump(line_set_array, f)
            f.close()

        self.line_set_shapely = line_set_shapely
        self.line_set_array = line_set_array
Exemplo n.º 2
0
def build_city_lane_graphs(
        am: ArgoverseMap) -> Mapping[str, Mapping[int, List[int]]]:
    """
        Args:
        -   am

        Returns:
        -   city_graph_dict
    """
    city_lane_centerlines_dict = am.build_centerline_index()

    city_graph_dict = {}
    for city_name in ["MIA", "PIT"]:
        city_graph = {}

        for lane_id, segment in city_lane_centerlines_dict[city_name].items():
            # allow left/right lane changes
            if segment.l_neighbor_id:
                if lanes_travel_same_direction(lane_id, segment.l_neighbor_id,
                                               am, city_name):
                    city_graph.setdefault(str(lane_id), []).append(
                        str(segment.l_neighbor_id))

            if segment.r_neighbor_id:
                if lanes_travel_same_direction(lane_id, segment.r_neighbor_id,
                                               am, city_name):
                    city_graph.setdefault(str(lane_id), []).append(
                        str(segment.r_neighbor_id))

            if segment.predecessors:
                for pred_id in segment.predecessors:
                    city_graph.setdefault(str(pred_id),
                                          []).append(str(lane_id))

            if segment.successors:
                for succ_id in segment.successors:
                    city_graph.setdefault(str(lane_id),
                                          []).append(str(succ_id))

        for k, v in city_graph.items():
            city_graph[k] = list(set(v))
            city_graph[k].sort()

        city_graph_dict[city_name] = city_graph
    return city_graph_dict
Exemplo n.º 3
0
from argoverse.map_representation.map_api import ArgoverseMap
import pandas as pd
import numpy as np

from tqdm import tqdm

avm = ArgoverseMap()
a = avm.build_centerline_index()

'''
AV - Autonomous Vehicle
AGENT - The object with most interesting trajectory or track
OTHERS - Include all the other objects in the scene for which tracks are recorded
'''

X_ID = 3
Y_ID = 4


def vecLink(a, polyID, AVTIME):
    a = np.array(a)
    ans = []
    type = 0 if a[0, 2] == 'AGENT' else 1
    for i in range(a.shape[0] - 1):
        l, r = a[i], a[i + 1]
        # if type == 1 and (l[0] > AVTIME or r[0] > AVTIME):
        #     break
        now = [l[X_ID], l[Y_ID], r[X_ID], r[Y_ID], type,
               l[0], # time stamp
               r[0],
               np.sqrt(np.square(l[X_ID]-r[X_ID])+np.square(l[Y_ID]-r[Y_ID])) / (r[0]-l[0]), # moved l2 distance normalized with time difference