Hi, can I render the agent on the basemap and get the image shown in the figure below? If you can, please tell me what to do. Thank you in advance!
How to render an agent on basemap
A possible way to render an agent onto the basemap could be:
import math
from matplotlib.patches import Rectangle
from pyquaternion import Quaternion
from nuscenes.eval.common.utils import quaternion_yaw
from nuscenes.map_expansion.map_api import NuScenesMap
from nuscenes.map_expansion.bitmap import BitMap
from nuscenes.nuscenes import NuScenes
nusc = NuScenes(dataroot='/data/sets/nuscenes', verbose=False)
nusc_map = NuScenesMap(dataroot='/data/sets/nuscenes', map_name='singapore-onenorth')
bitmap = BitMap(nusc_map.dataroot, nusc_map.map_name, 'basemap')
my_scene = nusc.scene[0]
first_sample_token = my_scene['first_sample_token']
my_sample = nusc.get('sample', first_sample_token)
my_annotation_token = my_sample['anns'][36]
my_annotation_metadata = nusc.get('sample_annotation', my_annotation_token)
print(my_annotation_metadata)
actor_center = my_annotation_metadata['translation']
actor_size = my_annotation_metadata['size']
ypr_rad = Quaternion(my_annotation_metadata['rotation']).yaw_pitch_roll
actor_yaw = math.degrees(-(math.pi / 2) + ypr_rad[0])
actor_range = 40
fig, ax = nusc_map.render_map_patch((actor_center[0] - actor_range, actor_center[1] - actor_range,
actor_center[0] + actor_range, actor_center[1] + actor_range),
[],
render_egoposes_range=False,
bitmap=bitmap)
ax.add_patch(Rectangle(actor_center, actor_size[0], actor_size[1], actor_yaw))
Feel free to check and modify my above code snippet for your use case