12. Camera Calibration¶
The Waveshare JetRacer ROS kit uses an IMX219-160 wide-angle CSI camera. That lens is wide enough that lane following, AprilTag pose estimation, and image overlays become geometry-sensitive. The ROS 2 lane follower in this workspace now consumes CameraInfo and rectifies frames before applying the bird's-eye-view warp, so calibration directly affects runtime behavior.
Prerequisites¶
- Install the ROS 2 calibration package on the Jetson target if it is not already present:
- Use a printed checkerboard with a known square size.
- Know the inner-corner count of the checkerboard, not the number of black/white squares.
Recommended Launch¶
The repository now provides a top-level ROS 2 launch entry point for calibration:
Arguments:
board_size: checkerboard inner-corner count ascols x rowssquare_size_m: one checker square edge length in metersimage_width: CSI capture width, default640image_height: CSI capture height, default480image_fps: CSI frame rate, default20flip_method: Jetsonnvvidconvflip mode, default0
If your checkerboard is different, override the launch values. Example for an 8x6 board with 24 mm squares:
What The Launch Starts¶
The calibration launch does two things:
- Starts the CSI camera pipeline with
gscamon/csi_cam_0/image_rawand/csi_cam_0/camera_info - Starts
camera_calibration/cameracalibratoragainst the matching ROS 2 topics andset_camera_infoservice
This is the ROS 2 equivalent of the old ROS 1 manual flow, but wrapped in a single launch file.
Calibration Procedure¶
- Keep the JetRacer stationary and well lit.
- Hold the checkerboard flat, then move it through the center, left/right edges, upper/lower edges, and all four corners of the image.
- Vary distance and yaw/pitch so the GUI coverage bars for position, size, and skew fill out.
- Wait for the
CALIBRATEbutton to turn active. - Click
CALIBRATE. - Inspect the reprojection result.
- Click
COMMIT.
COMMIT writes the new intrinsics through the camera driver's set_camera_info service. The file that gets updated is whatever camera_info_url points at. By default this repository uses jetracer_perception/config/cam_640x480.yaml.
Verify The Result¶
Restart the camera node or the lane-following stack after calibration.
Check that the camera info is populated:
Launch the lane follower in safe mode:
Then verify:
/lane_following/debug_image/compressedshowscal: RECTIFIED- the lane overlay is stable near the image edges
- AprilTag and other image-space consumers are using the updated
/csi_cam_0/camera_info
Troubleshooting¶
- If the calibrator window never appears, confirm the target has a graphical session or X11 forwarding.
- If
CALIBRATEnever enables, the checkerboard size is probably wrong. - If
COMMITfails, confirm/csi_cam_0/set_camera_infoexists. - If the updated YAML does not persist into runtime, rebuild or relaunch from the same workspace install that the launch files resolve via
FindPackageShare. - If the image is mirrored or upside down, adjust
flip_methodin the camera launch before calibrating.