Welcome to ROSMASTER A1 PRO repository
2.USB Camera Intrinsic Calibration
🎯 USB Camera Intrinsic Calibration (Camera Calibration)
1. Course Content
Obtain the camera intrinsic parameters of the USB camera through checkerboard calibration board, used for publishing camera camera_info messages.
Important
Target Audience: This course is for users with the USB camera version. Users with depth cameras can skip this step since the factory comes with chip-level calibration parameters.
Factory Image Protection: The factory system image already contains strictly calibrated camera intrinsic files. Please do not arbitrarily overwrite factory parameters during first use! This tutorial is for teaching calibration methods and recalibration when changing lenses.
2. Preparation
2.1 Prepare Checkerboard Calibration Board
Prepare a checkerboard calibration board, download and print the corresponding camera calibration board from the supporting materials [Attachments - Camera Checkerboard Calibration Board] and attach it to cardboard or other flat surface

2.2 Start Camera Driver and Calibration Program
Open the terminal and run the camera intrinsic calibration launch file:
ros2 launch dofbot_pro_driver A1pro_camera_arm.launch.py
Run the calibration node (specify internal corner points and physical square size):
xxxxxxxxxxros2 run camera_calibration cameracalibrator --size 9x6 --square 0.024 --ros-args -r image:=/usb_cam/image_raw
3. Calibration Operation Flow
3.1 Calibration Interface Description
The right side of the calibration window shows four progress bars:
X: Sample coverage for horizontal movement (left/right) of the checkerboard in the camera's field of viewY: Sample coverage for vertical movement (up/down) of the checkerboard in the camera's field of viewSize: Coverage for depth distance as the checkerboard moves closer/farther from the cameraSkew: Coverage for tilt, pitch, and roll rotation angles of the checkerboard in the field of view
3.2 Sampling and Calculation Steps
Hold the calibration board in front of the camera's field of view, slowly adjust the board position (up/down, left/right, closer/farther, and tilt/pitch/rotation);
When the algorithm successfully captures all internal corners, colored corner connection lines will be drawn in the image, and the corresponding progress bars on the right will change from red to yellow, and finally to green;
When all progress bars turn green and the
CALIBRATEbutton in the lower right corner of the interface is lit and activated, clickCALIBRATEto execute intrinsic parameter optimization (this process takes tens of seconds, please be patient);After the solution is complete, the terminal will print the camera intrinsic matrix and distortion error. Click
SAVEto save the calibration data to/tmp/calibrationdata.tar.gz;Click
COMMITto submit and exit.
4. Export and View Calibration Results
4.1 Extract Calibration Package
Execute the extraction command in the terminal:
xxxxxxxxxxmkdir -p ~/camera_calibration_datatar -zxvf /tmp/calibrationdata.tar.gz -C ~/camera_calibration_data/cd ~/camera_calibration_data/ls -la
After extraction, the directory contains all collected sample images, ost.txt, and the standard intrinsic file ost.yaml, which is the camera's intrinsic parameters.
4.2 Fill the Calibrated Intrinsics into These Two Files
Camera Startup Parameters
Startup command,
xcd ~/camera_calibration_data/cp ost.yaml ~/yahboomcar_ros2_ws/software/library_ws/src/usb_cam/config/camera_info.yaml# After replacement, compilecd ~/yahboomcar_ros2_ws/software/library_wscolcon build --packages-select usb_camSpatial 3D Grasping Camera Parameters
It is recommended to modify through vscode remote login, modify the following according to the intrinsic parameters from ost.yaml above:
xxxxxxxxxxgedit ~/yahboomcar_ros2_ws/dofbot_pro_ws/src/dofbot_pro_usb/config/usb_camera_params.yamlModify the parameters above

5. Camera Intrinsic YAML Structure Analysis
Standard Intrinsic File Reference:
xxxxxxxxxx~/yahboomcar_ros2_ws/software/library_ws/src/usb_cam/config/camera_info.yaml
xxxxxxxxxximage_width640image_height480camera_namenarrow_stereocamera_matrix rows3 cols3 data567.38936 0. 307.17636 0. 568.87412 227.58214 0. 0. 1. distortion_modelplumb_bobdistortion_coefficients rows1 cols5 data-0.435109 0.246398 0.002171 0.006236 0.000000rectification_matrix rows3 cols3 data1. 0. 0. 0. 1. 0. 0. 0. 1.projection_matrix rows3 cols4 data487.55125 0. 309.493 0. 0. 523.12151 226.38238 0. 0. 0. 1. 0. image_width/image_height: Camera image resolution, here 640×480 pixelscamera_name: Camera name identifiercamera_matrix: 3×3 camera intrinsic matrix K = [fx, 0, cx; 0, fy, cy; 0, 0, 1]fx,fy: x/y direction focal length (pixel units), determines image scalingcx,cy: Principal point coordinates (pixel position of optical center in image), ideally close to image center
distortion_model: Distortion model,plumb_bobis a 5-parameter distortion model (k1, k2, p1, p2, k3)distortion_coefficients: Distortion coefficientsk1,k2,k3: Radial distortion coefficients, describing barrel/pincushion distortion caused by lens curvaturep1,p2: Tangential distortion coefficients, describing distortion caused by lens installation deviation
rectification_matrix: 3×3 rectification matrix, for monocular camera it is identity matrix (no stereo rectification needed)projection_matrix: 3×4 projection matrix P = [fx', 0, cx', Tx; 0, fy', cy', Ty; 0, 0, 1, 0]For monocular camera, Tx=0, Ty=0, used to project 3D points to 2D image plane