Balance car control method and system
Through data acquisition and preprocessing, combined with Kalman filtering and natural heuristic algorithms to optimize PID control parameters, the problem that PID controller parameters cannot be adaptively changed in real time is solved, and the stability and control effect of the balance bike in different environments is optimized.
Patent Information
- Application Number
- CN202510572524.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-05-06
AI Technical Summary
In the existing balance bike control methods, the parameters of the PID controller cannot be adaptable in real time, making it difficult to maintain optimal control effects, affecting the stability of the balance bike.
Through data acquisition and preprocessing, the Kalman filtering algorithm is used to estimate the attitude angle of the balancing vehicle, and the balance performance prediction model is trained. Combined with the natural heuristic algorithm to obtain the optimal PID control parameter combination, and the neural network model is used to capture complex data relationships to achieve real-time parameter optimization.
The stability and control effect of the balance bike in different environments is improved, ensuring that the control effect is always in the best state.
Smart Images

Figure CN120428629A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of PID control technology, and more particularly to a balancing vehicle control method and system. Background Art
[0002] With the rapid development of science and technology, self-balancing scooters, as a new type of short-distance transportation tool, have been favored by people for their environmental protection and convenience. However, existing self-balancing scooters lack stability during driving and are prone to rollover. Therefore, existing self-balancing scooters are mostly controlled by PID controllers. The parameters of the PID controller in the self-balancing scooter need to be determined through experiments and debugging, and usually need to be adjusted according to the dynamic characteristics of the scooter and the feedback from the sensor. By reasonably adjusting the PID parameters, the self-balancing scooter can achieve automatic balance quickly and stably, thereby achieving precise control and movement.
[0003] However, in the existing process of controlling the balance vehicle through the PID controller, the controller's setting parameters cannot be adaptively changed in real time, making it difficult to maintain the optimal control effect. Different parameters in PID control have different effects on the control effect, which in turn affects the balance performance of the balance vehicle.
[0004] In view of this, the present invention provides a control method and system for a balancing vehicle, which performs real-time analysis on the parameters in PID control to obtain the optimal parameters, thereby ensuring that the control effect of the balancing vehicle is always in the best state, thereby ensuring the stability of the balancing vehicle in different driving environments. Summary of the Invention
[0005] In order to overcome the above-mentioned defects of the prior art, the present invention provides a method and system for controlling a balancing vehicle to solve the problems existing in the above-mentioned background technology.
[0006] The present invention provides the following technical solution: a method for controlling a balancing vehicle, comprising the following steps:
[0007] Step S1: Data collection and preprocessing: Collect historical data and real-time data of the balance vehicle and perform preprocessing operations;
[0008] Step S2: Using the Kalman filter algorithm to estimate the attitude angle of the self-balancing vehicle at the next moment, and training a balance performance prediction model based on the historical data of the self-balancing vehicle;
[0009] Step S3: Introducing the balance performance prediction model trained in step S2 into the nature-inspired algorithm, improving the nature-inspired algorithm, and obtaining the optimal PID control parameter combination based on the improved nature-inspired algorithm;
[0010] Step S4: Perform PID control on the balancing vehicle at the next moment based on the optimal PID control parameter combination.
[0011] Preferably, the real-time data includes the current posture data and driving data of the balance vehicle; the posture data includes the three-dimensional angular velocity and acceleration of the balance vehicle; the driving data includes the position, driving speed, driving distance and driving environment of the balance vehicle; the historical data includes the historical posture data, historical driving data, historical PID control parameter combination and corresponding historical performance data of the balance vehicle. The historical performance data includes the maximum tilt angle at which the balance vehicle can maintain balance in a stationary state, the time taken for the balance vehicle to recover from disturbance, and the duration and position offset of the balance vehicle to maintain balance on different slopes.
[0012] Preferably, the specific method of training the balance performance prediction model based on the historical data of the balance vehicle in step S2 is:
[0013] The PID control parameter combination, posture data, and driving data at time t in the historical data are used as a set of analysis data. T sets of analysis data are collected in advance, i.e., the PID control parameter combination, posture data, and driving data at T times. Each set of analysis data and the corresponding balance performance index are converted into a set of feature vectors.
[0014] Each set of feature vectors is used as the input of the balance performance prediction model. The balance performance prediction model uses a set of predicted balance performance indices corresponding to each set of analysis data as output, and the actual balance performance index corresponding to each set of analysis data as the prediction target. The actual balance performance index is the pre-collected balance performance index corresponding to the analysis data. The balance performance prediction model is trained with minimizing the sum of the prediction errors of all analysis data as the training goal, and the training is stopped when the sum of the prediction errors reaches convergence.
[0015] Preferably, the prediction error is expressed as: WC p =yc_xn p -acu_xn p Among them, WC p Indicates the prediction error of the pth group of analysis data, p represents the group number of the feature vector corresponding to the analysis data, yc_xn p Indicates the predicted balance performance index corresponding to the p-th group of analysis data, acu_xn p represents the actual balance performance index corresponding to the pth group of analysis data; p = 1, 2, 3, ..., T.
[0016] Preferably, the PID control parameter combination is a parameter combination of a PID controller, and the parameters of the PID controller include proportional gain K p , integral gain K i and the differential gain K d ;
[0017] The algorithm form of the PID controller is expressed as:
[0018]
[0019] Among them, u(t) represents the output of the PID controller at time t, e(t) represents the error of the PID controller at time t, τ represents the variable of the integral part, τ∈[0,t].
[0020] Preferably, the balance performance index is obtained as follows:
[0021] Get the maximum static stability angle of the balancing vehicle;
[0022] Get the anti-interference recovery time of the balancing vehicle;
[0023] Get the balance fluctuation of the balance car;
[0024] The balance performance index of the balancing vehicle is obtained based on the maximum static stability angle value, anti-interference recovery time and balance fluctuation of the balancing vehicle.
[0025] Preferably, the balance performance index formula of the balancing vehicle is expressed as:
[0026]
[0027] Among them, Per t Indicates the balance performance index at time t, time all represents the total time from the start of the balancing car to the return to a stable state; k1 and k2 are the corresponding proportional constants; θ max Indicates the maximum static stability angle value, time recover Indicates the anti-interference recovery time, θ b_t represents the equilibrium volatility at time t.
[0028] Preferably, the improved nature-inspired algorithm in step S3 is specifically implemented as follows:
[0029] Step S31: Consider each PID control parameter combination as a bat, randomly select R bats to construct the initial population, that is, the population size is R, and the position of the rth bat is p r , the speed is v r , the sound wave frequency is H r , the loudness of the sound wave is B r , the pulse frequency is I r , the maximum number of iterations λ max ;
[0030] Step S32: determining the fitness function;
[0031] Step S33: Find the optimal position p of the bats in the current population * , and update the positions and velocities of the bats; the optimal position of the bats in the current population is the position of the bat corresponding to the combination of PID control parameters with the maximum fitness value in this iteration;
[0032] Step S34: Generate a random number rand1 between [0, 1]. If rand1 > I r , then perform random flight, and a new position p will be randomly generated near the original optimal position new , otherwise update the positions of the bats according to the bat position update formula;
[0033] Step S35: Generate another random number rand3 on [0, 1]. If rand3 < Br, and the fitness value corresponding to the new optimal position is greater than the fitness value of the original optimal position, then accept this position, take the new position as the current optimal position, and adjust the sound wave loudness to decrease and the pulse frequency to increase;
[0034] Step S36: Determine whether the maximum number of iterations λ max is reached. If the maximum number of iterations is reached, the iteration ends; otherwise, let λ = λ + 1, and loop through steps S32 to S36; when the iteration ends, sort the fitness values of all bats, find the current optimal position, and obtain the combination of PID control parameters corresponding to the bat at the current optimal position as the optimal PID control parameter combination.
[0035] Preferably, the fitness function is expressed as: f r = Per_r; where f r represents the fitness of the combination of PID control parameters corresponding to the r-th bat, and Per_r represents the predicted balance performance index of the combination of PID control parameters corresponding to the r-th bat;
[0036] The method for obtaining the predicted balance performance index is:
[0037] Input the combination of PID control parameters corresponding to the r-th bat and the estimated value of the balance bike attitude angle at the next moment in step S2 into the trained balance performance prediction model to obtain the predicted balance performance index; that is, when the combination of PID control parameters at the next moment is the combination of PID control parameters corresponding to the r-th bat, the predicted balance performance index of the balance bike.
[0038] A balance bike control system includes a data acquisition and preprocessing module, a prediction model training module, a control parameter combination acquisition module, and an intelligent control module;
[0039] The data acquisition and preprocessing module is used to collect the historical data and real-time data of the balance bike and perform preprocessing operations;
[0040] The prediction model training module is used to estimate the attitude angle of the self-balancing vehicle at the next moment using the Kalman filter algorithm, and train the balance performance prediction model based on the historical data of the self-balancing vehicle;
[0041] The control parameter combination acquisition module is used to introduce the balance performance prediction model trained in step S2 into the nature-inspired algorithm, improve the nature-inspired algorithm, and obtain the optimal PID control parameter combination based on the improved nature-inspired algorithm;
[0042] The intelligent control module performs PID control on the balancing vehicle at the next moment based on the optimal PID control parameter combination.
[0043] The technical effects and advantages of the present invention are as follows:
[0044] The present invention is provided with steps S2 and S3, which is conducive to estimating the attitude angle of the balance vehicle at the next moment by adopting the Kalman filter algorithm, and training the balance performance prediction model based on the historical data of the balance vehicle, introducing the balance performance prediction model trained in step S2 into the nature-inspired algorithm, improving the nature-inspired algorithm, and integrating the neural network model into the fitness calculation of the nature-inspired algorithm, which can give full play to the nonlinear and multimodal data modeling capabilities of the neural network and effectively capture complex data relationships; based on the parallel computing processing mechanism, the computing efficiency is improved, and the balance performance of the balance vehicle under different data is predicted through deep learning technology, laying the foundation for the subsequent selection of the optimal PID control parameter combination; by performing real-time analysis of the parameters in the PID control to obtain the optimal parameters, the control effect of the balance vehicle is always guaranteed to be in the best state, thereby ensuring the stability of the balance vehicle in different driving environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a flow chart of the balance vehicle control method of the present invention.
[0046] Figure 2 This is a structural diagram of the balance vehicle control system of the present invention.
[0047] Figure 3 This is a schematic diagram of the PID control of the present invention. DETAILED DESCRIPTION
[0048] The technical solutions of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the present invention. In addition, the forms of the various structures described in the following embodiments are merely examples. The control method and system of a balancing vehicle involved in the present invention are not limited to the various structures described in the following embodiments. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0049] like Figure 1 and Figure 3 As shown, the present invention provides a method for controlling a balancing vehicle, comprising the following steps:
[0050] Step S1: Data acquisition and preprocessing: Collect historical data and real-time data of the balance vehicle and perform preprocessing operations; the real-time data includes the current posture data and driving data of the balance vehicle; the posture data includes but is not limited to the three-dimensional angular velocity and acceleration of the balance vehicle; the driving data includes but is not limited to the position, driving speed, driving distance and driving environment of the balance vehicle; the historical data includes but is not limited to the historical posture data, historical driving data, historical PID control parameter combination and corresponding historical performance data of the balance vehicle, and the historical performance data includes but is not limited to the maximum tilt angle at which the balance vehicle can maintain balance in a stationary state, the time taken for the balance vehicle to recover from the occurrence of disturbance and the duration and position offset of the balance vehicle to maintain balance on different slopes; the occurrence of disturbance means the occurrence of external force; the three-dimensional angular velocity of the balance vehicle can be obtained by collecting and obtaining it through a gyroscope, and the acceleration of the balance vehicle can be obtained by collecting and obtaining it through an accelerometer; the historical performance data can be obtained by collecting and obtaining it through sensors; the preprocessing operation includes but is not limited to cleaning and denoising the data to obtain data that can be directly used;
[0051] Step S2: Use the Kalman filter algorithm to estimate the attitude angle of the balance vehicle at the next moment, and train the balance performance prediction model based on the historical data of the balance vehicle; its purpose is to give full play to the nonlinear and multimodal data modeling capabilities of the neural network by constructing a neural network model, and effectively capture complex data relationships; based on the parallel computing processing mechanism, improve computing efficiency, and use deep learning technology to predict the balance performance of the balance vehicle under different data, laying the foundation for the subsequent selection of the optimal PID control parameter combination; using the Kalman filter algorithm to estimate the attitude data of the balance vehicle at the next moment is a prior art means, and is not the key part of this embodiment. Therefore, this embodiment will not go into too much detail on this, and those skilled in the art can implement this technical solution based on the existing technology;
[0052] Step S3: Introducing the balancing performance prediction model trained in step S2 into the nature-inspired algorithm, improving the nature-inspired algorithm, and obtaining an optimal PID control parameter combination based on the improved nature-inspired algorithm; the PID control parameter combination is a combination of proportional gain, integral gain, and differential gain; its purpose is to introduce the balancing performance prediction model into the nature-inspired algorithm, and combine the neural network model with the nature-inspired algorithm to more comprehensively understand the impact of different PID control parameter combinations on the balancing performance of the balancing vehicle, thereby improving the accuracy of obtaining the optimal PID control parameter combination;
[0053] Step S4: Perform PID control on the balancing vehicle at the next moment based on the optimal PID control parameter combination.
[0054] In this embodiment, it should be specifically explained that the specific method of training the balance performance prediction model based on the historical data of the balance vehicle in step S2 is:
[0055] The PID control parameter combination, posture data, and driving data at time t in the historical data are used as a set of analysis data. T sets of analysis data are collected in advance, i.e., the PID control parameter combination, posture data, and driving data at T times. Each set of analysis data and the corresponding balance performance index are converted into a set of feature vectors. Under the conditions of each set of analysis data, the balance performance of each set of data is comprehensively analyzed.
[0056] Each set of feature vectors is used as the input of the balance performance prediction model. The balance performance prediction model uses a set of predicted balance performance indices corresponding to each set of analysis data as output, and uses the actual balance performance index corresponding to each set of analysis data as the prediction target. The actual balance performance index is the pre-collected balance performance index corresponding to the analysis data. The training goal is to minimize the sum of the prediction errors of all analysis data. The formula for the prediction error is expressed as: WC p =yc_xn p -acu_xn p Among them, WC p Indicates the prediction error of the pth group of analysis data, p represents the group number of the feature vector corresponding to the analysis data, yc_xn p Indicates the predicted balance performance index corresponding to the p-th group of analysis data, acu_xn p represents the actual balance performance index corresponding to the p-th group of analysis data. The balance performance prediction model is trained until the sum of the prediction errors reaches convergence; p = 1, 2, 3, ..., T;
[0057] The balance performance prediction model is specifically a deep neural network model; it includes an input layer, a hidden layer and an output layer; each hidden layer includes multiple neurons, each neuron is connected to the neurons in the next layer, and the connection contains weights that determine the importance and influence of data transmission in the neural network; each neuron between the hidden layer and the output layer applies an activation function, and the activation function maps nonlinearity, allowing the network to learn more complex patterns and features.
[0058] In this embodiment, it should be specifically explained that the PID control parameter combination is a parameter combination of a PID controller, and the parameters of the PID controller include the proportional gain K p , integral gain K i and the differential gain K d ; The algorithm form of the PID controller is expressed as:
[0059]
[0060] Where u(t) represents the output of the PID controller at time t, e(t) represents the error of the PID controller at time t, and τ represents the integral variable, τ∈[0,t]. In a self-balancing car, the role of the PID controller is as follows:
[0061] Proportional gain K p The corresponding proportional controller adjusts the output of the motor according to the displacement of the balancing car. The greater the deviation, the greater the control amount output by the proportional controller, thereby quickly moving the car to the equilibrium position;
[0062] Integral gain K i The corresponding integral controller is used to eliminate the static error of the balancing car near the equilibrium position. If a static error exists, the integral controller will adjust the output of the motor according to the integral of the error so that the balancing car can accurately maintain the equilibrium position;
[0063] Differential gain K d The corresponding differential controller is used to improve the stability of the balancing car and reduce overshoot and oscillation. Through the rate of change of the deviation, the differential controller can adjust the output of the motor to make the movement of the balancing car more balanced.
[0064] In this embodiment, it should be specifically explained that the balance performance index is obtained in the following manner:
[0065] Obtain the maximum static stability angle value of the self-balancing vehicle to characterize the static stability of the self-balancing vehicle. The maximum static stability angle value is the maximum tilt angle at which the self-balancing vehicle remains stable and does not tip over in a stationary state. The larger the maximum static stability angle value, the better the balance performance of the self-balancing vehicle and the less likely it is to tip over. The formula is:
[0066] Among them, θ max Indicates the maximum static stability angle value, h represents the vertical height from the center of mass of the balancing vehicle to the ground, which can be obtained through actual measurement by the sensor; L represents the distance between the contact points of the wheels of the balancing vehicle, that is, the lateral distance between the contact points of the left and right wheels; for example, the distance between the contact points of the wheels of a balancing vehicle is 0.35m, and the vertical height from the center of mass to the ground is 0.18m, then L = 0.35, h = 0.18; That is, the maximum tilt angle at which the balancing vehicle can remain stable without tipping over when stationary is 44.1°;
[0067] Obtain the anti-interference recovery time of the balancing vehicle to characterize its anti-interference ability. The anti-interference recovery time is the time required for the balancing vehicle to return to a stable state when subjected to an external force. The longer the anti-interference recovery time is, the longer it takes for the balancing vehicle to return to a stable state when subjected to an external force, that is, the worse the balancing performance of the balancing vehicle. The formula is:
[0068] time recover =time end -time start ; Among them, time recovr Indicates the anti-interference recovery time, time end Indicates the time it takes for the balancing car to return to a stable state, time end Indicates the time it takes for the balancing car to return to a stable state, time start Indicates the time when the self-balancing vehicle is subjected to external force; the method for determining the external force is: when the self-balancing vehicle is in an unbalanced state, the time when the unbalanced state occurs is determined to be the time when the external force is applied;
[0069] The balance fluctuation of the self-balancing vehicle is obtained to characterize the balance control accuracy of the self-balancing vehicle. The balance fluctuation is the fluctuation of the attitude angle of the self-balancing vehicle when maintaining a stable state. The larger the balance fluctuation, the more intense the fluctuation of the attitude angle of the self-balancing vehicle when maintaining a stable state, that is, the worse the balance control accuracy and balance performance of the self-balancing vehicle are. The formula is expressed as:
[0070] Among them, θ b_t represents the equilibrium volatility at time t, θ t represents the attitude angle of the balancing vehicle at time t. In this embodiment, the tilt angle of the balancing vehicle body is selected as the value of the attitude angle, θ target Indicates the target balance angle, usually θ target =0°;
[0071] Based on the maximum static stability angle value, anti-interference recovery time and balance fluctuation of the balance vehicle, the balance performance index of the balance vehicle is obtained; the higher the balance performance index, the better the balance performance of the balance vehicle; the formula is expressed as:
[0072]
[0073] Among them, Per t Indicates the balance performance index at time t, time allrepresents the total time from the start of the balancing vehicle to the recovery to a stable state; k1 and k2 are corresponding proportional constants respectively; the values of k1 and k2 can be specifically set by those skilled in the art according to actual conditions. In this embodiment, k1=k2=1 is selected; the anti-interference recovery time represents the anti-interference recovery time closest to the time t. The total time from the start of the balancing vehicle to the recovery to a stable state corresponds to the anti-interference recovery time, that is, the anti-interference recovery time time recover In time all For example, when the self-balancing car starts to run at 5 o'clock, it is unbalanced due to external force at 5:29 and returns to a stable state at 5:30. The total time from the start of the self-balancing car to the return to a stable state is 30 minutes from 5 o'clock to 5:30, that is, time all = 30 minutes, the anti-interference recovery time is one minute from 5:29 to 5:30, that is, time recover =1 minute.
[0074] In this embodiment, it should be specifically explained that the natural inspiration algorithm in step S3 can be any one of a genetic algorithm, a cuckoo algorithm, and a bat algorithm. In this embodiment, the bat optimization algorithm is selected, and the specific method is as follows:
[0075] Step S31: Consider each PID control parameter combination as a bat, randomly select R bats to construct the initial population, that is, the population size is R, and the position of the rth bat is p r , the speed is v r , the sound wave frequency is H r , the loudness of the sound wave is B r , the pulse frequency is I r , the maximum number of iterations λ max When bats search for prey, they automatically adjust the wavelength and loudness of their sounds based on the distance between them and the target.
[0076] Step S32: determining the fitness function;
[0077] Step S33: Find the optimal position p of bats in the current population * , and update the bat position and speed; the optimal position of the bats in the current population is the bat position corresponding to the PID control parameter combination with the maximum fitness in this iteration;
[0078] The bat position update formula is: in, is the position of the r-th bat at the λ-th iteration, is the position of the rth bat at the λ-1th iteration; is the speed of the r-th bat at the λ-th iteration;
[0079] The bat speed update formula is: in, is the speed of the rth bat at the λ-1th iteration, H r is the frequency of the sound wave emitted by the rth bat;
[0080] H r =H min +(H max -H min )×β; where H min is the minimum frequency of the bat's sound waves, H max is the maximum frequency of the sound waves generated by bats, and the sound wave frequency range is [H min ,H max ], β is a random vector between [0,1];
[0081] Step S34: Generate a random number rand1 between [0,1]. If rand1>I r , then random flight is performed, and a new position p is generated near the original optimal position by random flight new Otherwise, the bat position is updated according to the bat position update formula; the formula for random flight is:
[0082] p new =p old +rand2×B λ ; Among them, p old is the original optimal position, rand2 is a random number between [0,1], B λ is the average loudness of all bats in the λth iteration;
[0083] When searching for prey, bats constantly adjust the loudness and frequency of their sound waves according to the location of their target prey to improve their hunting efficiency. As they gradually approach their prey, the spatial range within which they search for prey decreases. Therefore, they gradually reduce the loudness to a constant value while continuously increasing the frequency in order to quickly and dynamically grasp the location of their target prey.
[0084] Step S35: Generate a random number rand3 on [0,1]. If rand3 r , and the fitness corresponding to the new optimal position is greater than the fitness of the original optimal position, then the position is accepted and the new position is used as the current optimal position, and the sound wave loudness is reduced and the pulse frequency is increased;
[0085] The formula for adjusting the loudness and frequency of sound waves is:
[0086] Among them, α∈(0,1) is the sound wave loudness attenuation coefficient, γ>0 is the pulse frequency enhancement coefficient, is the sound wave loudness of the r-th bat at the λ+1th iteration, is the sound wave loudness of the r-th bat at the λ-th iteration, is the pulse frequency of the r-th bat at the λ+1th iteration, is the initial pulse frequency of the rth bat;
[0087] For any sound wave loudness attenuation coefficient and pulse frequency enhancement coefficient, when λ→∞, we have: when When it approaches 0, it can be considered that the bat has found prey and temporarily stops emitting pulses. The pulse variation range can be set by technicians in this field according to specific circumstances. Only when the bat's position is optimized will the loudness and frequency of the pulse be updated, which indicates that the bat is moving towards the optimal position.
[0088] Step S36: Determine whether the maximum number of iterations λ has been reached max If the maximum number of iterations is reached, the iteration ends; otherwise, let λ=λ+1 and loop through steps S32 to S35. At the end of the iteration, sort the fitness values of all bats to find the current optimal position, and obtain the PID control parameter combination corresponding to the bat at the current optimal position as the optimal PID control parameter combination.
[0089] In this embodiment, it should be specifically explained that the PID control parameter combination is a combination constructed by all PID control parameters, PID control parameters are parameters of the PID controller, and all PID control parameters are historical PID control parameters and all possible PID control parameters; the proportional gain, integral gain and differential gain in all PID control parameters are arbitrarily combined to form a PID control parameter combination;
[0090] The fitness function is expressed as: f r =Per_r; where f r represents the fitness of the PID control parameter combination corresponding to the r-th bat, and Per_r represents the predicted balance performance index of the PID control parameter combination corresponding to the r-th bat; the predicted balance performance index is obtained as follows:
[0091] The PID control parameter combination corresponding to the r-th bat and the estimated value of the balance vehicle attitude angle at the next moment in step S2 are input into the trained balance performance prediction model to obtain the predicted balance performance index; that is, the predicted balance performance index of the balance vehicle when the PID control parameter combination at the next moment is the PID control parameter combination corresponding to the r-th bat.
[0092] like Figure 2As shown, the present invention provides a balance vehicle control system, including a data acquisition and preprocessing module, a prediction model training module, a control parameter combination acquisition module and an intelligent control module;
[0093] The data acquisition and preprocessing module is used to collect historical data and real-time data of the balance vehicle and perform preprocessing operations;
[0094] The prediction model training module is used to estimate the attitude angle of the self-balancing vehicle at the next moment using the Kalman filter algorithm, and train the balance performance prediction model based on the historical data of the self-balancing vehicle;
[0095] The control parameter combination acquisition module is used to introduce the balance performance prediction model trained in step S2 into the nature-inspired algorithm, improve the nature-inspired algorithm, and obtain the optimal PID control parameter combination based on the improved nature-inspired algorithm;
[0096] The intelligent control module performs PID control on the balancing vehicle at the next moment based on the optimal PID control parameter combination.
[0097] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
[0098] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A method for controlling a balancing vehicle, characterized in that: The following steps are involved: Step S1: Data collection and preprocessing: Collect historical data and real-time data of the balance vehicle and perform preprocessing operations; Step S2: Using the Kalman filter algorithm to estimate the attitude angle of the self-balancing vehicle at the next moment, and training a balance performance prediction model based on the historical data of the self-balancing vehicle; Step S3: Introducing the balance performance prediction model trained in step S2 into the nature-inspired algorithm, improving the nature-inspired algorithm, and obtaining the optimal PID control parameter combination based on the improved nature-inspired algorithm; Step S4: Perform PID control on the balancing vehicle at the next moment based on the optimal PID control parameter combination.
2. A method for controlling a self-balancing vehicle according to claim 1, characterized in that: The real-time data includes the current posture data and driving data of the balance vehicle; the posture data includes the three-dimensional angular velocity and acceleration of the balance vehicle; the driving data includes the position, driving speed, driving distance and driving environment of the balance vehicle; the historical data includes the historical posture data, historical driving data, historical PID control parameter combination and corresponding historical performance data of the balance vehicle. The historical performance data includes the maximum tilt angle at which the balance vehicle can maintain balance in a stationary state, the time it takes for the balance vehicle to return to steady state from the occurrence of disturbance, and the duration and position offset of the balance vehicle maintaining balance on different slopes.
3. A method for controlling a self-balancing vehicle according to claim 2, characterized in that: The specific method of training the balance performance prediction model based on the historical data of the balance vehicle in step S2 is: The PID control parameter combination, posture data, and driving data at time t in the historical data are used as a set of analysis data. T sets of analysis data are collected in advance, i.e., the PID control parameter combination, posture data, and driving data at T times. Each set of analysis data and the corresponding balance performance index are converted into a set of feature vectors. Each set of feature vectors is used as the input of the balance performance prediction model. The balance performance prediction model uses a set of predicted balance performance indices corresponding to each set of analysis data as output, and the actual balance performance index corresponding to each set of analysis data as the prediction target. The actual balance performance index is the pre-collected balance performance index corresponding to the analysis data. The balance performance prediction model is trained with minimizing the sum of the prediction errors of all analysis data as the training goal, and the training is stopped when the sum of the prediction errors reaches convergence.
4. A method for controlling a self-balancing vehicle according to claim 3, characterized in that: The prediction error is expressed as: WC p =yc_xn p -acu_xn p Among them, WC p Indicates the prediction error of the pth group of analysis data, p represents the group number of the feature vector corresponding to the analysis data, yc_xn p Indicates the predicted balance performance index corresponding to the p-th group of analysis data, acu_xn p represents the actual balance performance index corresponding to the pth group of analysis data; p = 1, 2, 3, ..., T.
5. A method for controlling a self-balancing vehicle according to claim 4, characterized in that: The PID control parameter combination is a parameter combination of a PID controller, and the parameters of the PID controller include proportional gain K p , integral gain K i and the differential gain K d ; The algorithm form of the PID controller is expressed as: Among them, u(t) represents the output of the PID controller at time t, e(t) represents the error of the PID controller at time t, τ represents the variable of the integral part, τ∈[0,t].
6. A method for controlling a self-balancing vehicle according to claim 5, characterized in that: The balance performance index is obtained as follows: Get the maximum static stability angle of the balancing vehicle; Get the anti-interference recovery time of the balancing vehicle; Get the balance fluctuation of the balance car; The balance performance index of the balancing vehicle is obtained based on the maximum static stability angle value, anti-interference recovery time and balance fluctuation of the balancing vehicle.
7. A method for controlling a self-balancing vehicle according to claim 6, characterized in that: The balance performance index formula of the balancing vehicle is expressed as: Among them, Per t Indicates the balance performance index at time t, time all represents the total time from the start of the balancing car to the return to a stable state; k1 and k2 are the corresponding proportional constants; θ max Indicates the maximum static stability angle value, time recover Indicates the anti-interference recovery time, θ b_t represents the equilibrium volatility at time t.
8. A method for controlling a self-balancing vehicle according to claim 7, characterized in that: The specific method of the improved nature-inspired algorithm in step S3 is: Step S31: Consider each PID control parameter combination as a bat, randomly select R bats to construct the initial population, that is, the population size is R, and the position of the rth bat is p r , the speed is v r , the sound wave frequency is H r , the loudness of the sound wave is B r , the pulse frequency is I r , the maximum number of iterations λ max ; Step S32: determining the fitness function; Step S33: Find the optimal position p of bats in the current population * , and update the bat position and speed; the optimal position of the bats in the current population is the bat position corresponding to the PID control parameter combination with the maximum fitness in this iteration; Step S34: Generate a random number rand1 between [0,1]. If rand1>I r , then random flight is performed, and a new position p is generated near the original optimal position by random flight new , otherwise update the bat position according to the bat position update formula; Step S35: Generate a random number rand3 on [0,1]. If rand3 r , and the fitness corresponding to the new optimal position is greater than the fitness of the original optimal position, then the position is accepted and the new position is used as the current optimal position, and the sound wave loudness is reduced and the pulse frequency is increased; Step S36: Determine whether the maximum number of iterations λ has been reached max If the maximum number of iterations is reached, the iteration ends; otherwise, let λ=λ+1 and loop through steps S32 to S36. At the end of the iteration, sort the fitness values of all bats to find the current optimal position, and obtain the PID control parameter combination corresponding to the bat at the current optimal position as the optimal PID control parameter combination.
9. A method for controlling a self-balancing vehicle according to claim 8, characterized in that: The fitness function is expressed as: f r =Per_r; where f r represents the fitness of the PID control parameter combination corresponding to the r-th bat, and Per_r represents the predicted balance performance index of the PID control parameter combination corresponding to the r-th bat; The method for obtaining the predicted balance performance index is as follows: The PID control parameter combination corresponding to the r-th bat and the estimated value of the balance vehicle attitude angle at the next moment in step S2 are input into the trained balance performance prediction model to obtain the predicted balance performance index; that is, the predicted balance performance index of the balance vehicle when the PID control parameter combination at the next moment is the PID control parameter combination corresponding to the r-th bat.
10. A self-balancing vehicle control system, comprising: It includes data acquisition and preprocessing module, prediction model training module, control parameter combination acquisition module and intelligent control module; The data acquisition and preprocessing module is used to collect historical data and real-time data of the balance vehicle and perform preprocessing operations; The prediction model training module is used to estimate the attitude angle of the self-balancing vehicle at the next moment using the Kalman filter algorithm, and train the balance performance prediction model based on the historical data of the self-balancing vehicle; The control parameter combination acquisition module is used to introduce the balance performance prediction model trained in step S2 into the nature-inspired algorithm, improve the nature-inspired algorithm, and obtain the optimal PID control parameter combination based on the improved nature-inspired algorithm; The intelligent control module performs PID control on the balancing vehicle at the next moment based on the optimal PID control parameter combination.
Citation Information
Patent Citations
One-wheel robot system and control method thereof
CN101623865A
Multi-jet self-balancing aerocar
CN103552435A
Laser tracking balance car control method
CN110941280A
Two-wheeled self-balancing robot
CN118020038A
Monocycle balance control method and system based on PID (Proportion Integration Differentiation) controller
CN118112921A