Calibrating the PiCar-X

Some servo angles may be slightly tilted due to possible deviations during PiCar-X installation or limitations of the servos themselves, so you can calibrate them.

Of course, you can skip this chapter if you think the assembly is perfect and doesn’t require calibration.

  1. Run the calibration.py.

    cd /home/pi/picar-x/example/calibration
    sudo python3 calibration.py
    
  2. After running the code, you will see the following interface displayed in the terminal.

    ../_images/calibrate1.png
  3. The R key is used to test whether the servo that controls the direction of the front wheel can work normally and is not damaged.

  4. Press the number key 1 to select the front wheel servo, and then press the W/S key to let the front wheel looks as forward as possible without skewing left and right.

    ../_images/calibrate2.png
  5. Press the number key 2 to select the Pan servo, then press the W/S key to make the pan/tilt platform look straight ahead and not tilt left or right.

    ../_images/calibrate3.png
  6. Press the number key 3 to select the tilt servo, then press the W/S key to make the pan/tilt platform look straight ahead and not tilt up and down.

    ../_images/calibrate4.png
  7. Since the wiring of the motors may be reversed during installation, you can press E to test whether the car can move forward normally. If not, use the number keys 4 and 5 to select the left and right motors, then press the Q key to calibrate the rotation direction.

    ../_images/calibrate6.png
  8. When the calibration is completed, press the Spacebar to save the calibration parameters. There will be a prompt to enter y to confirm, and then press esc to exit the program to complete the calibration.

    ../_images/calibrate5.png