Talking about the control strategy of smart car

Expected goals of the experiment:

Realize the cursor tracking and positioning of the smart car, realize the smooth speed control of the smart car, and can also intelligently avoid obstacles.

experiment platform:

KL26 microcontroller, programming language C, OV7725 camera, SHARP infrared sensor, steering gear, motor,
frame, etc.

Experimental conditions:

Under conditions without strong sunlight.

Control algorithm: (increment, position)

  1. Steering gear control algorithm:
    After the smart car collects image data, in order to enable the smart car to quickly locate the cursor position and adjust the direction of the car body, it is widely used in industrial sites because of its clear formula and good control effect . In the steering gear control, the PD control algorithm in the PID control algorithm is adopted. PID is a traditional industrial control algorithm. The smart car has greater inertia in the steering gear control, so the direction control has hysteresis. In order to suppress the jitter of the car body during the direction change and the integral dead zone of the control quantity output, for this reason Use PD control algorithm to adjust. If PID adjustment is used, the integral term will accumulate continuously, which will cause integral saturation. Integral saturation means that the output of the control quantity reaches the maximum under the continuous accumulation of e(t), but the error is still In the accumulation, this will cause the integral term to be too large, even after the error becomes reverse, the output of the control quantity cannot be reduced in time due to the accumulation of the integral term, causing the entire system to oscillate. The formula of the analog system PD regulator is shown in formula (1).

          P(t)= Kp[e(t) +Td *de(t)/ dt] (1)
    

In the formula, P(t)——The output signal of the regulator (the output PWM duty ratio of this system);
e(t)——The deviation signal of the regulator, (the target median of the collected images of this system and the centerline of the camera deviation);
proportionality coefficient Kp-- regulator;
differential time Td-- regulator;

The formula after computer discretization is shown in (2).

      P(k)=Kp{E(k)+(Td /T)[E(k)-E(k-1)]} (2)

In the formula, T—— sampling period;
E(k)—— deviation at the kth sampling;
E(k-1)—— deviation at the
kth sampling ; k—— sampling sequence number;
P(t) ——The output of the k-th sampling regulator;
2. Motor control algorithm:
PID algorithm includes position PID and incremental PID, where position PID is suitable for one-to-one correspondence between valve opening and output, such as normalization After conversion, if the control quantity output is 0.5, the valve will be half open, and the control quantity output will be 0, then the valve will be fully closed (normally closed valve when there is no signal). For example, positional PID can be used for motors and steering gears. The output of incremental PID is the increment of the control quantity, only one increment at a time, which is used to control some actuators with integral links, such as stepper motors. They are all PID adjustments but in different forms. The advantage of the incremental type is that it only outputs one control increment each time, and its misoperation is very small. When the system fails, it will not produce large fluctuations; the incremental type will not cause the problem of integral saturation, because the increase is deduced. After the measurement formula, the increment of each output is only related to e(k), e(k-1), e(k+1), and has nothing to do with the cumulative amount of error, so there will be no problem of error accumulation; When switching between manual and automatic control output, the system will not oscillate due to excessive changes in the set value. And when using location type, may also be controlled according to some strategy windup problems, such as integration limiter, output is about integral term control within a certain range, do not let it be too large, in addition to the integration points
from items such as integration Control algorithm.
The positional deformation is used when controlling the motor of the smart car, and the derivation is as follows:
Current output:
Insert picture description here
Last output:
Insert picture description here
Difference (3) and (4):
Insert picture description here
Obtain: The
Insert picture description here
above positional deformation does not require integration The accumulation of terms only needs the last output and the three consecutive deviations of e(k), e(k-1), and e(k+1).
Among the above algorithms, there are proportional coefficients, integral coefficients, and differential coefficients. The quality of these three quantities affects the operation of the entire system. The choice of the three parameters is very critical. Modeling can be used for analysis. In addition, industrial sites are generally Use experience to debug parameters. This method is used when the system accuracy is not high.
3. Camera control algorithm: After the
camera collects the image, the image data is processed, and the data from the camera is decompressed to a binary two-dimensional array. The control of the camera mainly operates this array. This two-dimensional array represents an image. Our purpose is to extract the coordinates of the cursor center point in the image collection, because the experiment is ideally without the influence of strong sunlight, our image will only have the image produced by the cursor . We traverse each pixel of the two-dimensional array (here an array of data represents a pixel), when the pixel value jumps: when the pixel value changes from 0 to 1, remember this subscript, and then at 1. When changing to 0, remember the subscript at this time, and then make a difference to get the width of the current line, continue to traverse each line, and then use the bubble algorithm to get the widest line of the cursor, which is the ordinate of the cursor, and then set the widest The abscissa of the left and right transition points of a row is added and divided by 2 plus the leftmost transition point to get the abscissa of the cursor center. Finally, the value of the ordinate is brought into the steering gear for PD calculation. Although this process is ideal, there will still be some noise in the image unavoidable, so the image filtering method is adopted, because we don't need clear image information for image information, as long as the coordinate position, Gu will have Gaussian blur. A brief description of Gaussian blur: We have traversed the pixel as the center, take the neighboring pixels of this pixel, and assign each pixel a weight that satisfies a specific distribution and finally add the value to judge.
4. Obstacle avoidance control algorithm:
The main problems encountered in obstacle avoidance are misjudgment and the contingency of the evaluation index. Therefore, four sensors are used to reduce the contingency, and the data corresponding to each sensor is assigned a weight that matches the actual situation. It is thought that due to the different positions of the sensors, Their evaluation indicators are necessarily different and cannot be compared. The second point is the quality of the data that has just returned. For some reasons, the data collected by the sensor will be noisy, so the moving average filtering method is used to remove the burrs of these data. Moving average filtering: Since the average filtering has to collect a certain amount of data for weighted average each time, it will take a certain amount of time, while the moving average filtering uses the first-in-first-out principle of queuing for filtering. Great operating efficiency.

Guess you like

Origin blog.csdn.net/weixin_42595206/article/details/103348040