This document explains the issues found and fixes implemented to ensure proper visualization of camera point clouds in the Data Acquisition Digital Twin system.
After analyzing the code, the following issues were identified that prevented proper visualization of camera point clouds:
-
Frame ID Inconsistencies:
- The point cloud frame ID was hardcoded to
camera_link
in the driver but overridden tomap
in the manager - The frame IDs generated in the config didn't match the TF transforms published
- The point cloud frame ID was hardcoded to
-
Point Cloud Field Format Issues:
- The RGB field was using
FLOAT32
datatype instead of the requiredUINT32
for RViz compatibility - This caused RViz to not properly interpret the color information
- The RGB field was using
-
Missing or Inconsistent TF Transforms:
- The transforms between camera frames and the map frame weren't correctly established
- Each camera needed a separate and properly named transform for visualization
-
In
zed_camera_driver.cpp
:- Changed hardcoded
camera_link
frame ID to use the config's frame ID - Fixed the RGB field datatype from
FLOAT32
toUINT32
for proper visualization
- Changed hardcoded
-
In
camera_manager.cpp
:- Removed the code that overwrote the frame ID to
map
- Preserved the frame ID from the driver which now matches TF transforms
- Removed the code that overwrote the frame ID to
-
In
camera_config.h
:- Modified
getFrameId()
to return consistent frame IDs matching TF transforms - Added special cases for each camera model (ZED_CAMERA_X0, ZED_CAMERA_X1, ZED_CAMERA_2i)
- Modified
fix_camera_pointclouds.sh
:- Launches all three cameras with proper configuration
- Sets up TF transforms for each camera with sensible offsets for visual separation
- Configures RViz with a custom configuration showing all three point clouds
- Ensures proper cleanup when exiting
To test the camera point cloud visualization:
# After building the project with the fixes
source /home/user/Desktop/data-aquisition-digital-twin/install/setup.bash
# Run the specialized camera point cloud visualization script
./scripts/fix_camera_pointclouds.sh
The camera system now uses consistent frame IDs following this pattern:
zed_x0_camera_link
for the ZED X0 camerazed_x1_camera_link
for the ZED X1 camerazed_2i_camera_link
for the ZED 2i cameracamera_link
as a fallback
The point cloud RGB field is now properly configured:
field_rgb.name = "rgb";
field_rgb.offset = 12;
field_rgb.datatype = sensor_msgs::msg::PointField::UINT32; // Must be UINT32 for RGB
field_rgb.count = 1;
The TF tree now has this structure:
map
├── camera_link
├── zed_x0_camera_link
├── zed_x1_camera_link
└── zed_2i_camera_link
Each camera publishes its point cloud in its own frame, but all frames are children of the map frame.