Some 3D bboxes are shift from its correct position

nuscenes_data = NuScenes(version='v1.0-trainval', dataroot=DATA_ROOT, verbose=True)
for _, scene in enumerate(nuscenes_data.scene):
    first_sample_token = scene['first_sample_token']
    last_sample_token = scene['last_sample_token']
    sample_token = first_sample_token
    while sample_token != last_sample_token:
        sample = nuscenes_data.get('sample', sample_token)
        sample_lidar_token = sample['data']['LIDAR_TOP']
        lidar_file_path, box_list, ___ = nuscenes_data.get_sample_data(sample_lidar_token)
        lidar_pointcloud = LidarPointCloud.from_file(lidar_file_path)
        sample_token = nuscenes_data.get("sample", sample_token)["next"]
  1. Point cloud of LIDAR is default load at lidar’s frame
  2. use get_sample_data func load boxes at lidar’s frame too

Here is there render in ROS RVIZ, and you can see some bboex direction is not correct.

Can you do nusc.render_annotation(my_annotation_token) for that particular annotation?
It’s not clear to me from the above picture whether something is indeed wrong.

I have used nusc.render_annotation() and found the annos are all correct.
Is there some transform I didn’t apply in my code script?

  1. load point cloud in sensor frame using lidar_pointcloud = LidarPointCloud.from_file(lidar_file_path)
  2. load annos boxes in sensor frame using nusc.get_sample_data(sample_lidar_token)
    As a result, in the same frame the boxes and point cloud should be all correc, but it not.

Thanks for verifying. Your procedure looks correct to me.
Perhaps the way you encode the boxes for rviz is wrong?
You could try bring boxes and point cloud to global coordinates and check there.

If I want to extract the boxes out in vehicle frame, how do I get those params: [[0],[1],[2],box.wlh[0], box.wlh[1], box.wlh[2], box.orientation.radians]

I found the error: I mistook the box.orientation.raidas as the box yaw angle.
Thanks for your reply!

1 Like

Great! You’re welcome.

1 Like