Self-balancing two-wheeled robot

This work describes the design and implementation of a self-balancing two-wheeled robot. The system is similar to the classical unstable, non-linear mechanical control problem of an inverted pendulum on a cart. This paper derives the linearized system dynamics equations and approaches the control problem, of stabilizing the robot, using a Linear Quadratic Regulator for state feedback. Simulation results, using a Kalman Filter for state estimation, show that the controller manages to reject disturbances and stabilize the system using only a gyroscope and an accelerometer. The control algorithm is implemented using both Simulinkand C-programming. A complimentary filter is used for state reconstruction in the final implementation. A Kalman filter implementation is also approached, however it does not perform as well as the complementary filter. The resulting implementation manages to stabilize the pendulum in an upright position and reject disturbances such as gentle pushes. An alternative controller also returns the robot to its initial position in response to a disturbance. TABLE I LIST OF PARAMETERS AND NUMERICAL VALUES USED Parameter Value Description Mb 0.595 kg Mass of robot Mw 0.031 kg Mass of the wheels, Jb 0.0015 kgm2 Moment of inertia about CoM r 0.04 m radius of wheels Jw 5.96e-05 kgm2 Moment of inertia for the wheels Lm 0.08 m Distance from wheel axle to CoM Ke 0.468 V s/rad EMF constant Km 0.317 Nm/A Motor constant R 6.69 Ohm Motor resistance b 0.002 Nms/rad Viscous friction constant g 9.81 m/s2 Gravitational constant I. PROJECT OVERVIEW This report documents the design and implementation of a self-balancing robot, which is an unstable system; the basic model is that of an inverted pendulum balancing on two wheels. This work details the derivation of the model of the system and lays out the framework of the robot’s control system. It also shows the full implementation of a control system stabilizing the robot. The robot is built using Lego Mindstorm, an educational product first released by Lego in 1998. The Lego Mindstorm kit is equipped with a 32-bit ARM7 microprocessor with a bootloader modified to run the nxtOSEK real-time operating system. Brian Bonafilia, Nicklas Gustafsson, Per Nyman and Sebastian Nilsson are with Chalmers University of Technology, in the Department of Signals and Systems {bbrian, nigus, nper, sebnil}@student.chalmers.se In order to devise a control scheme for the robot, a mathematical model of the physical system was derived from free body diagrams and basic equations of motion. The mathematical model is then linearized around the operation point, namely a tilt angle of 0 degrees. The control scheme used is a Linear Quadratic Regulator (LQR) for state-feedback control. The LQR is setup to drive the tilt angle to zero. The initial focus is on stabilizing the unstable system and rejecting disturbances. A complementary filter is used to reconstruct an angle estimate to use in the LQR controller. The information used to estimate the current system states comes from three primary sensors: a 3axis accelerometer, a 1-axis gyroscope, and motor encoders. II. RELATED WORK The self-balancing robot is a system similar to the classical mechanical system of an inverted pendulum on a cart. It is an interesting system to control since it is relatively simple, yet non-linear and unstable. The literature is extensive from hobbyists and academic projects [3, 4, 7]; to advanced commercial products such as the Segway . Optimal control with the LQ controller is often used to solve the problem of stabilizing the unstable robot system without the need for manual tuning of the state-feedback controller . The balancing robot in this paper follows this common technique. Various strategies have been used in similar projects in the past to combine the information from a gyroscope and an accelerometer. A Kalman filter is also used in  to arrive at the best estimate for the angle from the available signals. For control of forward velocity of full-sized balancing vehicles, several techniques have been tested. Among them are setting a weighting on the control in the LQR and designing the controller in such a way that it is unable to eliminate the steady-state error caused by the rider leaning on the platform, forcing the controller to apply constant power to the motors which results in forward motion . The robot in this paper does not have the benefit of a rider providing a constant input disturbance to control forward motion, but some similar technique of using a constant steady-state error to motivate forward motion is being considered. Data gathering via Bluetooth has been used in similar projects in order to validate system models . The strategies used to compare simulation results with real system performance will be explored as this project advances. III.  The system requirements are divided into two categories, depending on whether they are considered needed or desired. The robot need to: