nuScenes Map Expansion Tutorial

该文是关于NuScenes数据集的MapExpansion模块的学习记录,主要涉及在GoogleColab环境中初始化地图加载、地图的可视化(包括渲染多个图层、特定记录的地图层)以及导航功能。文章还提到了数据探索和车道连接信息的处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

0.引言

1.Google colab

本地配置还是比较麻烦,使用官方的教程进行学习,官方的教程是基于colab的。

我的云盘:
在这里插入图片描述

挂载Google云盘:

from google.colab import drive
drive.mount('/content/drive/')
import os
os.chdir('/content/drive/My Drive/')
!pwd

运行时会提示:

在这里插入图片描述

2.初始化加载地图

!pip install nuscenes-devkit &> /dev/null  # Install nuImages.import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import tqdm
import numpy as np

from nuscenes.map_expansion.map_api import NuScenesMap
from nuscenes.map_expansion import arcline_path_utils
from nuscenes.map_expansion.bitmap import BitMap
from google.colab import drive
drive.mount('/content/drive/')
import os
os.chdir('/content/drive/My Drive/')
!pwd
nusc_map = NuScenesMap(dataroot='/content/drive/My Drive/data/sets/nuscenes', map_name='singapore-onenorth')

3.Visualization

  • Rendering multiple layers
    在这里插入图片描述
  • Rendering the lidar basemap

Rendering the lidar basemap
New: We can render the HD lidar basemap used for localization. The basemap is a bitmap image that can be underlaid for most functions (render_centerlines, render_egoposes_on_fancy_map, render_layers, render_map_patch, render_next_roads, render_record). The same BitMap class can also be used to render the semantic prior (drivable surface + sidewalk) from the original nuScenes release. Note that in this visualization we only show the lane annotations for better visibility.

在这里插入图片描述

  • Rendering a particular record of the map layer
    在这里插入图片描述

  • Rendering binary map mask layers
    在这里插入图片描述

在这里插入图片描述

  • Rendering map layers on top of camera images
!pip install nuscenes-devkit &> /dev/null  # Install nuImages.import matplotlib.pyplot as plt

# Init nuScenes. Requires the dataset to be stored on disk.
from nuscenes.nuscenes import NuScenes
from google.colab import drive
drive.mount('/content/drive/')
import os
os.chdir('/content/drive/My Drive/')
!pwd
nusc = NuScenes(version='v1.0-mini', dataroot='/content/drive/My Drive/data/sets/nuscenes', verbose=True, map_resolution=1)

# Pick a sample and render the front camera image.
sample_token = nusc.sample[9]['token']
layer_names = ['road_segment', 'lane', 'ped_crossing', 'walkway', 'stop_line', 'carpark_area']
camera_channel = 'CAM_FRONT'
nusc_map.render_map_in_image(nusc, sample_token, layer_names=layer_names, camera_channel=camera_channel)

在这里插入图片描述

  • Rendering ego poses on the map
    在这里插入图片描述

4.Navigation

We also provide functions for navigation around the road network. For this purpose, the road layers lane, road_block and road_segment are especially useful (see definitions below). The get_next_roads(x, y) function looks at the road layer at a particular point. It then retrieves the next road object in the direction of the lane or road_block. As road_segments do not have a direction (e.g. intersections), we return all possible next roads.

在这里插入图片描述

  • Working with Lanes

For the prediction challenge we added connectivity information to the map expansion (v1.2) to efficiently query which lane is connected to which other lanes. Below we render the lane and lane_connector objects. The lanes and lane_connectors are defined by parametric curves. The resolution_meters parameter specifies the discretization resolution of the curve. If we set it to a high value (e.g. 100), the curves will appear as straight lines. We recommend setting this value to 1m or less.

在这里插入图片描述

  • Data Exploration

Let’s render a particular patch on the map:
在这里插入图片描述

  • Polygon

在这里插入图片描述

  • Drivable Area

Drivable area is defined as the area where the car can drive, without consideration for driving directions or legal restrictions. This is the only layer in which the record can be represented by more than one geometric entity.
Note: On some machines this polygon renders incorrectly as a filled black rectangle.

在这里插入图片描述

If we render this road segment we can see that it is indeed an intersection:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5.other

其实我更好奇他是如何将数据转换为json文件的?

### nuScenes 数据集中的地图数据及其使用 nuScenes 是一个广泛用于自动驾驶研究的大规模多模态感知数据集。其中的地图数据对于理解车辆周围环境至关重要。 #### 地图数据结构 nuScenes 的地图数据主要由多个层组成,包括车道线、交通标志和其他道路特征。这些信息存储在专门设计的数据结构中,以便于高效访问和处理[^1]。 ```python from nuscenes.map_expansion.map_api import NuScenesMap nusc_map = NuScenesMap(dataroot='data/sets/nuscenes', map_name='singapore-onenorth') ``` 这段代码展示了如何加载特定区域的地图数据到 `NuScenesMap` 对象中。通过这个对象可以方便地查询各种地理要素的位置关系和服务区内的静态信息。 #### 获取地图元素 为了提取具体的地图元素,比如车道中心线或人行横道位置,可以通过调用相应的方法来完成: ```python # 查询给定坐标的最近车道 lane_record = nusc_map.get_closest_lane(x=0, y=0) # 获得指定ID的节点详情 node_data = nusc_map.layers_on_canvas['drivable_area'].nodes[id] ``` 以上操作允许研究人员基于地理位置快速检索所需的道路属性或其他重要地标的信息。 #### 可视化工具支持 除了基本的数据访问功能外,nuScenes 还提供了强大的可视化能力帮助开发者更好地理解和展示地图特性。这有助于直观呈现复杂的场景布局,并辅助算法开发过程中的调试工作。 ```python import matplotlib.pyplot as plt fig, ax = plt.subplots(1, 1, figsize=(9, 9)) nusc_map.render_layers(ax=ax, layers=['road_segment', 'lane']) plt.show() ``` 此段脚本能够绘制出所选区域内的重要路径组件,从而为用户提供清晰可见的空间分布概览。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值