Research on black line recognition algorithm and c

  • Detail

Research on smart car black line recognition algorithm and control strategy

0 introduction

Freescale Cup National College Student smart car competition is a national competition sponsored by Motorola Freescale company and hosted by the Automation Teaching Steering Committee of colleges and universities. It aims to strengthen college students' innovation awareness, teamwork spirit and cultivate students' innovation ability. The professional knowledge of this event involves control, pattern recognition, sensing technology, automotive electronics, electrical, computer, machinery and other disciplines, which plays a good role in promoting the integration of students' knowledge and the cultivation of practical ability, as well as the improvement of the academic level of control and automotive electronics in Colleges and universities

the model car used in the smart car competition is a rear wheel drive model car with differential, which is uniformly provided by the competition organizing committee. The automatic controller takes Freescale 16 bit microcontroller mc9s12dgl28 (S12) as the core control unit, and is equipped with sensors, motors, steering gear, batteries and corresponding drive circuits. It can independently identify the path and control the vehicle to run stably on the runway at high speed. The competition requires to design the control system and determine the control strategy by yourself. The winner is the one who completes the race in a short time on the specified track. The track consists of a white base plate and a black leader. According to the characteristics of the track, the competition organizing committee has determined two line finding schemes: 1. Photoelectric sensor

2. Camera

the characteristics of the two line finding schemes are as follows:

(1) photoelectric sensor scheme. The infrared light is emitted by the infrared transmitting tube to irradiate the runway, and the runway surface has different reflection intensity from the central leader. These information can be detected by using the infrared receiving tube. This scheme is simple and easy, the program debugging is simple and the cost is low, but it is limited by some competition rules (the organizing committee requires that the number of sensors should not exceed 16 (each pair of infrared sensors' transmitting and receiving units are counted as one sensor, and CCD sensors are counted as one sensor)), and the number of sensors cannot be placed too much, so the accuracy of road detection is low, and the amount of information that can be obtained from the guide line is also small. If this scheme is adopted, it is easy to cause the steering gear to swing back and take a serpentine route

(2) camera scheme. According to the characteristics of the track, the black-and-white image sensor can meet the requirements. There are two types of CCD cameras, area array and linear array, which are quite different in interface circuit, output signal and detection information. Area array cameras can obtain the image information of the track ahead, while linear array CCD can only obtain the image information of a straight line of the track. The amount of road information detected by the camera scheme is much larger than that of the photoelectric sensor scheme, and the camera can also detect a distance far enough to facilitate the controller to predict the road ahead. Although this scheme has high requirements for the controller, the computing power of mc9s12dgl28 (S12) provided by the Organizing Committee and the sampling speed of its own ad port can fully meet the requirements of video sampling of the camera and processing of a large amount of image data

under the premise of the camera scheme, this paper processes the image information on the basis of real-time image data acquisition, so as to extract the black leader in the center of the track, and then use it as the control basis of the steering gear and drive motor

1 characteristics of camera sampling data

the main working principle of the black-and-white camera used is: according to a certain resolution, the points on the image are collected by interlaced scanning. When a certain point is scanned, the gray level of the image at the point is converted into a voltage value corresponding to the gray level through the image sensor chip, and then the voltage value is output through the video signal terminal, as shown in Figure 1. The camera continuously scans a line on the image, and the output is a continuous voltage signal. The fluctuation of the voltage signal reflects the gray change of the line image. When a line is scanned, the video signal terminal outputs a level lower than the lowest video signal voltage (such as o.3v) and keeps it for a period of time. This is equivalent to a voltage groove immediately after each line of image signal. This groove is called line synchronization pulse, which is the sign of scanning line feed. Then, after skipping a line (because the camera is interlaced), start scanning a new line, and so on, until the video signal of the field is scanned, and then a field blanking area will appear. There are several composite blanking pulses in this area, one of which is much wider than (i.e. longer than) other blanking pulses, which is called field synchronization pulse, and it is the sign of scanning and field changing. The field synchronization pulse marks the arrival of a new field. However, the field blanking area just spans the end of the previous field and the beginning of the next field. When the field blanking area passes, the video signal of the next field really arrives. The camera scans 25 images per second, each of which is divided into odd and even fields, first odd field and then even field, so it scans 50 images per second. In odd field, only odd rows in the image are scanned, while in even field, only even rows are scanned

because the processing capacity of the mc9s12dgl28 (S12) control chip cannot reach the computing speed of the computer, the 320x240 CMOS single board camera with the smallest resolution on the market is adopted, which can also scan 501 images per second. In order to expand the scanning distance of the camera to meet the needs of image and control processing, the bus cycle of S12 MCU is overclocked to 32m, so that the camera can collect up to 70 points per line

according to the experiment, there are 320 lines of signals in each image scanned by the camera, of which lines 23 to 310 are video signals, that is, 288 lines of useful video signals in each field. Line 3LL to line 22 of the next field is the field blanking signal. In the actual image processing and control process, it is completely unnecessary to process all 288 lines of video signals. Because each line can collect 80 dotted pixels, the line signal is collected every 15 lines in each video signal, and 18 lines of video signal are used to judge whether the front is a straight road or a curve, so as to control the speed and steering of the car

2 extraction algorithm of black leader

the track is composed of black leader laid on white KT board, which is easy to extract black line with less external interference. Therefore, the image processing method is adopted, which is a relatively simple edge extraction algorithm. The reason why the edge and the nature of the image can be linked together is that the boundary between objects in the image, or between objects and the background, can be regarded as the edge, and the place where the gray and color of the image change sharply can also be regarded as the edge. The change of color in the image must have the change of gray, so the focus of edge detection and extraction can be focused on the gray. Because the reaction frame device must be applied in the verification process of black leader and white runway, the color difference is large, so a threshold value of black and white can be determined, and the threshold value (value) is determined to be 8 through experiments. Due to the intensity of light, the gray value of black pixels may not be exactly the same. In actual operation, we found that as long as the gray value is less than 4 (diffval), points can be regarded as black points

the image scanned by the camera is divided into the following two cases:

(1) the scanned image has only one vertical black line, as shown in Figure 2

the gray value of adjacent pixel points is subtracted (left minus right) from the first effective pixel point (usefu1_line) on the left. When the difference between the two is greater than the threshold (value), it is determined that the left edge of the black line corresponds to the next pixel point (usful_line+1). Continue subtraction. When the difference is greater than the threshold again, locate this pixel at the right edge of the black line. The procedure is as follows:

where G_ Ucdif is the absolute value of the difference between the gray values of two pixels, line_ Max is the maximum number of effective columns of the collected image, row_ Max is the maximum number of effective rows of the collected image, ucimage_ Data[][] is a two-dimensional array that stores image pixels, ucimage_ Temp is an array that temporarily stores images

(2) the scanned image is a black cross line, as shown in Figure 3.

as mentioned above, after the bus of S12 single chip microcomputer is overclocked, we can collect 70 effective data points for each line of image through AD conversion, and the width of the black line is only 25mm (specified by the competition organizing committee), which can only contain 6 effective data points. Therefore, for the black cross line, we only need to subtract the number of columns on the right edge from the number of columns on the left edge (1eft). If the difference is greater than 6, we can determine that it is a black cross line at this time. The program can be completed by adding a statement on the basis of the previous one

b1ackwire_ Data [] is the collected black line center line data, which will be used in the later control strategy

3 control algorithm of smart car

in the race, a key factor affecting the speed of the car is whether the car can recognize the curve and straight road in advance, that is to say, the control algorithm of the car plays a vital role in improving the performance of the car. The classical PID algorithm with good robustness and simple algorithm is used here. But ordinary PID is a linear algorithm. If the parameter setting is too large, the car is easy to oscillate when walking on the straight road, and it is easy to be slow and rush out of the track when walking on the curve at high speed. Therefore, the non-linear PID algorithm is adopted to make it insensitive to small deviation and sensitive to large deviation, so as to achieve the purpose of smooth straight road and sensitive curve

the PID control part of the drive motor is realized by the following algorithm:

among them, MVN, mvn-1; Current and 3. Pu court finish: last operation amount of 100% waterborne silicon Pu finish; △ MVN: differential of current operating quantity; EN, EN-1, En-2: current, last, previous deviation; The values of KP, Ki and KD are obtained through experiments

after testing, it is found that for the actuator control, when its integral link ki is O, the performance of the car is better, so the PD algorithm with nonlinearity is used for the actuator

the algorithm first needs to know the turning slope of the black line in the collected image (as shown in Figure 4). The straight line in the figure indicates that the track is a straight track, and the lines on the left and right sides respectively represent the black line conditions that may be collected by the camera during left and right turns. Different lines represent the turning slope of different steel balls. We will use this slope in the later PD control

the control strategy with prediction is adopted (as shown in Figure 5), which can be divided into the following situations:

(1) when the track is always straight, the procedure is as follows:

among them, steer_ Center is the steering center of the steering gear, G_ Oldpwm is the PWM output of the previous step, G_ Scure is the current turning deviation, G_ Solde is the turning deviation of the previous step

4 Conclusion

based on the fact that the camera has been able to collect more accurate images, this paper proposes and studies the edge extraction algorithm of the black leader, and then determines the steering control strategy of the steering gear on the basis of this algorithm. The practice shows that using this algorithm and control strategy can make the experimental machine adopt the high-speed test platform to obtain faster driving speed and more reliable steering performance

Copyright © 2011 JIN SHI