Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
đ Ready to explore and create with us? Click [here] and join today!
0. Calibrating the PiCar-Xď
Calibrate Motors & Servoď
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.
Run the
calibration.py
.cd ~/picar-x/example/calibration sudo python3 calibration.py
After running the code, you will see the following interface displayed in the terminal.
The
R
key is used to test if the 3 servos are working properly. After selecting a servo with the1
,2
or3
keys, then press theR
key to test that servo.Press the number key
1
to select the front wheel servo, and then press theW/S
key to let the front wheel looks as forward as possible without skewing left and right.Press the number key
2
to select the Pan servo, then press theW/S
key to make the pan/tilt platform look straight ahead and not tilt left or right.Press the number key
3
to select the tilt servo, then press theW/S
key to make the pan/tilt platform look straight ahead and not tilt up and down.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 keys4
and5
to select the left and right motors, then press theQ
key to calibrate the rotation direction.When the calibration is completed, press the
Spacebar
to save the calibration parameters. There will be a prompt to entery
to confirm, and then pressCtrl+C
to exit the program to complete the calibration.
Calibrate Grayscale Moduleď
Due to varying environmental conditions and lighting situations, the preset parameters for the greyscale module might not be optimal. You can fine-tune these settings through this program to achieve better results.
Lay down a strip of black electrical tape, about 15cm long, on a light-colored floor. Center your PiCar-X so that it straddles the tape. In this setup, the middle sensor of the greyscale module should be directly above the tape, while the two flanking sensors should hover over the lighter surface.
Run the
grayscale_calibration.py
.cd ~/picar-x/example/calibration sudo python3 grayscale_calibration.py
After running the code, you will see the following interface displayed in the terminal.
Press the âQâ key to initiate the greyscale calibration. Youâll then observe the PiCar-X make minor movements to both the left and the right. During this process, each of the three sensors should sweep across the electrical tape at least once.
Additionally, you will notice three pairs of significantly different values appearing in the âthreshold valueâ section, while the âline referenceâ will display two intermediate values, each representing the average of one of these pairs.
Next, suspend the PiCar-X in mid-air (or position it over a cliff edge) and press the âEâ key. Youâll observe that the âcliff referenceâ values are also updated accordingly.
Once youâve verified that all the values are accurate, press the âspaceâ key to save the data. You can then exit the program by pressing Ctrl+C.