What you will need

What you will get

  • A Duckiebot with a calibrated camera.

Camera Calibration#

This chapter describes how to perform the camera calibration procedure for your Duckiebot.

Introduction to camera calibration#

Every camera is unique due to manufacturing and assembly differences. Therefore, a camera calibration procedure needs to be performed to account for small manufacturing discrepancies.

This procedure involves displaying a predetermined pattern in front of the camera and using it to solve for the camera’s parameters.

For more information about the mathematics behind the process, review the appropriate learning experience.

Calibration board#

Duckietown camera calibration pattern in A3 format

Fig. 31 Duckietown camera calibration pattern.#

If you do not already have a Duckietown calibration board:

  1. Download the Duckietown calibration pattern

  2. Print it in A3 format

  3. Make sure the printing settings have not deformed the pattern, by measuring the features as indicated on the pattern itself

  4. Fix it to a rigid planar surface that you can move around

Note

  • The squares must have side lengths equal to 0.031 m (3.1 cm). Measure this, as having the wrong size may lead to your Duckiebot crashing.

  • In case your squares are not the correct size, make sure that your printer settings are set to A3 format, with no automatic scaling and size set to 100%.

Warning

If the pattern is not rigid, the calibrations should not be used. You can print on thick paper or adhere to something rigid to achieve this.

Intrinsic calibration#

The instrinsic camera calibration procedure identifies parameters that enable creating a relationship between the 2D image plane and the 3D world around the Duckiebot. These parameters account for various optical specifications such as the camera’s focal length, the pixel aspect ratio, and the distortion field applied by the fisheye lens.

For optimal performance, repeat this procedure if you change the focus of the camera by rotating the lens.

The Intrinsics Calibrator#

To perform the intrinsic camera calibration procedure for your Duckiebot, run:

dts duckiebot calibrate_intrinsics DUCKIEBOT_NAME
Duckietown instrinsics camera calibration interface

Fig. 32 The Duckietown intrinsics camera calibration interface.#

Note the keys in the table below.

Key

Function

X

Increase the Frame Rate

Z

Decrease the Frame Rate

Space

Calibrate the camera

F

Toggle the Undistort switch

R

Refresh the window

T

Open the Debug Console

Intrinsic calibration procedure#

To perform the intrinsic calibration procedure:

  1. Move the calibration pattern in front of your Duckiebot’s camera such that the entire checkerboard pattern is within its field of view and colored lines begin to overlay the checkerboard pattern.

  2. Rotate the mechanical focus ring on the lens until you can clearly read the x and y labels on the checkerboard pattern (do not adjust the focus again or place the lens cover back onto the lens unless you plan on repeating this procedure).

  3. Slowly move the calibration board left, right, up, down, forwards and backwards, relative to your Duckiebot’s camera, until each region within the x, y and Size bars is filled in.

  4. Slowly tilt and pan the calibration board, relative to your Duckiebot’s camera, until each region within the Skew bar is filled in.

  5. Click the Calibrate button.

  6. Wait for the spinner to disappear.

  7. (optional) Click the Undistort switch to see an undistorted view of what your Duckiebot sees.

Duckietown instrinsics camera calibration interface showing a successful procedure

Fig. 33 The Duckietown intrinsics camera calibration interface (Intrinsics Calibrator) with all of its bars filled in.#

Duckietown instrinsics camera calibration interface showing a successful procedure

Fig. 34 The Intrinsics Calibrator with the Undistort switch set to on.#

To confirm that a new intrinsic calibration file has been created on your Duckiebot, run the following command and inspect the contents of the Camera Intrinsic panel:

dts duckiebot dashboard DUCKIEBOT_NAME --page robot/calibrations
Duckietown instrinsics camera calibration interface showing a successful procedure

Fig. 35 The Camera Intrinsic panel on the Robot page of the Dashboard.#

Note

Within the Camera Intrinsic panel, under Local, you should see a tick next to Completed, the calibration date next to Calibration date and /data/config/calibrations/camera_intrinsic/DUCKIEBOT_NAME.yaml next to Files.

Extrinsic camera calibration procedure#

This camera calibration procedure outputs the relative pose between the camera and Duckiebot frame.

For optimal performance, repeat this procedure if you ship the Duckiebot or otherwise touch the camera holder.

The Extrinsics Calibrator#

The easiest way to perform the extrinsic camera calibration procedure for your Duckiebot is by using the Extrinsics Calibrator.

Duckietown extrinsics camera calibration interface

Fig. 36 The Extrinsics Calibrator.#

To open the Extrinsics Calibrator, run:

dts duckiebot calibrate_extrinsics DUCKIEBOT_NAME

Note the keys in the table below.

Key

Function

X

Increase the Frame Rate

Z

Decrease the Frame Rate

Space

Calibrate the camera

F

Toggle the Project switch

E

Toggle the Check error switch

R

Refresh the window

T

Open the Debug Console

Extrinsic calibration procedure#

To perform the extrinsic calibration procedure:

  1. (optional) Click the Check error switch to enforce a pose error bound for your Duckiebot’s camera based on it’s known intrinsic parameters (a trapezoid in the image under Camera View should appear).

  2. Position your Duckiebot on the calibration board such that it faces the checkerboard pattern, your Duckiebot’s axle is parallel to and directly above the large y-axis of the calibration board, and the axis that is perpendicular to and midway between your Duckiebot’s axle is directly above the large x-axis of the calibration board (if the Check error switch is set to on, the trapezoid in the image under Camera View should turn from black to blue).

  3. Click the Calibrate button.

  4. Wait for the spinner to disappear.

  5. (optional) Click the Project switch to see a top-down view of what your Duckiebot sees under Projection.

Duckiebot extrinsics camera calibration setup

Fig. 37 Extrinsic calibration setup: align the Duckiebot with the marks on the calibration pattern, on a white backdrop.#

Duckietown extrinsics camera calibration check error function

Fig. 38 The Extrinsics Calibrator with the Check error switch set to on.#

Duckietown extrinsics camera calibration projection functionality

Fig. 39 The Extrinsics Calibrator with the Project switch set to on.#

To confirm that a new extrinsic calibration file has been created on your Duckiebot, run the following command and inspect the contents of the Camera Extrinsic panel:

dts duckiebot dashboard DUCKIEBOT_NAME --page robot/calibrations
Duckietown extrinsics camera calibration extrinsics panel

Fig. 40 The Camera Extrinsic panel on the Robot page of the Dashboard.#

Note

Within the Camera Extrinsic panel, under Local, you should see a tick next to Completed, the calibration date next to Calibration date and /data/config/calibrations/camera_extrinsic/DUCKIEBOT_NAME.yaml next to Files.

Troubleshooting#

Troubleshooting

SYMPTOM

I do not see what my Duckiebot sees after refreshing the window and following .

RESOLUTION

Contact support.