Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 38 additions & 29 deletions notebooks/bev_matplotlib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"from py123d.datatypes.scene.arrow.arrow_scene_builder import ArrowSceneBuilder\n",
"from py123d.datatypes.scene.scene_filter import SceneFilter\n",
"\n",
"\n",
"from py123d.common.multithreading.worker_sequential import Sequential\n",
"# from py123d.datatypes.sensors.camera.pinhole_camera import PinholeCameraType "
]
Expand All @@ -24,7 +25,7 @@
"\n",
"# splits = [\"wopd_val\"]\n",
"# splits = [\"carla_test\"]\n",
"splits = [\"nuplan-mini_test\"]\n",
"splits = [\"nuscenes-mini_val\", \"nuscenes-mini_train\"]\n",
"# splits = [\"av2-sensor-mini_train\"]\n",
"# splits = [\"pandaset_train\"]\n",
"# log_names = None\n",
Expand All @@ -38,7 +39,7 @@
" split_names=splits,\n",
" log_names=log_names,\n",
" scene_uuids=scene_uuids,\n",
" duration_s=6.0,\n",
" duration_s=None,\n",
" history_s=0.0,\n",
" timestamp_threshold_s=20,\n",
" shuffle=True,\n",
Expand Down Expand Up @@ -145,61 +146,67 @@
") -> None:\n",
" layers: List[MapLayer] = [\n",
" # MapLayer.LANE,\n",
" # MapLayer.LANE_GROUP,\n",
" # MapLayer.GENERIC_DRIVABLE,\n",
" MapLayer.LANE_GROUP,\n",
" MapLayer.GENERIC_DRIVABLE,\n",
" # MapLayer.CARPARK,\n",
" # MapLayer.CROSSWALK,\n",
" MapLayer.INTERSECTION,\n",
" # MapLayer.INTERSECTION,\n",
" # MapLayer.WALKWAY,\n",
" MapLayer.ROAD_EDGE,\n",
" # MapLayer.ROAD_LINE,\n",
" MapLayer.ROAD_LINE,\n",
" ]\n",
" x_min, x_max = point_2d.x - radius, point_2d.x + radius\n",
" y_min, y_max = point_2d.y - radius, point_2d.y + radius\n",
" patch = geom.box(x_min, y_min, x_max, y_max)\n",
" map_objects_dict = map_api.query(geometry=patch, layers=layers, predicate=\"intersects\")\n",
" # print(map_objects_dict[MapLayer.ROAD_EDGE])\n",
"\n",
" done = False\n",
" for layer, map_objects in map_objects_dict.items():\n",
" for map_object in map_objects:\n",
" try:\n",
" if layer in [\n",
" MapLayer.GENERIC_DRIVABLE,\n",
" MapLayer.CARPARK,\n",
" MapLayer.CROSSWALK,\n",
" MapLayer.INTERSECTION,\n",
" # MapLayer.INTERSECTION,\n",
" MapLayer.WALKWAY,\n",
" ]:\n",
" add_shapely_polygon_to_ax(ax, map_object.shapely_polygon, MAP_SURFACE_CONFIG[layer])\n",
" print(f\"Added {layer.name} with id {map_object.object_id}\")\n",
"\n",
" if layer in [MapLayer.LANE_GROUP]:\n",
" map_object: AbstractLaneGroup\n",
" add_shapely_polygon_to_ax(ax, map_object.shapely_polygon, MAP_SURFACE_CONFIG[layer])\n",
"\n",
" if layer in [MapLayer.LANE]:\n",
" add_shapely_linestring_to_ax(ax, map_object.centerline.linestring, CENTERLINE_CONFIG)\n",
" if map_object.intersection is not None:\n",
" add_shapely_polygon_to_ax(ax, map_object.intersection.shapely_polygon, ROUTE_CONFIG)\n",
"\n",
" for lane in map_object.lanes:\n",
" add_shapely_linestring_to_ax(ax, lane.centerline.linestring, CENTERLINE_CONFIG)\n",
"\n",
" # if layer in [MapLayer.LANE]:\n",
" # add_shapely_linestring_to_ax(ax, map_object.centerline.linestring, CENTERLINE_CONFIG)\n",
" # add_shapely_polygon_to_ax(ax, map_object.shapely_polygon, MAP_SURFACE_CONFIG[layer])\n",
"\n",
" if layer in [MapLayer.ROAD_EDGE]:\n",
" add_shapely_linestring_to_ax(ax, map_object.polyline_3d.linestring, ROAD_EDGE_CONFIG)\n",
"\n",
" # if layer in [MapLayer.ROAD_LINE]:\n",
" # # line_type = int(map_object.road_line_type)\n",
" # # plt_config = PlotConfig(\n",
" # # fill_color=NEW_TAB_10[line_type % (len(NEW_TAB_10) - 1)],\n",
" # # fill_color_alpha=1.0,\n",
" # # line_color=NEW_TAB_10[line_type % (len(NEW_TAB_10) - 1)],\n",
" # # line_color_alpha=1.0,\n",
" # # line_width=1.5,\n",
" # # line_style=\"-\",\n",
" # # zorder=10,\n",
" # # )\n",
" # add_shapely_linestring_to_ax(ax, map_object.polyline_3d.linestring, ROAD_LINE_CONFIG)\n",
" if layer in [MapLayer.ROAD_LINE]:\n",
" # line_type = int(map_object.road_line_type)\n",
" # plt_config = PlotConfig(\n",
" # fill_color=NEW_TAB_10[line_type % (len(NEW_TAB_10) - 1)],\n",
" # fill_color_alpha=1.0,\n",
" # line_color=NEW_TAB_10[line_type % (len(NEW_TAB_10) - 1)],\n",
" # line_color_alpha=1.0,\n",
" # line_width=1.5,\n",
" # line_style=\"-\",\n",
" # zorder=10,\n",
" # )\n",
" add_shapely_linestring_to_ax(ax, map_object.polyline_3d.linestring, ROAD_LINE_CONFIG)\n",
"\n",
" except Exception:\n",
" import traceback\n",
"\n",
" print(f\"Error adding map object of type {layer.name} and id {map_object.id}\")\n",
" print(f\"Error adding map object of type {layer.name} and id {map_object.object_id}\")\n",
" traceback.print_exc()\n",
"\n",
" # ax.set_title(f\"Map: {map_api.map_name}\")\n",
Expand All @@ -213,12 +220,14 @@
"\n",
" point_2d = ego_vehicle_state.bounding_box.center.state_se2.point_2d\n",
" if map_api is not None:\n",
" add_debug_map_on_ax(ax, scene.get_map_api(), point_2d, radius=radius, route_lane_group_ids=None)\n",
" # add_debug_map_on_ax(ax, scene.get_map_api(), point_2d, radius=radius, route_lane_group_ids=None)\n",
"\n",
"\n",
" add_default_map_on_ax(ax, map_api, point_2d, radius=radius, route_lane_group_ids=None)\n",
" # add_traffic_lights_to_ax(ax, traffic_light_detections, scene.get_map_api())\n",
"\n",
" # add_box_detections_to_ax(ax, box_detections)\n",
" # add_ego_vehicle_to_ax(ax, ego_vehicle_state)\n",
" add_box_detections_to_ax(ax, box_detections)\n",
" add_ego_vehicle_to_ax(ax, ego_vehicle_state)\n",
"\n",
" zoom = 1.0\n",
" ax.set_xlim(point_2d.x - radius * zoom, point_2d.x + radius * zoom)\n",
Expand All @@ -239,7 +248,7 @@
" return fig, ax\n",
"\n",
"\n",
"# scene_index = \n",
"# scene_index =\n",
"iteration = 1\n",
"\n",
"scale = 10\n",
Expand All @@ -249,7 +258,7 @@
"# _plot_scene_on_ax(ax[1], scene, iteration, radius=50)\n",
"# _plot_scene_on_ax(ax[2], scene, iteration, radius=100)\n",
"\n",
"plt.show()\n"
"plt.show()"
]
},
{
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ nuplan = [
"guppy3",
"retry",
]
nuscenes = [
"lanelet2",
"nuscenes-devkit==1.2.0",
]
nuscenes_expanded = [
"nuscenes-devkit==1.2.0",
"pycocotools==2.0.10",
"laspy==2.6.1",
"embreex==2.17.7.post6",
"lanelet2==1.2.2",
"protobuf==4.25.3",
"pycollada==0.9.2",
"vhacdx==0.0.8.post2",
"yourdfpy==0.0.58",
]
waymo = [
"protobuf==6.30.2",
"tensorflow==2.13.0",
Expand Down
3 changes: 3 additions & 0 deletions scripts/conversion/nuscenes_mini_conversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export NUSCENES_DATA_ROOT="/home/daniel/nuscenes_mini/"

py123d-conversion datasets=["nuscenes_mini_dataset"] map_writer.remap_ids=true
Empty file.
Loading