Control method and device of balancing vehicle, balancing vehicle and computer-readable storage medium
Through the model predictive control algorithm, the stability problem caused by the balancing car control method is solved, ensuring that the thrust is within the available range, and improving the control stability of the balancing car.
Patent Information
- Application Number
- CN202111677875.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-12-31
AI Technical Summary
The existing balancing car control method can easily cause the balancing car to lose stability, resulting in a reduction in control stability.
The model predictive control algorithm is used to obtain the current state quantity based on the dynamic model of the balancing car, predict the state quantity at the target moment, and form a preset constraint condition by determining the correlation between the error and thrust, and determine the target under the constraint conditions. Thrust to ensure that the thrust is within the available range to prevent the balance car from losing stability.
It improves the control stability of the balancing car, ensures that the balancing car will not lose stability under a certain thrust, and enhances the reliability of the control.
Smart Images

Figure CN114442479B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of automatic control technology, and in particular, relates to a control method and device for a balancing vehicle, a balancing vehicle, and a computer-readable storage medium. Background Art
[0002] With the continuous development of automatic control technology and the improvement of people's living standards, more and more users choose self-balancing scooters as a means of transportation. The self-balancing scooter is a typical under-actuated system, which only has driving force on the driving wheels. Therefore, the stability control of the self-balancing scooter is a key problem that needs to be solved. It is necessary to control the moving speed of the self-balancing scooter while ensuring the stability of the overall tilt angle of the self-balancing scooter as much as possible.
[0003] The prior art usually controls the self-balancing vehicle based on the proportional integral derivative (PID) control algorithm, which uses the past state quantity and the current state quantity of the self-balancing vehicle to determine the thrust of the self-balancing vehicle at the current moment. However, the thrust determined based on this method often exceeds the range of driving force that the self-balancing vehicle can provide. The self-balancing vehicle driven and controlled based on the thrust determined in this way is likely to lose stability, reducing the stability of the self-balancing vehicle control. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a control method and device for a balancing vehicle, a balancing vehicle, and a computer-readable storage medium to solve the technical problem that the existing control method for a balancing vehicle easily causes the balancing vehicle to lose stability.
[0005] In a first aspect, an embodiment of the present application provides a control method for a balancing vehicle, comprising:
[0006] Obtaining a first state quantity of the balancing vehicle at the current moment;
[0007] Based on the first state quantity and the dynamic model of the self-balancing vehicle, a model predictive control algorithm is used to predict a second state quantity of the self-balancing vehicle at a target time, and an error between the second state quantity and an expected state quantity of the self-balancing vehicle at the target time is determined; the second state quantity is related to the first state quantity, the thrust exerted on the self-balancing vehicle at each control time, and the error, and the correlation constitutes a preset constraint condition, and the control time includes the current time and multiple preset times between the current time and the target time;
[0008] Determine the target thrust exerted on the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition;
[0009] The balancing vehicle is driven and controlled based on the target thrust received by the balancing vehicle at the current moment.
[0010] Optionally, a first time length is provided between each two adjacent preset moments, a first time length is provided between the first preset moment and the current moment, and a first time length is provided between the last preset moment and the target moment; correspondingly, the method of predicting a second state quantity of the self-balancing vehicle at the target moment by using a model predictive control algorithm based on the first state quantity and the dynamics model of the self-balancing vehicle includes:
[0011] Determine a discretized state transfer matrix of the self-balancing vehicle according to the dynamic model;
[0012] The state quantity at each of the preset moments and the second state quantity are determined according to the first state quantity and the discretized state transfer matrix.
[0013] Optionally, determining a discretized state transfer matrix of the self-balancing vehicle according to the dynamic model includes:
[0014] Determining a state space expression of the self-balancing vehicle according to a dynamic model of the self-balancing vehicle;
[0015] The discretized state transfer matrix is determined according to the state space expression of the balancing vehicle.
[0016] Optionally, after determining the state quantity at each of the preset moments and the second state quantity according to the first state quantity and the discretized state transfer matrix, the control method of the balancing vehicle further includes:
[0017] The preset constraint condition is determined according to the second state quantity obtained by using the discretized state transfer matrix and the error.
[0018] Optionally, a first time length is provided between each two adjacent preset moments, a first time length is provided between the first preset moment and the current moment, and a first time length is provided between the last preset moment and the target moment; the state quantity of the balance vehicle is described by the position and speed of the balance vehicle, the swing angle of the inverted pendulum of the balance vehicle, and the angular velocity of the inverted pendulum;
[0019] Correspondingly, the method of predicting the second state quantity of the self-balancing vehicle at the target time by using a model predictive control algorithm based on the first state quantity and the dynamic model of the self-balancing vehicle includes:
[0020] According to the dynamic model of the self-balancing vehicle, determining the acceleration expression of the self-balancing vehicle and the angular acceleration expression of the inverted pendulum;
[0021] According to the acceleration expression and the angular acceleration expression, the state quantity of the balancing vehicle at each of the preset moments and the second state quantity are obtained by recursion method.
[0022] Optionally, the state quantity of the balancing vehicle at each of the preset moments and the second state quantity are obtained by recursive method according to the acceleration expression and the angular acceleration expression, including:
[0023] Determine the velocity expression of the balancing vehicle and the angular velocity expression of the inverted pendulum according to the acceleration expression and the angular acceleration expression;
[0024] Determine the position expression of the balancing vehicle and the swing angle expression of the inverted pendulum according to the speed expression and the angular velocity expression;
[0025] According to the speed expression, the angular velocity expression, the position expression and the swing angle expression, the state quantity of the balancing vehicle at each of the preset moments and the second state quantity are successively obtained by recursion method.
[0026] In a second aspect, an embodiment of the present application provides a control device for a balancing vehicle, comprising:
[0027] A first acquisition unit, used to acquire a first state quantity of the self-balancing vehicle at a current moment;
[0028] A first determination unit is used to predict a second state quantity of the self-balancing vehicle at a target time by using a model predictive control algorithm based on the first state quantity and a dynamic model of the self-balancing vehicle, and determine an error between the second state quantity and an expected state quantity of the self-balancing vehicle at the target time; the second state quantity is related to the first state quantity, the thrust received by the self-balancing vehicle at each control time, and the error, and the correlation constitutes a preset constraint condition, and the control time includes the current time and multiple preset times between the current time and the target time;
[0029] A second determining unit is used to determine the target thrust received by the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition;
[0030] A driving control unit is used to drive and control the balancing vehicle based on the target thrust received by the balancing vehicle at the current moment.
[0031] In a third aspect, an embodiment of the present application provides another control device for a balancing vehicle, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, it implements the control method for the balancing vehicle described in the first aspect or any optional method of the first aspect.
[0032] In a fourth aspect, an embodiment of the present application provides a balance vehicle, comprising the control device of the balance vehicle described in the third aspect.
[0033] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the control method of the balance vehicle as described in the first aspect or any optional method of the first aspect is implemented.
[0034] In a sixth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a balance vehicle, the balance vehicle executes the control method of the balance vehicle described in the first aspect or any optional method of the first aspect.
[0035] The control method, device, balance vehicle, computer-readable storage medium, and computer program product provided by the embodiments of the present application have the following beneficial effects:
[0036] The control method of the balance vehicle provided in the embodiment of the present application obtains the first state quantity of the balance vehicle at the current moment, and based on the first state quantity and the dynamic model of the balance vehicle, uses the model prediction control algorithm to predict the second state quantity of the balance vehicle at the target moment, and determines the error between the second state quantity and the expected state quantity of the balance vehicle at the target moment, and determines the target thrust received by the balance vehicle at each control moment when the absolute value of the error is the minimum under the condition of satisfying the preset constraint condition, and drives and controls the balance vehicle based on the target thrust received by the balance vehicle at the current moment. Since the correlation between the second state quantity and the first state quantity, the thrust received by the balance vehicle at each control moment, and the error constitutes the preset constraint condition, the thrust received by the balance vehicle determined by the model prediction method is within the range of the driving force that the balance vehicle can provide, so that it can be ensured that the balance vehicle will not lose stability when the balance vehicle is driven and controlled based on the determined thrust, thereby improving the stability of the balance vehicle control. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0038] Figure 1 A structural schematic diagram of a trolley inverted pendulum model provided in an embodiment of the present application;
[0039] Figure 2 A schematic flow chart of a control method for a balancing vehicle provided in an embodiment of the present application;
[0040] Figure 3 A flowchart of the specific implementation of S22 in a method for controlling a balancing vehicle provided in an embodiment of the present application;
[0041] Figure 4 A flowchart of a specific implementation of S22 in a method for controlling a balancing vehicle provided in another embodiment of the present application;
[0042] Figure 5 A schematic diagram of the structure of a control device for a balancing vehicle provided in an embodiment of the present application;
[0043] Figure 6 A schematic structural diagram of a control device for a balancing vehicle provided in another embodiment of the present application. DETAILED DESCRIPTION
[0044] It should be noted that the terms used in the implementation methods of the embodiments of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two, "at least one" and "one or more" mean one, two or more than two.
[0045] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, it is defined that the "first" and "second" features may explicitly or implicitly include one or more of the features.
[0046] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0047] The control method of the balance vehicle provided in the embodiment of the present application is applied to balance vehicles, including but not limited to a one-wheel balance vehicle or a two-wheel balance vehicle. A balance vehicle control device may be provided inside the balance vehicle. In the embodiment of the present application, the execution subject of the control method of the balance vehicle is the control device of the balance vehicle. By configuring a target script file for the control device of the balance vehicle, the control method of the balance vehicle provided in the embodiment of the present application is described by the target script file, so that the control device of the balance vehicle executes the target script file when driving and controlling the balance vehicle, and then executes each step in the control method of the balance vehicle provided in the embodiment of the present application.
[0048] The balancing car can usually be simplified as an inverted pendulum model. Figure 1 , is a schematic diagram of the structure of a trolley inverted pendulum model provided in an embodiment of the present application. Figure 1 As shown, the trolley inverted pendulum model may include an inverted pendulum 11 and a trolley 12. The inverted pendulum 11 and the trolley 12 may be connected via a hinge, and the thrust applied to the trolley 12 may be controlled. The swing angle θ of the inverted pendulum 11 and the position of the trolley can be controlled.
[0049] Based on this, the dynamic model of the balance car can be expressed as:
[0050]
[0051] Wherein, M is the mass of the trolley 12, m is the mass of the inverted pendulum 11, is the acceleration of the car 12 (i.e., the balancing car), l is the length of the inverted pendulum 11, θ is the swing angle of the inverted pendulum 11 (i.e., the deflection angle of the inverted pendulum 11 relative to the vertical direction), is the angular velocity of the inverted pendulum 11, is the angular acceleration of the inverted pendulum 11, J is the moment of inertia of the inverted pendulum 11 around the hinge, g is the acceleration of gravity, and u is the thrust exerted on the trolley 12 (i.e., the balancing car).
[0052] In the embodiment of the present application, the state quantity of the balancing vehicle can be defined as:
[0053]
[0054] Wherein, x is the position of the balancing vehicle (i.e., the vehicle 12), To balance the speed of the car.
[0055] The control method of the balance vehicle provided in the embodiment of the present application is described in detail below.
[0056] See also Figure 2 , is a schematic flow chart of a control method of a balancing vehicle provided in an embodiment of the present application. Figure 2 As shown, the control method of the balancing vehicle may include S21 to S24, which are described in detail as follows:
[0057] S21: Obtain a first state quantity of the balancing vehicle at the current moment.
[0058] The current moment may be any moment during the movement of the balancing vehicle, that is, at each moment during the movement of the balancing vehicle, the control device of the balancing vehicle executes S21 to S24 in the embodiment of the present application.
[0059] The first state quantity can be described by the current position, speed, swing angle and angular velocity of the inverted pendulum of the balancing vehicle. The current position, speed, swing angle and angular velocity of the inverted pendulum of the balancing vehicle can be acquired by sensors inside the balancing vehicle.
[0060] For example, if the current time is time k, the first state quantity is:
[0061]
[0062] Among them, s k is the first state quantity, x k is the position of the balancing car at time k, is the speed of the balancing car at time k, θ k is the swing angle of the balancing car at time k, is the angular velocity of the balancing car at time k.
[0063] S22: Based on the first state quantity and the dynamic model of the self-balancing vehicle, a model predictive control algorithm is used to predict a second state quantity of the self-balancing vehicle at a target time, and an error between the second state quantity and an expected state quantity of the self-balancing vehicle at the target time is determined.
[0064] The target time can be any time after the current time. The time interval between the target time and the current time can be set according to actual needs and is not particularly limited here.
[0065] The second state quantity is related to the first state quantity of the balancing vehicle at the current moment, the thrust exerted on the balancing vehicle at each control moment, and the error between the second state quantity of the balancing vehicle at the target moment and the expected state quantity of the balancing vehicle at the target moment, and the correlation between the three constitutes a preset constraint condition.
[0066] The control time includes the current time and a plurality of preset time between the current time and the target time. The number of preset time can be set according to actual needs and is not particularly limited here.
[0067] For example, if the current time is time k, the time interval between the target time and the current time is T s , then the target time is k+T s Moment. If there are N-1 equally spaced preset moments between the current moment and the target moment, and the time interval between the first preset moment and the current moment is equal to the time interval between each adjacent preset moment, and the time interval between the last preset moment and the target moment is also equal to the time interval between each adjacent preset moment, then the N-1 preset moments can be:
[0068] k+T s / N,k+2*T s / N,...,(N-1)k+T s / N.
[0069] That is, the interval between each two adjacent preset moments is T s / N, the interval between the current time and the first preset time is T s / N, the interval between the N-1th preset time and the target time is also T s / N.
[0070] For ease of description, the N-1 preset moments may be represented by the order of the N-1 preset moments. For example, the first preset moment may be represented as k+1, and the N-1 preset moments may be simplified as follows:
[0071] k+1,k+2,...,k+N-1.
[0072] Then, the control moments are:
[0073] k,k+1,k+2,...,k+N-1.
[0074] The thrust of the balancing car at each control moment can be expressed as:
[0075] [u k u k+1 ...u k+N-1 ] T .
[0076] In one embodiment of the present application, the model predictive control algorithm may be a linear model predictive control (MPC) algorithm. Based on this, the step of using the model predictive control algorithm to predict the second state of the self-balancing vehicle at the target time based on the first state and the dynamic model of the self-balancing vehicle may be performed as follows: Figure 3 The implementation of S221 to S222 shown is described in detail as follows:
[0077] S221: Determine a discretized state transfer matrix of the self-balancing vehicle according to the dynamic model.
[0078] In this embodiment, the discretized state transfer matrix can be determined by the following two steps:
[0079] Step 1: Determine the state space expression of the self-balancing vehicle according to the dynamic model of the self-balancing vehicle.
[0080] Step 2: Determine the discretized state transfer matrix according to the state space expression of the self-balancing vehicle.
[0081] Specifically, the dynamic model of the balancing vehicle can be linearized at the equilibrium position to obtain the linearized equation of the dynamic model of the balancing vehicle at the equilibrium position, as follows:
[0082]
[0083] The equilibrium position refers to the position where the swing angle θ of the inverted pendulum of the balancing vehicle is equal to 0, that is, the inverted pendulum of the balancing vehicle is in the vertical direction.
[0084] Since the state quantity of the balancing car is Therefore, according to the state quantity of the balance car, the state space expression of the balance car can be obtained as follows:
[0085]
[0086] in, is the state space expression of the balancing car.
[0087] In this embodiment, for the convenience of description, the state space expression of the balancing vehicle can be simplified as follows: Then we can get:
[0088]
[0089] In this embodiment, after obtaining the state space expression of the balancing vehicle, the state transfer equation of the balancing vehicle can be determined based on the state space expression of the balancing vehicle, and then the discretized state transfer matrix of the balancing vehicle can be determined according to the state transfer equation of the balancing vehicle.
[0090] As an example but not limitation, the state transfer equation of the balancing vehicle can be determined according to the forward Euler method.
[0091] Specifically, the state space expression of the balancing car can also be expressed as:
[0092]
[0093] Among them, s(k+1) is the state of the balancing car at time k+1, and s(k) is the state of the balancing car at time k.
[0094] Therefore, we can get:
[0095]
[0096] Transforming formula (1) yields:
[0097] s(k+1)=(I+T s / N*A)s(k)+T s / N*Bu(k).
[0098] Among them, I is the unit matrix, and u(k) is the thrust exerted on the balancing car at time k.
[0099] The order of I is the same as the number of parameters in the state quantity of the balancing vehicle. In this embodiment, since the state quantity of the balancing vehicle includes 4 parameters, I is a fourth-order unit matrix.
[0100] Other Then we can get the state transfer equation of the balance car as follows:
[0101]
[0102] According to the state transfer equation of the balance car, the discretized state transfer matrix of the balance car can be obtained as follows:
[0103]
[0104] Among them, S k+1 is the state of the balancing car at time k+1, s k is the state of the balancing car at time k, u k is the thrust on the balancing car at time k.
[0105] S222: Determine the state quantity at each of the preset moments and the second state quantity according to the first state quantity and the discretized state transfer matrix.
[0106] In this embodiment, it is assumed that the thrust of the balancing vehicle at each control moment is
[0107] [u k u k+1 ... u k+N-1 ] T ;
[0108] Then, according to the first state quantity and the discretized state transfer matrix of the balancing vehicle, the state quantity of the balancing vehicle at each preset time and the state quantity of the balancing vehicle at the target time can be obtained, which are as follows:
[0109]
[0110] Among them, S(k+1) is the state quantity of the balance car at the first preset time, S(k+2) is the state quantity of the balance car at the second preset time, and so on, S(k+N-1) is the state quantity of the balance car at the N-1th preset time. S(k+N) is the second state quantity of the balance car at the target time.
[0111] It should be noted that the thrust exerted on the balancing vehicle at each moment is an unknown quantity, which needs to be obtained through S21 to S23 of the present application.
[0112] In the embodiment of the present application, the expected state quantity of the balancing vehicle at each moment during the movement process can be preset. The preset expected state quantity of the balancing vehicle at each moment during the movement process can be stored in the local memory of the balancing vehicle. The control device of the balancing vehicle can obtain the expected state quantity of the balancing vehicle at the target moment from the local memory of the balancing vehicle.
[0113] Afterwards, the second state quantity of the balancing vehicle at the target time can be subtracted from the expected state quantity of the balancing vehicle at the target time to obtain the error between the two, that is, the error between the two can be expressed as:
[0114] w=S d -S(k+N) Formula (3)
[0115] Where w is the error between the second state of the balancing vehicle at the target time and the expected state of the balancing vehicle at the target time, S d is the second state quantity of the balancing vehicle at the target time, and S(k+N) is the expected state quantity of the balancing vehicle at the target time.
[0116] Since the state of the balancing car is described by the position, speed, swing angle and angular velocity of the inverted pendulum of the balancing car, the error between the second state of the balancing car and the expected state of the balancing car at the target time can also be expressed as:
[0117] w=[w1 w2 w3 w4] T ;
[0118] Among them, w1 is the error between the actual position of the balance car at the target time and the expected position of the balance car at the target time, w2 is the error between the actual speed of the balance car at the target time and the expected speed of the balance car at the target time, w3 is the error between the actual swing angle of the inverted pendulum of the balance car at the target time and the expected swing angle of the inverted pendulum of the balance car at the target time, and w4 is the error between the actual angular velocity of the inverted pendulum of the balance car at the target time and the expected angular velocity of the inverted pendulum of the balance car at the target time.
[0119] In one embodiment of the present application, when the MPC algorithm is used to determine the target thrust of the balancing vehicle at each control moment, the preset constraint condition can be determined according to the second state quantity of the balancing vehicle at the target moment obtained by using the discretized state transfer matrix (i.e., formula (2)) and the error between the second state quantity and the expected state quantity at the target moment (i.e., formula (3)). That is, according to formula (2) and formula (3), the following preset constraint condition can be obtained:
[0120]
[0121] S23: Determine the target thrust that the balancing vehicle receives at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition.
[0122] In the embodiment of the present application, since the error between the second state quantity of the balancing vehicle at the target time and the expected state quantity of the balancing vehicle at the target time may be a positive value or a negative value, the smaller the absolute value of the error or the square of the error is, the closer the second state quantity is to the expected state quantity.
[0123] It can be understood that the problem of determining the target thrust exerted on the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraints is a quadratic programming problem.
[0124] Based on this, in one embodiment of the present application, when the MPC algorithm is used to determine the target thrust of the balancing vehicle at each control moment, the following equation can be obtained through the standard form of quadratic programming:
[0125]
[0126] In this embodiment, a quadratic programming solver may be used to solve the equation to obtain the target thrust exerted on the balancing vehicle at each control moment.
[0127] S24: driving and controlling the self-balancing vehicle based on the target thrust received by the self-balancing vehicle at the current moment.
[0128] In the embodiment of the present application, after the target thrust received by the balancing vehicle at each control moment is obtained, the balancing vehicle can be driven and controlled according to the target thrust received by the balancing vehicle at the current moment.
[0129] From the above, it can be seen that the control method of the balance car provided in this embodiment obtains the first state quantity of the balance car at the current moment, and based on the first state quantity and the dynamic model of the balance car, uses the model prediction control algorithm to predict the second state quantity of the balance car at the target moment, and determines the error between the second state quantity and the expected state quantity of the balance car at the target moment, and determines the target thrust of the balance car at each control moment when the absolute value of the error is the minimum under the condition of satisfying the preset constraint condition, and drives and controls the balance car based on the target thrust of the balance car at the current moment. Since the correlation between the second state quantity and the first state quantity, the thrust of the balance car at each control moment, and the error constitutes the preset constraint condition, the thrust of the balance car determined by the model prediction method is within the range of the driving force that the balance car can provide, so that it can be ensured that the balance car will not lose stability when the balance car is driven and controlled based on the determined thrust, thereby improving the stability of the balance car control.
[0130] In addition, by linearizing the dynamic model of the balancing vehicle near the equilibrium position, not only the control algorithm of the balancing vehicle can be simplified, but also the stability of the balancing vehicle near the equilibrium position can be improved.
[0131] However, if the balancing vehicle deviates far from the equilibrium position, the above method cannot ensure that the balancing vehicle is still in a stable state, that is, the use of a linearized model predictive control algorithm can ensure the stability of the balancing vehicle near the equilibrium position, but cannot ensure the stability of the balancing vehicle when it deviates from the equilibrium position. Based on this, in another embodiment of the present application, a nonlinear model predictive control (NMPC) algorithm can be used to determine the thrust exerted on the balancing vehicle at each control moment.
[0132] See also Figure 4 , is a schematic flow chart of a control method of a balancing vehicle provided by another embodiment of the present application. Figure 3 As shown, this embodiment and Figure 2-Figure 3 The difference between the corresponding embodiments is that S22 in this embodiment includes S223 to S224, which are described in detail as follows:
[0133] S223: Determine the acceleration expression of the balancing vehicle and the angular acceleration expression of the inverted pendulum according to the dynamic model of the balancing vehicle.
[0134] In this embodiment, the dynamic model of the balance vehicle is deformed to obtain the acceleration expression of the balance vehicle and the angular acceleration expression of the inverted pendulum as follows:
[0135]
[0136] S224: According to the acceleration expression and the angular acceleration expression, a recursive method is used to recursively obtain the state quantity of the balancing vehicle at each of the preset moments and the second state quantity.
[0137] In a possible implementation, a recursive method is used to determine the second state quantity of the balancing vehicle at the target time, which may specifically include the following steps:
[0138] Step 1: According to the acceleration expression and the angular acceleration expression, determine the speed expression of the balancing vehicle and the angular velocity expression of the inverted pendulum.
[0139] Step 2: According to the velocity expression and the angular velocity expression, determine the position expression of the balancing vehicle and the swing angle expression of the inverted pendulum.
[0140] Step 3: According to the speed expression, the angular velocity expression, the position expression and the swing angle expression, a recursive method is used to sequentially deduce the state quantity of the balancing vehicle at each of the preset moments and the second state quantity.
[0141] In this embodiment, according to formula (4), the acceleration expression of the balancing vehicle at each preset time and target time and the angular acceleration expression of the inverted pendulum are as follows:
[0142]
[0143] Then, the velocity expressions of the balancing car at each preset time and target time and the angular velocity expressions of the inverted pendulum can be as follows:
[0144]
[0145] The position expression of the balancing car at each preset time and target time and the swing angle expression of the inverted pendulum can be as follows:
[0146]
[0147] The control device of the self-balancing vehicle can start from time k+1 and, based on the above formulas (5), (6) and (7), recursively deduce the state of the self-balancing vehicle at time k+1, k+2, ..., k+N-1 and k+N. Then, the self-balancing vehicle at time k+T s The second state quantity at time (i.e. target time) can be expressed as:
[0148]
[0149] In this embodiment, since the relationship between the state quantity of the balancing vehicle and the thrust received by the balancing vehicle cannot be expressed by a definite relationship, the relationship between the state quantity of the balancing vehicle and the thrust received by the balancing vehicle is expressed by the function s i (u) is used to represent this. Based on this, the preset constraint condition can be s i (u)≥0. The following equation can be obtained through the standard form of quadratic programming:
[0150]
[0151] The equation is solved by a quadratic programming solver to obtain the target thrust of the balancing vehicle at each control moment.
[0152] From the above, it can be seen that the control method of the balance vehicle provided in this embodiment adopts a nonlinear model prediction method, which can not only improve the stability of the balance vehicle near the equilibrium position, but also improve the stability of the balance vehicle near the non-equilibrium position, that is, the global stability control of the balance vehicle can be achieved.
[0153] It is understandable that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0154] Based on the control method of the self-balancing vehicle provided in the above embodiment, the present invention further provides an embodiment of a control device for a self-balancing vehicle that implements the above method embodiment. Figure 5 , is a schematic diagram of the structure of a control device for a balancing vehicle provided in an embodiment of the present application. For ease of description, only the parts related to this embodiment are shown. Figure 5 As shown, the control device 50 of the self-balancing vehicle may include: a first acquisition unit 51, a first determination unit 52, a second determination unit 53 and a drive control unit 54. Among them:
[0155] The first acquisition unit 51 is used to acquire a first state quantity of the balancing vehicle at a current moment.
[0156] The first determination unit 52 is used to predict the second state quantity of the balance vehicle at the target time by using a model predictive control algorithm based on the first state quantity and the dynamic model of the balance vehicle, and determine the error between the second state quantity and the expected state quantity of the balance vehicle at the target time; the second state quantity is related to the first state quantity, the thrust exerted on the balance vehicle at each control time, and the error, and the correlation constitutes a preset constraint condition, and the control time includes the current time and multiple preset times between the current time and the target time.
[0157] The second determination unit 53 is used to determine the target thrust received by the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition.
[0158] The driving control unit 54 is used to control the driving of the self-balancing vehicle based on the target thrust received by the self-balancing vehicle at the current moment.
[0159] Optionally, the interval between each two adjacent preset moments is the first time length, the interval between the first preset moment and the current moment is the first time length, and the interval between the last preset moment and the target moment is the first time length; correspondingly, the first determination unit 52 includes a state transfer matrix determination unit and a state quantity determination unit. Wherein:
[0160] The state transfer matrix determination unit is used to determine the discretized state transfer matrix of the balance vehicle according to the dynamic model.
[0161] The state quantity determination unit is used to determine the state quantity at each of the preset moments and the second state quantity according to the first state quantity and the discretized state transfer matrix.
[0162] Optionally, the state transfer matrix determination unit is specifically used for:
[0163] Determining a state space expression of the self-balancing vehicle according to a dynamic model of the self-balancing vehicle;
[0164] The discretized state transfer matrix is determined according to the state space expression of the balancing vehicle.
[0165] Optionally, the control device 50 of the balancing vehicle further includes a third determination unit.
[0166] The third determination unit is used to determine the preset constraint condition according to the second state quantity obtained by using the discretized state transfer matrix and the error.
[0167] Optionally, a first time length is provided between each two adjacent preset moments, a first time length is provided between the first preset moment and the current moment, and a first time length is provided between the last preset moment and the target moment; the state quantity of the balance vehicle is described by the position and speed of the balance vehicle, the swing angle of the inverted pendulum of the balance vehicle, and the angular velocity of the inverted pendulum;
[0168] Correspondingly, the first determination unit 52 includes an expression determination unit and a recursion unit.
[0169] The expression determination unit is used to determine the acceleration expression of the balance vehicle and the angular acceleration expression of the inverted pendulum according to the dynamic model of the balance vehicle.
[0170] The recursive unit is used to obtain the state quantity of the balancing vehicle at each of the preset moments and the second state quantity by recursive method according to the acceleration expression and the angular acceleration expression.
[0171] Optionally, the recursive unit is specifically used for:
[0172] Determine the velocity expression of the balancing vehicle and the angular velocity expression of the inverted pendulum according to the acceleration expression and the angular acceleration expression;
[0173] Determine the position expression of the balancing vehicle and the swing angle expression of the inverted pendulum according to the speed expression and the angular velocity expression;
[0174] According to the speed expression, the angular velocity expression, the position expression and the swing angle expression, the state quantity of the balancing vehicle at each of the preset moments and the second state quantity are successively obtained by recursion method.
[0175] It should be noted that the information interaction, execution process and other contents between the above-mentioned units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be specifically referred to the method embodiment part and will not be repeated here.
[0176] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional units as needed, that is, the internal structure of the control device of the balance car can be divided into different functional units to complete all or part of the functions described above. The functional units in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0177] See also Figure 6 , Figure 6 This is a schematic diagram of the structure of a control device for a balancing vehicle provided in an embodiment of the present application. Figure 6 As shown, the control device 6 of the self-balancing vehicle provided in this embodiment may include: a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60, such as a program corresponding to the control method of the self-balancing vehicle. When the processor 60 executes the computer program 62, the steps in the control method of the self-balancing vehicle described above are implemented, such as Figure 2 Alternatively, when the processor 60 executes the computer program 62, the functions of each module / unit in the above-mentioned control device embodiment of the balancing vehicle are realized, for example Figure 5 The functions of the units 51 to 54 are shown.
[0178] Exemplarily, the computer program 62 may be divided into one or more modules / units, one or more modules / units are stored in the memory 61 and executed by the processor 60 to complete the present application. One or more modules / units may be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program 62 in the control device 6 of the balance vehicle. For example, the computer program 62 may be divided into a first acquisition unit, a first determination unit, a second determination unit, and a drive control unit. The functions of each unit can be described in detail in FIG. Figure 5 The relevant descriptions in the corresponding embodiments are not repeated here.
[0179] Those skilled in the art will understand that Figure 6 The control device 6 of the self-balancing vehicle is merely an example and does not constitute a limitation on the control device 6 of the self-balancing vehicle. The control device 6 may include more or fewer components than shown in the figure, or a combination of certain components, or different components.
[0180] The processor 60 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0181] The memory 61 may be an internal storage unit of the control device 6 of the balancing vehicle, such as a hard disk or memory of the control device 6 of the balancing vehicle. The memory 61 may also be an external storage device of the control device 6 of the balancing vehicle, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card or a flash card (flash card) equipped on the control device 6 of the balancing vehicle. Further, the memory 61 may also include both an internal storage unit and an external storage device of the control device 6 of the balancing vehicle. The memory 61 is used to store computer programs and other programs and data required by the control device of the balancing vehicle. The memory 61 may also be used to temporarily store data that has been output or is to be output.
[0182] The present application also provides a balancing vehicle, which may include Figure 5 or Figure 6 The control device of the balance vehicle in the corresponding embodiment.
[0183] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0184] An embodiment of the present application provides a computer program product. When the computer program product is run on a control device of a self-balancing vehicle, the control device of the self-balancing vehicle executes the steps in the above-mentioned method embodiments.
[0185] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0186] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0187] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for controlling a balancing vehicle, characterized in that: include: Obtaining a first state quantity of the balancing vehicle at the current moment; Based on the first state quantity and the dynamic model of the self-balancing vehicle, a nonlinear model predictive control algorithm is used to predict the second state quantity of the self-balancing vehicle at a target time, and an error between the second state quantity and the expected state quantity of the self-balancing vehicle at the target time is determined; the target time is any time after the current time; the second state quantity is related to the first state quantity, the thrust received by the self-balancing vehicle at each control time, and the error, and the correlation constitutes a preset constraint condition, and the relationship between the state quantity of the self-balancing vehicle and the thrust received by the self-balancing vehicle is determined by s i (u) indicates that the preset constraint condition is s i (u)≥0; the control time includes the current time and a plurality of preset times between the current time and the target time; Determine the target thrust exerted on the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition; Driving and controlling the self-balancing vehicle based on the target thrust received by the self-balancing vehicle at the current moment; The state quantity of the self-balancing vehicle is described by the position, speed, swing angle of the inverted pendulum of the self-balancing vehicle, and angular velocity of the inverted pendulum; correspondingly, based on the first state quantity and the dynamic model of the self-balancing vehicle, a nonlinear model predictive control algorithm is used to predict the second state quantity of the self-balancing vehicle at a target time, including: According to the dynamic model of the self-balancing vehicle, determining the acceleration expression of the self-balancing vehicle and the angular acceleration expression of the inverted pendulum; According to the acceleration expression and the angular acceleration expression, a recursive method is used to recursively obtain the state quantity of the balancing vehicle at each of the preset moments and the second state quantity; The determining of the target thrust exerted on the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition comprises: The quadratic programming solver is used to solve the following equation to obtain the target thrust of the balancing vehicle at each control moment: Wherein, w is the error, u is the target thrust of the balancing vehicle at each control moment, and s i is the state quantity of the balancing vehicle at each control moment.
2. The control method of the balancing vehicle according to claim 1, characterized in that: The method of recursively obtaining the state quantity of the balancing vehicle at each of the preset moments and the second state quantity according to the acceleration expression and the angular acceleration expression includes: Determine the velocity expression of the balancing vehicle and the angular velocity expression of the inverted pendulum according to the acceleration expression and the angular acceleration expression; Determine the position expression of the balancing vehicle and the swing angle expression of the inverted pendulum according to the speed expression and the angular velocity expression; According to the speed expression, the angular velocity expression, the position expression and the swing angle expression, the state quantity of the balancing vehicle at each of the preset moments and the second state quantity are successively obtained by recursion method.
3. A control device for a balancing vehicle, characterized in that: include: A first acquisition unit, used to acquire a first state quantity of the self-balancing vehicle at a current moment; The first determination unit is used to predict the second state quantity of the self-balancing vehicle at a target time by using a nonlinear model predictive control algorithm based on the first state quantity and the dynamic model of the self-balancing vehicle, and determine the error between the second state quantity and the expected state quantity of the self-balancing vehicle at the target time; the target time is any time after the current time; the second state quantity is related to the first state quantity, the thrust received by the self-balancing vehicle at each control time, and the error, and the correlation constitutes a preset constraint condition, and the relationship between the state quantity of the self-balancing vehicle and the thrust received by the self-balancing vehicle is determined by s i (u) indicates that the preset constraint condition is s i (u)≥0; the control time includes the current time and a plurality of preset times between the current time and the target time; A second determining unit is used to determine the target thrust received by the balancing vehicle at each control moment when the absolute value of the error is minimized while satisfying the preset constraint condition; A driving control unit, used for driving and controlling the self-balancing vehicle based on the target thrust received by the self-balancing vehicle at the current moment; The state quantity of the balancing vehicle is described by the position, speed, swing angle of the inverted pendulum of the balancing vehicle and the angular velocity of the inverted pendulum; correspondingly, the first determining unit includes: An expression determination unit, used to determine the acceleration expression of the balance vehicle and the angular acceleration expression of the inverted pendulum according to the dynamic model of the balance vehicle; A recursive unit, configured to obtain the state quantity of the balancing vehicle at each of the preset moments and the second state quantity by recursive method according to the acceleration expression and the angular acceleration expression; The second determining unit is specifically configured to: The quadratic programming solver is used to solve the following equation to obtain the target thrust of the balancing vehicle at each control moment: Wherein, w is the error, u is the target thrust of the balancing vehicle at each control moment, and s i is the state quantity of the balancing vehicle at each control moment.
4. A control device for a balancing vehicle, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the processor implements the control method of the balance vehicle as claimed in any one of claims 1 to 2 when executing the computer program.
5. A balancing vehicle, characterized in that: Comprising the control device of the balancing vehicle as described in claim 3 or 4.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the control method of the balance vehicle as described in any one of claims 1 to 2 is implemented.
