|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a manual LiDAR-Camera calibration tool for ROS 2 that provides a graphical interface for performing extrinsic calibration between LiDAR sensors and cameras. The application is built with PySide6 and operates on recorded rosbag data (.mcap files) without requiring a live ROS 2 environment. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Installation and Setup |
| 12 | +```bash |
| 13 | +# Install the project in development mode |
| 14 | +python -m pip install . |
| 15 | +``` |
| 16 | + |
| 17 | +### Running the Application |
| 18 | +```bash |
| 19 | +# Run the calibration tool |
| 20 | +ros2_calib |
| 21 | +``` |
| 22 | + |
| 23 | +### Code Quality |
| 24 | +```bash |
| 25 | +# Run linter (configured in pyproject.toml) |
| 26 | +ruff check |
| 27 | + |
| 28 | +# Format code |
| 29 | +ruff format |
| 30 | +``` |
| 31 | + |
| 32 | +## Architecture Overview |
| 33 | + |
| 34 | +The application follows a modular GUI-based architecture: |
| 35 | + |
| 36 | +**Core Workflow:** |
| 37 | +1. User loads a rosbag file (.mcap format) |
| 38 | +2. Application displays available topics for selection |
| 39 | +3. User selects image, point cloud, and camera info topics |
| 40 | +4. Interactive calibration view allows manual 2D-3D correspondences |
| 41 | +5. RANSAC-based PnP solver provides initial estimate |
| 42 | +6. Scipy least-squares optimization refines the transformation |
| 43 | + |
| 44 | +**Key Components:** |
| 45 | + |
| 46 | +- **main.py**: Application entry point with PySide6 QApplication setup |
| 47 | +- **main_window.py**: Primary GUI window handling rosbag loading and topic selection |
| 48 | +- **calibration_widget.py**: Interactive widget for 2D/3D point selection and visualization |
| 49 | +- **calibration.py**: Core mathematical calibration logic using OpenCV and Scipy |
| 50 | +- **bag_handler.py**: Rosbag file processing and message extraction utilities |
| 51 | +- **ros_utils.py**: Mock ROS 2 message dataclasses (PointCloud2, Image, CameraInfo) and conversion utilities |
| 52 | + |
| 53 | +**Key Components (Continued):** |
| 54 | + |
| 55 | +- **transformation_widget.py**: Node graph visualization for TF trees using NodeGraphQt |
| 56 | +- **lidar_cleaner.py**: Point cloud processing based on RePLAy ECCV 2024 paper for removing occluded points |
| 57 | +- **tf_transformations.py**: Transform utilities for coordinate frame conversions |
| 58 | + |
| 59 | +**Application Flow:** The main application uses a QStackedWidget to manage multiple views: |
| 60 | +1. Initial view for rosbag loading and topic selection (main_window.py) |
| 61 | +2. Interactive calibration view with 2D/3D visualization (calibration_widget.py) |
| 62 | +3. Transform tree visualization and management (transformation_widget.py) |
| 63 | + |
| 64 | +**Dependencies:** The project uses `rosbags` library for ROS bag processing, avoiding dependency on live ROS 2 installation. All ROS message types are mocked as dataclasses in `ros_utils.py`. NodeGraphQt provides the graph visualization for TF trees. |
| 65 | + |
| 66 | +**Calibration Algorithm:** Two-stage approach using OpenCV's `solvePnPRansac` for robust initial pose estimation followed by Scipy's `least_squares` optimization for refinement. The objective function minimizes reprojection error between 3D LiDAR points and 2D image correspondences. Point cloud cleaning uses algorithms from the RePLAy paper to remove occluded points. |
| 67 | + |
| 68 | +## Configuration |
| 69 | + |
| 70 | +- **Linting**: Configured in `pyproject.toml` with ruff (line length: 100, select: E, F, W, I) |
| 71 | +- **Entry Point**: Defined in `pyproject.toml` as `ros2_calib = "ros2_calib.main:main"` |
| 72 | +- **Dependencies**: PySide6, rosbags, numpy, opencv-python-headless, scipy, ruff, NodeGraphQt, transforms3d, setuptools |
| 73 | + |
| 74 | +## Development Notes |
| 75 | + |
| 76 | +- The application is designed to work offline with recorded rosbag data |
| 77 | +- GUI framework: PySide6 for cross-platform compatibility |
| 78 | +- No test suite is currently present in the codebase |
| 79 | +- Code uses modern Python with type hints and dataclasses |
| 80 | +- The LiDAR cleaning implementation is based on the RePLAy ECCV 2024 paper for removing projective artifacts |
| 81 | +- Transform visualization uses NodeGraphQt for interactive graph-based TF tree management |
0 commit comments