Skip to content

Latest commit

 

History

History
86 lines (62 loc) · 2.99 KB

CAMERA_POINT_CLOUD_FIXES.md

File metadata and controls

86 lines (62 loc) · 2.99 KB

Camera Point Cloud Visualization Fixes

This document explains the issues found and fixes implemented to ensure proper visualization of camera point clouds in the Data Acquisition Digital Twin system.

Issues Identified

After analyzing the code, the following issues were identified that prevented proper visualization of camera point clouds:

  1. Frame ID Inconsistencies:

    • The point cloud frame ID was hardcoded to camera_link in the driver but overridden to map in the manager
    • The frame IDs generated in the config didn't match the TF transforms published
  2. Point Cloud Field Format Issues:

    • The RGB field was using FLOAT32 datatype instead of the required UINT32 for RViz compatibility
    • This caused RViz to not properly interpret the color information
  3. 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

Code Changes Implemented

  1. 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 to UINT32 for proper visualization
  2. 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
  3. 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)

New Visualization Scripts

  1. 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

Usage Instructions

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

Technical Details

Frame ID Management

The camera system now uses consistent frame IDs following this pattern:

  • zed_x0_camera_link for the ZED X0 camera
  • zed_x1_camera_link for the ZED X1 camera
  • zed_2i_camera_link for the ZED 2i camera
  • camera_link as a fallback

Point Cloud Field Format

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;

TF Tree Structure

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.