Nonlinear reduced dynamics modelling and simulation of two-wheeled self-balancing mobile robot: SEGWAY system

ABSTRACT Segway is a self-balancing motorized two-wheeled vehicle which is able to carry the human body. In the presented paper, a problem of nonholonomic constrained mechanical systems is treated. New methods in nonholonomic mechanics are applied to a problem of a two-wheeled self-balancing robots motion ‘SEGWAY’. This method of the geometrical theory of general nonholonomic constrained systems on fibred manifolds and their jet prolongations, based on so-called Chetaev-type constraint forces, was proposed and developed in the last decade by Krupková and others. The equations of motion of a two-wheeled self-balancing robot are highly nonlinear and rolling without slipping condition can only be expressed by nonholonomic constraint equations. In this paper, the geometrical theory is applied to the above mentioned mechanical problem using the above mentioned Krupková approach. Additionally, the results of numerical solutions of constrained equations of motion derived within the theory are in good agreement with results of (1) [Maddahi, A., Shamekhi, A. H., & Ghaffari, A. (2015). A Lyapunov controller for self-balancing two-wheeled vehicles. Robotica, 33(1), 225–239]. using Lyapunov's feedback control design technique. The existence, continuity, and uniqueness of the solution for the proposed control system are proved utilizing the Filippov's solution (2). And with fuzzy controller proposed by [Qian, Q., Wu, J., & Wang, Z. (2017). A novel configuration of two-wheeled self-balancing robot/Nova konfiguracija samobalansirajuceg robota na dva kotaca (Original scientific paper/Izvorni znastveni clanak). Tehnicki Vjesnik-Technical Gazette, 24(2), 459–465].


Introduction
In recent years, two-wheeled self-balancing vehicle is widely used for its advantages such as energy saving, environmental protection, simple structure, flexible operation, and so on (Liu, Huang, Wang, Zhang, & Li, 2016). The research has a strong theoretical significance and practical value. In 1986, Yamato Gaoqiao, professor of Tokyo Electric Communication University, first designed the mobile robot of double coaxial and self-standing (Lam, Lee, Leung, & Tam, 2009). In 2002, the first twowheeled self-balancing vehicle Segway human transporter (HT) was produced (Sun, Zhou, Li, Wei, & Li, 2009). Now, a variety of standing and sitting vertical twowheeled self-balancing vehicles have been developed. On the other hand, many researchers have been devoted to the stability analysis and control system design of the two-wheeled self-balancing robots. In the field of control, Ravichandran and Mahindrakar presented a controller design and employed a strategy that combines time scaling and Lyapunov redesign. They verified the CONTACT Haddout Soufiane haddout.ens@gmail.com methodology by employing it in a two-wheeled robot (Ravichandran & Mahindrakar, 2011). Maddahi, Shamekhi, and Ghaffari (2015) investigated the design and validation of a controller for an inertial two-wheeled vehicle using the Lyapunov's feedback control design technique. The existence, continuity, and uniqueness of the solution for the proposed control system are proved utilizing the Filippov's solution. Huang, Guan, Matsuno, Fukuda, and Sekiyama (2010) improved a robust-velocity-tracking by proposing two sliding-mode control methods. Cui, Guo, and Mao (2015) designed a backstepping-based adaptive control to achieve tracking for the two-wheeled selfbalancing robot. Yue, Wei, and Li (2014a) considered the overall dynamical model of Grasser, Arrigo, Colombi, & Silvio, 2002, as three subsystems: rotational motion, longitudinal motion, and zero dynamics. Particularly, the inclination angle of the chassis is treated as zero dynamics where the longitudinal acceleration is taken as the control input. Then the sliding-mode control techniques are used to derive the controllers (Yue et al., 2014a). In another paper they employed adaptive laws for the design parameters beside the sliding-mode controllers (Yue, Wei, & Li, 2014b).
In the field of dynamical modelling, many researchers are devoted to the modelling of the two-wheeled mechanisms, which has more degrees of freedom compared with the regular two-wheeled self-balancing robot. A regular two-wheeled self-balancing robot has two actuated drive wheels connected to an intermediate chassis. Goher, Ahmad, and Tokhi (2010) employed Lagrangian approach for dynamical modelling of twowheeled robots and added more degrees of freedom in comparison with the works done by the former researchers. Larimi, Zarafshan, and Moosavian (2015) presented a new stabilization mechanism of two-wheeled mobile robots, where a reaction wheel is considered to control the position of center of gravity (CoG). Almeshal, Goher, and Tokhi (2013) employed Lagrangian approach for dynamical modelling of two-wheeled robots and added more degrees of freedom in comparison with the works done by the former researchers. Huang, Ding, Fukuda, and Matsuno (2013) investigated a novel narrow vehicle based on a two-wheeled robot and a movable seat. The dynamic model of the vehicle is derived by Lagrange's equation of motion.
On the dynamical modelling of the regular twowheeled self-balancing robot, Grasser et al. (2002) derived a dynamic model of the system using Newtonian approach and linearized the equations around an operating point to design a controller. Pathak, Franch, and Agrawal (2005) analyzed the dynamic model from a controllability and feedback linearizability point of view. Kim, Kim, and Kwak (2005) investigated the dynamics of the robot with the aid of Kane's method. Ghaffari, Shariati, and Shamekhi (2016) propose a new term in the dynamic formulation for two-wheeled self-balancing robots which is not considered in the Kim's formulation. Recently, Qian, Wu, and Wang (2017) propose a new configuration of two-wheeled self-balancing vehicle pendulum system. The dynamics model has been derived by Lagrangian equation and the parallel double fuzzy controller based on information fusion technology was designed and applied to control the robot.
On the other hand, the wheeled mobile Robot-is a typical nonlinear system constraint by nonholonomic, and the two-wheeled self balancing robot is the special one (See Figure 1, the overall view of a two-wheeled self-balanced vehicle). Since the first commercial twowheeled self-balancing vehicle emerged, people are deeply interest in the controlling of two-wheeled selfbalancing motion, and work more in its research (Karkoub, 2006;Salerno & Angeles, 2007;Thibodeau, Deegan, & Grupen, 2006). Mainly, it is possible to distinguish between two different approaches: the first obtains the motion equations using the Newton's laws, while the second studies the system from a Lagrangian or Hamiltonian point of view (Koon & Marsden, 1997;Neimark & Fufaev, 1972). So far, the greatest part of the existing literature has been dedicated to models with lots of simplifications, even if these have been capable to explain the dynamical characteristics of the two-wheeled self-balancing robots. For example, linearized equations of motion are commonly introduced in order to cope more easily with the problem.
The aim of this paper is to use the geometrical theory for obtaining nonlinear equations of motion of the above Figure 1. 3D view of two-wheeled self-balancing vehicle system. exposed mechanical problem for the first time, using the above mentioned Krupková approach for a practical mechanical system and find their solution in some particular cases, any simplification are not used. This is made in the last section, where the sets of equations of motion i.e. reduced, are derived. The numerical solution of reduced equation is presented.
The organization of this paper is as follows: In Section II, we introduce the geometrical theory of nonholonomic mechanical systems. Further, Section III presents the nonlinear dynamics of two-wheeled self-balancing robots. After that the proposed the reduced equations for a twowheeled self-balancing robots and numerical solution in Section VI. Finally, the paper is wrapped up with outlines conclusions and future work in Section V.

Geometrical concept of nonholonomic mechanical systems
The motion of mechanical systems is frequently subjected to various constraint conditions, holonomic or nonholonomic. Nonholonomic constraints lead typically to nonlinear equations of motion of the constrained system. While theories of holonomic or some special types of linear nonholonomic constraints are already well elaborated for quite general situations, various theoretical approaches to general nonholonomic mechanics occur up to now, from the physical point of view on the one hand, and from the geometrical point of view on the other (Janová & Musilová, 2009). On the other hand, in last decades numerous physical and engineerings applications make necessary to profound research and complete the theory of the nonholonomic systems and numerical aspects of solutions are presented. Therefore problems of nonholonomics mechanics are intensively studied in many papers, e.g. (Bullo & Lewis, 2004); (Cardin & Favreti, 1996); (Carinena & Raada, 1993); (Cortés, De León, Marrero, & Martinez, 2005); (De Leon, Marrero, & de Diego, 1997a;De Leon, Marrero, & de Diego, 1997b); (Giachetta, 1992); (Janová & Musilová, 2009); (Czudková & Musilová, 2013;Haddout, 2018), in which are used modern methods and concepts of differential geometry and global analysis and which contribute to the essential advance in both from the theoretical and application aspects. The geometrical theory used in the presented paper was presented for first order mechanical problems in (Krupková, 1997a) and then generalized for higher order case in (Krupková, 2000) brings an appropriate tool for constructing certain type of equations of motion of nonholonomic mechanical systems subjected to quite general constraints (an application to typically non-linear constraint see in (Krupková & Musilová, 2001)). The theory is developed on fibred manifolds and their jet prolongations as underlying geometrical structures, naturally related to the character of physical problems (Janová & Musilová, 2009). The main physical idea of the theory is based on the concept of Chetaev-type constraint forces introduced in analogy to 'classical' Chetaev forces (see Chetaev, 1932Chetaev, -1933. Equations of corresponding unconstrained motion are related to the socalled dynamical form and they define the components of this form (Janová & Musilová, 2009). Using equations of constraints a special canonical distribution on the first jet prolongation of the underlying manifold (corresponds to the phase space) can be constructed. Then first prolongations of admissible trajectories of the constrained motion are just integral sections of this distribution. By adding Chetaev-type forces (with Lagrange multipliers) to equations of motion, a dynamical form of the constrained problem is obtained and deformed equations of motion are constructed. These equations together with constraint conditions give the system of differential equations for unknown constrained trajectories and Lagrange multipliers (Janová & Musilová, 2009). Another possible approach to the problem within the same theory starts from its description by the so-called Lepage class of forms instead the dynamical form itself. The Lepage class is, of course, closely related to the dynamical form, and it is obtained by the factorization of modules of forms by special submodules irrelevant from the point of view of the problem (Janová & Musilová, 2009). This procedure leads to the so-called reduced equations of motion containing no Lagrange multipliers and giving the system of differential equations for constrained trajectories only. Nevertheless, constraint forces can be then obtained from deformed equations. Additionally, on the base of the geometrical theory with Chetaev-type constraint forces, one can formulate a constraint variational principle and solve the corresponding constraint inverse variational problem (see e.g. Krupková & Musilová, 2005), as well as study symmetries of constrained systems. Symmetries and arising first integrals may then essentially simplify integration of the resulting constrained equations of motion, see e.g. (Swaczyna, 2005(Swaczyna, , 2011) (Nevertheless, in the present paper no attention is paid to higher order theories, field theories and the constraint variational problem.). Of course, the calculation procedure itself is made in coordinates. Its practical advantage lies in the possibility to choose appropriate coordinates, and also in two equivalent alternatives of solving the problem. The first of them is based on the solution of reduced equations of motion free of Lagrange multipliers and additional computation of these multipliers and corresponding constraint forces from dynamical equations, or alternatively, the direct solution of dynamical equations containing Lagrange multipliers (Janová & Musilová, 2009). The decision between these two procedures is influenced by the concrete physical problem. Even though the corresponding constraint is semiholonomic and thus it could be in principle treated by classical methods of Lagrange multipliers (for details concerning the method in general see e.g. the classical textbook of analytical mechanics (Brdicka & Hladík, 1987)), the direct application of Krupková's geometrical theory is very effective in this situation (Janová & Musilová, 2009).
In this section, we recall basic geometrical concepts of the theory we will use. For more details and proofs see (Krupková, 1997a). As underlying geometrical structures of the theory fibred manifolds and their jet prolongations are considered. Key geometrical objects adapted to the fibred structure are sections and their jet prolongations, projectile and vertical vector fields, as well as horizontal and contact differential forms. The detailed theoretical background can be noted in (Krupková, 1998).
The geometrical theory of nonholonomic mechanical systems is developed on an (m + 1)-dimensional underlying fibred manifold (Y, π, X) with the one-dimensional base X is considered, ((t ∈ X) being time in non-relativistic mechanics), m-dimensional fibres (configuration space), and its jet prolongations Recall, that a vector field η on J r Y is called π r -projectile if there exists a vector field η 0 on X such that Tπ r η = η 0 • π r . A vector field η is called π r -vertical if Tπ r η = 0. A form ρ on J r Y is called π r -horizontal if its contraction by an arbitrary chosen π r -vertical vector field ηvanishes, i.e. it holds i η ρ = 0. A form ρ is called contact if J r γ * ρ = 0 for all sections γ of (Y, π, X). Concepts of π r,s -projectile vector field, π r,s -vertical vector field, and π r,s -horizontal form are defined by the quite analogous way. Moreover, for every k-form ρ on J r Y there exists the unique decomposition into its q-contact components, 0 ≤ q ≤ k, π * r+1,r ρ = k q=0 p q ρ, the 0-contact components p q ρ = hρ are called also the horizontal one.
From the point of view of physics, all possible trajectories of so-called first order unconstrained mechanical system on a fibred manifold are given just by section γ of (Y, π, X) such that they are solution of the system of m second order ordinary differential equations of motion: where 1 ≤ λ ≤ m and Einstein summation are used. Consider the 1-contact π 2,0 -horizontal 2-form on J 2 γ = 0, E = E σ ω σ ∧ dt = 0, called dynamical form. A solution γ of Equation (1) is called a path of E. We define the Lapage class [α] of E by the requirement p 1 α = E (see, Krupková, 1997aKrupková, , 1997b.
The class [α] is named also the mechanical system. Every representative of this class is of the form: where ω σ = dq σ −q σ dt are contact 1-forms forming the basis of 1-forms (dt, ω σ ,q σ )on J 1 Y adapted to the contact structure. So, [α]= α mod 2-contact forms. The following proposition was proved (see, Krupková, 1997aKrupková, , 1997b: A section γ of (Y, π, X)is a path of the dynamical from E if and only if For every π 1 -vertical vector field η on J 1 Y.

Nonholonomic dynamics
A nonholonomic constrained mechanical system is defined on the (2m + 1 − k)-dimensional constrained submanifold ℘ ⊂ J 1 Y fibred over Y and given by k equations Or in the explicit normal forṁ It is evident that only admissible trajectories for a nonholonomic mechanical system are such sections γ : I t → Y for which J 1 γ (t) ∈ ℘ for all t ∈ I, i.e, f i • J 1 γ = 0 for 1 ≤ i ≤ k (the so-called ℘-admissible sections). The constraint (4) leads to the canonical distribution of codimension k on ℘. Its annihilator is of the form where ι: ℘ → J 1 Y is the canonical embedding. The canonical distribution is closely related to the constraint ideal ( 0 ).
where ϕ i are 1-forms on ℘ called canonical constraint 1forms. The importance of the canonical distribution is evident from its following property (see, Krupková, 1997b;Swaczyna, 2005): A section γ of Y is ℘-admissible if and only if J 1 γ is an integral section of the canonical distribution.
We have already mentioned in the first part that there are two possible equivalent approaches to the description of nonholonomic mechanical system-one of them, called physical, is based on deformed equations with constraint forces and Lagrange multipliers and the other, geometrical one, uses reduced equations.
Geometrical approach introduces the constrained mechanical system related to the mechanical system [α] by the equivalence relation: A ℘ -admissible section γ of (Y, π, X) is called a path constrained system [α ℘ ] if for every π 1 -vertical vector field η belonging to the canonical distribution it holds.
The following proposition can be formulated (see again, Krupková, 1997b):

Proposition: A section γ of (Y, π , X) is a path of the deformed system [α ] if and only if for every π 1 -vertical vector field η belonging to holds
Relations (8) represent the system of reduced equations for m unknown functions q σ γ (k of them are first order and (m − k) second order ordinary differential equations).
Physical approach is based on Chetaev-type constraint forces. Such a force is given by the constraint itself, in analogy with holonomic situations. It is expressed by the dynamical form (Janová & Musilová, 2009): where functions μ i (t, q λ ,q λ ) are Lagrange multipliers. Note that such dynamical form satisfies the generalized principle of virtual work i η | U = 0 for every π 1 -vectical vector field η belonging to the constraint distribution U , 0 U = span{ϕ i , df i , 1 ≤ i ≤ k}, U, U ∩ Q = ∅ being an open set of a chart on J 1 Y, (Janová & Musilová, 2009). Denote The equivalence class [α ] is called the deformed mechanical system. A The following proposition holds (see, Krupková, 1997bKrupková, , 1998:

Proposition: A section γ of Y is a path of the deformed system [α ] if and only if for every π 1 -vectical vector field
System (13) is given by k first order and m second order ordinary differential equations for unknown functions μ i and q σ γ and it represents the deformed equation.
Semiholonomic constraints: Let us now describe a special type of nonholonomic constraints, called semiholonomic. Such conditions usually take place for rolling of rigid bodies without slipping. A system of constraints (3) is called semiholonomic if the constraint ideal (5) is differential, i.e. the canonical distribution (4) is completely integrable (see. e.g. Krupková, 1997a). This means that dϕ ∈ ( 0 ) and thus following conditions hold: In the following section we apply the obtained equations (8 and 13) obtained for general nonholonomic mechanical system to the example of two-wheeled selfbalancing vehicle system.

Lagrange's equation of two-wheeled self-balancing vehicle
We will consider the two-wheeled self-balancing vehicle shown in Figure 2. The two-wheeled self-balancing vehicle enables seven degrees of freedom.
The Lagrange equation determination can be determined by defining total potential and kinetic energy of the system as a function of generalized coordinates: xandy are the linear displacement of base along X and Y direction, respectively, z is the linear displacement of vehicle along Z-direction, θ is the tilt angle of link with respect to Z-axis, β is the angular displacement of link with respect to upright position, and ϕ L andϕ R are the angular velocity of left and right wheels. On the other hand, the total kinetic energy due to translational and rotational motions and the potential energy of the system in function of generalized coordinates are written as follows: The Lagrange function of unconstrained mechanical system is given by relation: where m l is combined mass of human body, link and seat, m w is a mass of each wheel, m b = M − 2m w where M is a mass of entire vehicle, J b will be moment of inertia of combination of link, seat, human, and base with respect to Z-axis, J w is the moment of inertia of each wheel about Z-axis and J l is the link moment of inertia with respect to Y-axis passing from its centre of mass; a is the distance between centre of mass and joint of link, 2d is the wheelbase and R is the radius of each wheel.

Formulation of a problem
Using the geometrical theory of nonholonomic system mentioned in the second section we define the structure of the mechanical system as follows. In cases where the number of degrees of freedom is greater than the number of generalized coordinates, additionally defined coordinates are not independent of the present generalized coordinates. Equations with terms in the time derivatives of the generalized coordinates and which cannot be integrated are called nonholonomic constraint equations. There are seven degrees of freedom of the corresponding unconstrained mechanical system. Thus, the fibred manifold of the problem is (R × R 7 , pr 1 , R) where pr 1 is the cartesian projection on the first factor. We choose the fibred chart on Y as (V, ξ) where V is an open set V ⊂ Y and ξ 1 = (t, q 1 , q 2 , q 3 , q 4 , q 5 , q 6 , q 7 ) = (t, x, y, z, θ, β, ϕ L , ϕ R ). The associated chart on the base is (pr 1 , ), = (t) where t is the time coordinate, and associated fibred chart on The basic parameters used to specify the two-wheeled self-balancing vehicle geometry are illustrated in Figure 2. On the other hand, the Euler-Lagrange equations of system motion are: The Lepage class of the unconstrained mechanical system is thus given by the representative: where: and

The constraint
The condition that the two-wheeled self-balancing vehicle rolls without sliding on the plane means that the instantaneous velocity of the point of contact of the twowheeled self-balancing vehicle is equal to zero at all times. This gives rise to the following nonholonomic constraints: Or in normal forṁ These three nonholonomic conditions define the constraint submanifold ℘ = dim J 1 Y − 3 = 12. Constraint (21) obeys condition (14), i.e. it is semiholonomic. The geometric theory allows us to solve such a problem immediately, without integrating the constraint.

Constrained mechanical system-reduced equations
The geometrical approach described in the first section applied to our problem leads to the constrained mechanical system [α ℘ ] related to the unconstrained mechanical system [α]. The class [α ℘ ] is generated e.g. by the following representative: where: Computing the coefficients A l according to Equation (9) we obtain following expressions: And coefficients B ls according to Equation (10) are: The reduced equations are of the form: There is no analytical solution of reduced equations of motion, in general situation.

Numerical solution of reduced equations of motion and theory compared
The reduced equations of the two-wheeled self-balan cing vehicle motion derived in Section above (Equation (26) In Figures 3-6, the graphical outputs θ (t), β (t), ϕ L (t) and ϕ R (t) calculations are presented.
On the other hand, the geometrical theory is compared with (1) fuzzy controller, based on new configuration of two-wheeled self-balancing vehicle-pendulum system proposed by Qian et al. (2017) (See, Qian et al., 2017 for further information). The dynamics model has been derived by Lagrangian equation and verified by simulating the system in MATLAB Simulink environment; and (2) Lyapunov's controller, the system equations of motion are derived followed by finding the Lyapunov function required to design the controller (See, Maddahi et al., 2015, for further information). Based on Qian et al. (2017); and Maddahi et al. (2015) in same condition, a comparison with geometrical results was carried out in this section. In Figures 7 and 8, the graphical outputs θ(t) and β (t) of calculations are presented for three approaches.  It can be seen from Figures 7 (tilt angle) and 8 (angular displacement of link) that the Krupkova approach performs satisfactory to Lyapunov controller and Fuzzy controller.
A real the two-wheeled self-balancing vehicle is a complex space structure. The Governing equations for the dynamic response of the two-wheeled self-balancing vehicle, i.e. reduced equations are derived based on Krupková approach. These equations are essentially representing the coupled engineering problem of structural dynamics and multi-body dynamics are difficult to solve analytically. The numerical studies of reduced equations of motion are presented and we find it as effective and applicable for problems in physics and engineering for preliminary visualization.

Conclusions
Nonlinear reduced dynamics modelling and simulation of two-wheeled self-balancing mobile robot system has been presented in this research. Moreover, the presented results formulation indicate the effectiveness of the geometrical theory of nonholonomic constraints for formulating of motion of concrete nonholonmoic constraints systems with constraints based on the assumption of rolling without slipping. For semiholoonomic constraints an advantage of the theory lies also in the possibility to include the constraint directly into equations of motion. Then it appears that the model of Chetaev-type forces is appropriate for describing the studied type of the constraint from the point of view of physics.