赞
踩
轨迹预测常用的有场景数据ArgoverseScenario和地图ArgoverseStaticMap
轨迹序列读取的API为scenario_serialization
可视化的API为visualize_scenario
argoverse2和argoverse1不一样的地方是,每一段轨迹序列(Scenario)内有自己的json地图文件(虽然说都是同一幅HD map,但是对应HD map中的不同的位置),而argoverse1是所有轨迹序列共享一个地图文件
# 存放轨迹序列的类
from av2.datasets.motion_forecasting.data_schema import ArgoverseScenario
# 用于读取轨迹序列的API
from av2.datasets.motion_forecasting import scenario_serialization
# 用于可视化的API
from av2.datasets.motion_forecasting.viz.scenario_visualization import visualize_scenario
# 用于读取地图的API
from av2.map.map_api import ArgoverseStaticMap
自己写的一个简单的读取例子,具体的可以参考av2-api文件夹中的generate_forecasting_scenario_visualizations.py文件
def generate_scenarios(argoverse_scenario_dir: Path, num_scenarios: int = 100) -> list: scenario_map_list = [] all_scenario_files = sorted(argoverse_scenario_dir.rglob("*.parquet")) for scenario in all_scenario_files[:num_scenarios]: scenario, static_map = generate_scenario(Path(scenario)) scenario_map_list.append([scenario, static_map]) return scenario_map_list # Build inner function to generate visualization for a single scenario. def generate_scenario(scenario_path: Path) -> (ArgoverseScenario, ArgoverseStaticMap): """Generate and save dynamic visualization for a single Argoverse scenario. NOTE: This function assumes that the static map is stored in the same directory as the scenario file. Args: scenario_path: Path to the parquet file corresponding to the Argoverse scenario to visualize. """ scenario_id = scenario_path.stem.split("_")[-1] static_map_path = scenario_path.parents[0] / f"log_map_archive_{scenario_id}.json" scenario = scenario_serialization.load_argoverse_scenario_parquet(scenario_path) static_map = ArgoverseStaticMap.from_json(static_map_path) return scenario, static_map if __name__ == "__main__": argoverse2_dataset_path = Path("/media/gah/New/Datasets/Argoverse2/val") num_scenarios = 10 scenario_map_list = generate_scenarios(argoverse2_dataset_path, num_scenarios) print("debug")
每个scenario有11s长的序列,包含actor的历史轨迹集合,就是这里面的tracks,对于每一个scenario,提供了以下的顶层属性:
scenario_id
: 该scenario的特有IDtimestamps_ns
: 该scenario的所有时间戳tracks
: 该scenario的所有轨迹序列focal_track_id
: 该scenario的焦点agent(focal agent)的track IDcity_name
: 该scenario对应的城市名每个track包含以下属性:
track_id
: 该track的特有IDobject_states
: 该轨迹序列对应的object在这11s内的有效观测的状态,以timestep表示时间步,一般来说最多有110步,因为采样频率为10Hz,一步对应0.1sobject_type
: 该轨迹序列对应的object的类型,如vehicle等category
: 给轨迹序列分配种类,用于给轨迹预测的数据质量提供参考,一般来说,有四种:SCORED_TRACK,UNSCORED_TRACK,FOCAL_TRACK,TRACK_FRAGMENT。其中FOCAL_TRACK和SCORED_TRACK数据质量较好,UNSCORED_TRACK用于当作上下文输入,数据质量一般,而TRACK_FRAGMENT的时间长度不定,数据质量较差
TRACK_FRAGMENT
: Lower quality track that may only contain a few timestamps of observations. 在数据中以整数0表示UNSCORED_TRACK
: Unscored track used for contextual input. 在数据中以整数1表示SCORED_TRACK
: High-quality tracks relevant to the AV - scored in the multi-agent prediction challenge. 在数据中以整数2表示FOCAL_TRACK
: The primary track of interest in a given scenario - scored in the single-agent prediction challenge. 在数据中以整数3表示每个object_states包含以下属性,对应某一actor在某一时间点的所有信息:
observed
: Boolean 指示这个object state是否在该scenario的观测区间内(observed segment)
timestep
: 时间步,范围是[0, num_scenario_timesteps) Time step corresponding to this object state [0, num_scenario_timesteps).
position
: (x, y) Coordinates of center of object bounding box. object bounding box的xy坐标
heading
: Heading associated with object bounding box (in radians, defined w.r.t the map coordinate frame). object bounding box的航向角,单位是弧度,是在地图坐标系下的
velocity
: (x, y) Instantaneous velocity associated with the object (in m/s). object的xy方向的速度
每个track有以下10种label:
Dynamic
VEHICLE
PEDESTRIAN
MOTORCYCLIST
CYCLIST
BUS
Static
STATIC
BACKGROUND
CONSTRUCTION
RIDERLESS_BICYCLE
UNKNOWN
The core feature of the HD map is the lane graph, consisting of a graph G = (V, E), where V are individual lane segments.
Argoverse2 提供了3D的道路边界线,而不是仅仅有centerlines,也提供了快速获取特定采样分辨率的centerlines的API,在release中多边形的分辨率被设置为1cm
地图以json文件的形式提供
可以通过以下方式读取:
from av2.map.map_api import ArgoverseStaticMap
log_map_dirpath = Path("av2") / "00a6ffc1-6ce9-3bc3-a060-6006e9893a1a" / "map"
avm = ArgoverseStaticMap.from_map_dir(log_map_dirpath=log_map_dirpath, build_raster=False)
LaneSegment中包含以下属性:
id
: unique identifier for this lane segment (guaranteed to be unique only within this local map). 该lane segment的特有ID(仅在局部地图中保证是特有的ID)is_intersection
: boolean value representing whether or not this lane segment lies within an intersection. boolean value,用来表示该lane segment是否位于一个路口内lane_type
: designation of which vehicle types may legally utilize this lane for travel. 表示车道线类型right_lane_boundary
: 3d polyline representing the right lane boundary. 3D线条,表示右车道边界线left_lane_boundary
: 3d polyline representing the left lane boundary. 3D线条,表示左车道边界线right_mark_type
: type of painted marking found along the right lane boundary . 右车道边界线的线型left_mark_type
: type of painted marking found along the left lane boundary. 左车道边界线的线型predecessors
: unique identifiers of lane segments that are predecessors of this object. 该lane segment的前继lane segment的unique IDsuccessors
: unique identifiers of lane segments that represent successor of this object. Note: this list will be empty if no successors exist. 该lane segment的后继lane segment的unique IDright_neighbor_id
: unique identifier of the lane segment representing this object’s right neighbor. 该lane segment的右邻lane segment的unique IDleft_neighbor_id
: unique identifier of the lane segment representing this object’s left neighbor. 该lane segment的左邻lane segment的unique ID多边形向量的分辨率也是1cm
包含以下属性:
id
: unique identifier. 特有IDarea_boundary
: 3d vertices of polygon, representing the drivable area’s boundary. 3D多边形,用来表示可行驶区域的边界代表人行道,由两条沿同一主轴的edge构成
id
: unique identifier of pedestrian crossing. 人行道的特有IDedge1
: 3d polyline representing one edge of the crosswalk, with 2 waypoints. 3D多边形,代表人行道的其中一边,由2个waypoints组成edge2
: 3d polyline representing the other edge of the crosswalk, with 2 waypoints. 3D多边形,代表人行道的其中一边,由2个waypoints组成Each scenario’s local map includes all entities found within a 100 m dilation in l2-norm from the ego-vehicle trajectory.
每个scenario的局部地图包含距离ego-vehicle的轨迹100m l2距离内的所有实体
import pandas as pd from av2.datasets.motion_forecasting.data_schema import ArgoverseScenario from av2.datasets.motion_forecasting import scenario_serialization from av2.datasets.motion_forecasting.viz.scenario_visualization import visualize_scenario from av2.map.map_api import ArgoverseStaticMap from av2.map.map_primitives import Polyline from av2.utils.io import read_json_file # 利用pandas读取轨迹序列parquet文件 df = pd.read_parquet文件(os.path.join(self.raw_dir, raw_file_name, f'scenario_{raw_file_name}.parquet')) # 加载地图json文件 map_data = read_json_file(map_path) # 从地图的json文件读取车道中心线 centerlines = {lane_segment['id']: Polyline.from_json_data(lane_segment['centerline']) for lane_segment in map_data['lane_segments'].values()} # 加载地图API map_api = ArgoverseStaticMap.from_json(map_path) # 以某个query中心搜索附近一定半径的的lane_segments query_center = scenario_df.loc[0, ['position_x', 'position_y']].values search_radius_m = 30 nearby_lane_segments = map_api.get_nearby_lane_segments(query_center, search_radius_m) # 通过map_api获取lane_segments的车道中心线 nearby_lane_centerlines = get_lane_centerlines(map_api, nearby_lane_segments) # 获取地图内的所有pedestrian crossings(目前av2 API没有提供获取附近pedestrian crossings的API) crosswalks = map_api.get_scenario_ped_crossings()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。