Design of segmented PID control algorithm for intelligent vehicle based on CCD camera

Publisher:RainbowPromiseLatest update time:2011-03-23 Source: 电子设计工程 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Automatic tracking Smart car Involves many advanced technologies in the current high-tech field, among which the most important are sensor technology, path planning and motion control. This topic is based on the Freescale smart car competition, with a single-chip microcomputer as the core control unit, a camera as a path recognition sensor, a DC motor as the driving device of the car, and a servo to control the steering of the car. The track of the car model competition is a KT board with specific geometric size constraints, friction coefficients and optical properties. The center is affixed with a black strip with strong absorption characteristics for both visible and invisible light as a guide line with a width of 2.5 cm. During driving, the system obtains image data of the track in front through the camera, and obtains the speed of the smart car in real time through the speed sensor. The path search algorithm is used for line-finding judgment and speed analysis, and then control decisions are made to control the steering servo and DC drive motor. The smart car "drives" quickly along the track by adjusting its own movement speed and direction in real time. This article mainly introduces how the camera extracts the black line information of the track and hands it over to the microcontroller for processing. The microcontroller outputs a control signal to control the steering of the servo to control the steering of the car model, thereby automatically tracking the track.

1 Overall hardware and software structure and ideas

This intelligent vehicle positioning system uses a camera to shoot the track in front of the vehicle, and samples the video signal through MC9S12XS128 to obtain image data. Then use a suitable algorithm, such as tracking edge detection algorithm, to analyze the image data and extract the target guide line. Then, the system applies appropriate control to the servo and motor according to the position information of the target guide line. The structural diagram of this intelligent vehicle motion system is shown in Figure 1.

Structural diagram of the intelligent vehicle motion system

Because the system is an organic whole, it is necessary to coordinate the system's camera, control microcontroller, motor (including DC servo motor, photoelectric encoder), steering gear and auxiliary circuit (power board, motor drive board) and other parts. The steering gear controls the steering of the car model in real time and is the key to the speed and stability of the competition. There are many control algorithms for steering gear control, such as: PID classic control algorithm, fuzzy algorithm, artificial intelligence algorithm, etc.

2 System program overall control flow

The basic software flow of the system is: first, initialize each functional module and control parameter; then, obtain the image data of the front track through the image acquisition module, and obtain the speed of the car through the speed sensor module. Use PID to feedback control the servo. In addition, according to the detected speed, combined with the speed control strategy, the speed of the car is continuously adjusted appropriately, so that the car can run quickly along the track while complying with the rules of the game. The basic software structure flow chart of the system is shown in Figure 2.

Basic software structure flow chart

The system software requires control accuracy and stability. Sampling and extracting black lines is the basis for controlling input, which requires accurate and stable sampling. After the input is given to the servo, the servo output is required to be fast responsive, stable and accurate. After many experiments and nearly a semester of adjustment experience, the classic PID controller was selected and improved to control and adjust the servo of the car model.

3 Image Recognition

Use CCD camera to collect black lines within a certain distance in front of the car model, extract relevant quantities from them, and use them to control the steering of the servo to realize automatic tracking of the smart car. Due to the limited data processing capacity and speed of the single-chip microcomputer, the entire image cannot be processed in a short time of 20 ms. This system sets the camera forward look to 1.2 m. Under the premise of not affecting the accuracy of road detection, this system uses interlaced acquisition to compress image data, that is, one line of data is collected at different intervals of effective lines (less near, more far), and a total of 44 lines of data can be collected. In addition, in order to further improve the speed of A/D conversion, this system also appropriately overclocks the CPU of XS12 and sets the precision of A/D converter to 8 bits, so that each line can sample 67 points, forming a plane array, and the black line occupies some points in it. Since we collect 67 points in one line, the median value is 33. The image is the bottom layer of the smart car. The correctness of image acquisition is particularly important in future control. Therefore, we must ensure the authenticity and validity of the collected black lines, and add filtering algorithms. For example, when the effective look-ahead is very small, it is enough to judge the direction of the black line and give the steering gear an extreme turning angle to make the car turn sharply. However, when there are very few effective lines, if no special filtering method is used, as long as one line of black lines is wrong, the car may turn wrong, and even turn out of bounds.

4-segment PID control

4.1 Amount of image information extracted

The control quantity is extracted from the collected images to control the steering of the servo and realize the automatic tracking of the smart car. This system uses the black line offset even_diff and the slope of a certain section of the black line D_diff-erent to control the servo, which can be called a PD controller. Since the car model is a follow-up system, the black lines covered within the 1.2 m forward range of the camera may not have the set 44 lines, especially when the curve ahead is particularly sharp, the black lines covered within the forward viewing angle of the camera will be particularly few, such as 13 lines or less. According to this feature, an effective forward-looking quantity valid_line can be set as a response to the smoothness of the curve ahead.

The offset of the row is obtained by subtracting the black line position value of each row from the middle value. The middle value 33 is the center position point of the track. The offset represents the position value of the black line in the track from the perspective of the car model. The sum of the offsets of each row is divided by the number of black line rows extracted within the camera's forward-looking range to obtain the overall offset of the black line relative to the center of the car model, even_diff. The difference between the offsets of some distant rows and some nearby rows (such as the first half and the second half) in the valid row is used to obtain the slope D_differen of the black line in the valid row.

In this way, from the black line position data of a field, the system extracts three quantities: valid_line, even_diff, and D_different to control the servo. In actual situations, D_different can be very flexible, because the slope of the black line in front can be obtained in different segments, and the slope values ​​of different segments can be obtained according to actual requirements. For example, when the speed is fast, the slope of the black line farther away from the vehicle can be appropriately taken to achieve advanced control.

When debugging parameters for smart cars , it is very important to understand these three quantities. Specifically, valid_line represents the effective foresight of the car model, that is, how far it can see. For smart cars driving on the road, if they can see far, it means that the black lines are all in front, and if they can't see far, it means that the black lines in front of the smart car have deviated to the left or right. The size of this quantity can just represent the gentleness and urgency of the curve. In addition, if you can see far, the camera will collect more black lines and the system will have a large amount of information. Then how to process this large amount of information for our use becomes very critical. For example, if you can see 1.2 m, it means that the car must be on a long straight road, otherwise it is a small S-bend. With a little processing, the small S-bend can be filtered out, making the car seem to be running on a straight road; if you can see very close, it means that the bend is very sharp. At this time, as long as you can judge which direction the bend turns, you can give the servo an extreme sharp turn. even_diff represents the degree of deviation between the car and the black line in a certain field of view. This quantity allows the smart car to decide how big the turning angle is for the servo in a certain field of view. D_different is particularly important when looking far ahead effectively, because it can predict the bend ahead and make the turn ahead of time.

[page]

4.2 PD controller form

The system processes these three quantities into the form of a PD controller:

3 quantities are processed into the form of PD controller

Where a is the different valid rows determined based on the effective foresight of the track. Centre is the control intermediate value of the servo in a straight line. Steer is the input of the PD controller to the servo. Since the steering control of the car model servo is a nonlinear system, the entry condition "valid row judgment" is set, which can just divide this nonlinear system into different segments. In each segment, the steering control system can be approximately considered to be linear. That is, within a small range, the obtained black line position and the corresponding servo PID reference angle are processed into a linear relationship. Finally, simple segmented PID control is achieved .

5. Segmented PID control parameter rules

In the actual shunting process, we concluded that the parameters Kp and Kd of the PD controller are related to the effective look-ahead valid_line and the speed of the car model. In simple terms, the faster the car speed is, the earlier the car model should turn in advance when encountering a curve. In summary, there is the following relationship:

The following relationship

Among them, A is the basic value of Kp, valid_line is the effective look-ahead of the car model running to a certain state (estimated by the number of extracted black lines), and speed is the pulse value of the car within a period of time, which represents the speed of the car model running at all times. At low speed, speed/C can be approximately considered to be zero, and the value of A can be determined by experimental method. After determining the basic value of Kp, you can accelerate, and debug to get the appropriate B value and C value when the car speed is slightly higher, so that the car can finally tangent and follow the track smoothly and accurately. From this relationship, it can be seen that the change of effective look-ahead is the quantity that has the greatest and most direct impact on the Kp value. We know from our usual experience in adjusting cars that the B parameter should be much more sensitive than C. The reduction of one effective line has a much greater impact on the steering angle of the servo than the impact of the car speed on Kp. The effect of speed on the rapidity of the servo's sharp turn is very obvious when the car model is at high speed.

In order to increase the robustness of the system and better solve the nonlinear problem of the system, we divide the car's look-ahead into segments. In our 1.2 m look-ahead, there are a total of 44 black lines. All of them are extracted on the straight road and can be divided into 7 segments: less than 37 valid lines, more than 30 valid lines, more than 24 valid lines, more than 18 valid lines, more than 13 valid lines and less than 13 valid lines.

The control program is processed as follows:

Processed into a control program

Although it is divided into 7 sections, each section is controlled separately, and the parameters are adjusted separately, but the negative correlation between Kp value and effective row (effective look-ahead) still holds true. Therefore, Kp, Kp1, Kp2, Kp3, Kp4, and Kp5 still generally follow the negative correlation with the effective row, that is, Kp increases linearly with the decrease of effective rows.

Adjust the parameters of the PD controller in each section so that the car can navigate curves of different types and radii. This forms segmented PD control, which can solve the nonlinear problem of the car and enhance the robustness of the system. At the same time, in order to protect the servo from being turned too hard to the left or right, the left and right limit values ​​of the servo can be limited:
Limit the left and right limits of the servo
by debugging parameters A, B, and C and adjusting different Kp values, practice has proved that the car can move forward smoothly and quickly while automatically patrolling the line.

6 Conclusion

The algorithm relates the steering Kp coefficient of the servo to the vehicle speed, which can coordinate the vehicle speed and the servo steering well. It proposes a rule for segmenting PD parameters with specific smart car parameters, which is very helpful for the actual production of smart cars and has a wide promotion value in smart car competitions.

Practice has proved that when the parameters are adjusted appropriately, the smart car can adapt well to the track and run the best path desired. In order to participate in the fifth "Freescale" Cup National College Student Smart Car Competition, this control algorithm performed perfectly in the school-level representative team qualification selection, and finally ran a good score of 2.5 m/s, successfully selected to participate in the North China Division. Practice has proved that the segmented PID control steering of the smart car servo is feasible and practical.

2011/3/19 20:55:57
Reference address:Design of segmented PID control algorithm for intelligent vehicle based on CCD camera

Previous article:Fault Monitoring in Imperfect Battery Management Systems
Next article:Application of power devices in hybrid electric vehicles (HEV)

Latest Automotive Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号