Next Article in Journal
Personalized Daily Hand Movement Training Methods and Effects: A Case Study
Previous Article in Journal
AraFast: Developing and Evaluating a Comprehensive Modern Standard Arabic Corpus for Enhanced Natural Language Processing
Previous Article in Special Issue
Enhanced Berth Mapping and Clothoid Trajectory Prediction Aided Intelligent Underground Localization
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Design and Implementation of a Two-Wheeled Self-Balancing Car Using a Fuzzy Kalman Filter

1
China Electric Power Research Institute, Beijing 100192, China
2
School of Automation, Beijing Information Science and Technology University, Beijing 100192, China
*
Author to whom correspondence should be addressed.
Submission received: 8 May 2024 / Revised: 10 June 2024 / Accepted: 13 June 2024 / Published: 19 June 2024
(This article belongs to the Special Issue Mobile Robotics and Autonomous Intelligent Systems)

Abstract

:
To improve the upright balancing performance of the two-wheeled self-balancing car, this paper proposes an attitude estimation algorithm based on fuzzy Kalman filtering. Fuzzy logic is used to correct the inclination angle and angular velocity of the two-wheeled self-balancing car, thereby optimizing the state of the Kalman filter and ultimately improving the balancing performance of the car. This paper combines dual closed-loop PID control with the complementary filtering algorithm, Kalman filtering algorithm, and fuzzy Kalman filtering algorithm to conduct experiments on a physical two-wheeled self-balancing car. The experimental results validate the superiority of the fuzzy Kalman filtering algorithm proposed in this paper for improving the upright balancing performance of the two-wheeled self-balancing car.

1. Introduction

With the advancement of science and technology, the two-wheeled self-balancing car has garnered renewed research interest and widespread application development owing to its simple structure, agile maneuverability, capacity to navigate narrow spaces and execute specialized tasks in unique environments, and adaptability to diverse terrains. Presently, various types of robots resembling the principles of the self-balancing car are ubiquitous in major venues such as shopping malls, transportation hubs, airports, and dining establishments [1]. The two-wheeled self-balancing car system resembles an inverted pendulum system, characterized by multivariable dynamics, nonlinearity, and strong coupling, rendering its study inherently complex [2]. However, in certain intricate environments, diverse interferences may induce disparate speeds between the left and right motors of the two-wheeled self-balancing car, thereby impeding the system’s ability to follow its intended trajectory. Key to maintaining precision and stability in controlling the car system lies in the accuracy and real-time acquisition of the vehicle’s attitude information and velocity measurements.
Attitude information stands as a cornerstone for ensuring the successful operation of the entire system. However, the two-wheeled self-balancing car cannot consistently traverse smooth, disturbance-free environments. Achieving optimal attitude control solely through attitude sensors in complex environments poses a considerable challenge. The integration of filtering algorithms into the main controller ensures the integrity and accuracy of attitude information. A plethora of scholars have extensively researched this area, exploring methods such as feedback control [3], complementary filtering algorithms [4], and Kalman filtering algorithms [5]. Reference [4] presents a system design for a quadcopter based on an improved complementary filtering fusion approach, showcasing minimal static error, smooth dynamic curve transitions, and ideal real-time tracking performance. Similarly, reference [6] utilizes a complementary filtering algorithm to enhance the system’s dynamic characteristics with low computational overhead, facilitating real-time measurement of terrain undulations during the locomotion process of intelligent agents. The Kalman filtering algorithm, pioneered by American scientist Kalman in 1960, initially demonstrated significant effectiveness in the field of positioning and navigation. In contrast to complementary filtering algorithms, the Kalman filtering algorithm cleverly integrates observed and estimated data, managing errors in a closed-loop manner and confining them within a defined range, rendering it more straightforward to implement than alternative filters. Importantly, the Kalman filtering algorithm does not necessitate all past observations but estimates the current signal value based on the preceding estimate and the most recent observation. Implemented through state equations and recursion methods, the Kalman filter does not impose requirements on the stationarity or time invariance of signals [7]. Reference [8] applies the Kalman filtering algorithm to PID control of a micro-rotorcraft system, successfully conducting experimental flight control tests. This method achieves excellent filtering effects, fulfilling the objective of stable flight for the aircraft. Similarly, reference [9] realizes real-time tracking of mobile robots using the Kalman filtering algorithm. References [10,11] advocate for the use of Kalman filtering for attitude estimation in aircraft attitude control, leveraging quaternions as state variables and accelerometers as observation quantities for state updates. The Kalman filtering algorithm demonstrates commendable real-time performance and convergence. However, challenges persist due to the covariance matrix and measurement process noise inherent in the Kalman filtering model, making it difficult to accurately ascertain the statistical characteristics of the covariance matrix. While the Kalman filter’s theoretical foundation lies in linear Gaussian systems, its efficacy may diminish for nonlinear, non-Gaussian systems. In contrast, fuzzy control can address nonlinear and fuzzy problems, rendering it suitable for complex systems.
Fuzzy control represents an intelligent control methodology grounded in fuzzy set theory, fuzzy linguistic variables, and fuzzy logic reasoning, which emulates human fuzzy reasoning and decision-making processes [12]. This approach encompasses three primary components: fuzzification, fuzzy control rule generation, and defuzzification. Fuzzification converts precise inputs into fuzzy inputs, while fuzzy control rule generation infers output fuzzy quantities from input fuzzy quantities. Finally, the defuzzification process transforms fuzzy outputs into precise outputs. In addressing the challenge of inaccurate attitude angle estimation during carrier motion, reference [13] proposes the adoption of a fuzzy Kalman filtering algorithm for attitude estimation. Leveraging accelerometer data as an input to the fuzzy controller, this approach notably enhances accuracy during motion and augments real-time performance under static, rotational, and motion conditions. Similarly, reference [14] introduces a parking kinematic model employing fuzzy Kalman filtering for vehicle speed estimation. This model effectively mitigates calculation errors in displacement and heading angle during parking maneuvers. Reference [15] combines fuzzy theory with a Kalman filter for processing unobservable spectral components of uncertain experimental data. In reference [16], a fuzzy PI model regulator and an adaptive Kalman filter are applied to accurately estimate the state of charge. Moreover, reference [17] constructs a mobile robot kinematic model within Simulink and designs a fuzzy controller based on real-time robot angles to facilitate precise obstacle avoidance.
This study addresses the issue of low stability in sensor data acquisition for the two- wheeled self-balancing car by integrating a fuzzy controller into the Kalman filter, proposing the fuzzy Kalman filtering algorithm to enhance the speed and stability of the upright loop of the two-wheeled self-balancing car. Accelerometer data are utilized as an input for the fuzzy controller, and fuzzy logic is employed to adjust the parameters of the Kalman filtering algorithm. The Kalman filtering measurement noise variance is continuously adjusted to obtain the optimal estimate of the car’s balance posture. Additionally, a dual closed-loop PID control algorithm is formulated, incorporating attitude information and velocity as feedback control variables. This algorithm is combined with the use of the high-performance STM32F103C8T6 (STMicroelectronics corporation from Geneva, Switzerland) chip as the main controller to enhance the stability and anti-interference capability of the two-wheeled self-balancing car system. To compare the proposed fuzzy Kalman filtering algorithm with other methods, namely complementary filtering and Kalman filtering algorithms, in terms of speed and stability on the two-wheeled self-balancing car, this study conducted comparative verifications. Through simulation comparisons, the fuzzy Kalman filtering algorithm proposed in this paper demonstrates stronger system stability and anti-interference capability.
This paper is structured as follows: Section 2 describes the two-wheeled self-balancing car system and includes the dynamic model of the considered two-wheeled self-balancing car and the PD control algorithm of the upright loop of the two-wheeled self-balancing car. Section 3 proposes the fuzzy Kalman filtering algorithm to leverage information derived from observation data to continuously estimate and rectify the model and noise statistical characteristics in real time. To compare with other filtering algorithms, this section also briefly introduces the classical Kalman filtering theory without fuzzy theory and the widely used complementary filtering theory. Section 4 focuses on verifying the effectiveness of the mentioned methods under a laboratory test environment. Section 5 summarizes the findings and conclusions of the study.

2. The Two-Wheeled Self-Balancing Car System

Figure 1 depicts a physical representation of the two-wheeled self-balancing car under study in this paper. The primary components of the system include an angle acquisition module, MPU-6050 sensor (TDK corporation from Japan Tokyo), STM32 control module (STMicroelectronics corporation from Geneva, Switzerland), motor drive module, and signal acquisition module. The overall circuit design of the experimental car system is illustrated in Figure 2. Utilizing the STM32F103C8T6 (STMicroelectronics corporation from Geneva, Switzerland) as the main control chip, it facilitates high-speed processing of sensor data, execution of control algorithms, and communication with the upper computer. The vehicle is powered by a 3S battery, providing a stable 12 V output voltage. The motor drive circuit employs the TB6612FNG motor drive chip (Toshiba-Semiconductor from Bangkok, Thailand). The attitude sensor utilized is the MPU-6050 (TDK corporation from Tokyo, Japan), which integrates both an accelerometer and a gyroscope, capable of measuring acceleration and angular velocity along the vertical, coronal, and sagittal axes.

2.1. Dynamic Model of the Two-Wheeled Self-Balancing Car

The two-wheeled self-balancing car can be conceptualized as an inverted pendulum model [18], with its force analysis diagram illustrated in Figure 3.
In Figure 3, the mass of the car body is denoted as m , the inclination angle with respect to the vertical direction is θ , the angular velocity of the car body is represented by ϖ , the acceleration of the car is denoted by a , and the magnitude of the inertial force acting on the car, inertial F , is proportional to the acceleration a , with the proportionality coefficient being the mass m , i.e., F = m a . When the inclination angle θ is small, the acceleration a is directly proportional to the inclination angle θ , with the proportionality coefficient denoted by k 1 , yielding the dynamic equation of the car:
F = m g θ m k 1 θ .
When k 1 > g , the direction of the restoring force F is opposite to the direction of inclination, thereby causing the car to return to its equilibrium position. If the car cannot accurately reach the neutral position and stabilize, it will inevitably oscillate around the neutral position, thus prolonging the time required for balance. In order to mitigate oscillations and achieve stability at the equilibrium position promptly, it is necessary to take into account additional damping force k 2 θ . The magnitude of this added damping force is directly proportional to the angular velocity θ , yet acts in the opposite direction, with the proportionality coefficient denoted by k 2 . Therefore, the dynamic equation of the car at this juncture can be succinctly expressed as follows:
F = m g θ m ( k 1 θ + k 2 θ ) .
The acceleration of the car can then be obtained as follows:
a = k 1 θ + k 2 θ .
Managing both the direction and magnitude of acceleration facilitates the control of the car’s attitude. In this context, the adjustment of the pulse width modulation (PWM) magnitude mirrors the regulation of the car’s acceleration. This method of controlling acceleration also encompasses the manipulation of the motor PWM, effectively serving as the controller for the car’s upright loop. The incremental PD, PI, and PD algorithms are, respectively, employed in the upright, velocity, and steering loops to achieve functions such as balancing and turning of the two-wheeled self-balancing car.
This note introduces a Fuzzy-Kalman-filtering-based attitude estimation algorithm to enhance the upright stability performance of the two-wheeled self-balancing car, with particular emphasis on filtering the measured angles and angular velocities of the car. The velocity and steering loops are utilized to control the car’s speed and turning.
Considering the state-space model of the two-wheeled self-balancing car depicted in Figure 1, it is formulated as follows:
θ k θ b k = 1 T 0 1 θ k 1 θ b k 1 + T 0 θ k 1 + q q ,
θ c k = θ k + r ,
where θ k R and θ k R , respectively, represent the actual angle and angular velocity measured by the gyroscope of the two-wheeled self-balancing car at time k . θ b k R represents the gyroscope’s static error, where static error refers to the angular velocity value output by the gyroscope when the two-wheeled self-balancing car is stationary. θ c k R denotes the angle calculated by the accelerometer, T R represents the filtering period, q R and r R , respectively, denote the covariance of process noise and measurement noise.

2.2. The PD Control for the Two-Wheeled Self-Balancing Car

Upon initialization of the self-balancing car, the first step involves state detection to determine whether the current orientation matches the target inclination angle. If not, the motor is adjusted to accelerate accordingly, aiming to bring the vehicle to an upright position through angle control. Concurrently, the velocity sensor provides feedback on motor status to fine-tune input values, thereby establishing a complete negative feedback system. Upon the acquisition of angle information by the sensors, the angular velocity undergoes PD control within the upright loop to regulate the vehicle’s posture. Increasing the proportional coefficient enhances the vehicle’s responsiveness, while the differential coefficient influences the stability of the self-balancing car when it is not inclined. Once the proportional and differential coefficients are established, adjustments to the motion posture of the two-wheeled self-balancing car can be made based on speed information provided by the encoder feedback. The expression for its PD control within the upright loop can be simplified as follows:
M ( k ) = k p e ( k ) + k d ( e ( k ) e ( k 1 ) ) = k p [ θ ¯ k θ k ] + k d ( 0 θ k ) .
where θ ¯ k denotes the desired equilibrium angle, typically set to zero, and M ( k ) signifies the PWM value. k p and k d , respectively, correspond to the proportional and derivative coefficients of the PD control algorithm.
The precision of angle data acquisition significantly impacts the efficacy of control algorithms. However, relying solely on accelerometers and gyroscopes for angle determination presents certain limitations. Accelerometers provide relatively accurate long-term readings but exhibit notable fluctuations, potentially due to high-frequency noise contamination. Conversely, gyroscopes offer short-term accuracy but are susceptible to integration errors, suggesting the presence of low-frequency noise. To mitigate the adverse effects of noise on data accuracy, angle measurements obtained from accelerometers and gyroscopes can undergo filtering and smoothing procedures, thereby enhancing measurement precision.

3. Fuzzy Kalman Filtering Algorithm Design

In optimal conditions, when a dual-wheel self-balancing car operates under normal conditions, and with known system and measurement noise parameters, fixed complementary and Kalman filters effectively mitigate measurement errors. However, in scenarios where the vehicle’s measurement sensors deviate due to environmental disturbances or when external noise is uncertain, relying solely on a Kalman filter with predetermined noise parameters may fail to accurately ascertain the vehicle’s genuine angle and velocity information. This paper proposes a fusion of fuzzy control theory and the Kalman filtering method, leveraging information derived from observation data to continuously estimate and rectify the model and noise statistical characteristics in real time. Such an approach promises to enhance filtering performance and bolster the stability of the vehicle.
To compare with other filtering algorithms, this section first introduces the fuzzy Kalman filter algorithm proposed by the author, and then briefly introduces the classical Kalman filtering theory without fuzzy theory and the widely used complementary filtering theory.

3.1. Fuzzy Kalman Filtering Algorithm Design

This section first introduces the Kalman filtering algorithm for filtering the angle and angular velocity of the self-balancing car, followed by the establishment of the fuzzification and defuzzification processes of process noise and measurement noise based on the fuzzy theory.
The covariance of process noise and measurement noise experienced by the two-wheeled self-balancing car is:
q k = α k · q r k = β k · r
where q k R and r k R respectively, represent the covariance of process noise and measurement noise at time instant k , while α k R and β k R are used to adjust the parameters of measurement noise and process noise covariance.
The Kalman filter, as a linear optimal estimation algorithm, utilizes a “predict–measure–correct” pattern to eliminate random disturbances of the system by updating the measurement values, thus optimizing the restoration of the system’s state. The Kalman filter has two main functions, namely prediction and correction, as shown in Figure 4. Prediction involves the time update equation, while correction involves the measurement update equation. The time update equation estimates the a priori estimate and covariance of the state variables at the current time by evaluating the state value at the previous time, while the measurement equation calculates the posterior estimate by combining the a priori estimate with the current measurement value, achieving the purpose of correction.
A prior estimation of the angle and angular velocity of the two-wheeled self-balancing car is designed as follows:
θ ^ k θ ^ b k = 1 T 0 1 θ ^ k 1 θ ^ b k 1 + T 0 θ ^ k 1 ,
θ ^ c k = θ ^ k
where θ ^ k , θ ^ k , θ ^ c k and θ ^ b k are, respectively, the estimated values of the car’s angle, angular velocity, accelerometer angle, and static error.
The accelerometer angle obtained from the prior estimate needs to be corrected through posterior estimation. The covariance matrix of the posterior estimate is defined as P k [19], yielded using the following equation:
P k = I K k 1 H A P k 1 A T + Q k 1 , K k = K 1 k K 2 k = p 11 k p 11 k + r k p 21 k p 11 k + r k ,
θ c f k = θ ^ c ( k ) + P ( k ) ( θ c ( k ) θ ^ c ( k ) ) ,
where I is the unit matrix, K k is the Kalman gain vector, H = 1 0 , A = 1 T 0 1 ,   Q k 1 = q k 1 0 0 q k 1 , P k = p 11 k p 12 k p 21 k p 22 k , and θ c f k represents the corrected accelerometer angle, which is also the final output of the filter.
Two time-varying parameters, α k and β k are selected as the outputs of the fuzzy control; the noise covariance matrix of the filter is modified by adjusting the values of α k and β k .
Let e θ k = θ c k θ c f k be defined as the residual, indicating the extent to which the self-balancing car system relies on measurement values. The variance and mean of the residual can be used to assess the performance of the filter, with the mean and variance of residual are computed as follows:
e ¯ k = 1 n k = m n m e θ k ,
P ^ e k = 1 n k = m n + 1 m e θ k 2
where n R represents the statistical time length, m Z + . The mean and variance of the residual are chosen as inputs for fuzzy control. Next, the inputs α k and β k are fuzzified.
Drawing upon the fuzzy method outlined in reference [12], the mean residual e ¯ k and residual variance P ^ e k are subjected to fuzzification for the fuzzy rules. Triangular membership functions, comprising large (L), medium (M), and small (S) fuzzy sets, are selected. The waveform diagrams illustrating the membership functions for the mean and variance of the residual are depicted in Figure 5 and Figure 6, respectively.
The curves in the graph represent different scenarios based on the mean residual being less than or equal to 1 and the residual variance being less than or equal to 0.4, indicating that both fall within the small (S) fuzzy interval, signifying reliable measurement information for the two-wheeled self-balancing car. When the mean is between 1 and 3.5 and the variance is between 0.4 and 1.4, both are in the medium (M) fuzzy interval, indicating relatively reliable measurement information. Moreover, when the mean is between 3.5 and 5 and the variance is between 1.4 and 2, both are in the large (L) fuzzy interval, indicating unreliable measurement information. Based on the actual data and empirical evidence from the car’s operation, fuzzy rules are established as shown in Table 1.
Through fuzzy reasoning, the mean and variance of the residual are assessed, facilitating the real-time adjustment of covariance parameters for measurement noise and process noise in the Kalman filter. The centroid method [19] is employed as a defuzzification algorithm to derive specific numerical outputs.
(1)
When the output falls within the S fuzzy interval:
α k = 1 β k = 1
(2)
When the output falls within the M fuzzy interval:
α k = 0.8 0.1 P ^ e k β k = 1.4 + 0.1 P ^ e k
(3)
When the output falls within the L fuzzy interval:
α k = 0.6 0.2 e ¯ k β k = 1.2 + 0.2 e ¯ k
Remak 1. 
The calculation coefficients in defuzzification Equations (13)–(15) are primarily selected based on the scale values of the membership distribution chart. In this study, keeping the parameter α k as a fixed value, the parameter β k is continuously adjusted to achieve the optimal filtering effect. Conversely, when the parameter β k is fixed, adjustments are made to the parameter α k . Eventually, based on approximately 50 experimental and trial datasets, the feasibility of this dataset is inferred and further utilized for subsequent experiments to compare and validate the effectiveness of the algorithm.
For the purpose of comparative experiments, in the case where the PD control parameters remain unchanged for the upright, velocity, and steering loops of the two-wheeled self-balancing car, the following two sections will introduce two commonly used filtering algorithms for the car, namely the complementary filtering algorithm and traditional Kalman filtering algorithm.

3.2. Kalman Filtering Algorithm

The prior estimation of the angle and angular velocity of the two-wheeled self-balancing car is designed in the same way as (8) and (9), while the covariance matrix of the posterior estimate is
P k = I K k 1 H A P k 1 A T + Q , K k = K 1 k K 2 k = p 11 k p 11 k + r p 21 k p 11 k + r ,
θ c f k = θ ^ c ( k ) + P ( k ) ( θ c ( k ) θ ^ c ( k ) ) ,
where the meanings of I , H , A , P ( k ) , and θ c f k are the same as in Equation (10), Q = q 0 0 q . θ ^ c k is computed using Equation (9).

3.3. Complementary Filtering Algorithm

The complementary filtering algorithm, with its characteristics of low computational complexity, high reliability, and low precision requirements for inertial devices, is widely used in the attitude applications of various robots. The complementary filtering algorithm combines a low-pass filter and a high-pass filter, which are then overlaid to enhance the accuracy of attitude angular velocity [20]. The principle of the complementary filter is illustrated in Figure 6.
From Figure 7, it can be observed that in the low-frequency range below the cutoff frequency of the low-pass filter, the accelerometer primarily influences, while in the high-frequency range above the cutoff frequency of the high-pass filter, the gyroscope dominates. By adjusting the cutoff frequency of the filter, the filtering effects on the gyroscope and accelerometer can be tuned. The time-domain expression of the output angular velocity after the complementary filter is as follows:
θ ( k ) = λ θ m ( k ) ( 1 λ ) [ θ ( k 1 ) + Δ t θ k ]
where the proportional coefficient λ = Δ t Δ t + τ , which represents the degree of trust idifferent data, Δ t is the sampling time, τ is the time constant of the filter, the angle transformed from the accelerometer is denoted as θ m ( k ) , the gyroscope measures angular velocity as θ k , and θ ( k ) represents the angle output after the filtering algorithm is processed.

4. Experimental Verification

This experiment compares the time for a dual-wheel self-balancing car to return to balance from an unbalanced state and the angular fluctuations in the balanced state under the fuzzy Kalman filtering algorithm, Kalman filtering algorithm [21], and complementary filtering algorithm [20]. The self-balancing car is placed on the ground, and it is rotated around the motor axis to find the angle at which the car approaches balance, which is considered the mechanical center of the robot. In this experiment, the mechanical center of the robot is defined as 0 ° .
The CH340G driver for the USB to TTL module was installed, MCUISP v0.995 software was used to flash the pre-written program into the STM32 microcontroller (STMicroelectronics corporation from Geneva, Switzerland), the robot was connected to the PC using a MicroUSB cable, the MiniBalance 3.5 software was opened, the appropriate port was selected, and the baud rate was set to 115,200. This configuration allows the operator to view the data waveform of the robot’s inclination angle through the software. To ensure the stable operation of the dual-wheel self-balancing car depicted in Figure 1, it is imperative to fine-tune the controller parameters governing the car’s upright, speed, and steering loops. The PD controller parameters for the upright loop are set as: K p = 225 and K d = 1.08 ; the PI controller parameters for the speed loop are set as: K p = 160 and K i = 0.80 ; the PD controller parameters for the steering loop are set as: K p = 42 and K d = 0.40 . The covariance of process noise and measurement noise are set as q = 0.25 and r = 0.16 ; the filtering period is set as T = 0.005 , i.e., filtering is performed every 5 milliseconds.
Measurements were conducted to observe the car’s behavior under three different filtering algorithms as it transitioned from tilting backward at angles of 10°, 20°, and 30° (denoted as −10°, −20°, and −30°), as well as tilting forward at angles of 10°, 20°, and 30° (denoted as 10°, 20°, and 30°), until it reached a balanced state. Subsequently, angle fluctuation graphs were generated, as depicted in Figure 8, Figure 9, Figure 10, Figure 11, Figure 12 and Figure 13. To assess the variations in the car’s stability across the three filtering algorithms, the integral absolute error (IAE) was employed as the error metric, where I A E = k = 200 600 e k .
Figure 8, Figure 9, Figure 10, Figure 11, Figure 12 and Figure 13 depict the effectiveness of the proposed fuzzy Kalman filtering algorithm, Kalman filtering algorithm [21], and complementary filtering algorithm [20] in restoring the system to a balanced state when the vehicle is tilted backward or forward by 10°, 20°, and 30°. Table 2 presents the time taken for the system to return to a balanced state under each algorithm, while Table 3 shows the IAE metric values for each algorithm at various tilt angles. The first 200 scales are the adjustment time for the two-wheeled self-balancing car at a certain starting angle, and the filtering algorithm is added at around the 200th scale. From the simulation results, it is evident that the jitter of the two-wheeled self-balancing car is minimized when employing the designed Kalman filtering algorithm proposed in this study compared to the other two algorithms. Additionally, the time required for the system to recover to a balanced state from the same angle is shorter, and the absolute error is smaller than with the other two algorithms. Note that there is a visible difference between positive and negative tilting, which may be caused by the measurement error in the experimental process.

5. Conclusions

In this paper, an attitude estimation algorithm based on a fuzzy Kalman filter is proposed, which uses fuzzy logic to correct the tilt angle of a two-wheeled self-balancing car, so as to optimize the state of the Kalman filter and improve the balance performance of the car. Under the same controller parameters, the effects of the fuzzy Kalman filtering algorithm, Kalman filter algorithm [21], and complementary filtering algorithm [20] are compared by experimenting with the two-wheeled self-balancing car, and the results show that the fuzzy Kalman filter algorithm designed in this note makes the two-wheeled self-balancing car more quickly and precisely return to the balance position. The fuzzy Kalman filter algorithm can effectively realize the balance control of two-wheeled cars, which has certain reference significance for the design and research of speed loops and steering rings of racing balance cars.

Author Contributions

Conceptualization, S.X.; data curation, F.M.; formal analysis, S.X.; funding acquisition, Y.M.; methodology, S.X.; software, F.M.; supervision, S.X.; writing—original draft, Y.M.; writing—review and editing, Y.M. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation (NNSF) of China under grant number 62103057 and enterprises and institutions supporting scientific and technological projects under grant number S2326061.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The original contributions presented in the study are included in the article.

Conflicts of Interest

The authors declare no conflicts of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

References

  1. Arndt, D.; Bobrow, J.E.; Peters, S.; Iagnemma, K.; Dubowsky, S. Two-wheel self-balancing of a four-wheeled vehicle. IEEE Control. Syst. Mag. 2011, 31, 29–37. [Google Scholar]
  2. Ji, P.; Zhu, Y.; Cheng, C.; Du, X. Design of self-balancing two-wheeled vehicle control system based on STM32. Electron. Sci. Technol. 2014, 27, 96–99. [Google Scholar]
  3. Wu, J.; Sun, L. Two-wheeled self-balancing robot control method study. J. Harbin Univ. Sci. Technol. 2014, 19, 22–26. [Google Scholar]
  4. Sun, J.; Gao, G.; Pan, H.; Mao, R. Attitude information fusion processing of quadrotor based on nonlinear complementary filtering algorithm. Sens. World 2017, 23, 14–19. [Google Scholar]
  5. Liu, K.; Bai, M.; Ni, Y. Two-wheel self-balanced car based on Kalman filtering and PID algorithm. In Proceedings of the 2011 IEEE 18th International Conference on Industrial Engineering and Engineering Management, Changchun, China, 3–5 September 2011; pp. 281–285. [Google Scholar]
  6. Fu, X.; Zhao, M.; Zhou, W. Attitude detection of mobile robot based on complementary filter Algorithm. Meas. Control. Technol. 2015, 34, 31–33. [Google Scholar]
  7. Li, J.; Wang, Y.; Wei, C.; Zhang, P. A survey on the application of Kalman filtering method in power system. Power Syst. Prot. Control. 2014, 42, 135–144. [Google Scholar]
  8. Hu, K.; Li, Y.; Liu, W. Control algorithm of the quadrotor aircraft based on Kalman filter. J. Detect. Control. 2020, 42, 50–55. [Google Scholar]
  9. Li, Q.; Chu, J.; Li, R.; Wang, H. Moving object tracking algorithm for mobile robot based on Kalman filter. Transducer Microsyst. Technol. 2008, 27, 66–71. [Google Scholar]
  10. Filho, L.C.; Filho, J.F.; da Silva, N.B.; Branco, K.C. Attitude estimation of a simulated flight and GPS positioning with Kalman filter. In Proceedings of the International Conference on Unmanned Aircraft Systems, Denver, CO, USA, 9–12 June 2015; pp. 742–750. [Google Scholar]
  11. Wu, T.; Bai, R.; Zhu, L.; Qian, Z. Design of a navigation posture reference system based on Kalman filtering. J. Sens. Technol. 2016, 29, 531–535. [Google Scholar]
  12. Li, Y.; Tong, S.; Li, T. Adaptive fuzzy output-feedback control for output constrained nonlinear systems in the presence of input saturation. Fuzzy Sets Syst. 2014, 248, 138–155. [Google Scholar] [CrossRef]
  13. Li, L.; Zhao, L.; Tang, X.; He, W.; Li, F. Attitude estimation algorithm based on fuzzy Kalman filter. Instrum. Tech. Sens. 2019, 100–105, 110. [Google Scholar]
  14. Wang, L.; Li, H. Parking kinematic modeling based on fuzzy Kalman filter speed estimation. J. Chongqing Univ. Technol. (Nat. Sci.) 2021, 35, 63–70. [Google Scholar]
  15. Gomes, D.; Serra, G. Interval type-2 evolving fuzzy Kalman filter for processing of unobservable spectral components from uncertain experimental data. J. Frankl. Inst. 2024, 361, 637–669. [Google Scholar] [CrossRef]
  16. Peng, S.; Miao, Y.; Xiong, R.; Bai, J.; Cheng, M.; Pecht, M. State of charge estimation for a parallel battery pack jointly by fuzzy-PI model regulator and adaptive unscented Kalman filter. Appl. Energy 2024, 360, 122807. [Google Scholar] [CrossRef]
  17. Yang, X.; Zhang, W.; Gao, H.; Mi, H. Study on obstacle avoidance of mobile robot based on fuzzy control. Transducer Microsyst. Technol. 2017, 36, 51–54. [Google Scholar]
  18. Yan, L.; Qu, Q.; Bai, T.; Shu, D.; Zhou, C. Simulation analysis of loop tracking algorithm based on extended Kalman filter. Firepower Command. Control. 2022, 47, 14–17. [Google Scholar]
  19. Yuan, X.; Li, H. Fuzzy system of center of gravity method based on input-output data and its generalized approximability. Fuzzy Syst. Math. 2011, 25, 85–92. [Google Scholar]
  20. Liang, G.; Du, M.; Zhou, Z.; Liu, C.; Wen, Y. Attitude control based on complementary filter for two-wheel self-balanced car. Meas. Control. Technol. 2015, 34, 72–74. [Google Scholar]
  21. Liu, E.; Jiang, X. Kalman filter-based attitude detection of two-wheeled self-balancing vehicle. Autom. Instrum. 2015, 2, 52–54. [Google Scholar]
Figure 1. Photograph of the two-wheeled self-balancing car.
Figure 1. Photograph of the two-wheeled self-balancing car.
Applsci 14 05296 g001
Figure 2. Block diagram of the circuit system.
Figure 2. Block diagram of the circuit system.
Applsci 14 05296 g002
Figure 3. Inverted pendulum system for the two-wheeled self-balancing car.
Figure 3. Inverted pendulum system for the two-wheeled self-balancing car.
Applsci 14 05296 g003
Figure 4. Kalman filter update schematic.
Figure 4. Kalman filter update schematic.
Applsci 14 05296 g004
Figure 5. Residual mean affiliation distribution.
Figure 5. Residual mean affiliation distribution.
Applsci 14 05296 g005
Figure 6. Residual variance affiliation distribution.
Figure 6. Residual variance affiliation distribution.
Applsci 14 05296 g006
Figure 7. The principle of complementary filter.
Figure 7. The principle of complementary filter.
Applsci 14 05296 g007
Figure 8. Angular fluctuations of −10° back to equilibrium [20,21].
Figure 8. Angular fluctuations of −10° back to equilibrium [20,21].
Applsci 14 05296 g008
Figure 9. Angular fluctuations of −20° back to equilibrium [20,21].
Figure 9. Angular fluctuations of −20° back to equilibrium [20,21].
Applsci 14 05296 g009
Figure 10. Angular fluctuations of −30° back to equilibrium [20,21].
Figure 10. Angular fluctuations of −30° back to equilibrium [20,21].
Applsci 14 05296 g010
Figure 11. Angular fluctuations of 10° back to equilibrium [20,21].
Figure 11. Angular fluctuations of 10° back to equilibrium [20,21].
Applsci 14 05296 g011
Figure 12. Angular fluctuations of 20° back to equilibrium [20,21].
Figure 12. Angular fluctuations of 20° back to equilibrium [20,21].
Applsci 14 05296 g012
Figure 13. Angular fluctuations of 30° back to equilibrium [20,21].
Figure 13. Angular fluctuations of 30° back to equilibrium [20,21].
Applsci 14 05296 g013
Table 1. Fuzzy rule table.
Table 1. Fuzzy rule table.
Input   e ¯ k Input   P ^ e k Output   α k ,   β k
SS
SMM
LS
SM
MML
LL
SM
LML
LL
Table 2. Equilibrium time for different angles (unit: seconds).
Table 2. Equilibrium time for different angles (unit: seconds).
−10°−20°−30°10°20°30°
Fuzzy Kalman filtering algorithm0.751.051.600.831.011.63
Kalman filtering algorithm (Liu 2015) [21]0.951.302.001.021.212.12
Complementary filtering algorithm (Liang 2015) [20]1.451.802.451.431.852.39
Table 3. Tilt angle integral absolute error.
Table 3. Tilt angle integral absolute error.
−10°−20°−30°10°20°30°
Fuzzy Kalman filtering algorithm255.84243.43335.70337.07232.82352.51
Kalman filtering algorithm (Liu 2015) [21]302.27298.31398.30356.58271.24473.89
Complementary filtering algorithm (Liang 2015) [21]592.61378.13632.18697.28455.38609.13
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ma, Y.; Meng, F.; Xiong, S. Design and Implementation of a Two-Wheeled Self-Balancing Car Using a Fuzzy Kalman Filter. Appl. Sci. 2024, 14, 5296. https://0-doi-org.brum.beds.ac.uk/10.3390/app14125296

AMA Style

Ma Y, Meng F, Xiong S. Design and Implementation of a Two-Wheeled Self-Balancing Car Using a Fuzzy Kalman Filter. Applied Sciences. 2024; 14(12):5296. https://0-doi-org.brum.beds.ac.uk/10.3390/app14125296

Chicago/Turabian Style

Ma, Yimin, Fanhao Meng, and Shuangshuang Xiong. 2024. "Design and Implementation of a Two-Wheeled Self-Balancing Car Using a Fuzzy Kalman Filter" Applied Sciences 14, no. 12: 5296. https://0-doi-org.brum.beds.ac.uk/10.3390/app14125296

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop