Picar-X Direction Servo control and Line tracking sensor

I have started working on Sunfounder Picar-X and following the below tutorial
https://docs.sunfounder.com/projects/picar-x/en/latest/python/python_calibrate.html

I am facing a few issues:

  1. While calibrating when I access the calibration code
    cd /home/pi/picar-x/example/calibration
    sudo python3 calibration.py
    I can move the car and stop it, change the motors everything moves smoothly but i dont understand how can I change the direction of the car by turning the direction servo.

  2. Initiallly all the car was moving fine on the obstacle avoidance code, but now after a few days when I execute the same code, the car does not move smoothly, only the back tyres move, the front tyres are static. If I test the movement of the car using the calibration.py all four tyres move smooth.

  3. I am trying to configure the line tracking sensor, when i run the code it can detect the black line by changing the values which i can see on my screen, but it does not move. when i pick the car the tyres start rotating. I tried to change the calibration of sensor by turning the button and calibrating on different values but it does not follow the line, i doesn’t even detect.

  4. One of the cars, after adjusting the servo and testing it through calibration.py and pressing “R”, the camera servos work fine but the direction servo turns left and then gets stuck while making noise, but after a few second it stops.

can you please provide some guidance on these issues so I can work on my project, I have 7 Picar-X among which I have assembled and configured three, where I am facing the above mentioned issues.

This issue needs to be tested and verified, we’ll try to give you a solution tomorrow.

1 Like

1, calibration.py code is to calibrate the servo and motor, so it is not specifically to control the cart.
Your comment that you don’t understand how to change the direction of the car by turning the direction servo has nothing to do with this example, this example is just to calibrate the accuracy of the motor and servo.
You can read our tutorial carefully: Calibrating the PiCar-X — SunFounder picar-x documentation

2、Please provide your problem video to us, so that we can analyze and solve the problem.
Did you press Q to calibrate the rotation direction in the calibration.py code, which caused the rear wheel motor to move in one positive and one negative direction. You can try to calibrate the rotation direction by pressing Q again. If the motor movement direction is positive and negative, it will cause the cart to work in place, so you macro think that the front wheel is not working.

3、Line tracking does not work as described in the tutorial?
Please provide a video of the problem to us so that we can analyze and solve the problem.

4、After adjusting the servo and testing through calibration.py and pressing “R”, the camera servo works fine, but the directional servo turns to the left and then gets stuck when making noise, but stops after a few seconds?
What about when you did the servo adjustment back to zero beforehand, the servo was correctly zeroed before assembling the fixed servo arm. The stuck when making noise could be that you secured the servo without zeroing it properly during servo return, causing the servo operation to be limited when you tested the calibration, resulting in a Raspberry Pi reboot situation. If you unfasten the servo arm of the directional servo, the situation should not occur.
Please redo the servo return to zero adjustment for the directional servo, and then go back to fixing the screws. Please read our online tutorials and assembly tutorials carefully:

https://docs.sunfounder.com/projects/picar-x/en/latest/python/python_start/py_servo_adjust.html
https://github.com/sunfounder/sf-pdf/raw/master/assembly_file/a0000710-picar-x.pdf
103101

1 Like

Please have a look at the above video link. I am running the minecraft.py file for line tracking. When i run the code, one tyre moves in the forward direction and the other backwards, which makes the car not move.

I have not made any change in the code, what can be the possible reason?

You can go ahead and perform a calibration of the motor and follow our tutorial to calibrate the motor:
https://docs.sunfounder.com/projects/picar-x-v20/en/latest/python/python_calibrate.html
Execute the command:
cd ~/picar-x/example/calibration
sudo python3 calibration.py

110301

You can record a video of the process of calibrating the motor to us and we will help you analyze the problem.

1 Like

Thank you for your support. The motors are working fine now.

1 Like

About the servos configuration, I was running the avoiding_obstacles.py file from the Picar examples, and encountered an error, where the servos turn in one direction and get stuck. is this because of the servo zeroing? to solve it i need to reassemble the car? Is it not possible to do servo zeroing while the servos are attached to the car.

I am attaching a video also which can show you exact problem

Secondly, I have been working the Picar-X car and when I use it for line tracking I am encountering some irregularities. Can you please tell me what would be the ideal width of the black line as per the installed sensor, so I can check the performance of the car on that line.

1, picar-X does not have saving_obstacles.py file Oh, you write your own code?
If yes, please provide the code to us, so that we can analyze and solve the problem.
You go to run the move.py file, whether it can work properly.
If you run the program and find that the front wheel servo is stuck, there is a big possibility that your servo is assembled and fixed without zero adjustment.
If this is the case, you will need to remove the front wheel servo fixing to the front wheel.
Execute the script for servo return to zero, before executing the script, you need to upset the angle of the servo, before picking up P11 and executing the script:
cd ~/picar-x/example
sudo python3 servo_zeroing.py
At this point you will see the servo zeroing.
After successful zero return, follow the assembly diagram to assemble the rudder and fix it. (Pay attention to the assembly angle of the rudder and servo, please see the picture)
112201

2、The black line width is about 18-30mm, close to the distance between.
Suggest you control the black line width at about 20mm.

Thank you very much. It works fine now.

1 Like