> For the complete documentation index, see [llms.txt](https://wiki.ariitk.in/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.ariitk.in/wiki/computer-vision/intelrealsense-d435i-calibration.md).

# IntelRealSense D435i Calibration

Calibration of IntelRealSenseD435i using AprilGrid

### Installing Kalibr

#### Building Kalibr from Source

1. Install the necessary dependencies:

   ```bash
   sudo apt-get install -y git wget autoconf automake nano libeigen3-dev libboost-all-dev libsuitesparse-dev doxygen libopencv-dev libpoco-dev libtbb-dev libblas-dev liblapack-dev libv4l-dev python3-dev python3-pip python3-scipy python3-matplotlib ipython3 python3-wxgtk4.0 python3-tk python3-igraph python3-pyx
   ```
2. Create and configure a workspace:

   ```bash
   mkdir -p ~/kalibr_workspace/src
   cd ~/kalibr_workspace
   export ROS1_DISTRO=noetic # Replace 'noetic' with your ROS version
   source /opt/ros/$ROS1_DISTRO/setup.bash
   catkin init
   catkin config --extend /opt/ros/$ROS1_DISTRO
   catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
   ```
3. Clone the Kalibr project and build it:

   ```bash
   cd ~/kalibr_workspace/src
   git clone https://github.com/ethz-asl/kalibr.git
   cd ~/kalibr_workspace/
   catkin build -DCMAKE_BUILD_TYPE=Release -j4
   ```

   Source the workspace setup:

   ```bash
   source ~/kalibr_workspace/devel/setup.bash
   ```

### Recording a Rosbag

To record a rosbag, follow these steps:

1. Start ROS using the command:

   ```bash
   roscore
   ```
2. Install the IntelRealSense ROS package for your ROS distribution:

   ```bash
   sudo apt-get install ros-$ROS_DISTRO-realsense2-camera
   source devel/setup.bash
   ```
3. Launch the camera node using:

   ```bash
   roslaunch realsense2_camera rs_camera.launch
   ```
4. Check that camera topics are listed with:

   ```bash
   rostopic list
   ```

   You should see topics such as `camera/color/image_raw`.
5. Record a rosbag from all topics:

   ```bash
   rosbag record -a
   ```

   Press Ctrl+C to stop recording. The rosbag will be saved in the current directory.

   **Important points during recording:**

   * Excite all IMU axes (rotation and translation).
   * Avoid shocks, especially at the beginning and end of recording.
   * Maintain low motion blur through low shutter times and good illumination.
   * Ensure timestamps have low jitter and are synchronized.
6. Check the rosbag info and play it using:

   ```bash
   rosbag info
   rosbag play
   ```

### Calibrating the Camera Using AprilGrid

1. Ensure the AprilGrid details are specified in a `.yaml` file.
2. To calibrate the camera, run the following command in the directory containing the `.yaml` file and rosbag:

   ```bash
   rosrun kalibr kalibr_calibrate_cameras --target [name of .yaml file] --models [camera/distortion models to be fitted] --topics [name of topic where image from camera is being published] --bag [path to rosbag] --bag-freq 10.0 --show-extraction
   ```

   **Notes:**

   * The camera distortion model used should be `pinhole-radtan`.
   * The `--show-extraction` flag shows the calibration alongside the feed.
   * The `--bag-freq 10.0` sets the playback frequency of the rosbag to 10 Hz during calibration.

The results of the calibration process will be saved in a PDF and the matrix parameters will be stored in a `.yaml` file in the same directory.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.ariitk.in/wiki/computer-vision/intelrealsense-d435i-calibration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
