{'fraction_non_alphanumeric': 0.039372539216298984, 'fraction_numerical': 0.010061871133054184, 'mean_word_length': 4.143683702989392, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Stochastic properties of an inverted pendulum on a wheel on a soft surface

We study dynamics of the inverted pendulum on the wheel on a soft surface and under a proportional-integral-derivative controller. The behaviour of such pendulum is modelled by a system with a differential inclusion. If the the system has a sensor for the rotational velocity of the pendulum, the tilt sensor and the encoder for the wheel then this system is observable. The using of the observed data for the controller brings stochastic perturbations into the system. The properties of the differential inclusion under stochastic control is studied for upper position of the pendulum. The formula for the time, which the pendulum spends near the upper position, is derived.


Introduction
The wheeled inverted pendulum (WIP) is a popular model for studies nor only dynamics and the system of the control for robotics equipments near instability positions. A list of contemporary works in this field is too large.
Here we should mention studies for the derivation of the mathematical model for the WIP and the control synthesis, which one can see for example in the book [5], and the article [15]. The questions concerned an stability and control for WIP with two wheels were considered in [18] for the horizontal and in [17] for the inclined surface.
We apply the proportional-integral-derivative (PID) controller to stabilize the WIP at the upper point. We should mention the PID controller is often used to the objects of different nature [2]. For example the PID controller can be used to stabilize the WIP on the hard horizontal, see [16], [1] and a review [19]. But the soft surface is more complicated to stabilize the WIP. The mathematical model for the WIP controlled by the PID controller on z x y α β Figure 1: The inverted pendulum on the wheel. Let us denote r is the radius of the wheel, l is the pendulum length, α is the angle of the pendulum turn, β is the angle of the wheel turn and z is the inclination angle of the surface. the soft surface was offered and detailed studied in [11] (see also preprint [12]).
The major part of the PID controller is an observation value of the angle of the pendulum position. This angle can be found by gyroscope sensor . Usually the sensor obtains the value with a small stochastic error. The maximal amplitude and the dispersion for the error is standardized by specification of the sensor, see for example [7].
An additional sensor for the WIP is a tilt sensor. Such sensors are commonly used and have a detailed specification in which the interval of errors and the dispersion are pointed, see for example [6].
To obtain amount of the rotation of the wheel we use an encoder. If the wheel does not slip, the errors of the digital encoder appear due to round up only. Slipping brings additional errors to the value of the encoder. Therefore one of the problems for the controller is to detect the slipping.
In this work we show that the gyroscope and tilt for the pendulum and encoder for the wheel are enough to observe the state of the system in framework of the mathematical model.
However the noise of the sensors and the slipping bring stochastic errors into the value of the sensors. Therefore the controller which uses these values has stochastic perturbations. Hence the mathematical model with the digital PID controller is stochastic.
In section 2 we describe the mathematical model of WIP on the soft surface with the PID controller. The dynamic model on the soft surface contains a rolling resistance. Pure mathematically this resistance is described by the differential inclusion, see [11].
In section 3 one can find the formulas for the current state of the WIP. These formulas use the data obtained from the gyroscope, tilt sensor and encoder.
In section 4 we discuss the stochastic properties of the data for the PID controller. The errors and dispersion of the data from the sensors are assumed as known form the technical notes.
In section 5 we consider the properties of the WIP under the PID controller with stochastic perturbations. The perturbations appear in the control by using the data with the stochastic errors.

Dynamical system for the WIP
Here we will consider the moving of the WIP with the additional control torque on the wheel. The torque is denoted by u. Let us assume that the equipment moves on soft surface with inclination z. The value of z depends on the traversed path by the wheel and hence one can write z = z(β). The mathematical model of such moving has the form (see [11], also preprint [12]):α Let us denote In formula (1) the map F (α,α,α,β) has the form: Here the parameters of the mathematical model are following: α is an angle of the pendulum turn, β is the angle of wheel turn, z is the current inclination of the soft surface, ν is the torque of the friction resistant, ρ = r/l is the ratio of the wheel radius and the length of the pendulum, ζ is the ratio of pendulum mass and the rim mass.
The system (1) can be simplify for hard (ν = 0) surface with the constant inclination (z ≡ ). As a result one gets the second order equation for α: The particular case for the WIP on the hard horizontal ( = 0) looks as follow: The control torque with the PID controller has the following form: In this case system (1) has a particular solution: where There exists the set of the parameters ζ, ρ, k 1 , k 2 , k 3 when solution (4) is an attractor as (t − t 0 ) < T [11] (see also preprint [12]).
In an ideal case the control should be defined by the current values of α,α, A, but for real equipment these parameters can be obtained using the sensors at the moment t i , where i ∈ N. As a result the control is a discrete function: At the interval t ∈ (t i , t i+1 ) the control torque u i is a constant. Such system has a first integral and can be integrate in quadratures.
For example the moving on the hard surface with the constant inclination (2) has a first integral at the interval t ∈ (t i , t i+1 ): This formula allows us to integrateα at the interval t ∈ (t i , t i+1 ) and we can write the parameters of the system at t = t i+1 : One can obtain the first integral for WIP on the hard horizontal surface (3) if one assumes = 0.
The mathematical model for the WIP on the soft surface does not integrate obviously. Nevertheless this model can be written in the form: One can obtain the numeric solution of this differential inclusion at the interval t ∈ (t i , t i+1 ). Let us define the map: Formally this map can be written like a discrete dynamical system: , where X n = (A n , α n , a n , β n , b n , u n ).

Observability of the mathematical model for WIP
In this section we consider the set of the data necessary for the observability of the parameters of the mathematical model for WIP (1). The angle of the tilt for the pendulum is defined by gyroscope. The gyroscope can be work in two different cases. The first one it defines the angle of the pendulum and the second one it define the angle velocity for the pendulum. In the second case one should integrates the angle velocity to obtain the pendulum angle. Below we will use the gyroscope in the mode of angle velocity. This means the value of the angle velocityα is known at the moment of the measurement.
Besides the gyroscope we assume as existing the tilt sensor. This sensor define the linear acceleration of the pendulum in the plane of the moving of WIP.
Let us define the coordinates as (x, y), where x is the horizontal coordinate and y is the vertical one. The projections of the acceleration vector on the coordinate axes Ox and Oy one can write as follows: x =βr cos(z(β)) +αl sin(α), y =βr sin(z(β)) +αl cos(α) + g.
It is convenient to write these formulas in the form: One more sensor is the encoder. This sensor allows us to define the turn of the wheel. The data from the encoder allow to obtain the mean value of the angle velocity of the wheel as value of the difference between the current value of the turn angle of the wheel and another one value at previous measurement:β Let us consider the system for WIP on the horizontal surface (i.e. z = 0): αl cos(α) =ÿ βr cos(α) =ẍ cos(α) −ÿ sin(α) + g sin(α).
The value a 1 =α is known from the sensor. Let us define by a 2 (t) =ÿ/l, b 2 =ẍ/r, γ = g/l and b 1 =β. Then the dynamical system (1) can be written as the system of the trigonometric equation and the inclusion: where The angle of the pendulum α and the control torque u are the unknown variables in the system (6), (7). If b 1 = 0 or b 1 = 0 ∪ |f | ≥ ν then the inclusion (7) turn to the following equation: As a result one get the system of the equations for α, u. The control torque u can be easy found through the trigonometric functions of α and hence one get the trigonometric equation for α .
As {b 1 = 0} ∪ {|f | < ν} the angle of the pendulum should be solution of the inequality: Here one get the observed parameter u. To obtain the integral term A of the PID controller one should use the following formula: Theorem 1 Let one know the values of the acceleration (ẍ,ÿ), angle velocity of the pendulumα and angle velocity of the wheelβ, then the observed dynamical system is solution of the trigonometric equation (6) and the inclusion (7).
The equations for small values of ν, α,ÿ,α,ẍ,β and (z ≡ 0) can be written in the following form: Corollary 1 The important case for the WIP on the hard horizontal is more simplest. In particular the angle α is the solution of the equation: For small values of ν, α,ÿ,α,ẍ,β we get:

The observability and the stochastic properties
The value of the controlling torque at t i is defined by the measurement of observed values of the parameters of the dynamic system. The obtained data from the sensors and the computed observed data at t i will be denoted by variables with upper symbol•. The absolute errors and the dispersion are known for typical sensors. Below we will assume that we know the standard deviation σ j of the measured data at t = t j .
For smallÿ, α,α,ẍ,β, ν we obtain the formulas for errors of the observed data α and A: Remark.While the WIP moves on the soft horizontal the stochastic layer appears near the hyperplaneβ = 0. The width of this layer is min{δ (4) } ≤ β ≤ max{δ (4) }. In this layer the stochastic error can be ±ν when |f | > ν. It is important the value of this errors defines by value of the rolling resistance for the wheel and does not depend on the error of the encoder.
The data with stochastic errors are used in the PID controller. As a result the stochastic perturbations appear in the mathematical model for the WIP (3 and in the systems (2) and (1). Therefore the mathematical model with the PID controller looks like the stochastic differential inclusion (1). In partial the results for the observed values of (β,β) and α with stochastic errors are showed in the figures 2 and 3.
The remark about filtering data The current values of the parameters of the dynamic system for WIP one can obtain by the different approaches.
The first one is the integration of the differential inclusion as the predetermined process. Such approach gives the errors at any step of the integration because of two causes. First of all this errors appear because of the errors in the initial data on the first step of integration. One more cause of the appearance of the errors is the inaccuracy of the mathematical model. The value of the angleα i is defined as the observed calculated using the angle acceleration and angle velocity from the equation (10). The valuesα andα were used to obtainȂ by integrating by the trapezoidal rule. The value of the control torque u i+1 was obtained at the interval t ∈ (t i , t i+1 ). The system of the equations was solved at the interval t ∈ (t i , t i+1 ) with the constant value of the control torque u = u i+1 by Runge-Kutta fourth-order method with the step equals by 0.1.
Another one approach is to use the observability of this system. This case does not needed to integrate the differential inclusion. But the errors appears in the current moment because of the errors of the measurement of the data using the sensors.
To minimize the quadratic deviation of the data one can combine the observed data and the forecasted data using the deterministic methematical model. Such algorithms are called as the filters. The filters for the linare system are well-knowing, see [10], [9], [4]. FOr nonlinear smooth systems like the WIP on the hard surface is convenient the generalized Kalman's filter, see [14], [3]. But for the considered here case of WIP on the soft surface the generalized Kalman's filter is not appropriated because of non-lineared the dinamical system in the neighbouhood of the hypersurfaceβ = 0. One of the opportunity to use filtering in such case is the sigma-point filter, see [20], [8].

Stochastic properties for WIP on soft horizontal
Let the interval dt between the moments of the measurements be small. Then one can see at the dynamic system as a determined dynamic system (1) with stochastic perturbation. The stochastic perturbation is contained in the control torque:ũ i = k 1αi + k 2α + k 0Ãi . In the work [11] (see also preprint [12]) it was shown that the unperturbed dynamical system with the PID controller has the attractor as sgn(β) = ±1. This attractor is a line belonged the fifth-dimensional phase space: (A, α,α, β,β) = (A ± , 0, 0, 0,β), where 2 ρ k 0 A ± = ±ν.
On this line the system for WIP is unstable and due to the perturbations crosses to the trajectory with changing of the signum of rotation of the wheel from sgn(β) = ±1 to sgn(β) = ∓1. As a result the numeric modelling gives the trajectory like the hysteresis loop, see [11].
Let us consider here the impact of the stochastic perturbation on the stability for the hysteresis loop. The typical trajectory for the system with the stochastic perturbation is shown on the figure 4.

Theorem 2
The line (A ± , 0, 0, 0,β) as sgn(β) = ±1 is the attractor for the stochastic system (1).  The value of the angleα i is defined as the observed data through the angle acceleration and the angle velocity using (1). The valueȂ is computed using α,α integrating by the trapezoidal method. It allows to obtain the control torque u i+1 at the interval t ∈ (t i , t i+1 ), where t i+1 − t i = dt. At t ∈ (t i , t i+1 ) the system for the WIP on the soft horizontal is solved for the constant value the control torque u = u i+1 by the Runge-Kutta method of the fourth order with the step equals 0.01. This theorem is corollary from the results of [11] concerning the stability of the line (A ± , 0, 0, 0,β) as sgn(β) = ±1 for pure determined dynamical system for WIP under the PID controller and the theorem about stability under constantly perturbations [13].
There exists the small neighbourhood (∆ ± ) near the unstable lines (A ± , 0, 0, 0,β), where can be obtained four typical cases: The sequence of the changes of the trajectories at the neighbourhoods of the lines (A ± , 0, 0, 0) leads to the appearance of the hysteresis loop at the phase plane (β,β), see figure 2.
Here it is important for applications the average time,which the WIP spends in the neighbourhood of the upper position.
The time between the sequence measurements is equal dt. Let the trajectory be in the neighbourhood ∆ ± of the unstable line. The probability of sgn(δ (3) ) = ±1 in primary order as ∆ ± → 0 equals p ± ∼ 1/2. The average time for trajectory in this neighbourhood is following: Theorem 3 The average time spending at ∆-neighbourhood of the unstable lines (A ± , 0, 0, 0,β) for the stochastic system (1) equals 2dt, where dt is the time between the sequenced measurements of the state for the system.

Conclusion
The system for the WIP with discrete control by the PID controller is stochastic due to the errors of the measurements. The stabilising of the WIP on the soft surface leads to the appearance of the hysteresis loop in the plane of the phase variables β,β. The average time spending near the upper position was calculated.