Self-Balancing Vehicle Using Kalman Filter
Self-Balancing Vehicle Using Kalman Filter
Abstract—At present our daily lives are being more and more To demonstrate the benefits of such a design, we built an
inclined towards automation. The use of robots can therefore be upright, self-balancing, two-wheeled robot utilizing an IMU
an efficient way to get the tasks done which are hazardous and and a PID feedback control loop to maintain stability. This
are difficult to get done by humans, these robots can even lower report contains a thorough discussion of our project, including
down the overhead costs and be effective in many other scenarios. details about the mechanics, electronics, software, and
A self-balancing vehicle is a two wheel vertical drives which stays everything else that went into designing, building, and testing
upright across its vertical position and maintain its position while our self-balancing robot.
being subjected to external and internal forces. Being a inverted
pendulum design it is inherently unstable so it needs constant
control to provide appropriate acceleration. We provide this The rest of the paper is mentioned as below. Section II
control with a PID controller implemented in a microcontroller. describes the physical model. Section III describes the angle
The angular displacement and velocity is fed by a gyroscope and measurement. Section IV describes about the kalman filter.
accelerometer, both sensors are fused by using Kalman Filter. Section V describes about the mathematical model. Section VI
describes about the Mechanical structure. Section VII
Index Terms—PID, Kalman filter, Self balancing Robot, PID describes the PID tuning. Section VIII lists the advantages. At
Tuning last, section IX concludes the paper.
I. INTRODUCTION II. THE PHYSICAL MODEL
The physical model for this type of vehicles are simple, it
A quick look at the range of mobile robots in existence will stand vertically in two points along its wheels, when there
reveals an enormous diversity in shape, form, and modes of is any external disturbance in the vehicle’s equilibrium it will
mobility. However, one thing that most of them have in fall in either direction and lose its verticality, the system will
common is that they are passively balanced (i.e. their bodies provide the movement of the wheel in the direction of the
are constantly in a state of stable equilibrium). While this is falling so the vehicle rises in opposite direction of fall and
perfectly logical in most cases, there are certain recover its vertical position.
applications, such as Segway and humanoid robots, that take This model is inspired by Segway-type vehicle which is a
advantage of an unstable-equilibrium, inverted pendulum classic example of inverted pendulum control problem which
design to enhance their capabilities. While their self-balancing can be solved by considering two degrees of freedom for the
mechanisms may increase the complexity of their design, the simple model as used in this paper . The vehicle corrects it’s
benefits, which include greater manoeuvrability and stability, position of an induced lean angle by moving in either forward
outweigh the costs. or backward direction so the system retains its position to
The two-wheeled design of the self- absolute vertical or at least not fall over when continuous
balancing Segway Personal Transporter significantly increases disturbances are applied.
its manoeuvrability, because it reduces the turn radius to zero. To achieve this objective, we have to measure the angle of
The vehicle can rotate in place to instantly change its direction inclination (i.e. Roll) that the vehicle has, and also have to
of motion and precisely navigate tight spaces that a three or operate the motors through a microcontroller such that the
four-wheeled robot cannot. Additionally, while a passively motors will move in clockwise or anticlockwise to achieve the
balanced, stable-equilibrium system may tip over the instant it effective angle 0, such that the verticality is maintained.
is put off balance, an actively balancing, unstable-equilibrium This concept is based on the principle of inverted
system like the Segway can take actions to recover if its pendulum design, i.e. a two-wheeled vehicle that balances
balance is temporarily disturbed. This stability-enhancing itself up in the vertical position with reference to the ground.
behaviour directly mimics the natural behaviour of a human The design is done such that the weight is concentrated on the
that avoids a fall by taking a step in the direction of motion. topmost possible position. Using a generic feedback controller
(i.e. PID controller) we will find its stable inverted position.
The mechanical system is composed of two suitable generic
DC gear motors, a microcontroller developer board, an
Sooraj Kumar, Vijaydeep and Pooja Gupta are with the School of Electronics accelerometer and a gyroscope which will provide data of
Engineering, Kalinga Institute of Industrial Technology (KIIT) University, reference acceleration and angle with respect to ground
India–751024. (email: [email protected])
(vertical) respectively. This raw data taken as the system
parameters which will then compute the required force to
retain the equilibrium or maintain the balance of the vehicle.
1496
This process will prevent the robot from falling by providing inclination are correlated, this correlation is expressed by a
acceleration in the wheels corresponding to its inclination from covariance matrix which is always symmetric and is denoted
the neutral vertical. As the vehicle gets deviated by an angle, as Pk
then in the frame of reference of the wheels and the centre of
mass will encounter a pseudo force and apply a torque opposite =
Ε Σ
(3)
to the direction of tilt. Σ Σ
1497
of the robot and calculates an error value i.e. angle from the After obtaining the tilt angle by calculations from the
vertical and the ideal value i.e. 0 degrees from the vertical. The accelerometer and gyroscope, we need to amplify the data in
PID control constantly tries to minimize this error by such a way that the bot tends to obtain the equilibrium
continuously adjusting the control variable i.e. motor torque position. For this we use a PID controller. The values of PID
according to the following equation, where u(t) denotes the gains are set by using the Ziegler-Nichols Method. Using this
control variable, e(t) denotes the current error measured in method, the Proportional gain is set first to obtain oscillations
process variable, and Kp, Ki, and Kd are coefficients that are of constant oscillations, then the Integral gain and lastly the
to be tuned so as to achieve the desired behaviour of the Derivative gain for a smoother operating bot.
controller:
VII. PID Tuning
VI. MECHANICAL STRUCTURE This algorithm fuses the accelerometer and gyroscope raw data
and helps to eliminate noise more efficiently than normal
We will use a simple material like acrylic, wood etc. to create a methods. The existing approach compares the raw data
floored chassis such that it’s center of mass is as higher as regularly with the position of vehicle which results in slower
possible for easy balancing, so we put the batteries in top floor, processing time. This approach is independent of vehicle size,
motors and motor drivers at bottom and Arduino and sensors at motor speeds and terrain unlike other approaches where we
middle. A higher center of mass will ensure inverted pendulum have to make adjustments in code every time the bot is
behavior and will be easy to balance with Kalman Filter. Apart powered on.The PID tuning also seem to be faster when
from the chassis we will require. Kalman Filter is used.
The bot works on the principle of inverted pendulum. The IX. CONCLUSION
main fundamentals of the control system are to balance the bot
by applying a force to the hinge point. A major requirement of The fabrication of self-balancing bot involved making a
the controller is to implement a combination of wheel encoder, chassis which will have its centre of mass roughly on the axle
gyroscope and accelerometer sensors to calculate the altitude of the bot after the mounting of all components.
of the platform and then use the information obtained to drive The control part involved a feedback mechanism which was
the motor in the direction to maintain an upright and balanced developed by using a Inertial Measurement Unit and
position platform. processing its data accurately to obtain a stable value of tilt
The sensor gives accelerometer and gyroscope data over an angle.The second part of control mechanism was to provide
I2C bus. The data obtained is unreliable to an extent that PWM signals to the bot for optimum balancing of the bot. This
accelerometer data fluctuates rapidly and gyroscope data drifts was done by using a PID controller and tuning it by various
away with time. To address these issues of measurement noise methods. In this way by implementing these functions we were
and the limitations of measurements, we merge the data from able to obtain operating Self Balancing Bot.
the accelerometer and the gyroscope. The result obtained was
thus an accurate reading of the angle the device is getting tilted
to.
1498
REFERENCES
[1] K. K. C. Yu, N. R. Watson and J. Arrillaga, "An adaptive Kalman filter [8] Bonita Sawatzky, “The Segway Personal Transporter as an Alternative
for dynamic harmonic state estimation and harmonic injection tracking," Mobility Device for People With Disabilities: A Pilot Study”
in IEEE Transactions on Power Delivery, vol. 20, no. 2, pp. 1577-1584, International Seating Symposium, March 11−14, 2007, Orlando/Lake
April 2005.doi: 10.1109/TPWRD.2004.838643 Buena Vista, FL. doi: 10.1016/j.apmr.2007.08.005
[2] Sun and J. Gan, "Researching of Two-Wheeled Self-Balancing Robot [9] Rai, Neerparaj, and Bijay Rai. "Neural network based closed loop speed
Base on LQR Combined with PID," 2010 2nd International Workshop control of DC motor using arduino uno." International Journal of
on Intelligent Systems and Applications, Wuhan, 2010,pp.1-5.doi: Engineering Trends and Technology 4.2 (2013): 137-140.
10.1109/IWISA.2010.5473610 [10] Munadi and M. A. Akbar, "Simulation of fuzzy logic control for DC
[3] J. Han, "From PID to Active Disturbance Rejection Control," in IEEE servo motor using Arduino based on MATLAB/Simulink," 2014
Transactions on Industrial Electronics,0 vol. 56, no. 3, pp. 900-906, International Conference on Intelligent Autonomous Agents, Networks
March 2009. doi: 10.1109/TIE.2008.2011621 and Systems, Bandung, 2014, pp. 42-46.
[4] F. Lizarralde and J. T. Wen, "Attitude control without angular velocity doi: 10.1109/INAGENTSYS.2014.7005723
measurement: a passivity approach," in IEEE Transactions on Automatic [11] Vikhe, Pratap, Neelam Punjabi, and Chandrakant Kadu. "Real Time DC
Control, vol. 41, no. 3, pp. 468-472, Mar1996. doi: 10.1109/9.486654 Motor Speed Control using PID Controller in LabVIEW." International
[5] H. S. Juang and K. Y. Lurrr, "Design and control of a two-wheel self- Journal of Advanced Research in Electrical, Electronics and
balancing robot using the arduino microcontroller board," 2013 10th Instrumentation Engineering 3.9 (2014): 12162-12167.
IEEE International Conference on Control and Automation (ICCA), [12] Julier, Simon J., and Jeffrey K. Uhlmann. "New extension of the Kalman
Hangzhou, 2013, pp. 634-639.doi: 10.1109/ICCA.2013.6565146 filter to nonlinear systems." AeroSense'97. International Society for
[6] K. Pathak, J. Franch and S. K. Agrawal, "Velocity and position control of Optics and Photonics, 1997. doi:10.1117/12.280797
a wheeled inverted pendulum by partial feedback linearization," in IEEE [13] K.Sakthidasan@Sankaran, S.Bhuvaneshwari, and V.Nagarajan, “A New
Transactions on Robotics, vol. 21, no. 3, pp. 505-513, June 2005. doi: Edge Preserved Techniques Using Iterative Median Filter”, IEEE
10.1109/TRO.2004.840905 International Conference on Communication and Signal Processing-
[7] J. H. Park and K. D. Kim, "Biped robot walking using gravity- (ICCSP14), April 2014, pp. 1750 - 1754.
compensated inverted pendulum mode and computed torque [14] P. Kasprzak, B. Elecktronika, P. Kowalczuk and T. Zawada, "Kalman-
control," Proceedings. 1998 IEEE International Conference on Robotics Singer filter: Theory and practice," 2013 Signal Processing Symposium
and Automation (Cat. No.98CH36146), Leuven, 1998, pp. 3528-3533 (SPS), Serock, 2013, pp. 1-5.
vol.4.doi: 10.1109/ROBOT.1998.680985 doi: 10.1109/SPS.2013.6623579
1499