Argoverse代码笔记:map_api.py

Argoverse对象:

该类为我们的矢量地图和光栅化地图提供了接口。没有提供精确的车道边界,但如果考虑到平均车道宽度,则可以想象出车道边界。

map_files_root

get_vector_map_lane_polygons

Get list of lane polygons for a specified city Args: city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: Numpy array of polygons

get_vector_map_driveable_areas

Get driveable area for a specified city
Args: city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: das: driveable areas as n-d array of NumPy objects of shape (n,3) Note: 'z_min', 'z_max' were removed

get_da_contours:

We threshold the binary driveable area or ROI image and obtain contour lines. These contour lines represent the boundary.

Args:city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh;

Returns:Drivable area contours

build_centerline_index

""" Build dictionary of centerline for each city, with lane_id as key Returns: city_lane_centerlines_dict: Keys are city names, values are dictionaries (k=lane_id, v=lane info) """

build_city_driveable_area_roi_index:

Load driveable area files from disk. Dilate driveable area to get ROI (takes about 1/2 second). Returns: city_rasterized_da_dict: a dictionary of dictionaries. Key is city_name, and value is a dictionary with driveable area info. For example, includes da_matrix: Numpy array of shape (M,N) representing binary values for driveable area city_to_pkl_image_se2: SE(2) that produces takes point in pkl image to city coordinates, e.g. p_city = city_Transformation_pklimage * p_pklimage

build_city_ground_height_index:

Build index of rasterized ground height. Returns: city_ground_height_index: a dictionary of dictionaries. Key is city_name, and values are dictionaries that store the "ground_height_matrix" and also the city_to_pkl_image_se2: SE(2) that produces takes point in pkl image to city coordinates, e.g. p_city = city_Transformation_pklimage * p_pklimage

get_rasterized_driveable_area:

Get the driveable area. Args: city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: da_mat: Numpy array of shape (M,N) representing binary values for driveable area city_to_pkl_image_se2: SE(2) that produces takes point in pkl image to city coordinates, e.g. p_city = city_Transformation_pklimage * p_pklimage

get_rasterized_roi:

Get the region of interest (5 meter dilation of driveable area). Args: city_name: string, either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: roi_mat: Numpy array of shape (M,N) representing binary values for the region of interest. city_to_pkl_image_se2: SE(2) that produces takes point in pkl image to city coordinates, e.g. p_city = city_Transformation_pklimage * p_pklimage

build_hallucinated_lane_bbox_index:

Populate the pre-computed hallucinated extent of each lane polygon, to allow for fast queries. Returns: city_halluc_bbox_table city_id_to_halluc_tableidx_map

render_city_centerlines:

Draw centerlines for the entire city_name Args: city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh

get_rasterized_ground_height:

Get ground height matrix along with se2 that convert to city coordinate Args: city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: ground_height_matrix city_to_pkl_image_se2: SE(2) that produces takes point in pkl image to city coordinates, e.g. p_city = city_Transformation_pklimage * p_pklimage

remove_ground_surface:

Get a lidar point, snap it to the grid, perform the O(1) raster map query. If our z-height is within THRESHOLD of that grid's z-height, then we keep it; otherwise, discard it. Args: point_cloud: NumPy n-d array of shape (n,3) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh return_logicals: whether to return pointwise boolean of function result Returns: subset of original point cloud, with ground points removed optionally, pass boolean array where `True` indicates point was not part of "ground"

remove_non_driveable_area_points:

Get a lidar point, snap it to the grid, perform the O(1) raster map query. Decimate the point cloud to the driveable area only. Args: point_cloud: NumPy n-d array of shape (n,3) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: lidar_point_cloud: subset of original point cloud, with non-driveable area removed

remove_non_roi_points:

Remove any points that don't fall within the region of interest (ROI). Args: point_cloud: NumPy n-d array of shape (n,3) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: lidar_point_cloud: subset of original point cloud, with ROI points removed

get_ground_points_boolean:

Check whether each point is likely to be from the ground surface. Args: point_cloud: Numpy array of shape (N,3) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: is_ground_boolean_arr: Numpy array of shape (N,) where ith entry is True if the LiDAR return is likely a hit from the ground surface.

get_ground_height_at_xy:

Get ground height for each of the xy locations in a point cloud. Args: point_cloud: Numpy array of shape (k,2) or (k,3) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: ground_height_values: Numpy array of shape (k,)

append_height_to_2d_city_pt_cloud:

Accept 2d point cloud in xy plane and return 3d point cloud (xyz). Args: pt_cloud_xy: Numpy array of shape (N,2) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: pt_cloud_xyz: Numpy array of shape (N,3)

get_raster_layer_points_boolean:

driveable area is "da" Args: point_cloud: Numpy array of shape (N,3) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh layer_name: indicating layer name, either "roi" or "driveable area" Returns: is_ground_boolean_arr: Numpy array of shape (N,) where ith entry is True if the LiDAR return is likely a hit from the ground surface.

get_nearest_centerline:

KD Tree with k-closest neighbors or a fixed radius search on the lane centroids is unreliable since (1) there is highly variable density throughout the map and (2) lane lengths differ enormously, meaning the centroid is not indicative of nearby points. If no lanes are found with MAX_LABEL_DIST_TO_LANE, we increase the search radius. A correct approach is to compare centerline-to-query point distances, e.g. as done in Shapely. Instead of looping over all points, we precompute the bounding boxes of each lane. We use the closest_waypoint as our criterion. Using the smallest sum to waypoints does not work in many cases with disproportionately shaped lane segments. and then choose the lane centerline with the smallest sum of 3-5 closest waypoints. Args: query_xy_city_coords: Numpy array of shape (2,) representing xy position of query in city coordinates city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh visualize: Returns: lane_object: Python dictionary with fields describing a lane. Keys include: 'centerline', 'predecessor', 'successor', 'turn_direction', 'is_intersection', 'has_traffic_control', 'is_autonomous', 'is_routable' conf: real-valued confidence. less than 0.85 is almost always unreliable dense_centerline: numpy array

get_lane_direction:

Get vector direction of the lane you're in. We ignore the sparse version of the centerline that we could trivially pull from lane_obj['centerline']. Args: query_xy_city_coords: Numpy array of shape (2,) representing (x,y) position in city coordinates city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh visualize: to also visualize the result Returns: lane_dir_vector: Numpy array of shape (2,) representing the direction (as a vector) of the closest lane to the provided position in city coordinates conf: real-valued confidence. less than 0.85 is almost always unreliable We have access to all of the following fields in "lane_obj": 'centerline', 'predecessor', 'successor', 'turn_direction', 'is_intersection', 'has_traffic_control'

get_lane_ids_in_xy_bbox:

Prune away all lane segments based on Manhattan distance. We vectorize this instead of using a for-loop. Get all lane IDs within a bounding box in the xy plane. This is a approximation of a bubble search for point-to-polygon distance. The bounding boxes of small point clouds (lane centerline waypoints) are precomputed in the map. We then can perform an efficient search based on manhattan distance search radius from a given 2D query point. We pre-assign lane segment IDs to indices inside a big lookup array, with precomputed hallucinated lane polygon extents. Args: query_x: representing x coordinate of xy query location query_y: representing y coordinate of xy query location city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh query_search_range_manhattan: search radius along axes Returns: lane_ids: lane segment IDs that live within a bubble

get_lane_segment_predecessor_ids:

Get land id for the lane predecessor of the specified lane_segment_id Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: predecessor_ids: list of integers, representing lane segment IDs of predecessors

get_lane_segment_successor_ids:

Get land id for the lane sucessor of the specified lane_segment_id Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: successor_ids: list of integers, representing lane segment IDs of successors

get_lane_segment_adjacent_ids:

Get land id for the lane adjacent left/right neighbor of the specified lane_segment_id Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: adjacent_ids: list of integers, representing lane segment IDs of adjacent left/right neighbor lane segments

get_lane_segment_centerline:

We return a 3D centerline for any particular lane segment. Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: lane_centerline: Numpy array of shape (N,3)

get_lane_segment_polygon:

Hallucinate a 3d lane polygon based around the centerline. We rely on the average lane width within our cities to hallucinate the boundaries. We rely upon the rasterized maps to provide heights to points in the xy plane. Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: lane_polygon: Array of polygon boundary (K,3), with identical and last boundary points

lane_is_in_intersection:

Check if the specified lane_segment_id falls within an intersection Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: is_intersection: indicating if lane segment falls within an intersection

get_lane_turn_direction:

Get left/right/none direction of the specified lane_segment_id Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: turn_direction: string, can be 'RIGHT', 'LEFT', or 'NONE'

lane_has_traffic_control_measure:

You can have an intersection without a control measure. Args: lane_segment_id: unique identifier for a lane segment within a city city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh Returns: has_traffic_control: indicating if lane segment has a traffic control measure

remove_extended_predecessors:

Remove lane_ids which are obtained by finding way too many predecessors from lane sequences. If any lane id is an occupied lane id for the first coordinate of the trajectory, ignore all the lane ids that occured before that Args: lane_seqs: List of list of lane ids (Eg. [[12345, 12346, 12347], [12345, 12348]]) xy: trajectory coordinates city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: filtered_lane_seq (list of list of integers): List of list of lane ids obtained after filtering

get_cl_from_lane_seq:

Get centerlines corresponding to each lane sequence in lane_sequences Args: lane_seqs: Iterable of sequence of lane ids (Eg. [[12345, 12346, 12347], [12345, 12348]]) city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: candidate_cl: list of numpy arrays for centerline corresponding to each lane sequence

get_candidate_centerlines_for_traj:

Get centerline candidates upto a threshold. . Algorithm: 1. Take the lanes in the bubble of last obs coordinate 2. Extend before and after considering all possible candidates 3. Get centerlines with max distance along centerline Args: xy: trajectory of shape (N, 2). city_name viz: Visualize Returns: candidate_centerlines: List of candidate centerlines

dfs:

Perform depth first search over lane graph up to the threshold. Args: lane_id: Starting lane_id (Eg. 12345) city_name dist: Distance of the current path threshold: Threshold after which to stop the search extend_along_predecessor: if true, dfs over predecessors, else successors Returns: lanes_to_return (list of list of integers): List of sequence of lane ids Eg. [[12345, 12346, 12347], [12345, 12348]]

draw_lane:

Draw the given lane. Args: lane_segment_id: lane ID city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh legend: True if legends specifying lane IDs are to shown as well

get_lane_segments_containing_xy:

Get the occupied lane ids, i.e. given (x,y), list those lane IDs whose hallucinated lane polygon contains this (x,y) query point. This function performs a "point-in-polygon" test. Args: query_x: representing x coordinate of xy query location query_y: representing y coordinate of xy query location city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns: occupied_lane_ids: list of integers, representing lane segment IDs containing (x,y)

plot_nearby_halluc_lanes:

Plot lane segment for nearby lanes of the specified x, y location Args: query_bbox: An array of shape (4,) representing a 2d axis-aligned bounding box, with order [xmin,xmax,ymin,ymax] city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh

find_local_lane_polygons:

Find land polygons within specified area Args: query_bbox: An array of shape (4,) representing a 2d axis-aligned bounding box, with order [xmin,xmax,ymin,ymax] city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns local_lane_polygons: Array of arrays, representing local hallucinated lane polygons

find_local_driveable_areas:

Find local driveable areas within specified area Args: query_bbox: An array of shape (4,) representing a 2d axis-aligned bounding box, with order [xmin,xmax,ymin,ymax] city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh Returns local_das: Array of arrays, representing local driveable area polygons

find_local_lane_centerlines:

Find local lane centerline to the specified x,y location

Args:
    query_x: x-coordinate of map query
    query_y: x-coordinate of map query
    city_name: either 'MIA' for Miami or 'PIT' for Pittsburgh

Returns
    local_lane_centerlines: Array of arrays, representing an array of lane centerlines, each a polyline
  • 28
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值