A balance car control method and system
By collecting data from self-balancing scooters and training a neural network model using Kalman filtering and an improved natural heuristic algorithm, the optimal PID control parameters are obtained. This solves the problem that PID controller parameters cannot adapt to changes in real time, and achieves real-time optimization of the stability and control effect of the self-balancing scooter.
Patent Information
- Application Number
- CN202510572524.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2045-05-06
AI Technical Summary
In existing self-balancing scooter control methods, the parameters of the PID controller cannot be changed adaptively in real time, making it difficult to maintain optimal control performance and affecting the stability of the self-balancing scooter.
By collecting historical and real-time data from the self-balancing scooter, the Kalman filter algorithm is used to estimate the attitude angle at the next moment. Based on the improved natural heuristic algorithm and neural network model, a balance performance prediction model is trained to obtain the optimal combination of PID control parameters and achieve real-time adjustment.
It achieves real-time optimization of the self-balancing scooter's control effect, ensuring stability and control precision under different driving environments.
Smart Images

Figure CN120428629B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of PID control, and more particularly to a balance car control method and system. BACKGROUND
[0002] With the rapid development of science and technology, as a new type of short-distance transportation tool, balance car is favored by people because of its environmental protection and convenience, but the stability of the existing balance car is insufficient during driving, and it is easy to overturn, so the existing control of the balance car mostly adopts PID controller, the parameters of the PID controller in the balance car need to be determined through experiment and debugging, and usually need to be adjusted according to the dynamics characteristics of the car and the feedback of the sensor, through reasonable adjustment of the PID parameters, the balance car can quickly and stably realize automatic balance, so as to realize accurate control and movement.
[0003] However, in the process of controlling the balance car by the existing PID controller, the setting parameters of the controller cannot be adaptively changed in real time, so that the control effect is difficult to keep optimal all the time, different parameters in the PID control have different influences on the control effect, which further affects the balance performance of the balance car.
[0004] Therefore, the present application provides a balance car control method and system, which analyzes the parameters in the PID control in real time to obtain optimal parameters, so as to ensure that the control effect of the balance car is always in the best state, and further ensure the stability of the balance car in different driving environments. SUMMARY
[0005] In order to overcome the above-mentioned defects of the prior art, the present application provides a balance car control method and system to solve the problems in the background art.
[0006] The present application provides the following technical scheme: a balance car control method, comprising the following steps:
[0007] Step S1: data acquisition and preprocessing: collecting historical data and real-time data of the balance car, and performing preprocessing operation;
[0008] Step S2: using Kalman filtering algorithm to estimate the balance car attitude angle at the next moment, and training balance performance prediction model based on the historical data of the balance car;
[0009] Step S3: introducing the balance performance prediction model trained in step S2 into the natural heuristic algorithm, improving the natural heuristic algorithm, and obtaining the optimal PID control parameter combination based on the improved natural heuristic algorithm;
[0010] Step S4: PID control of the balance car at the next moment based on the optimal PID control parameter combination.
[0011] Preferably, the real-time data comprises attitude data and travel data of the balance car at the current time; the attitude data comprises three-dimensional angular velocity and acceleration of the balance car; the travel data comprises position, travel speed, travel distance and travel environment of the balance car; the historical data comprises historical attitude data, historical travel data, historical PID control parameter combination and corresponding historical performance data of the balance car, the historical performance data comprises maximum tilt angle that the balance car can maintain in a static state, time consumed by the balance car from disturbance to recovery of steady state, and time length and position offset of the balance car maintaining balance on different slopes.
[0012] Preferably, the specific way of training the balance performance prediction model based on the historical data of the balance car in the step S2 is as follows:
[0013] Taking the PID control parameter combination, attitude data and travel data of the balance car at time t in the historical data as a group of analysis data, T groups of analysis data, i.e. PID control parameter combinations, attitude data and travel data at T times, are collected in advance; each group of analysis data and corresponding balance performance index are converted into a group of feature vectors;
[0014] Taking each group of feature vectors as input of the balance performance prediction model, the balance performance prediction model takes a group of predicted balance performance indexes corresponding to each group of analysis data as output, takes actual balance performance index corresponding to each group of analysis data as prediction target, and the actual balance performance index is the balance performance index corresponding to the analysis data collected in advance; the balance performance prediction model is trained until the sum of prediction errors reaches convergence, and the training is stopped.
[0015] Preferably, the formula of the prediction error is as follows: WC p = yc_xn p - acu_xn p ; wherein, WC p presents the prediction error of the pth group of analysis data, p presents the group number of the feature vector corresponding to the analysis data, yc_xn p presents the predicted balance performance index corresponding to the pth group of analysis data, acu_xn p presents 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 comprise proportional gain K p , integral gain K i and differential gain K d ;
[0017] The algorithm form of the PID controller is represented as:
[0018]
[0019] Wherein, u(t) represents the output of the PID controller at t time, e(t) represents the error of the PID controller at t time, τ represents the variable of the integral part, τ ∈ [0, t].
[0020] Preferably, the balance performance index is obtained in the following manner:
[0021] Obtaining the maximum static stability angle value of the balance car;
[0022] Obtaining the anti-interference recovery time of the balance car;
[0023] Obtaining the balance fluctuation degree of the balance car;
[0024] Based on the maximum static stability angle value, the anti-interference recovery time and the balance fluctuation degree of the balance car, the balance performance index of the balance car is obtained.
[0025] Preferably, the balance performance index of the balance car is represented by the following formula:
[0026]
[0027] Wherein, Per t represents the balance performance index at t time, time all represents the total time of the balance car from starting to travel to recovering to the stable state; k1 and k2 are the corresponding proportional constants; θ max represents the maximum static stability angle value, time recover represents the anti-interference recovery time, θ b_t represents the balance fluctuation degree at t time.
[0028] Preferably, the improved natural heuristic algorithm in step S3 is specifically as follows:
[0029] Step S31: Each PID control parameter combination is regarded as a bat, and R bats are randomly selected to construct an initial population, i.e. the population size is R, the position of the rth bat is p r , the speed is v r , the sound wave frequency is H r , the sound wave loudness is B r , the pulse frequency is I r , and the maximum iteration number is λ max ;
[0030] Step S32: Determining the fitness function;
[0031] Step S33: finding out the best bat position p in the current population * , and updating the bat position and speed; the best bat position in the current population is the bat position corresponding to the PID control parameter combination with the maximum fitness value in this iteration;
[0032] Step S34: generating a random number rand1 between 0 and 1, if rand1>I r , then performing random flight, and generating a new position p around the original best position through random flight new , otherwise updating the bat position according to the bat position updating formula;
[0033] Step S35: generating a random number rand3 between 0 and 1 again, if rand3<Br, and the fitness value corresponding to the new best position is greater than the fitness value of the original best position, then accepting the position, taking the new position as the current best position, and adjusting the sound loudness to decrease and the pulse frequency to increase;
[0034] Step S36: judging whether the maximum iteration number λ is reached max , if the maximum iteration number is reached, the iteration is ended, otherwise, setting λ=λ+1, and repeating steps S32 to S36; when the iteration is ended, sorting the fitness values of all bats, finding out the current best position, and taking the PID control parameter combination corresponding to the bat of the current best position as the optimal PID control parameter combination.
[0035] Preferably, the fitness function is expressed as: f r =Per_r; wherein, f r r represents the fitness value of the PID control parameter combination corresponding to the rth bat, and Per_r represents the predicted balance performance index of the PID control parameter combination corresponding to the rth bat;
[0036] The predicted balance performance index is obtained in the following manner:
[0037] inputting the PID control parameter combination corresponding to the rth bat and the balance car attitude angle estimation value at the next time in step S2 into the trained balance performance prediction model to obtain the predicted balance performance index; that is, when the PID control parameter combination at the next time is the PID control parameter combination corresponding to the rth bat, the predicted balance performance index of the balance car.
[0038] A balance car control system, comprising 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 for acquiring historical data and real-time data of the balance car, and performing preprocessing operation;
[0040] The prediction model training module is configured to estimate the balance car attitude angle at the next moment by using a Kalman filtering algorithm, and train a balance performance prediction model based on historical data of the balance car.
[0041] The control parameter combination acquisition module is configured to introduce the balance performance prediction model trained in step S2 into the natural heuristic algorithm, improve the natural heuristic algorithm, and acquire the optimal PID control parameter combination based on the improved natural heuristic algorithm.
[0042] The intelligent control module performs PID control on the balance car at the next moment based on the optimal PID control parameter combination.
[0043] The technical effects and advantages of the present application are as follows:
[0044] The present application has the steps S2 and S3, which are beneficial to estimate the balance car attitude angle at the next moment by using a Kalman filtering algorithm, train a balance performance prediction model based on historical data of the balance car, introduce the balance performance prediction model trained in step S2 into the natural heuristic algorithm, improve the natural heuristic algorithm, and integrate the neural network model into the fitness calculation of the natural heuristic algorithm, so as to fully exert the nonlinear and multi-modal data modeling capabilities of the neural network and effectively capture complex data relationships. According to the parallel computing mechanism, the calculation efficiency is improved, and the balance performance of the balance car under different data is predicted by the deep learning technology, which lays a foundation for subsequent selection of the optimal PID control parameter combination. The optimal parameters are obtained by real-time analysis of the parameters in the PID control, so as to ensure that the control effect of the balance car is always in the best state, and thus the stability of the balance car under different driving environments is ensured. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 The balance car control method of the present application is shown in the flowchart.
[0046] Figure 2 The balance car control system structure diagram of the present application is shown in the structure diagram.
[0047] Figure 3 The PID control schematic diagram of the present application is shown in the schematic diagram. DETAILED DESCRIPTION
[0048] The technical solutions in the present application will be described in detail below with reference to the accompanying drawings. The forms of the structures described in the following embodiments are only examples, and the balance car control method and system of the present application are not limited to the structures described in the following embodiments. All other embodiments obtained by those skilled in the art without making creative efforts fall within the scope of protection of the present application.
[0049] As Figure 1 and Figure 3 The present application provides a balance car control method, comprising the following steps:
[0050] Step S1: data acquisition and preprocessing: collecting historical data and real-time data of the balance car, and performing preprocessing operation; the real-time data includes attitude data of the balance car at the current time and driving data at the current time; the attitude data includes but is not limited to three-dimensional angular velocity and acceleration of the balance car; the driving data includes but is not limited to balance car position, driving speed, driving distance and driving environment; the historical data includes but is not limited to historical attitude data, historical driving data, historical PID control parameter combination and corresponding historical performance data of the balance car, the historical performance data includes but is not limited to the maximum inclination angle that the balance car can maintain in the static state, the time consumed by the balance car from disturbance to steady state recovery, and the time length and position offset of the balance car maintaining balance on different slopes; the disturbance is the external force; the three-dimensional angular velocity of the balance car can be obtained by collecting the gyroscope, and the acceleration of the balance car can be obtained by collecting the accelerometer; the historical performance data can be obtained by collecting the sensor; the preprocessing operation includes but is not limited to data cleaning and noise reduction, etc., to obtain directly usable data;
[0051] Step S2: using Kalman filtering algorithm to estimate the balance car attitude angle at the next time, and training balance performance prediction model based on the historical data of the balance car; the purpose is to build a neural network model, give full play to the nonlinear and multi-modal data modeling ability of neural network, effectively capture the complex data relationship; according to parallel computing mechanism, improve the calculation efficiency, and through deep learning technology, predict the balance performance of the balance car under different data, lay the foundation for subsequent selection of optimal PID control parameter combination; using Kalman filtering algorithm to estimate the balance car attitude data at the next time is a prior art means, and is not the key part of the embodiment, so this embodiment does not make too much repetition, and those skilled in the art can realize this technical solution based on the prior art;
[0052] Step S3: introducing the balance performance prediction model trained in step S2 into the natural heuristic algorithm, improving the natural heuristic algorithm, and obtaining the optimal PID control parameter combination based on the improved natural heuristic algorithm; the PID control parameter combination is the combination of proportional gain, integral gain and derivative gain; the purpose is to introduce the balance performance prediction model into the natural heuristic algorithm, combine the neural network model with the natural heuristic algorithm, and more comprehensively understand the influence of different PID control parameter combinations on the balance performance of the balance car, so as to improve the accuracy of obtaining the optimal PID control parameter combination;
[0053] Step S4: performing PID control on the balance car at the next time based on the optimal PID control parameter combination.
[0054] In this embodiment, it needs to be specifically pointed out that the specific way of training the balance performance prediction model based on the historical data of the balance car in step S2 is as follows:
[0055] Taking the PID control parameter combination, the attitude data and the driving data at time t in the historical data as a group of analysis data, T groups of analysis data, i.e. the PID control parameter combination, the attitude data and the driving data at T times, are collected in advance; each group of analysis data and the corresponding balance performance index are converted into a group of feature vectors; under the condition of each group of analysis data, the balance performance of each group of data is comprehensively analyzed;
[0056] Each group of feature vectors is taken as the input of the balance performance prediction model, the balance performance prediction model takes a group of predicted balance performance indexes corresponding to each group of analysis data as the output, and the actual balance performance index corresponding to each group of analysis data as the prediction target, and the actual balance performance index is the balance performance index corresponding to the analysis data collected in advance; the training target is to minimize the sum of prediction errors of all analysis data; the formula of the prediction error is: WC p = yc_xn p - acu_xn p ; wherein, WC p represents 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 represents the predicted balance performance index corresponding to the pth group of analysis data, acu_xn p represents the actual balance performance index corresponding to the pth group of analysis data, the balance performance prediction model is trained until the sum of prediction errors reaches convergence, and the training is stopped; p = 1, 2, 3, …, T;
[0057] The balance performance prediction model is specifically a deep neural network model; which includes an input layer, a hidden layer and an output layer; each hidden layer includes a plurality of neurons, each neuron is connected with the next layer of neurons, and the connection contains weights which determine the importance and influence of data transmission in the neural network; an activation function is applied to each neuron between the hidden layer and the output layer, the activation function maps into nonlinearity, allowing the network to learn more complex patterns and features.
[0058] In this embodiment, it needs to be specifically pointed out that the PID control parameter combination is the parameter combination of the PID controller, and the parameters of the PID controller include proportional gain K p , integral gain K i and differential gain K d ; the algorithm form of the PID controller is represented 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 variable of the integral part, τ∈[0,t]; In the self-balancing scooter, the role of the PID controller is as follows:
[0061] Proportional Gain K p The corresponding proportional controller adjusts the motor output according to the displacement of the self-balancing vehicle. The greater the deviation, the greater the control quantity output by the proportional controller, thereby quickly moving the vehicle towards the balance position.
[0062] Integral gain K i The corresponding integral controller is used to eliminate static errors of the self-balancing scooter near the balance position. If static errors exist, the integral controller will adjust the motor output according to the integral of the error, so that the self-balancing scooter can accurately maintain the balance position.
[0063] Differential gain K d The corresponding differential controller is used to improve the stability of the self-balancing scooter and reduce overshoot and oscillation. By measuring the rate of change of the deviation, the differential controller can adjust the output of the motor, making the movement of the self-balancing scooter more balanced.
[0064] In this embodiment, it should be specifically noted that the method for obtaining the balance performance index is as follows:
[0065] The maximum static stability angle value of the self-balancing scooter is obtained to characterize its static stability. This maximum static stability angle value is the maximum tilt angle at which the scooter remains stable and does not tip over when stationary. A larger maximum static stability angle value indicates better balance performance and a lower likelihood of tipping over. The formula is as follows:
[0066] Where, θ max The maximum static stability angle value is represented by h, which represents the vertical height of the scooter's center of gravity from the ground, and can be obtained through sensor measurement. L represents the wheel contact point distance of the scooter, i.e., the lateral distance between the contact points of the left and right wheels. For example, if the wheel contact point distance of a scooter is 0.35m and the vertical height of its center of gravity from the ground is 0.18m, then L = 0.35m and h = 0.18m. That is, the maximum tilt angle at which the self-balancing scooter remains stable and does not tip over when stationary is 44.1°;
[0067] The anti-interference recovery time of the balance car is acquired to represent the anti-interference capability of the balance car; the anti-interference recovery time is the time required for the balance car to recover to a stable state when the balance car is subjected to an external force, and the longer the anti-interference recovery time, the longer the time required for the balance car to recover to a stable state when the balance car is subjected to an external force, that is, the poorer the balance performance of the balance car; the formula is expressed as:
[0068] time recover = time end - time start ; wherein, time recovr represents the anti-interference recovery time, time end represents the time for the balance car to recover to a stable state, time end represents the time for the balance car to recover to a stable state, and time start represents the time for the balance car to be subjected to an external force; the determination mode of the time for the balance car to be subjected to an external force is that when the balance car appears an unbalanced state, the time for the unbalanced state to appear is determined as the time for the balance car to be subjected to an external force.
[0069] The balance fluctuation degree of the balance car is acquired to represent the balance control precision of the balance car; the balance fluctuation degree is the fluctuation of the attitude angle of the balance car when maintaining a stable state, and the greater the balance fluctuation degree, the more intense the fluctuation of the attitude angle of the balance car when maintaining a stable state, that is, the poorer the balance control precision of the balance car and the poorer the balance performance; the formula is expressed as:
[0070] wherein, θ b_t represents the balance fluctuation degree at t moment, θ t represents the attitude angle of the balance car at t moment, the body inclination angle of the balance car is selected as the value of the attitude angle in the embodiment, θ target represents a target balance angle, and θ target = 0° is usually taken.
[0071] Based on the maximum static stable angle value of the balance car, the anti-interference recovery time and the balance fluctuation degree, the balance performance index of the balance car is acquired; the higher the balance performance index, the better the balance performance of the balance car; the formula is expressed as:
[0072]
[0073] wherein, Per t represents the balance performance index at t moment, time allrepresents the total time from the start of the balance car to the recovery to the stable state; k1 and k2 are respectively corresponding proportional constants; the values of k1 and k2 can be set by the person skilled in the art according to the actual situation, and in the embodiment, k1=k2=1 is selected; the anti-interference recovery time represents the anti-interference recovery time closest to the time t, and the total time from the start of the balance car to the recovery to the stable state corresponds to the anti-interference recovery time, that is, the anti-interference recovery time time recover occurs within time all ; for example, when the balance car starts to run at 5 o'clock, is unbalanced at 5:29 due to external force, and recovers to the stable state at 5:30, the total time from the start of the balance car to the recovery to the stable state is thirty minutes from 5 o'clock to 5:30, that is, time all =30 minutes, and the anti-interference recovery time is one minute from 5:29 to 5:30, that is, time recover =1 minute.
[0074] In the embodiment, it needs to be specifically explained that the natural heuristic algorithm in the step S3 can be any one of a genetic algorithm, a cuckoo algorithm and a bat algorithm, and the bat optimization algorithm is selected in the embodiment, and the specific mode is as follows:
[0075] Step S31: regarding each PID control parameter combination as a bat, R bats are randomly selected to construct an initial population, that is, the population size is R, the position of the rth bat is p r , the speed is v r , the sound wave frequency is H r , the sound wave loudness is B r , the pulse frequency is I r , and the maximum iteration number is λ max ; the bat adjusts the wavelength and loudness automatically according to the distance between the target and itself when searching for prey;
[0076] Step S32: determine the fitness function;
[0077] Step S33: find the optimal position p * of the bat in the current population and update the bat position and speed; the optimal position of the bat in the current population is the position of the bat corresponding to the PID control parameter combination corresponding to the maximum fitness value in this iteration;
[0078] The bat position updating formula is: wherein, is the position of the rth bat at the λth iteration, is the position of the rth bat at the (λ-1)th iteration; is the speed of the rth bat at the λth iteration;
[0079] The bat speed updating formula is: Wherein, is the speed of the rthbat at the (λ-1)thiteration, H r is the sound wave frequency emitted by the rthbat;
[0080] H r = H min +(H max -H min )×β; wherein, H min is the minimum frequency of the sound wave emitted by the bat, H max is the maximum frequency of the sound wave emitted by the bat, and the sound wave frequency range is [H min , H max ], and β is a random vector between 0 and 1;
[0081] Step S34: a random number rand1 between 0 and 1 is generated, if rand1>I r , random flight is performed, and a new position p new around the original optimal position is generated, otherwise the bat position is updated according to the bat position updating formula; the random flight formula is:
[0082] p new =p old +rand2×B λ ; wherein, p old is the original optimal position, rand2 is a random number between 0 and 1, and B λ is the average loudness of all bats in the λthiteration;
[0083] In the process of searching for prey, the bat will constantly adjust the loudness and frequency of the emitted sound wave according to the direction of the target prey to improve the hunting efficiency, and in the process of gradually approaching the prey, the spatial range of the bat searching for the prey is gradually reduced, so it will gradually reduce the loudness to a certain value while constantly increasing the frequency, so as to quickly and dynamically grasp the direction of the target prey;
[0084] Step S35: a random number rand3 between 0 and 1 is generated again, if rand3<B r , and the fitness corresponding to the new optimal position is greater than the fitness of the original optimal position, the position is accepted, the new position is taken as the current optimal position, and the sound wave loudness is adjusted to be reduced and the pulse frequency is adjusted to be increased;
[0085] The formula for adjusting the sound wave loudness and frequency is:
[0086] Wherein, α∈(0,1) is the sound wave loudness attenuation coefficient, and γ>0 is the pulse frequency enhancement coefficient, sound loudness of the rthbat at the (l+1)thiteration, sound loudness of the rthbat at the lthiteration, pulse frequency of the rthbat at the (l+1)thiteration, initial pulse frequency of the rthbat;
[0087] For any sound loudness attenuation coefficient and pulse frequency enhancement coefficient, when l->∞, there is: When tends to 0, it can be considered that the bat has found the prey and temporarily does not emit pulses, and the change range of the pulse can be set by a person skilled in the art according to specific circumstances. Only when the position of the bat is optimized, the loudness and frequency of the pulse are updated, which implies that the bat is moving towards the best position;
[0088] Step S36: judging whether the maximum iteration number l is reached max If the maximum iteration number is reached, the iteration is ended, otherwise, let l=l+1, and the steps S32 to S35 are cycled; when the iteration is ended, the fitness values of all bats are sorted, the current optimal position is found, and the PID control parameter combination corresponding to the bat at the current optimal position is obtained as the optimal PID control parameter combination.
[0089] In the embodiment, it needs to be specifically explained that the PID control parameter combination is a combination constructed by all PID control parameters, the PID control parameter is a parameter of a PID controller, and all PID control parameters are historical PID control parameters and all possible PID control parameters; the proportional gain, the integral gain and the differential gain in all PID control parameters are combined to form a PID control parameter combination;
[0090] The fitness function is expressed as: f r =Per_r; wherein, f r represents the fitness of the PID control parameter combination corresponding to the rthbat, and Per_r represents the predicted balance performance index of the PID control parameter combination corresponding to the rthbat; the predicted balance performance index is obtained in the following manner:
[0091] The PID control parameter combination corresponding to the rthbat and the balance car attitude angle estimation value at the next time in the step S2 are input into the trained balance performance prediction model to obtain the predicted balance performance index; that is, when the PID control parameter combination at the next time is the PID control parameter combination corresponding to the rthbat, the predicted balance performance index of the balance car.
[0092] As Figure 2As shown, the application provides a balance car control system, comprising 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 for acquiring historical data and real-time data of the balance car and performing preprocessing operations.
[0094] The prediction model training module is used for estimating the balance car attitude angle at the next time by using the Kalman filtering algorithm, and training the balance performance prediction model based on the historical data of the balance car.
[0095] The control parameter combination acquisition module is used for introducing the balance performance prediction model trained in step S2 into the natural heuristic algorithm, improving the natural heuristic algorithm, and acquiring the optimal PID control parameter combination based on the improved natural heuristic algorithm.
[0096] The intelligent control module performs PID control on the balance car at the next time based on the optimal PID control parameter combination.
[0097] Finally: the above only for the preferred embodiments of the application and not for limiting the application, any modification, equivalent replacement, improvement, etc. within the spirit and principles of the application, should be included in the protection scope of the application.
[0098] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A balance car control method, characterized in that: Includes the following steps: Step S1: Data Acquisition and Preprocessing: Collect historical and real-time data of the self-balancing scooter and perform preprocessing operations; Step S2: Use the Kalman filter algorithm to estimate the attitude angle of the self-balancing vehicle at the next moment, and train the balance performance prediction model based on the historical data of the self-balancing vehicle; Step S3: Introduce the balanced performance prediction model trained in step S2 into the natural heuristic algorithm to improve the natural heuristic algorithm, and obtain the optimal combination of PID control parameters based on the improved natural heuristic algorithm; Step S4: Perform PID control on the self-balancing vehicle at the next moment based on the optimal PID control parameter combination; The improved natural heuristic algorithm in step S3 is as follows: Step S31: Each PID control parameter combination is regarded as a bat, and a random selection is made Only the initial population is constructed, that is, the population size is , the first The position of the bat is , the speed is , the sound wave frequency is , the sound wave loudness is , the pulse frequency is , and the maximum iteration number is ; Step S32: Determine the fitness function; Step S33: finding out the bat optimal position in the current population and updating the bat position and speed; the bat optimal position in the current population is the bat position corresponding to the PID control parameter combination with the maximum fitness value in this iteration; Step S34: generate a random number between 0 and 1 between 0 and 1 , if , then a random flight is performed, and a new position is generated by the random flight near the original optimal position , otherwise the bat position is updated according to the bat position update formula Step S35: Regenerate a random number on the current optimal position , and if the new optimal position corresponds to a fitness value greater than the fitness value of the original optimal position, accept the new position, take the new position as the current optimal position, and adjust the sound loudness reduction and the pulse frequency increase Step S36: judging whether the maximum iteration number is reached , if the maximum iteration number is reached, the iteration is ended, otherwise, let , the steps S32 to S36 are looped; the fitness values of all bats are sorted when the iteration is ended, the current optimal position is found, and the PID control parameter combination corresponding to the bat at the current optimal position is obtained as the optimal PID control parameter combination; The fitness function is expressed as: ; wherein, represents the PID control parameter combination corresponding to the i-th bat, represents the fitness of the PID control parameter combination corresponding to the i-th bat, represents the predicted balance performance index of the PID control parameter combination corresponding to the i-th bat, represents the predicted balance performance index of the PID control parameter combination corresponding to the i-th bat. The method for obtaining the predicted balance performance index is as follows: The first The PID control parameter combination corresponding to the bat and the estimated attitude angle of the self-balancing vehicle 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, when the PID control parameter combination at the next moment is the first... The predicted balance performance index of the self-balancing scooter when the PID control parameter combination corresponding to the bat is specified.
2. The balance car control method of claim 1, wherein: The real-time data includes the current attitude data and current driving data of the self-balancing scooter; the attitude data includes the three-dimensional angular velocity and acceleration of the self-balancing scooter; the driving data includes the position, speed, distance traveled, and driving environment of the self-balancing scooter; the historical data includes the historical attitude data, historical driving data, historical PID control parameter combinations, and corresponding historical performance data of the self-balancing scooter. The historical performance data includes the maximum tilt angle at which the self-balancing scooter can maintain balance when stationary, the time it takes for the self-balancing scooter to recover to a steady state from a disturbance, and the duration and positional deviation of the self-balancing scooter in maintaining balance on different slopes.
3. The balance car control method of claim 2, wherein: The specific method for training the balance performance prediction model based on the historical data of the self-balancing vehicle in step S2 is as follows: The PID control parameter combination, attitude 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, that is, the PID control parameter combination, attitude data, and driving data at T time points. Each set of analysis data and the corresponding balance performance index are transformed into a set of feature vectors. Each set of feature vectors is used as input to the balance performance prediction model. The balance performance prediction model outputs a set of predicted balance performance indices corresponding to each set of analysis data 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 balance performance index corresponding to the analysis data that has been collected in advance. The balance performance prediction model is trained with the goal of minimizing the sum of prediction errors of all analysis data until the sum of prediction errors converges. Training stops when the sum of prediction errors converges.
4. The balance car control method of claim 3, wherein: The formula of the prediction error is expressed as: ; wherein, represents the prediction error of the analysis data of the th group, represents the group number of the characteristic vector corresponding to the analysis data, represents the prediction balance performance index corresponding to the analysis data of the th group, represents the actual balance performance index corresponding to the analysis data of the th group; .
5. The balance car control method of claim 4, wherein: The PID control parameter combination is a parameter combination of a PID controller, and the parameters of the PID controller include a proportional gain , an integral gain , and a differential gain ; The algorithm of the PID controller is expressed as follows: ; wherein represents a PID controller the output at the time t, represents a PID controller the error at the time t, represents a variable of the integral part, .
6. The balance car control method of claim 5, wherein: The method for obtaining the balance performance index is as follows: Obtain the maximum static stability angle value of the self-balancing scooter; Obtain the anti-interference recovery time of the self-balancing scooter; To obtain the balance fluctuation of the self-balancing scooter; The balance performance index of the self-balancing scooter is obtained based on its maximum static stability angle, anti-interference recovery time, and balance fluctuation.
7. The balance car control method of claim 6, wherein: The formula for the balance performance index of the self-balancing scooter is expressed as follows: ; wherein, represents the balance performance index at the time point, represents the total time from the start of the ride to the restoration to the stable state; and are the corresponding proportional constants, respectively; represents the maximum static stability angle value, represents the anti-interference recovery time, represents the balance fluctuation degree at the time point. 8.A balance car control system according to any one of the balance car control methods of claims 1-7. It includes a data acquisition and preprocessing module, a prediction model training module, a control parameter combination acquisition module, and an intelligent control module; The data acquisition and preprocessing module is used to collect historical and real-time data of the self-balancing scooter and perform preprocessing operations. The prediction model training module is configured to estimate the balance car attitude angle at the next moment by using a Kalman filtering algorithm, and train a balance performance prediction model based on historical data of the balance car; The control parameter combination acquisition module is configured to introduce the balance performance prediction model trained in step S2 into the natural heuristic algorithm, improve the natural heuristic algorithm, and acquire the optimal PID control parameter combination based on the improved natural heuristic algorithm; The intelligent control module performs PID control on the balance car 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