A dolly adaptive tracking method based on Susan operator and sliding fuzzy PID
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-08
- Publication Date
- 2026-08-11
AI Technical Summary
然而,普通PID调节参数困难以及难以应对各种突发情况并且输出相应速度较模糊控制器较差
[0061]1、本发明实施例通过大津法将道路灰度图像分为前景和背景两个部分,然后利用Susan算子并比对OTSU得到的阈值对指定区域进行滑动检索,可以提取出道路边缘,再根据道路边缘计算出平均偏移量;之后将平均偏移量作为模糊PID系统的输入,输出的PWM波用来控制舵机,实现小车的转向;最后根据所需的目标速度和平均偏移量计算出实际期望速度并将其作为滑动模糊PID的输入,输出的PWM波用来控制电机,即小车的速度,也即是本发明将Susan算子与OTSU相结合用于道路边缘提取,优势在于可以快速提取出于周围环境有着明显色差的车道线,采用的是灰度图对环境具有良好的适应性,且Susan算子对噪点不敏感,对局部噪点具有较强的抗干扰能力,利用Susan算子对局部图像进行检索,提取出车道线信息,并将车道线信息反馈给系统,计算出准确的平均偏移量输入到舵机模糊PID控制器中,模糊PID控制器相较普通PID控制器能够提高整个系统的响应速度,保证控制系统的活力性;大大提高了抗噪性,获得了更高的边缘检测精度;在速度控制中采用基于滑动滤波器的模糊PID控制系统,并结合反馈机制,能将整个电机控制过程更加平滑,提高了精度的同时又兼顾响应速度。
Smart Images

Figure CN117985051B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of autonomous driving technology, specifically to an adaptive tracking method for a vehicle based on the Susan operator and sliding fuzzy PID. Background Technology
[0002] Autonomous driving, as a hot topic in social life, has been extensively studied. Two crucial issues in this field are road edge extraction and control system precision. Regarding road edge extraction, the Susan edge detection method, proposed by researchers, has shown superior edge detection capabilities compared to other methods, thus attracting widespread attention. However, the traditional Susan edge detection method uses the gray-level difference of individual pixels to characterize pixel differences, making it susceptible to noise interference and significantly impacting its noise resistance. Furthermore, Susan edge detection typically extracts lane lines by convolving the entire image with the Susan operator and then using Hough transform. This process involves searching the entire image, resulting in high computational costs and difficulty in extracting relevant lane line information. In addition, regarding control system precision, the classic digital PID algorithm is frequently used. However, ordinary PID controllers are difficult to adjust parameters, struggle to handle various unexpected situations, and have a slower output response compared to fuzzy controllers. While fuzzy controllers can improve response speed, interference in practical applications can lead to less smooth and stable outputs. Summary of the Invention
[0003] To address the shortcomings of existing technologies, the purpose of this invention is to provide an adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID. This method is inspired by the edge growing method, has virtually no complex calculations in the algorithm, can greatly save computing power, is insensitive to local noise, has strong noise resistance, and has strong environmental adaptability.
[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0005] An adaptive line-following method for a vehicle based on the Susan operator and sliding fuzzy PID control, the key of which includes the following steps:
[0006] Step 1: Obtain a grayscale image of the road and obtain the threshold G for grayscale value difference and the threshold T for constraining edge quality;
[0007] Step 2: Calculate the OTSU threshold of the entire grayscale image using the Otsu method;
[0008] Step 3: Compare the threshold values and extract the road edges using the Susan operator;
[0009] Step 4: Calculate the average offset of the car based on the road edge;
[0010] Step 5: Input the average offset of the car into the fuzzy PID controller and control the steering of the car's servo motor according to the output PWM wave;
[0011] Step 6: Calculate the actual expected speed based on the target speed and average offset of the car, input the actual expected speed of the car into the fuzzy PID controller based on the sliding filter, and control the speed of the car according to the output PWM wave.
[0012] Furthermore, the process of setting the threshold G for grayscale value difference in step 1 is as follows:
[0013] Step 1.1: Acquire grayscale images of the road using a grayscale camera;
[0014] Step 1.2: Observe the difference in grayscale values at the road edges of the collected road grayscale image;
[0015] Step 1.3: Based on the circular template of the Susan operator, compare the gray values of the pixels inside the circular template with the gray values of the pixels at the center of the circular template to obtain the threshold G that makes the area of the kernel value similarity region account for half of the area of the entire circular template, and use half of the area of the entire circular template as the threshold T for constraining the edge quality.
[0016] Furthermore, the calculation process for the area of the kernel value similarity region is as follows:
[0017] Compare the grayscale value of each pixel within the circular template with the grayscale value of the center pixel of the circular template to obtain the pixels that have the same or similar grayscale value as the center pixel of the template. The calculation formula is as follows:
[0018]
[0019] Where r is the center pixel of the circular template, r0 is any pixel within the circular template, I(r) is the gray value of the center pixel r of the circular template, and I(r0) is the gray value of any pixel r0 within the circular template.
[0020] All pixels with the same or similar gray values to the center of the template are grouped into a kernel value similarity region;
[0021] The area of the kernel value similarity region is calculated using the following formula:
[0022]
[0023] Where n(r0) represents the area of the kernel value similarity region centered at r.
[0024] Furthermore, in step 2, the formula for calculating the OTSU threshold of the entire grayscale image using the Otsu method is as follows:
[0025] g = w0·w1·(u0-u1) 2
[0026] Where g is the OTSU threshold, w0 is the pixel ratio of the background image, w1 is the pixel ratio of the foreground image, u0 is the average gray level of the background image, and u1 is the average gray level of the foreground image.
[0027] Furthermore, the specific steps for extracting the road edge in step 3 are as follows:
[0028] Step 3.1: Determine the starting point of the road edge;
[0029] Step 3.2: Determine the road edge points of each row of pixels.
[0030] Furthermore, the specific process for determining the starting point of the road edge in step 3.1 is as follows:
[0031] Step A1: Locate the pixel in the middle column of the bottom row of the grayscale image of the road;
[0032] Step A2: Move horizontally one pixel at a time from the middle column to both sides. Compare the difference between the gray value of each pixel and the OTSU threshold. If it is less than the threshold t, calculate the area of the kernel value similarity region for each pixel. If it is greater than the threshold t, continue to move to the next pixel and repeat the above process until the area of the kernel value similarity region is less than the threshold T. Stop the column search for that row to obtain the starting point of the road edge.
[0033] Furthermore, the specific process for determining the road edge points of each row of pixels in step 3.2 is as follows:
[0034] Step B1: Use the column containing the starting point of the road edge as the reference;
[0035] Step B2: Use the Susan operator to perform a horizontal search on the next row to find pixels whose gray value and the difference between the pixel and the OTSU threshold are less than the threshold t.
[0036] Step B3: Calculate the area of the kernel value similarity region for each pixel found in step B2;
[0037] Step B4: Compare the area of the kernel value similarity region obtained in step B3 with the threshold T. If the area is less than the threshold T, stop the column search for that row and obtain the left and right road edge points corresponding to that row.
[0038] Step B5: Using the left and right road edge points obtained in step B4 as a reference, repeat steps B2-B4 to obtain the next row of road edge points until the road edge points corresponding to each row of pixels in the grayscale image are obtained.
[0039] Furthermore, the calculation steps for the average offset of the car in step 4 are as follows:
[0040] Step 4.1: Calculate the offset of each row in the grayscale image of the road;
[0041] Step 4.2: Sum the offsets of each row to get the total offset;
[0042] Step 4.3: Calculate the average offset based on the total offset and the number of valid rows.
[0043] Furthermore, in step 5, the average offset of the car is input into the fuzzy PID controller, and the specific process of controlling the steering of the car's servo motor based on the PWM wave output by the fuzzy PID controller is as follows:
[0044] Step 5.1, Error Quantization: Take the average offset as input and quantize the deviation e and the rate of change of deviation ec of the car servo motor to obtain the mapped and quantized deviation E and the rate of change of deviation EC.
[0045] Step 5.2, Error Fuzzification: Determine the 7 linguistic variables in the fuzzy subset, and assign the deviation E and the rate of change of deviation EC to their respective membership degrees through membership functions;
[0046] Step 5.3, Parameter Fuzzy Reasoning: Based on the membership degree of E and EC, look up the table to obtain the membership degree of the output parameters △KP, △KI, and △KD;
[0047] Step 5.4: Obtain parameter values: Multiply the membership degree of each parameter obtained by fuzzy inference by the corresponding membership value, and then sum them to obtain the parameter values of parameters △KP, △KI, and △KD. Then, obtain the values of output parameters KP, KI, and KD according to the set gain of each output parameter.
[0048] Step 5.5, Output Control: After obtaining the values of output parameters KP, KI, and KD, a traditional PID controller is used to output a PWM wave, which is then limited and output to the drive to rotate the servo motor.
[0049] Furthermore, in step 6, the specific steps for inputting the target speed of the vehicle into the fuzzy PID controller based on the sliding filter to obtain the PWM wave output by the fuzzy PID controller to control the speed of the vehicle are as follows:
[0050] Step 6.1 Error Quantization: Calculate the real-time expected speed of each motor of the car based on the set target speed and average offset. Use the real-time expected speed as the input of the fuzzy PID controller, and quantize the deviation and rate of change of the car speed to obtain the deviation and rate of change of the deviation after mapping quantization.
[0051] Step 6.2, Error Fuzzification: Determine the 7 linguistic variables in the fuzzy subset, and assign the deviation E and the rate of change of deviation EC to their respective membership degrees through membership functions;
[0052] Step 6.3, Parameter Fuzzy Reasoning: Based on the membership degrees of the quantified deviation and the rate of change of deviation, the membership degrees of parameters △KP, △KI, and △KD are obtained by looking up a table;
[0053] Step 6.4: Obtain parameter values: Multiply the membership degree of each parameter obtained by fuzzy inference by the corresponding membership value, and then sum them to obtain the parameter values of parameters △KP, △KI, and △KD. Then, obtain the values of output parameters KP, KI, and KD according to the set gain of each output parameter.
[0054] Step 6.5, Output Control: After obtaining the values of output parameters KP, KI, and KD, a traditional PID controller is used to output a PWM wave, which is then limited and output to the drive to control the speed of the vehicle.
[0055] Step 6.6 Feedback Input: The current speed of the vehicle is collected in real time and processed by a sliding filter. The current speed value obtained by the sliding filter is fed back to the input of the fuzzy PID controller. The deviation and the rate of change of deviation are updated by subtracting the target speed, and then the next round of speed control is performed.
[0056] Furthermore, the implementation process of the sliding filter is as follows:
[0057] Set the sampled values of multiple car speeds into a queue of fixed length;
[0058] The sampled value of the car's current speed, collected in real time, is placed at the end of the queue, and the data at the beginning of the queue is discarded.
[0059] The current velocity value after sliding filtering is obtained by averaging the multiple sampled data in the queue.
[0060] The significant effects of this invention are:
[0061] 1. This invention uses the Otsu method to divide a grayscale image of a road into foreground and background parts. Then, it uses the Susan operator and compares the threshold obtained by OTSU to perform a sliding search on a specified area to extract the road edges. The average offset is then calculated based on the road edges. This average offset is used as the input to a fuzzy PID system, and the output PWM wave is used to control the servo motor to achieve the steering of the vehicle. Finally, the actual desired speed is calculated based on the required target speed and the average offset, and this is used as the input to the sliding fuzzy PID system. The output PWM wave is used to control the motor, i.e., the speed of the vehicle. In other words, this invention combines the Susan operator with OTSU for road edge extraction, which has the advantage of quickly extracting road edges with significant color differences from the surrounding environment. The lane markings are rendered using grayscale images, which are highly adaptable to various environments. The Susan operator is insensitive to noise and exhibits strong anti-interference capabilities against localized noise. The Susan operator is used to retrieve lane marking information from local images and feed this information back to the system. The resulting accurate average offset is then input into the fuzzy PID controller for the servo motor. Compared to a conventional PID controller, the fuzzy PID controller improves the overall system response speed, ensuring the control system's dynamism; it also significantly enhances noise immunity and achieves higher edge detection accuracy. Furthermore, the speed control employs a fuzzy PID control system based on a sliding filter, combined with a feedback mechanism, which smooths the entire motor control process, improving both accuracy and response speed.
[0062] 2. The road edge line-finding method of the present invention can identify routes of various colors as long as there is a significant color difference between the target line and the background environment. For example, with white as the background, it can effectively identify black, blue, and red routes. The line-following method of the present invention has strong anti-interference ability and low computational load for line following. It can adapt to various scenarios and lighting conditions and has high flexibility. Fuzzy PID control can make the control more precise and has a faster response speed, while the adaptive fuzzy PID control based on sliding filter has the advantages of both response speed and output stability. Attached Figure Description
[0063] Figure 1 This is a flowchart of the method of the present invention;
[0064] Figure 2 This is a schematic diagram of the circular template for the Susan operator.
[0065] Figure 3 Schematic diagram of USAN area under different conditions;
[0066] Figure 4 This is a schematic diagram illustrating the starting point of the road edge derived based on the Susan operator;
[0067] Figure 5A schematic diagram of the Suan operator's moving search;
[0068] Figure 6 This is a schematic diagram of the grayscale values within a circular template at the left starting point of the road edge.
[0069] Figure 7 This is a schematic diagram of the starting point of the retrieved road edge;
[0070] Figure 8 This is the final extracted road edge map;
[0071] Figure 9 The Simulink model diagram of the fuzzy PID controller for the car's servo motor;
[0072] Figure 10 A schematic diagram of the membership triangle relationship of fuzzy PID controllers;
[0073] Figure 11 This is a schematic diagram of a fuzzy rule table;
[0074] Figure 12 The Simulink model diagram of the fuzzy PID controller based on the sliding filter for the car motor is shown.
[0075] Figure 13 The waveform diagram of the effect of the sliding filter;
[0076] Figure 14 The waveforms are a comparison of the three controllers. Detailed Implementation
[0077] The specific embodiments and working principles of the present invention will be further described in detail below with reference to the accompanying drawings.
[0078] like Figure 1 As shown, an adaptive line-following method for a car based on the Susan operator and sliding fuzzy PID is presented, with the following specific steps:
[0079] Step 1: Obtain the grayscale image of the road, and obtain the threshold G for grayscale value difference and the threshold T for constraining edge quality. The specific process is as follows:
[0080] Step 1.1: Apply black tape to a foam board with a white background to simulate a road scene. Use a grayscale camera to capture images. The grayscale image captured by the grayscale camera has a resolution of 120*160 pixels.
[0081] Step 1.2: Observe the difference in grayscale values at the road edges of the collected road grayscale image;
[0082] Step 1.3: Based on the circular template of the Susan operator, compare the gray values of the pixels inside the circular template with the gray values of the pixels at the center of the circular template, set a threshold G for the difference between the gray values of the two points, and call the region composed of pixels within the threshold G in a circular template the kernel value similarity region. Obtain the threshold G that makes the area of the kernel value similarity region account for half of the area of the entire circular template, and use half of the area of the entire circular template as the threshold T for constraining the edge quality.
[0083] The template for the Susan operator is essentially a circular template consisting of 37 points, such as... Figure 2 As shown, the purpose is to achieve isotropic detection. In practical applications, due to the digitization of images, a true circular template cannot be achieved, and an approximate circle is often used instead. A circular template is applied to the image, and the grayscale of each pixel within the template is compared with the grayscale of the center pixel of the template. If the difference between the grayscale of a pixel within the template and the grayscale of the center pixel is less than a certain value, then that point is considered to have the same or similar grayscale as the kernel.
[0084] The region consisting of pixels that meet these conditions is called the kernel similarity region (USAN).
[0085] The USAN area is largest when the circular template is completely within the background or target. Figure 3 As shown in (a);
[0086] As the circular template moves towards the edge, the area of the USAN region decreases, such as... Figure 3 As shown in (b);
[0087] When the center of the circle is at the edge, the area of the USAN is very small, such as... Figure 3 As shown in (c);
[0088] The area of USAN is minimized when the center of the circle is at a corner point, such as... Figure 3 As shown in (d);
[0089] Therefore, the area of the USAn at each point in the image is used as a measure of the significance of the feature at that point; the smaller the USAn area, the more significant the feature. Figure 3 As shown.
[0090] Therefore, the calculation process for the area of the kernel value similarity region is as follows:
[0091] Compare the grayscale value of each pixel within the circular template with the grayscale value of the center pixel of the circular template to obtain the pixels that have the same or similar grayscale value as the center pixel of the template. The calculation formula is as follows:
[0092]
[0093] Where r is the center pixel of the circular template, r0 is any pixel within the circular template, I(r) is the gray value of the center pixel r of the circular template, and I(r0) is the gray value of any pixel r0 within the circular template.
[0094] All pixels with the same or similar gray values to the center of the template are grouped into a kernel value similarity region;
[0095] The area of the kernel value similarity region is calculated using the following formula:
[0096]
[0097] Where n(r0) represents the area of the kernel value similarity region centered at r.
[0098] Therefore, to extract the road edge, the area of the USAN zone is generally as follows: Figure 3 As shown in (c): the area of USAN occupies about half of the entire circular template.
[0099] Step 2: Calculate the OTSU threshold of the entire grayscale image using the Otsu method;
[0100] For OTSU, first calculate the background pixel ratio w0, the foreground pixel ratio w1, the average gray level of the background u0, and the average gray level of the foreground u1. Then, combine these with the formula to obtain the OTSU threshold g, and then combine with the following formula:
[0101] g = w0·w1·(u0-u1) 2
[0102] The OTSU threshold g is obtained, and the function of threshold g is to obtain the average gray value of the entire image.
[0103] Step 3: Compare the threshold values and extract the road edges using the Susan operator. The specific steps are as follows:
[0104] Step 3.1: Determine the starting point of the road edge;
[0105] Because the acquired grayscale image is distorted at a distance, the first consideration in algorithm design is to determine the starting point of the road edge at the bottom of the image. Simply put, the starting point of the road edge is the edge point between the black tape and the white foam board, such as... Figure 4 As shown. Therefore, after observing the acquired grayscale image, it was confirmed that the direction of line finding is from near to far, and the circular template of the Susan operator has a certain size. Therefore, this invention selects the 116th row of the image as the starting line. Therefore, the specific steps for the starting point of the road edge are as follows:
[0106] Step A1: Select the pixel at the bottom row (row 116) of the image as point A from all pixels at the vertical center position of the image. Figure 4 80 columns ( Figure 4 The K-line is a line connecting all 80 columns of pixels, with the pixel at point A being the starting row;
[0107] Step A2: First, compare the grayscale value of point A with the OTU threshold g. Set a threshold t for this difference. The main function of threshold t is to filter out some obvious noise and reduce unnecessary calculations. If the difference is too large, it indicates the presence of noise, and the point is directly removed. If the difference is less than threshold t, then compare the grayscale value of point A ( Figure 5 (red dot) and circular template ( Figure 5 The grayscale values of each image pixel within the region centered at the red dot are compared. If the difference between the grayscale value of a pixel within the template and the grayscale value of point A is less than a certain value, then that pixel is considered to have the same or similar grayscale value as the kernel. The number of pixels with similar grayscale values is counted, which is the area of the USAn region centered at point A.
[0108] After obtaining the area of the USAn region at point A, compare whether the current USAn area value is less than or equal to the threshold T (which is half the area of the entire circular template, 18 pixels; unlike the t above, T here is used to constrain edge quality). If this condition is not met, shift one unit to the left to obtain point B, as shown below. Figure 5 As shown, first compare the difference between the gray value at point B and the OTU threshold g. If the difference is greater than the threshold t, then continue comparing the gray value at point B. Figure 4 (white dots in the middle) and circular template ( Figure 4 The grayscale values of each pixel within the circle centered at point B are compared, and the number of pixels with similar grayscale values is counted. This counts as the area of the USAn region centered at point B. The region is then checked to see if this USAn area is less than or equal to a threshold T (half the area of the entire circular template, 18 pixels). If this condition is not met, the horizontal search continues until the USAn region area is less than or equal to the threshold T. Figure 6 As shown, the grayscale value of the middle pixel of the circular template is 141. If a similar point is defined as having an absolute grayscale difference of less than 15, then the USAn region area of that point is 18 pixels. The search stops when the above requirement is met. The final point where the search stops is the starting point of the road edge. Figure 7 Points C and D are shown.
[0109] Step 3.2: Determine the road edge points for each row of pixels;
[0110] Because roads are continuous, the search for road edge points in each subsequent row can be performed by looking near the column number of the edge points in the previous row. Specifically:
[0111] Step B1: Use the column containing the starting point of the road edge as the reference;
[0112] Step B2: Use the Susan operator to perform a horizontal search on the next row to find pixels whose gray value and the difference between the pixel and the OTSU threshold are less than the threshold t.
[0113] Step B3: Calculate the area of the kernel value similarity region for each pixel found in step B2;
[0114] Step B4: Compare the area of the kernel value similarity region obtained in step B3 with the threshold T. If the area is less than the threshold T, stop the column search for that row and obtain the left and right road edge points corresponding to that row.
[0115] Step B5: Using the left and right road edge points obtained in step B4 as a reference, repeat steps B2-B4 to obtain the next row of road edge points until the road edge points corresponding to each row of pixels in the grayscale image are obtained.
[0116] For example, if the column number of the left road edge starting point (point C) in row 116 is 14, then the number of columns to search for the left road edge point in row 115 is 9-19 (14 plus or minus 5). That is, starting from column 14 and moving right to column 19, the difference in grayscale values is compared to see if it is less than a threshold t. If it is less than the threshold t, the Susan operator is used for a horizontal search. During the search, if the area of the USAn region of any pixel is less than or equal to 18 pixels, the search stops. If no match is found, the difference in grayscale values is compared starting from column 14 and moving left to column 9. If it is less than the threshold t, the Susan operator is used for a horizontal search. During the search, if the area of the USAn region of any pixel is less than or equal to 18 pixels, the search stops. The same logic applies to the right road edge starting point. The two left and right road edge points found at this point are the left and right road edge points of row 115. Similarly, the complete road edge points can be extracted at the end. Figure 8 As shown by the two white lines; the centerline of the road can be obtained from the left and right road edge points, as shown in the image. Figure 8 As shown by the black line.
[0117] The SUSAN operator has some unique features compared to other edge and corner detection operators:
[0118] (1) When using the SUSAN operator to detect edges and corners, it is not necessary to calculate the derivative, which makes the SUSAN operator more robust to noise.
[0119] (2) The SUSAN detection operator can provide edge accuracy that is independent of the template size. In other words, the calculation of the minimum USAN area is a relative concept and is independent of the template size, so the performance of the SUSAN edge operator is not affected by the template size.
[0120] (3) The selection of control parameters is simple and has little arbitrariness, making it easy to automate the selection process.
[0121] However, in the field of autonomous driving, lane line extraction typically involves using the traditional Susan operator to convolve the entire image and then using Hough transform to extract lane lines. This process involves searching the entire image, resulting in a large computational load and difficulty in extracting relevant lane line information. The lane line detection proposed in this invention directly uses the Susan operator for edge detection in local images, significantly reducing computational load, simplifying unnecessary steps, accelerating the overall system's computation speed, and directly extracting the relevant lane line positions for direct application in the control system.
[0122] Step 4: Calculate the average offset of the car based on the road edge. The calculation steps are as follows:
[0123] Step 4.1: Calculate the offset of each row in the road grayscale image. The formula for calculating the offset of each row is:
[0124] Offset per row = (column number of left road edge points + column number of right road edge points) / 2 * column number of the center line in the image.
[0125] Step 4.2: After obtaining the offset of each row, sum up the offsets of each row to obtain the total offset;
[0126] Step 4.3: Due to the blurring of distant areas in the image, road edges are considered valid. Therefore, the number of rows with valid road edges is called the valid rows. The average offset is then calculated based on the total offset and the number of valid rows. The final formula for calculating the average offset is:
[0127] Average offset = Total offset / Number of valid rows.
[0128] Step 5: Input the average offset of the car into the fuzzy PID controller, and perform Simulink modeling as follows. Figure 9 As shown, the steering of the car's servo motor is controlled by the PWM wave output by the fuzzy PID controller. The specific process is as follows:
[0129] Step 5.1, Error Quantization: Using the average offset e as input, before fuzzification, e (deviation) and ec (deviation change rate) need to be quantized. Quantization means mapping the input quantity to a certain numerical level using a quantization function. As the car moves, it continuously updates the current servo deviation and deviation change rate. If the deviation measurement range is [-30, 30], we can map the car deviation E to the range of -3 to 3. -30 corresponds to -3, and 30 corresponds to 3. Therefore, all deviations will be mapped to the range of -3 to 3. Similarly, if the change range of ec is twice that of e, from [-60, 60], we can also quantize it to the interval [-3, 3]. The quantization formulas for E and EC are: E = 6e / (max - min), Ec = 6ec / (max - min), where e and ec are the actual deviation and deviation change rate, and E and EC are the mapped quantized deviation and deviation change rate.
[0130] Step 5.2, Error Fuzzification: After mapping E and EC to the interval from -3 to 3, determine the fuzzy subsets: negative large [NB], negative medium [NM], negative small [NS], zero [ZO], positive small [PS], positive medium [PM], and positive large [PB]. These seven linguistic variables can express the fuzzy subsets with sufficient precision. Define the fuzzy subsets of E and EC as {NB, NM, NS, ZO, PS, PM, PB}, then divide each endpoint into -3 (NB), -2 (NM), -1 (NS), 0 (ZO), 1 (PS), 2 (PM), and 3 (PB). Then, we assign specific values of the membership degrees of E and EC to their respective members through membership functions, with a value range of [0,1].
[0131] Through such Figure 10 The triangular membership formula shown yields the membership degree between the current e and ec. If the quantized value of input e is E = 2.4, then the values of the green and red lines are 0.4 and 0.6 respectively. These two are the membership degrees, which are also probabilities. This means that the probability of the input belonging to PB is 0.6, and the probability of it belonging to PM is 0.4. The membership degree of EC is determined in the same way.
[0132] Step 5.3, Parameter Fuzzy Inference: Based on the membership degree of E and EC, the magnitude of the output is obtained by looking up the table, i.e., NB, NS, etc. The core work of fuzzy inference is to establish an inference table, which is a table of the corresponding parameter △KP. By looking up the table, the membership degree of parameter △KP can be obtained. Similarly, the membership degrees of parameters △KI and △KD can be obtained.
[0133] Specifically: By combining E and EC, query the fuzzy rule tables corresponding to parameters △KP, △KI, and △KD respectively, to... Figure 11Taking the fuzzy table of parameter △KP as an example, the membership degree of the current parameter △KP is determined. If the input E is 2.4 and EC is 0.6, then the membership degree of E is 0.6 (PM) and 0.4 (PB), and the membership degree of EC is 0.6 (PS) and 0.4 (ZO). Then, the membership degrees of E and EC are combined pairwise and a table is looked up to obtain the following results:
[0134] 0.24 (NM) = 0.4 (ZO) * 0.6 (PM)
[0135] 0.76(NB)=0.4(ZO)*0.4(PB)+0.6(PS)*0.6(PM)+0.6(PS)*0.4(PB)
[0136] Similarly, the membership degrees of △KI and △KD can be obtained.
[0137] Step 5.4: Obtain parameter values: Multiply the membership degree of each parameter obtained by fuzzy inference by the corresponding membership value, and then sum them to obtain the parameter values of parameters △KP, △KI, and △KD. Then, obtain the values of output parameters KP, KI, and KD according to the set gain of each output parameter.
[0138] In other words, the process involves clarification. The quantized parameters △KP, △KI, and △KD are obtained by multiplying the membership degree and membership value of △KP, △KI, and △KD respectively. Taking △KP as an example, KP = 0.24*(-2) + 0.76*(-3) (-1.09). Finally, the actual output parameter KP value is obtained through the gain coefficient: KP = KP*5 = -5.5. Similarly, the values of KD and KI can be obtained.
[0139] Step 5.5, Output Control: After obtaining the values of output parameters KP, KI, and KD, a traditional PID controller is used to output a PWM wave. After passing through the PWM limiter [600, 900], the wave is output to the control variable, i.e., the servo motor, so as to respond quickly and realize the steering of the car.
[0140] The advantages of fuzzy PID control, as is generally known, are:
[0141] Fuzzy PID controllers are closely related to traditional PID controllers, but the difference lies in the fact that traditional controllers require familiarity with the model structure of the controlled object, while fuzzy controllers, due to their nonlinear characteristics, offer superior control performance. For time-varying systems, the stability and dynamism of the control results can be improved if fuzzy controllers are used effectively.
[0142] Step 6: The speed control of the vehicle is achieved by controlling the motor speed. A fuzzy PID controller based on a sliding filter is used, which adds an extra feedback step by incorporating a sliding filter. This is then modeled using Simulink. Figure 12 As shown above. After inputting the target speed Speed, the desired real-time speeds Speed1 and Speed2 of the two motors are further calculated using the offset, where Speed1 = Speed + e * K and Speed2 = Speed - e * K, where e is the offset and K is a constant coefficient. This achieves differential speed control between the two motors, making the vehicle's movement smoother. The final output is obtained by measuring the speed through sensors. In the feedback process, the obtained speed result is subjected to sliding filtering, then subtracted from the target speed to update the deviation e and the rate of change of deviation ec, and then the next round of control update is performed. The specific steps are as follows:
[0143] Step 6.1 Error Quantization: Calculate the real-time expected speed of each motor of the car based on the set target speed and average offset. Use the real-time expected speed as the input of the fuzzy PID controller, and quantize the deviation and rate of change of the car speed to obtain the deviation and rate of change of the deviation after mapping quantization.
[0144] Step 6.2: Determine the 7 linguistic variables of the fuzzy subset, and assign the deviation E and the rate of change of deviation EC to their respective membership degrees through membership functions;
[0145] Step 6.3, Parameter Fuzzy Inference: Based on the membership degree of E and EC, the magnitude of the output is obtained by looking up the table, i.e., NB, NS, etc. The core work of fuzzy inference is to establish an inference table, which is a table corresponding to the parameter △KP. By looking up the table, the membership degree of parameter △KP can be obtained. Similarly, the membership degrees of parameters △KI and △KD can be obtained.
[0146] Step 6.4: Obtain parameter values: Multiply the membership degree of each parameter obtained by fuzzy inference by the corresponding membership value, and then sum them to obtain the parameter values of parameters △KP, △KI, and △KD. Then, obtain the values of output parameters KP, KI, and KD according to the set gain of each output parameter.
[0147] Step 6.5, Output Control: After obtaining the values of output parameters KP, KI, and KD, a traditional PID controller is used to output a PWM wave, which is then limited and output to the drive to control the speed of the vehicle.
[0148] Step 6.6 Feedback Input: The current speed of the vehicle is collected in real time, and a sliding filter is used for sliding filtering during the feedback process. The current speed value obtained by sliding filtering is fed back to the input of the fuzzy PID controller. Then, it is subtracted from the target speed to update the deviation e and the rate of change of deviation ec, and then the next round of control update is performed.
[0149] The advantages of a sliding filter are:
[0150] ① Data stability: Sliding filters smooth data by calculating the average of a series of data points, thereby reducing noise and abrupt changes in the data. This improves data stability, making the data more reliable and predictable.
[0151] ② Real-time performance: Sliding filters can process data in real time and update the filtering results instantly. This is crucial for applications requiring real-time monitoring and feedback, such as sensor data processing and real-time control.
[0152] ③ Simple and easy to implement: The implementation of a sliding filter is relatively simple. It only requires establishing a data buffer and calculating the average value of the data, which makes the sliding filter widely used in embedded systems and real-time applications.
[0153] ④ Wide applicability: Sliding filters are suitable for various types of data, including analog and digital signals.
[0154] ⑤ Adjustability: The smoothness of the sliding filter can be controlled by adjusting the size of the data buffer. A larger buffer provides a smoother result, while a smaller buffer provides a faster response.
[0155] This embodiment proposes a combination of fuzzy PID control and sliding filter. Fuzzy PID control has a fast response speed and is often used in nonlinear control. However, in actual use, there is often interference in the feedback. Therefore, sliding filter fuzzy PID control is proposed to effectively filter out some noise and improve the final output accuracy.
[0156] In this example, the implementation process of the sliding filter is as follows:
[0157] Set the sampled values of multiple car speeds into a queue of fixed length;
[0158] The sampled value of the car's current speed, collected in real time, is placed in column 1, and the data from the first position in the original queue is discarded.
[0159] The current velocity value after sliding filtering is obtained by averaging multiple sampled data in the queue using allicin.
[0160] For example, consider 7 sampled values as a queue with a fixed length of 7. Each time a new data point is sampled, it is added to the tail of the queue, and the previous data point at the head of the queue is discarded. The arithmetic mean of the 7 data points in the queue yields the new filtering result.
[0161] To verify the feasibility of the sliding filter, the input waveform in the Simulink model is a synthesis of three signals, corresponding to step signals of 70ε(t) and 80ε(t-140), and random noise with amplitudes in the range of [-5, 5]. The waveforms with and without the filter are shown below. Figure 13 As shown. The desired input speed is set to 100. When the motor outputs, the output speed is measured using an coded sensor. Then, 10MHz random noise is artificially introduced to simulate the interference caused by the motor movement, with an amplitude change of [-5, 5]. This noise is then added to the measured speed and input into a sliding filter. The resulting numerical output is fed back to the controller for the next round of control quantity updates.
[0162] like Figure 14 The diagram shows the output waveforms of the three controllers, corresponding to the sliding filter fuzzy PID controller (red line), fuzzy PID control (blue line), and traditional PID controller (green line), respectively. Compared with the traditional PID controller, the sliding filter fuzzy PID controller has a faster waveform response and smaller overshoot, and the output is smoother than that of the fuzzy controller.
[0163] This embodiment employs a fuzzy PID control system for a trolley motor based on a sliding filter. Compared to existing technologies, it offers the following advantages: By integrating the fuzzy PID control algorithm with a filter, rule-based PID control improves the robustness of closed-loop control, reduces false closed-loop events, and enhances output accuracy and stability. PID control based on fuzzy rules further improves the robustness of closed-loop control, strengthens the anti-interference capability of the motor control system, and reduces false closed-loop events. The moving average filtering algorithm can eliminate sampling deviations caused by occasional impulse interference, thus improving system stability. Addressing the difficulty in precise control of nonlinear systems and systems with uncertain models commonly used in existing control systems, the fuzzy PID control algorithm allows for model quantization and precise control even when the control model is unknown. Using a target desired speed as the controller input allows for obtaining satisfactory dynamic characteristics of the transient process. Adding a sliding filter during speed feedback prevents excessive speed detection deviations, contributing to system stability.
[0164] In summary, this invention uses the Otsu method to divide a road grayscale image into foreground and background parts. Then, it employs the Susan operator and compares the threshold obtained from OTSU to perform a sliding search on a specified region to extract road edges. The average offset is then calculated based on these road edges. This average offset is used as input to a fuzzy PID system, and the output PWM wave is used to control the servo motor, thus steering the vehicle. Finally, the actual desired speed is calculated based on the target speed and the average offset, and this is used as input to a sliding fuzzy PID system. The output PWM wave is used to control the motor, i.e., the vehicle's speed. In other words, this invention combines the Susan operator with OTSU for road edge extraction, offering the advantage of quickly extracting edges with obvious characteristics from the surrounding environment. The lane markings using grayscale images exhibit good environmental adaptability, and the Susan operator is insensitive to noise and has strong anti-interference capabilities against local noise. The Susan operator is used to retrieve lane marking information from local images and feed this information back to the system. The resulting accurate average offset is then input into the servo motor's fuzzy PID controller. Compared to a conventional PID controller, the fuzzy PID controller improves the overall system response speed, ensuring the control system's dynamism; it also significantly enhances noise immunity and achieves higher edge detection accuracy. In speed control, a fuzzy PID control system based on a sliding filter, combined with a feedback mechanism, smooths the entire motor control process, improving both accuracy and response speed.
[0165] The technical solution provided by this invention has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this invention. It should be noted that those skilled in the art can make several improvements and modifications to this invention without departing from the principles of this invention, and these improvements and modifications also fall within the protection scope of the claims of this invention.
Claims
1. An adaptive line-following method for a vehicle based on the Susan operator and sliding fuzzy PID, characterized in that, Includes the following steps: Step 1: Obtain a grayscale image of the road and obtain the threshold G for grayscale value difference and the threshold T for constraining edge quality; Step 2: Calculate the OTSU threshold of the entire grayscale image using the Otsu method; Step 3: Compare the threshold values and extract the road edges using the Susan operator; Step 4: Calculate the average offset of the car based on the road edge; Step 5: Input the average offset of the car into the fuzzy PID controller and control the steering of the car's servo motor according to the output PWM wave; Step 6: Calculate the actual expected speed based on the target speed and average offset of the car, input the actual expected speed of the car into the fuzzy PID controller based on the sliding filter, and control the speed of the car according to the output PWM wave.
2. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 1, characterized in that, The process of setting the threshold G for grayscale value difference in step 1 is as follows: Step 1.1: Acquire grayscale images of the road using a grayscale camera; Step 1.2: Observe the difference in grayscale values at the road edges of the collected road grayscale image; Step 1.3: Based on the circular template of the Susan operator, compare the gray values of the pixels inside the circular template with the gray values of the pixels at the center of the circular template to obtain the threshold G that makes the area of the kernel value similarity region account for half of the area of the entire circular template, and use half of the area of the entire circular template as the threshold T for constraining the edge quality.
3. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 2, characterized in that, The calculation process for the area of the kernel value similarity region is as follows: Compare the grayscale value of each pixel within the circular template with the grayscale value of the center pixel of the circular template to obtain the pixels that have the same or similar grayscale value as the center pixel of the template. The calculation formula is as follows: Where r is the center pixel of the circular template, r0 is any pixel within the circular template, I(r) is the gray value of the center pixel r of the circular template, and I(r0) is the gray value of any pixel r0 within the circular template. All pixels with the same or similar gray values to the center of the template are grouped into a kernel value similarity region; The area of the kernel value similarity region is calculated using the following formula: Where n(r0) represents the area of the kernel value similarity region centered at r.
4. The adaptive line-following method for a car based on the Susan operator and sliding fuzzy PID according to claim 1, characterized in that, In step 2, the formula for calculating the OTSU threshold of the entire grayscale image using the Otsu method is as follows: g=w0·w1·(u0-u1) 2 Where g is the OTSU threshold, w0 is the pixel ratio of the background image, w1 is the pixel ratio of the foreground image, u0 is the average gray level of the background image, and u1 is the average gray level of the foreground image.
5. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 1, characterized in that, The specific steps for extracting the road edge in step 3 are as follows: Step 3.1: Determine the starting point of the road edge; Step 3.2: Determine the road edge points of each row of pixels.
6. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 5, characterized in that, The specific process for determining the starting point of the road edge in step 3.1 is as follows: Step A1: Locate the pixel in the middle column of the bottom row of the grayscale image of the road; Step A2: Move horizontally one pixel at a time from the middle column to both sides. Compare the difference between the gray value of each pixel and the OTSU threshold. If it is less than the threshold t, calculate the area of the kernel value similarity region for each pixel. If it is greater than the threshold t, continue to move to the next pixel and repeat the above process until the area of the kernel value similarity region is less than the threshold T. Stop the column search for that row to obtain the starting point of the road edge.
7. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 6, characterized in that, The specific process for determining the road edge points of each row of pixels in step 3.2 is as follows: Step B1: Use the column containing the starting point of the road edge as the reference; Step B2: Use the Susan operator to perform a horizontal search on the next row to find pixels whose gray value and the difference between the pixel and the OTSU threshold are less than the threshold t. Step B3: Calculate the area of the kernel value similarity region for each pixel found in step B2; Step B4: Compare the area of the kernel value similarity region obtained in step B3 with the threshold T. If the area is less than the threshold T, stop the column search for that row and obtain the left and right road edge points corresponding to that row. Step B5: Using the left and right road edge points obtained in step B4 as a reference, repeat steps B2-B4 to obtain the next row of road edge points until the road edge points corresponding to each row of pixels in the grayscale image are obtained.
8. The adaptive line-following method for a car based on the Susan operator and sliding fuzzy PID according to claim 1, characterized in that, The steps for calculating the average offset of the car in step 4 are as follows: Step 4.1: Calculate the offset of each row in the grayscale image of the road; Step 4.2: Sum the offsets of each row to get the total offset; Step 4.3: Calculate the average offset based on the total offset and the number of valid rows.
9. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 1, characterized in that, In step 5, the average offset of the car is input into the fuzzy PID controller. The specific process of controlling the steering of the car's servo motor based on the PWM wave output by the fuzzy PID controller is as follows: Step 5.1, Error Quantization: Take the average offset as input and quantize the deviation e and the rate of change of deviation ec of the car servo motor to obtain the mapped and quantized deviation E and the rate of change of deviation EC. Step 5.2, Error Fuzzification: Determine the 7 linguistic variables in the fuzzy subset, and assign the deviation E and the rate of change of deviation EC to their respective membership degrees through membership functions; Step 5.3, Parameter Fuzzy Inference: Obtain the membership degrees of parameters △KP, △KI, and △KD based on the fuzzy rule table determined by E and EC; Step 5.4: Obtain parameter values: Multiply the membership degree of each parameter obtained by fuzzy inference by the corresponding membership value, and then sum them to obtain the parameter values of parameters △KP, △KI, and △KD. Then, obtain the values of output parameters KP, KI, and KD according to the set gain of each output parameter. Step 5.5, Output Control: After obtaining the values of output parameters KP, KI, and KD, a traditional PID controller is used to output a PWM wave, which is then limited and output to the drive to rotate the servo motor.
10. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 1, characterized in that, In step 6, the actual desired speed is calculated based on the target speed and average offset of the vehicle. The specific steps for inputting the actual desired speed of the vehicle into the fuzzy PID controller based on the sliding filter and controlling the vehicle speed according to the output PWM wave are as follows: Step 6.1 Error Quantization: Calculate the real-time expected speed of each motor of the car based on the set target speed and average offset. Use the real-time expected speed as the input of the fuzzy PID controller, and quantize the deviation and rate of change of the car speed to obtain the deviation and rate of change of the deviation after mapping quantization. Step 6.2, Error Fuzzification: Determine the 7 linguistic variables in the fuzzy subset, and assign the deviation E and the rate of change of deviation EC to their respective membership degrees through membership functions; Step 6.3, Parameter Fuzzy Inference: Obtain the membership degrees of parameters △KP, △KI, and △KD based on the fuzzy rule table determined by E and EC; Step 6.4: Obtain parameter values: Multiply the membership degree of the parameter by the corresponding membership value, and then sum them to obtain the parameter values of △KP, △KI, and △KD. Then, according to the set gain of each output parameter, obtain the values of output parameters KP, KI, and KD. Step 6.5, Output Control: After obtaining the values of output parameters KP, KI, and KD, a traditional PID controller is used to output a PWM wave, which is then limited and output to the drive to control the speed of the vehicle. Step 6.6 Feedback Input: The current speed of the vehicle is collected in real time and processed by a sliding filter. The current speed value obtained by the sliding filter is fed back to the input of the fuzzy PID controller. The deviation and the rate of change of deviation are updated by subtracting the target speed, and then the next round of speed control is performed.
11. The adaptive tracking method for a car based on the Susan operator and sliding fuzzy PID according to claim 10, characterized in that, The implementation process of the sliding filter is as follows: Set the sampled values of multiple car speeds into a queue of fixed length; The sampled value of the car's current speed, collected in real time, is placed at the end of the queue, and the data at the beginning of the queue is discarded. The current velocity value after sliding filtering is obtained by averaging the multiple sampled data in the queue.
Citation Information
Patent Citations
Intelligent vehicle control system and method based on gray scale camera detection
CN111123954A
Planning in mobile robots
US20230089978A1