Method for determination of interaction between a two-wheeled self-balancing vehicle and its rider

The paper presents a method for determination of interaction between a two-wheeled self-balancing vehicle and its rider while driving. The presented approach is a new direction of research, because this kind of interaction is usually overlooked in simulation and analytical studies whose aim is to determine and verify the vehicle control method. The proposed method is based on the comparison of experimental results with the computer simulation results. The mathematical model of the vehicle–rider system used in the simulation includes a postulated qualitative mathematical form of interaction with unknown coefficients (in practice, they estimate parameters of the rider). These  unknown coefficients have been  obtained by designation of the matching function between the experimental data and simulation data. Based on these coefficients, the generalized form of interaction between a two-wheeled self-balancing vehicle and its rider has been found. DOI: http://dx.doi.org/10.5755/j01.mech.22.5.13315


Introduction
A two-wheeled self-balancing vehicle (the commercial version is called the Segway™) is a device in which acceleration of a vehicle is controlled by an appropriate balancing of the rider's body.The rider's interaction with the vehicle's platform causes the vehicle to lean; the on-board computer records it and on that basis controls the vehicle's motors.The rider-vehicle interaction consists in applying torque by the rider to the vehicle's platform, causing its rotation.The control method of such a system is very similar to the problem of stabilizing the two-wheeled inverted pendulum, see for example [1][2][3].There are many papers describing the theory of TWSBV (a two-wheeled self-balancing vehicle), where the main attention is focused on the problem of stability of an already leaning vehicle [4][5][6][7][8], and a mathematical model of the vehicle is approximated by a two-wheeled inverted pendulum.This approach is correct if the model is used only to determine the stability control of the vehicle in the upright position.Such a model has also been used in this work, but only in order to determine the motor control.At this point the question arises whether the model of a two-wheeled selfbalancing vehicle with a rider can be completely approximated by two-wheeled inverted pendulum model.The answer is no, because a model like that does not include interaction between the vehicle and its rider, and the inverted pendulum cannot unbalance itself from the equilibrium position, what is the primary goal of the TWSBV rider.The rider is the one who decides how fast and in what direction the vehicle is moving and he does it by properly balancing its body.It can be concluded that the main signal controlling the vehicle does not act directly on the motors, but is the result of interaction between the vehicle and its rider.To consider this interaction in the model of the vehicle with the rider, at least one additional degree of freedom that describes the user's position relative to the vehicle must be included in the mathematical description of the system.In other words, the rider of the vehicle, together with the platform on which it stands, cannot be described by one rigid body system.In 2013, Mohtasib A.M. and Shawar M.H. in [9] presented a model of the system which contained the rider-vehicle interaction.The value of this interaction, however, was determined arbitrarily.
The main objective of this paper is to present a method of determining a quantitative and qualitative description of interaction between the two-wheeled selfbalancing vehicle and its rider.It should be noted that this is a new topic in research, because such interactions have not been studied previously, and inclusion of this interaction into the mathematical model of the rider-vehicle system makes it more realistic.To achieve this goal the exper-iment using a self-designed vehicle was performed (Section 2).The next step was to develop a mathematical model of the system, including the rider-vehicle interaction (Section 3).One of the most important things was to hypothesize a qualitative mathematical form of interaction (Section 4).The final step was to determine the unknown interaction based on the comparison of experimental data with the computer simulation results (Section 5).The general form of interaction between the vehicle and its rider is given in Section 6.Preliminary results are presented in [10].

Experimental results
To collect the experimental data, the self-designed vehicle was used.The vehicle is shown in Fig. 1.It consists of a platform on which the rider stands, a handlebar to change the direction of travel and wheels driven by electric motors located under the platform of the vehicle.To estimate the inclination angle of the platform and its angular velocity the inertial measurement unit was used.Velocity of the vehicle was calculated using an incremental quadrature encoder mounted on motor axes.The experiment consisted of a straight line acceleration from the zero vehicle speed to the desired final velocity VT in time T, and a simultaneous measurement of selected variables of the state vector.The measured variables were the velocity of the vehicle and the angle of inclination of the platform.The data was logged into the microcontroller's memory with a frequency of 10 Hz.There were thirty experiments performed for various values of the final velocity.The outcome of one of these is presented in Fig. 2. The solid lines describe the measurement data ( -platform inclination, V -vehicle velocity).The dashed lines come from the polynomial interpolation of measurement data derived by Hermite interpolation [11].These interpolation functions will be used in further analysis.Fig. 2 Experimental results for experiment no. 1

Mathematical model
To enable interaction between the rider and vehicle, an extra degree of freedom was added to the system, enabling change of the user's position relative to the platform.This additional degree of freedom is the ankle ϕ (Fig. 3), because users of this type of vehicles mainly bend at the ankle joint as seen from observation.

Fig. 3 Ankle joint mode
Torque generated in the ankle joint consists of a passive part (instinctive, not user controlled) and an active part (completely under the user control): where Tu is a torque active part, and s s kb   is a passive part.The passive part of total torque Ms was approximated by a damped harmonic oscillator model [12,13].The active part of torque is unknown and its designation is the main goal.
The model of the vehicle platform was approximated by a perfectly rigid body of known mass and the moment of inertia.The rider's model was approximated by a perfectly rigid body of known mass, the moment of inertia and the centre of gravity position.The rider is coupled to the vehicle by the ankle joint.The wheels of the vehicle were described by a rigid body of known parameters.The system has three degrees of freedom: platform inclination, user inclination, and wheel rotation angle (and thus the position of the vehicle, because the movement takes place without slipping).As you can see the model does not take account of the changing direction.The vehicle-rider interaction, which results in a change of direction, is simply a deflection of the handlebar, so it is not very interesting.In addition, the experiment concerned the straight line changing speed, and therefore a more complex model is not necessary.

Fig. 4 Physical model of vehicle
The Table 1 contains values of the system parameters.The system has been described by the Lagrange formalism, see [14].The position of the platform is described by a vector: Describing the position of the platform by angle  follows from the assumption that the motion takes place without slipping.The position of the rider's center of mass is: The kinetic energy of the rider is the sum of the translational kinetic energy of the center of mass and the angular kinetic energy about an axis passing through its center of mass and parallel to horizontal axis of the wheels: The kinetic energy of the platform takes the form: The kinetic energy of the wheels is: Potential energy of the rider and the spring modelling the ankle joint is: The Lagrangian of the vehicle-rider system takes the form: Using Eqs. ( 4)-( 8) and taking into account nonconservative forces from the motors and the ankle, the Euler-Lagrange equations take the form: where the motor torque: The solution of Eq. ( 9) are the equations of motion of the system: where To determine the motor control of the vehicle, the state feedback control has been used.This feedback is a linear function of the measured variables of the state vector, such as:  platform inclination,  -angular velocity of the platform,  angular velocity of the wheels.Therefore, the function of voltage U applied to motors takes the form: . Coefficients k1 and k2 were calculated using the LQR regulator, see for example [15,16].The LQR controller requires a full state feedback, but variable (user inclination) is not measured.Therefore, to apply the LQR control, the state vector of the system must be reduced.To achieve this, the mathematical model of the vehicle must be approximated by a two-wheeled inverted pendulum (as it was mentioned in the introduction).The reduction is based on the assumption that  = .The nominal values of the parameters k1 and k2 are as follows: According to the Eq. ( 11), the electric voltage is equal to: The investigated system is not observable, therefore determination of the unknown torque Tu directly from the model Eq. ( 10) is not possible.The solution of the problem is to find a mathematical form of the rider -vehicle interaction Tu, so that the computer simulation results using the proposed model (10) are consistent with the experimental results (according to the compliance criterion).
In the next sections of this paper the solution method of this problem will be presented.

Hypothesis about interaction form
The main task of the rider is to obtain the desired vehicle speed, so torque Tu should depend on the desired speed and the actual speed of the vehicle.While driving, the rider can change the elasticity and damping coefficients of the ankle joint by a suitable tension of muscles.According to these assumptions it can be hypothesized that torque Tu takes the form: where ), C1, C2, C3 -unknown parameters.
The verification method of this hypothesis is based on a numerical solution of the mathematical model of the vehicle (10), taking into account torque Tu described by (13).The purpose of the numerical analysis is to find the matching function , where y describes the time evolution of the system obtained from the numerical solution of the equations ( 10), and ŷ describes the experimental data approximated by Hermite interpolation.The parameters C1, C2 and C3, for which function  has a maximum are the sought coefficients of Eq. ( 13) for the current tested experiment.

Matching results
In order to compare the experimental data with the computer simulation results, the matching function   was defined based on the vehicle velocity (V plot in Fig. 2).Thus, the aim for different parameters C1 C2, C3, is to determine the matching function: where V is the vehicle velocity function obtained from the simulation of model Eq.(10) ), and V is the Hermite interpolation function of experimental measured velocity.The matching function (15) was determined by the use of the numerical solution of the system Eq.( 10) in the nodes of the mesh of parameters C1 C2, C3.
An appropriate selection of mesh parameters C = (C1, C2, C3) is important due to the calculation time of the simulation.Too dense a mesh will cause an unacceptably long computation time.When the grid is too sparse the results may not be sufficient.The problem of selecting mesh density has been solved by carrying out the calculation in two steps.After carrying out preliminary tests of numerical simulation, the mesh density in the first step is defined arbitrarily as: C1 varies in the range of 0 -100 with step 2, C2 and C3 varies in the range of 0 -8000 with step 200.The second step is to increase the mesh density but only in the places where the matching function  has reached the highest value in the calculations carried out in the first step.After completing the calculation,  as the function of parameters C1 and C2 can be drawn.To better visualize the relationship, function  in Fig. 5 is presented in the eighth power.The maximum values of the fit (forming the surface ridge) are arranged in a straight line.One can speak of a linear relationship between C1 and C2 when you take into account the best matching points.Taking into account 200 points of the best fit (ridge of the surface) this relationship can be drawn as shown in Fig. 6.  in Fig. 6 is the average value of the matching function for 200 points of the best fit.with the coefficient of determination: r 2 = 0.99939.From the above regression results it can be concluded that three unknown parameters C1, C2, C3 in function ( 13) can be expressed by one unknown parameter C1.
To determine the unknown parameter C1, the relationship between the maximum value of  for each C1 should be calculated.This relationship, i.e. φmax = Max [φ(C1)], is presented in Fig. 9.The resulting data can be approximated using nonlinear regression.As can be seen in Fig. 9, the approximating function should quickly reach the saturation point.The family of functions having such properties are logistics functions.In this case, the logistic function reaches a saturation level too slowly.The better solution is to use a modified logistic function which takes the form:  To specify the unknown parameter C1 from function (18), such C1 should be taken for which function φmax has reached a saturation point (parameter a in Eq. ( 18)).In theory, of course, a saturation point is reached at infinity.In practice, it can be assumed this will happen in a situation where φmax ≈ a.In these calculations it was assumed that φmax has reached a saturation point when φmax = 0.999a.When φmax = 0.999a, the matching function  has a sufficiently high value, while the rider's energy consumption is low.Thus, C1 value is a value for which φmax = 0.999a.According to ( 18 Using parameter C1 described by ( 19) and formulas ( 16), ( 17), the rider -vehicle interaction Tu given by ( 13) can be determined.It takes the form: The comparison of the experimental results (see Fig. 2) with the numerical simulation results, when interaction torque Tu is described by (20), is shown in Fig. 10.The solid lines describes the numerical data ( -platform inclination, V -vehicle velocity).The dashed lines describe the experimental data.The matching functions for the velocity of vehicle is equal to: φV = 0.98, and for the platform inclination it is: φa = 0.91.The matching function results confirm the correctness of the hypothesis about the interaction form described by Eq. ( 13).It is worth emphasizing, that the matching function  was defined based on the vehicle velocity only.Even so, the matching function results for the platform inclination has a high value, and it can be seen in Fig. 10.Angle , which describes the rider inclination (Fig. 4), was not measured in the experiment.However, it was determined in the computer simulation.To illustrate the rider's behaviour, it is better to show the plot -, that means the rider's inclination with respect to the platform: Fig. 11 Simulation results for experiment no. 1 The matching functions (15) were calculated for all thirty experiments (see Section 2).For each of them an analysis of the determination of parameters C1, C2, C3 was calculated.Detailed results of the analysis are presented in Table 2. Table 2 presents the results obtained for 30 experiments.Column "No." specifies the number of the experiment, r 2 is a coefficient of determination for linear regression, T -the vehicle acceleration time measured in the experiment and VT -the desired final velocity measured in the experiment.The average matching functions for thirty experiments take the following values: 9 .7 0 Table 2 Linear regression and experimental results The comparison of the experimental results with the numerical simulation results for a few selected experiments is shown in Fig. 12 and Fig. 13.Fig. 12 Comparison of the results for experiment no. 2 Fig. 13 Comparison of the results for experiment no.17

Generalized form of interaction
The designated model, however, has some disadvantages -it is not a general model.To describe each of the thirty experiments, parameter C1 and function C2 = f (C1) and C3 = f (C2) are required.The interaction described by equation ( 13) explicitly depends on the desired final wheel speed, and thus the desired final linear velocity of the vehicle.It is a natural assumption because the user's goal is acceleration to the desired velocity.It is obvious that the user can reach the desired final velocity at different times, so torque Tu should explicitly depend on the time needed to obtain this speed.To check if torque Tu depends on the acceleration time T, the relationship between the designated parameter C1 and vehicle acceleration T should be examined.This relationship is shown in Fig. 14.Looking at the results in Table 2, it can be concluded that coefficients b1 for the thirty experiments differ very little from each other and can be regarded (with a good approximation) as equal.It turns out that there is a fairly strong relationship between parameters C1 and a1 contained in Table 2.This relationship is shown in Fig. 15.
Fig. 15 The relationship a1 = f (C1) Based on the graphical presentation of the data shown in Fig. 15, it can be assumed that the function approximating the relationship between C1 and a1 takes the form:   As a result, parameter C2 in Eq. ( 13) can be written as:   2, did not show any dependence on time T or parameters C1 or C2.In this case, generalization consists in taking the average values of coefficients a2 and b2 obtained for the thirty experiments.Parameter C3 in Eq. ( 13) can be written as: Substituting C2 from Eq. (24) into Eq.( 25) is obtained as follows:  24), ( 26) and ( 13) the generalized form of interaction between the vehicle and its rider is expressed as follows: It should be emphasized that the general form of interaction described by Eqs. ( 27) or (28) has been designated for a particular vehicle with a particular user and for a specific control law of vehicle motors.Changing the physical properties of the vehicle (e.g.mass of the platform or radius of the wheels) or the rider (e.g.their mass) will cause that the designated numerical values in Eq. (28) will not be appropriate for a system with the altered physical properties.Changing the motor control law described by Eq. ( 12) will have the same effect.In order to express all the numerical parameters of Eq. (28) as the physical properties of the system, a series of experiments for vehicles and users with different values of physical properties occurring in the mathematical model of the vehicle must be performed.Then, you need to carry out an extensive statistical analysis.
The comparison of the experimental results with the numerical simulation results using a general form of interaction for a few selected experiments is shown in the graphs in Fig. 16, Fig. 17

Conclusions
Determination of the mathematical model of interaction between the vehicle and its rider, consisted of several stages.Firstly, an experiment was carried out.Secondly, the mathematical model of the system was created.Thirdly, the hypothesis about the character of interaction was postulated.Next, the comparison method between the simulation and experimental data was developed.Finally, the quantitative and qualitative description of interaction and its generalized form was designated.The results presented on the graphs (Figs.16,17,18) show, that the generalized form of interaction between the TWSBV and its rider can be recognized, with high probability, as correct.This is also confirmed by the results of the matching functions.Of course, if parameters C1, C2, C3 in Eq. ( 13) are unique for each experiment, the results of the matching functions are better than in the general case.However, the difference is not big, and the benefit of generalization is enormous.The generalized description of the interaction depends explicitly only on two variables (excluding, of course, the state vector).These variables are the desired final velocity and the time after which this velocity will be achieved.As a result of the analysis, the previously unknown torque Tu applied by the user in the ankle joint was described in this way.Therefore, the mathematical model of the vehicle-rider system became more realistic than the commonly used two-wheeled inverted pendulum model.

Fig. 1
Fig. 1 Two-wheeled self-balancing vehicle . The parameter k3 is determined from the equation of the motor torque, assuming that the linear velocity of the vehicle does not change when the angle of inclination of the platform is equal to zero.According to Newton's First law, assuming that 0   , the motor torque takes the form: was defined based on the normalized root mean square error (NRMSE) between the experimental data and simulation data.The normalized root mean square error can be achieved by normalizing the RMSE value to the range of the observed data, see for example[18].This function takes the form: and minimum values measured in the experiment.Due to the fact that the angle of inclination of the platform measured in the experiment is distorted by the platform vibration ( plot in Fig.2), the matching function

Fig. 10
Fig. 10 Comparison of the results for experiment no. 1

Fig. 14
Fig. 14 The relationship C1 = f (T)The results presented in Fig.14show, that parameter C1 can be expressed as a function of acceleration time T. If the rider intends to accelerate to the desired final velocity in a long time, torque Tu, and hence parameters C1, should be small.In another words, parameter C1 should be inversely proportional to time T. Therefore, the function approximating the relationship between C1 and T takes the form:

23) where 1 b
is mean value of parameter b1.Substituting C1 from Eq. (21) into Eq.(23) is obtained as follows: .(21) and (24), parameters C1 and C2 can be represented as a function of acceleration time T. Unfortunately, parameters of function . (21), ( Fig. 16 Comparison of the results for experiment no. 1

Fig. 17
Fig. 17 Comparison of the results for experiment no. 2 Fig. 17 Comparison of the results for experiment no. 2

Table 1
The vehicle and the rider's parameters