1 Introduction

Single-track vehicles, such as motorcycles and bicycles, provide superior maneuverability and deployment performance in comparison to double-track vehicles, such as cars and trucks. Recently, autonomous bicycle and motorcycle robots attract much attention, because they can be used as a kind of efficient transportation tools working in the cities and/or in the mountains without any environmental burden and do not require wide contact space to the ground. Moreover, the light weight of the single-track vehicles also provides attractive properties, such as high energy efficiency and fast acceleration.

Research on the modeling of the bicycles and motorcycles has a long history. The reader is referred to [1] and [2] for a comprehensive review of the existing methods. Bicycles share many similar properties with motorcycles. Generally speaking, the motorcycle models differ from the bicycle models in the way contact between tires, and ground is modeled. The bicycle models, such as Getz’s model proposed in [3] and [4], assume nonholonomic contact, while the motorcycle models include a more realistic tire-ground interaction model, considering lateral sliding and normal load. Getz’s bicycle model, also called the simplified motorcycle model in [5], captures many important aspects of real bicycle and motorcycle dynamics and has been applied effectively in the development of a smart motorcycle driver [6]. More complex motorcycle models were considered in [7] and [8]. In [7], a dynamic model of the motorcycle was developed by using Getz’s modeling approach [4]. The model is modified by adding motorcycle trail and caster angle, and can capture the steering effect on the vehicle motion. In [8], Meijaard and Popov analyzed the dynamic behaviors of the motorcycle models by using the motion equations generated by a symbolic multibody program. Branches of stationary and periodic solutions together with bifurcations of these solutions were calculated for the motorcycle dynamics.

Motion control of the single-track vehicles became a popular topic for researchers in the latter half of the last century. It is normally classified into two categories: stabilization control [912] and tracking control [4, 7, 1318].

Stabilization control is to balance a stationary robot around the upright position with the steering handlebar and/or a balancer. In [9], decoupling and linearization were achieved based on feedback linearization for the single-input single-output dynamic model of the bicycle robot. Then, a steering handlebar and a balancer were simultaneously used to stabilize the robot around the upright position. Keo and Yamakita proposed a nonlinear output-zeroing controller for stabilizing a bicycle robot at zero speed, also with both steering handlebar and balancer [10]. A first-order sliding mode controller with an observer is given in [11] to stabilize a bicycle robot at zero velocity and varying velocities. In [12], stability analysis of a human neurological control of a stationary bicycle was accomplished by the sweeping frequency method and the stability charts for time-delay dynamical systems.

Tracking control is to guide a robot to track a given trajectory at a non-zero velocity, while preventing the robot from falling down. In [4], Getz proposed a feedback control law such that the bicycle robot’s position can track a desired trajectory. The tracking control of robot’s position was also solved in [7], where an asymptotically stable controller was designed. However, tracking of the robot’s yaw angle was not considered in the above two controllers. In [13], a simplified inverted pendulum model was utilized, and a proportional derivative controller with a disturbance observer was designed for a bicycle robot to track a straight-line trajectory. However, the controller was designed based on an approximate linearized model, and the linearization errors were not considered. In addition, the robot can only execute its motion approximately on a straight-line trajectory, which is quite limited. Yamaguchi et al. [14] designed a self-sustaining controller for an electric bicycle using acceleration control based on the Lyapunov method and the backstepping technique. The running performance in low-speed range was improved by the proposed acceleration control. Thus, the controller is applicable to a wider speed range than the conventional methods. Defoort and Murakami proposed a second-order sliding mode controller for stabilizing a bicycle robot around a trajectory. The controller is robust against disturbances and measurement noises [15]. Hwang et al. [16] proposed a variable structure underactuated tracking controller for an electric bicycle. The time-varying system uncertainties and the wind effect were both considered. In [17], a virtual holonomic constraint (VHC) which specifies the roll angle of the bicycle robot as a function of its position along a strictly convex Jordan curve was adopted. It was shown that if the mean curvature of the curve is sufficiently small, then the VHC manifold is invariant, and the closed orbit is asymptotically stable. The bicycle robot can traverse the curve with bounded speed, and its speed is periodic in steady-state. In [18], Gundes and Nanjangud proposed low-order controllers with only the steering torque as input to control any number of linear bicycle models at different forward velocity. The controllers are simple and provide some freedom in the design parameters. Frezza et al. [19] implemented a path following controller for a simplified motorcycle model using a model predictive control (MPC) strategy. Yi et al. [20] analyzed the external/internal convertible (EIC) dynamical structure of the motorcycle dynamics. A nonlinear tracking controller was designed based on the EIC system. The controller guarantees exponential convergence of the motorcycle’s position to a neighborhood of the desired trajectory while the roll angle converges to a neighborhood of the desired equilibrium.

Trajectory planning is also a key issue for the control and navigation of the bicycle and motorcycle robots. Hauser et al. addressed the trajectory exploration for the nonholonomic motorcycle model in [5, 21]. In [5], the problem whether a bounded roll trajectory is guaranteed to exist was addressed for a simplified motorcycle, given a planar trajectory with a desired velocity signal. The motorcycle was constrained on the given planar trajectory, and then an iterative algorithm was designed for calculating the required roll trajectory approximately consistent with the planar trajectory. In [21], an extended control system was embedded into the motorcycle dynamics by adding two nonphysical control inputs. Then, these additional control inputs were optimized away by the projection operator approach, such that a flatland trajectory can be lift into a state-input trajectory.

From the above literature review, we can see that almost all the related researches focus on modeling and motion control of the single-track robots. However, the problem of trajectory planning of the bicycle and motorcycle robots has not been fully addressed. Moreover, most of the previous researches on tracking control of the bicycles and motorcycles, e.g., [3, 4, 7, 13, 20], only solved the problem of partial-state tracking control, i.e., only the position coordinates and the roll angle of the system were controlled to track their desired trajectories, without taking the yaw angle into account. In this paper, we consider both the trajectory planning and tracking control for the Getz’s bicycle model. The main contributions of this paper are twofold. (1) We plan an optimal desired trajectory for the bicycle robot by minimizing the maximum of the roll angle’s equilibrium of the robot. This optimization problem is solved by the use of the PSO algorithm. (2) We design a full-state tracking controller for the bicycle robot to approximately track the desired trajectory with a good balance. Compared with the existing tracking controllers, the proposed controller can drive not only the position and roll angle but also the yaw angle to track the desired trajectories.

The remainder of the paper is organized as follows: the dynamics of the bicycle robot is described in Sect. 2. In Sect. 3, the problem of trajectory planning is solved by the PSO algorithm. Then, the tracking and balance controller is designed in Sect. 4. Simulations are given in Sect. 5 to verify the proposed method. The paper is concluded in Sect. 6.

2 Dynamics of bicycle robot

We view the bicycle robot [4, 5] as a plane that is allowed to move and roll on the ground, as shown in Fig. 1. For simplicity, the wheels of the bicycle robot are considered to roll without sideslip and to move in a flat plane without vertical motion.

Consider a ground-fixed inertial reference frame \(O-XYZ\) with \(x\) and \(y\) axes in the ground plane and \(z\) axis perpendicular to the ground plane in the direction opposite to gravity. The key variables and parameters are

\(x\) :

x coordinate of the point of contact of the rear wheel

\(y\) :

y coordinate of the point of contact of the rear wheel

\(\theta \) :

Yaw (or heading) angle of the robot frame (rear wheel)

\(\varphi \) :

Roll (or lean) angle of the robot frame (rear wheel)

\(\delta \) :

Steering angle

\(m\) :

Robot mass

\(h\) :

Height of the center of mass (when the robot is vertical)

\(p\) :

Robot wheelbase

\(b\) :

Horizontal distance between rear wheel contact point and the robot center of mass

\(R\) :

Turning radius

\(g\) :

Gravity acceleration

Consider Fig. 1, the generalized coordinates describing the configuration of the bicycle robot are the position \((x,y)\) of the contact point of rear wheel, yaw angle \(\theta \), and roll angel \(\varphi \), which are written in short as \({{\varvec{q}}}=(x,y,\theta ,\varphi )^{T}\). For roll angle \(\varphi \), we define tilting right from the vertical line is positive and for steering angle \(\delta \), turning left is the positive direction.

Fig. 1
figure 1

Bicycle robot model

The kinematics of the planar motion is given as follows:

$$\begin{aligned} \left[ {{\begin{array}{l} {\dot{x}} \\ {\dot{y}} \\ {\dot{\theta }} \\ \end{array} }} \right] =\left[ {{\begin{array}{l} {v\cdot \cos \theta } \\ {v\cdot \sin \theta } \\ {v\cdot \sigma } \\ \end{array} }} \right] \end{aligned}$$
(1)

where \(v\) is the longitudinal velocity of the rear wheel, and \(\sigma \) is the curvature. Note that the nonholonomic constraint of the rear wheel implies that the lateral velocity of the rear wheel is \(v_\bot =0\).

The roll dynamics of the bicycle robot is that of an inverted pendulum given by

$$\begin{aligned} h\ddot{\varphi }=g\sin \varphi +[(1+h\sigma \sin \varphi )\sigma v^{2}+b(\dot{v}\sigma +v\dot{\sigma })]\cos \varphi \end{aligned}$$
(2)

Equation (2) describes the internal dynamics of the system. The control inputs of the model given by (1) and (2) are \(\dot{v}\) and \(\dot{\sigma }\), which are denoted by \({{\varvec{u}}}=(u_1 ,u_2 )^{T}=(\dot{v},\dot{\sigma })^{T}\). The complete Lagrangian dynamics and the derivation for the reduced equations were given in [4]. The model given by (1) and (2) is the same as that described in [4]. It is a simplified version of the motorcycle model in [7], because the motorcycle trail and caster angle are not considered.

Next, we consider the roll angle’s equilibrium, denoted by \(\varphi _e \). We define the implicit function \(F(\varphi )\) of \(\varphi \) as

$$\begin{aligned} F(\varphi )&= g\sin \varphi +[(1+h\sigma \sin \varphi )\sigma v^{2}\nonumber \\&+\,b(\dot{v}\sigma +v\dot{\sigma })]\cos \varphi \end{aligned}$$
(3)

For a given external control input \({{\varvec{u}}}^{\text {ext}}=(\dot{v}^\mathrm{ext},\dot{\sigma }^\mathrm{ext})^{T}\), the roll angle’s equilibrium \(\varphi _e \) is a solution of the algebraic equation \(F(\varphi )=0\), by substituting \({{\varvec{u}}}^{\text {ext}}=(\dot{v}^\mathrm{ext},\dot{\sigma }^\mathrm{ext})^{T}\) into (3). The internal equilibrium manifold for the system is

$$\begin{aligned} \varepsilon (t)=\left\{ {(x,y,\varphi ,\dot{\varphi })|\varphi =\varphi _e ,\dot{\varphi }=0} \right\} \end{aligned}$$
(4)

3 Trajectory planning for bicycle robot

Assume that a start point \(P_0 =(x_0 ,y_0 )\) and a destination point \(P_f =(x_\mathrm{f} ,y_\mathrm{f} )\) of the robot have been assigned in the Cartesian plane. We will plan a curve between \(P_0 \) and \(P_\mathrm{f} \) which satisfies given constraints on the initial and final tangent angles \(\theta _0 \) and \(\theta _\mathrm{f} \). The curve can be represented by a parameterization \(P_\mathrm{d} (t)=(x_\mathrm{d} (t),y_\mathrm{d} (t))\) with time parameter \(t\in [t_0 ,t_\mathrm{f} ]\), where the initial time \(t_0 \) can be set as \(t_0 =0\) without loss of generality, and the final time \(t_\mathrm{f} \) can be assigned according to the dynamic properties of the bicycle robot. The final time \(t_\mathrm{f} \) can also be selected by some optimality criterion. In this paper, we set \(t_\mathrm{f} \) to be a constant.

At least the first derivative of \(P_\mathrm{d} (t)\)’s curvature should exist, because one of the control inputs of the robot is \(\dot{\sigma }\). We choose 3rd order polynomials of time to parameterize \(x_\mathrm{d} (t)\) and \(y_\mathrm{d} (t)\) as

$$\begin{aligned} \left\{ {{\begin{array}{l} {x_\mathrm{d} (t)=\alpha _0 +\alpha _1 t+\alpha _2 t^{2}+\alpha _3 t^{3}} \\ {y_\mathrm{d} (t)=\beta _0 +\beta _1 t+\beta _2 t^{2}+\beta _3 t^{3}} \\ \end{array} }} \right. \end{aligned}$$
(5)

Subject to the boundary conditions

$$\begin{aligned} \left\{ {{\begin{array}{l} {P_\mathrm{d} (t_0 )=P_0 } \\ {\theta _\mathrm{d} (t_0 )=\theta _0 } \\ {P_\mathrm{d} (t_\mathrm{f} )=P_\mathrm{f} } \\ {\theta _\mathrm{d} (t_\mathrm{f} )=\theta _\mathrm{f} } \\ \end{array} }} \right. \end{aligned}$$
(6)

The polynomial coefficients \(\alpha _i \) and \(\beta _i \;(i=0,1,2,3)\) are detailed by the following linear algebraic equations:

$$\begin{aligned} \left\{ {{\begin{array}{l} {\alpha _0 =x_0 } \\ {\beta _0 =y_0 } \\ {\alpha _1 =\lambda _1 \cos \theta _0 \;\;\;} \\ {\beta _1 =\lambda _1 \sin \theta _0 \;\;\;} \\ {\alpha _0 +\alpha _1 t_\mathrm{f} +\alpha _2 t_\mathrm{f} ^{2}+\alpha _3 t_\mathrm{f} ^{3}=x_\mathrm{f} } \\ {\beta _0 +\beta _1 t_\mathrm{f} +\beta _2 t_\mathrm{f} ^{2}+\beta _3 t_\mathrm{f} ^{3}=y_\mathrm{f} } \\ {\alpha _1 +2\alpha _2 t_\mathrm{f} +3\alpha _3 t_\mathrm{f} ^{2}=\lambda _2 \cos \theta _\mathrm{f} } \\ {\beta _1 +2\beta _2 t_\mathrm{f} +3\beta _3 t_\mathrm{f} ^{2}=\lambda _2 \sin \theta _\mathrm{f} } \\ \end{array} }} \right. \end{aligned}$$
(7)

where the real parameters \(\lambda _1 \) and \(\lambda _2 \) in (7) can be freely selected, and they can influence the curve shape without violating the endpoint constraint (6). The parameter vector \(\lambda =[\lambda _1 ,\lambda _2 ]^{T}\) can be optimized to adjust the shape of the planned trajectory such that the maximum of the desired roll angle’s equilibrium of the robot is minimized.

Note that the planar trajectory of the bicycle robot has six constraints on the initial and final states, i.e., four position constraints \(P_0 =(x_0 ,y_0 )\) and \(P_\mathrm{f} =(x_\mathrm{f} ,y_\mathrm{f} )\), as well as two yaw angle constraints \(\theta (t_0 )=\theta _0 \) and \(\theta (t_\mathrm{f} )=\theta _\mathrm{f} \). The 3rd order polynomial in terms of time given in (5) has eight parameters. Thus, the two parameters \(\lambda _1 \) and \(\lambda _2 \) can be freely chosen. Higher order polynomials can be adopted when more constraints are imposed on the robot’s motion trajectory.

Assume that the desired planar motion trajectory of the bicycle is denoted by \(\Gamma _\mathrm{d} (t)=(x_\mathrm{d} (t),y_\mathrm{d} (t),\theta _\mathrm{d} (t))\), where \(x_\mathrm{d} (t)\) and \(y_\mathrm{d} (t)\) are given in (5). From (5), it is shown that \(x_\mathrm{d} (t)\) and \(y_\mathrm{d} (t)\) are at least thrice differentiable. From (1), the desired linear velocity is \({{\varvec{v}}}_{{\varvec{d}}} =\pm \sqrt{\dot{x}_\mathrm{d} ^{2}+\dot{y}_\mathrm{d} ^{2}}\) and the desired yaw angle is \(\theta _\mathrm{d} =a\tan 2(\dot{y}_\mathrm{d} ,\dot{x}_\mathrm{d} )+k\pi (k\in \mathrm{Z})\). In this paper, we assume that the bicycle robot can only move forward. Thus, the desired linear velocity and yaw angle of the system are

$$\begin{aligned} v_\mathrm{d}&= \sqrt{\dot{x}_\mathrm{d} ^{2}+\dot{y}_\mathrm{d} ^{2}}\end{aligned}$$
(8)
$$\begin{aligned} \theta _\mathrm{d}&= \hbox {a}\tan 2(\dot{y}_\mathrm{d} ,\dot{x}_\mathrm{d} )+2n\pi \;(n\in \mathrm{Z}) \end{aligned}$$
(9)

The desired curvature of the path is

$$\begin{aligned} \sigma _\mathrm{d} =\frac{\ddot{y}_\mathrm{d} \dot{x}_\mathrm{d} -\ddot{x}_\mathrm{d} \dot{y}_\mathrm{d} }{(\dot{x}_\mathrm{d} ^{2}+\dot{y}_\mathrm{d} ^{2})^{3/2}} \end{aligned}$$
(10)

Then the desired roll angle’s equilibrium \(\varphi _\mathrm{ed} \), compatible with \(v_\mathrm{d} \) and \(\sigma _\mathrm{d} \), can be determined by \(F(\varphi _\mathrm{d} )=0\), where

$$\begin{aligned} F(\varphi _\mathrm{d} )&= g\sin \varphi _\mathrm{d} +[(1+h\sigma _\mathrm{d} \sin \varphi _\mathrm{d} )\sigma _\mathrm{d} v_\mathrm{d} ^{2}\nonumber \\&+b(\dot{v}_\mathrm{d} \sigma _\mathrm{d} +v_\mathrm{d} \dot{\sigma }_\mathrm{d} )]\cos \varphi _\mathrm{d} \end{aligned}$$
(11)

In order to prevent the robot from falling down and retain balance more reliably, \(\lambda \) is calculated by solving the following optimization problem:

$$\begin{aligned} \mathop {\min }\limits _{\lambda \in \mathbf{R}^{2}} \mathop {\max }\limits _{t\in [t_0 ,t_\mathrm{f} ]} \left| {\varphi _\mathrm{ed} (\lambda ,t)} \right| \end{aligned}$$
(12)

For a given \(\lambda \), e.g., \(\lambda =\lambda _{ 0} \), the problem to solve \(\mathop {\max }\limits _{t\in [t_0 ,t_\mathrm{f} ]} \left| {\varphi _\mathrm{ed} (\lambda _0,t)} \right| \) is equivalent to

$$\begin{aligned} \left\{ {{\begin{array}{l} {\mathop {\max }\limits _{t\in [t_0 ,t_\mathrm{f} ]} \varphi _\mathrm{ed} (\lambda { }_0,t),\quad \mathrm{if}\;\varphi _\mathrm{ed} (\lambda { }_0,t)\ge 0} \\ {\mathop {\min }\limits _{t\in [t_0 ,t_\mathrm{f} ]} \varphi _\mathrm{ed} (\lambda { }_0,t),\quad \mathrm{otherwise}\quad \;\quad } \\ \end{array} }} \right. \end{aligned}$$
(13)

Subject to

$$\begin{aligned} F(\varphi _\mathrm{ed} ,t)&= g\sin \varphi _\mathrm{ed} +[(1+h\sigma _\mathrm{d} \sin \varphi _\mathrm{ed} )\sigma _\mathrm{d} v_\mathrm{d} ^{2}\nonumber \\&+b(\dot{v}_\mathrm{d} \sigma _\mathrm{d} +v_\mathrm{d} \dot{\sigma }_\mathrm{d} )]\cos \varphi _\mathrm{ed}\nonumber \\ \;&= 0 \end{aligned}$$
(14)

In fact, the solution to (13) subject to (14) is to calculate the local extrema of the implicitly defined function of \(\varphi _\mathrm{ed} \) about the time variable \(t\). The detailed derivation is placed in the appendix.

The optimization problem in (12) is strongly nonlinear and thus has many local minima. For this reason, it has to be solved by an algorithm which has the ability of global optimization. In this paper, the optimal solution is obtained by using the PSO algorithm. The PSO algorithm was proposed by Eberhart and Kennedy in [22]. It has been widely used to solve nonlinear optimization problems. Some improvements and applications have also been discussed in [2327]. The PSO algorithm always converges faster and searches better than the gradient descent technique or direct search, which may fall into a local extremum. On the contrary, the PSO algorithm has the ability of global search.

In the PSO algorithm, a candidate solution to the optimization problem is represented by a particle. The PSO uses a population of particles to constitute multiple candidate solutions. The PSO iteratively improves each candidate solution with regard to a given fitness function, by moving the particles around in the search-space over the particle’s position and velocity.

The particle with the optimal fitness value is regarded as the local optimal solution found so far and is called pBest. The best one among all the pBest particles in the search-space is regarded as the global optimal solution and is called gBest. Each particle’s movement is influenced by pBest but is also guided toward gBest. The velocity of a particle is updated by

$$\begin{aligned} V_{iq}^\mathrm{new}&= \omega \cdot V_{iq} ^\mathrm{old}+c_1 \cdot Rand_1 ()\cdot (pBest_{iq} -x_{iq} )\nonumber \\&+c_2 \cdot Rand_2 ()\cdot (gBest_q -x_{iq} ) \end{aligned}$$
(15)

where \(V_{iq}^\mathrm{new} \) denotes the velocity of the \(i\)th particle in the \(q\)th dimension in the next generation; \(V_{iq} ^\mathrm{old}\) denotes the velocity of the \(i\)th particle in the \(q\)th dimension in the current generation; \(pBest_{iq} \) is the current \(pBest\) value of the \(i\)-th particle in the \(q\)th dimension; \(gBest_q \) is the current \(gBest\) value of the whole particle swarm in the \(q\)th dimension; \(x_{iq} \) is the current position of the \(i\)th particle in the \(q\)th dimension; \(\omega \) is the weight; \(c_1 \) is the acceleration of a particle to move to its \(pBest\); \(c_2 \) is the acceleration of a particle to move to the \(gBest\); \(Rand_1 ()\) and \(Rand_2 ()\) are two random numbers between 0 and 1.

The new position of a particle is obtained by

$$\begin{aligned} x_{iq}^\mathrm{new} =x_{iq}^\mathrm{old} +V_{iq}^\mathrm{new} \end{aligned}$$
(16)

We use the PSO algorithm to search the optimal \(\lambda \). The fitness function is defined by \(f(\lambda _{ 0} )=1\big /\big [ 1+\mathop {\max }\limits _{t\in [t_0 ,t_\mathrm{f} ]} \left| {\varphi _\mathrm{ed} (\lambda _{ 0} ,t)} \right| \big ]\) for a given \(\lambda =\lambda _{ 0} \). As a result, a desired motion trajectory with minimized maximum roll angle’s equilibrium is achieved.

4 Controller design

Trajectory tracking control is one of the representative problems of the mobile mechanical platforms, such as unicycle systems, car-like robots, and bicycle robots. Trajectory tracking control of the mobile robots has been investigated for many years and various kinds of methods have been proposed in [2832]. However, trajectory tracking control for the bicycle and motorcycle robots is a new issue in the field of robotics. In this section, we consider the trajectory tracking control for the bicycle robot given in (1) and (2). This problem has to satisfy two specifications. First, the robot has to be balanced such that it will not fall down. Second, the robot must follow \(\Gamma _\mathrm{d} \). To meet these two requirements, the controller is developed in three steps. The first step is to design a balancing controller for roll dynamics. The second step is to design a controller for tracking the desired planar trajectory \(\Gamma _\mathrm{d} \). Finally, we design a controller for tracking with balance by balancing the roll dynamics around its equilibrium manifold, which depends on the tracking controller designed in the second step.

4.1 Controller for balancing roll angle

For roll dynamics in (2), we consider the control input

$$\begin{aligned} \dot{\sigma }^{int}&= \frac{1}{bv\cos \varphi }[h\ddot{\varphi }{ }_\mathrm{d}-k_1 (\dot{\varphi } - \dot{\varphi }_\mathrm{d} )- k_2 (\varphi - \varphi _\mathrm{d} )\nonumber \\&\quad - g\sin \varphi -(1 + h\sigma ^{int}\sin \varphi )v^{2}\sigma ^{int}\nonumber \\&\quad \cos \varphi - b\dot{v}\sigma ^{int}\cos \varphi ] \end{aligned}$$
(17)

where the constants \(k_i\, (i=1,2)\) are chosen such that the polynomial equation \(hs^{2}+k_1 s+k_2 =0\) is Hurwitz. It is apparent that by (17), the roll angle \(\varphi \) exponentially converges to its desired trajectory.

4.2 Controller for tracking desired planar trajectory

If we ignore the roll angle, a tracking controller can be designed for planar motion of the robot. We define the tracking errors with respect to the moving body frame and represent them as seen by an observer riding the vehicle.

$$\begin{aligned} \left[ {{\begin{array}{l} {e_x } \\ {e_y } \\ {e_\theta } \\ \end{array} }} \right] =\left[ {{\begin{array}{lll} {\cos \theta }&{}\quad {\sin \theta }&{}\quad 0 \\ {-\sin \theta }&{}\quad {\cos \theta }&{}\quad 0 \\ 0&{}\quad 0&{}\quad 1 \\ \end{array} }} \right] \cdot \left[ {{\begin{array}{l} {x_\mathrm{d} -x} \\ {y_\mathrm{d} -y} \\ {\theta _\mathrm{d} -\theta } \\ \end{array} }} \right] \end{aligned}$$
(18)

From (18), \(\mathop {\lim }\limits _{t\rightarrow \infty } (e_x ,e_y ,e_\theta )=(0,0,2n\pi )\Leftrightarrow \mathop {\lim }\limits _{t\rightarrow \infty } (x,y,\theta )=(x_\mathrm{d} ,y_\mathrm{d} ,\theta _\mathrm{d} +2n\pi ) \quad n\in \mathbf{Z}\).

For the planar motion of the robot, we give a tracking controller as follows.

Theorem 1

Assume that the desired planar trajectory is given by \(\Gamma _\mathrm{d} (x_\mathrm{d} ,y_\mathrm{d} ,\theta _\mathrm{d} )\), where \(x_\mathrm{d} \) and \(y_\mathrm{d} \) are thrice differentiable, \(v_\mathrm{d} \ne 0, \mathop {\lim }\limits _{t\rightarrow \infty } \sigma _\mathrm{d} \ne 0\), if the control inputs are

$$\begin{aligned} v_\mathrm{pl} ^\mathrm{ext}&= v_\mathrm{d} \nonumber \\ \sigma _\mathrm{pl} ^\mathrm{ext}&= \sigma _\mathrm{d} +\frac{2}{k_4 \cdot v_\mathrm{d} } \nonumber \\&\cdot \left[ 2k_3 \cdot v_\mathrm{d} \cdot \left( e_y \cdot \cos \frac{e_\theta }{2}\!-\!e_x \cdot \sin \frac{e_\theta }{2}\right) \!+\!\sin \frac{e_\theta }{2}\right] \nonumber \\ \end{aligned}$$
(19)

\((x,y,\theta )\) will asymptotically converge to \(\Gamma _\mathrm{d} \), where \(k_3 >0, k_4 >0\).

Proof

From (18),

$$\begin{aligned} \left[ {{\begin{array}{l} {\dot{e}_x } \\ {\dot{e}_y } \\ {\dot{e}_\theta } \\ \end{array} }} \right] =\left[ {{\begin{array}{rl} {-1}&{}\quad {e_y } \\ 0&{}\quad {-e_x } \\ 0&{}\quad {-1} \\ \end{array} }} \right] \cdot \left[ {{\begin{array}{l} {v_\mathrm{pl} ^\mathrm{ext}} \\ {v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}} \\ \end{array} }} \right] +\left[ {{\begin{array}{l} {v_\mathrm{d} \cdot \cos e_\theta } \\ {v_\mathrm{d} \cdot \sin e_\theta } \\ {v_\mathrm{d} \sigma _\mathrm{d} } \\ \end{array} }} \right] \end{aligned}$$
(20)

Choose the Lyapunov function as \(V=\frac{1}{2}k_3 \cdot (e_x ^{2}+e_y ^{2})+k_4 \cdot (1-\cos \frac{e_\theta }{2})\).

Then

$$\begin{aligned} \dot{V}&= k_3 \cdot (e_x \cdot \dot{e}_x +e_y \cdot \dot{e}_y )+\frac{k_4 }{2}\cdot \sin \frac{e_\theta }{2}\cdot \dot{e}_\theta \\&= k_3 \cdot \left[ e_x \cdot \left( e_y v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}-v_\mathrm{pl} ^\mathrm{ext}+v_\mathrm{d} \cdot \cos e_\theta \right) \right. \\&\left. +e_y \cdot \left( -e_x \cdot v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}+v_\mathrm{d} \cdot \sin e_\theta \right) \right] +\frac{k_4 }{2} \\&\cdot \sin \frac{e_\theta }{2}\cdot \left( v_\mathrm{d} \sigma _\mathrm{pl} ^\mathrm{ext}-v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}\right) \\&= k_3 v_\mathrm{d} \cdot \left[ (\cos e_\theta -1)\cdot e_x + e_y \cdot \sin e_\theta \right] \\&+ \frac{k_4 }{2}\left( v_\mathrm{d} \sigma _\mathrm{d} - v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}\right) \cdot \sin \frac{e_\theta }{2} \\&= \left[ 2k_3 v_\mathrm{d} \cdot \left( e_y \cdot \cos \frac{e_\theta }{2}-e_x \cdot \sin \frac{e_\theta }{2}\right) \right. \\&+\left. \frac{k_4 }{2}\left( v_\mathrm{d} \sigma _\mathrm{d} - v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}\right) \right] \cdot \sin \frac{e_\theta }{2} \\&= -\sin ^{2}\frac{e_\theta }{2}\le 0 \\ V&\ge 0,\dot{V}\le 0\Rightarrow V\in L_\infty \Rightarrow e_x ,e_y \in L_\infty \\&\Rightarrow v_\mathrm{pl} ^\mathrm{ext},\sigma _\mathrm{pl} ^\mathrm{ext}\in L_\infty \Rightarrow \dot{e}_x ,\dot{e}_y ,\dot{e}_\theta \in L_\infty \\&\Rightarrow \mathop {\lim }\limits _{t\rightarrow \infty } \sin \frac{e_\theta }{2}=0\Rightarrow \mathop {\lim }\limits _{t\rightarrow \infty } e_\theta =2n\pi ,\;n\in \mathbf{Z}. \end{aligned}$$

In addition,

$$\begin{aligned} \ddot{e}_\theta =&\dot{v}_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}+v_\mathrm{pl} ^\mathrm{ext}\dot{\sigma }_\mathrm{pl} ^\mathrm{ext}-(\dot{v}_\mathrm{d} \sigma { }_\mathrm{d}+v_\mathrm{d} \dot{\sigma }_\mathrm{d} )\\ =&-\frac{4k_3 }{k_4 }\left[ \dot{v}_\mathrm{d} \left( e_y \cdot \cos \frac{e_\theta }{2}-e_x \cdot \sin \frac{e_\theta }{2}\right) \right. \\&+v_\mathrm{d} \left( \dot{e}_y \cos \frac{e_\theta }{2}-\frac{1}{2}e_y \cdot \sin \frac{e_\theta }{2}\cdot \dot{e}_\theta -\dot{e}_x \cdot \sin \frac{e_\theta }{2}\right. \\&\left. \left. -\frac{1}{2}e_x \cdot \cos \frac{e_\theta }{2}\cdot \dot{e}_\theta \right) \right] -\frac{1}{k_4 }\cdot \cos \frac{e_\theta }{2}\cdot \dot{e}_\theta \end{aligned}$$

where \(\dot{v}_\mathrm{d} =\frac{\dot{x}_\mathrm{d} \cdot \ddot{x}_\mathrm{d} +\dot{y}_\mathrm{d} \cdot \ddot{y}_\mathrm{d} }{\sqrt{\dot{x}_\mathrm{d} ^{2}+\dot{y}_\mathrm{d} ^{2}}}\in L_\infty \). Thus, \(\ddot{e}_\theta \in L_\infty \), we know that \(\dot{e}_\theta \) is uniformly continuous. According to Extended Barbalat Lemma, \(\mathop {\lim }\limits _{t\rightarrow \infty } \dot{e}_\theta = \mathop {\lim }\limits _{t\rightarrow \infty } -\frac{2}{k_4 }[2k_3 \cdot v_\mathrm{d} \cdot \quad (e_y \cdot \cos \frac{e_\theta }{2}-e_x \cdot \sin \frac{e_\theta }{2})+\sin \frac{e_\theta }{2}]=\mathop {\lim }\limits _{t\rightarrow \infty } (-\frac{4k_3 }{k_4 }\cdot v_\mathrm{d} \cdot e_y )=0\Rightarrow \mathop {\lim }\limits _{t\rightarrow \infty } e_y =0\). Then, from (19) it is known that \(\mathop {\lim }\limits _{t\rightarrow \infty } \sigma =\sigma _\mathrm{d} \).

From (20),

$$\begin{aligned} \ddot{e}_y&= -\dot{e}_x v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}-e_x (\dot{v}_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}+v_\mathrm{pl} ^\mathrm{ext}\dot{\sigma }_\mathrm{pl} ^\mathrm{ext})\\&+\dot{v}_\mathrm{d} \sin e_\theta +v_\mathrm{d} \cdot \cos e_\theta \cdot \dot{e}_\theta \\ \quad&= -\dot{e}_x v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}-e_x (\dot{v}_\mathrm{d} \sigma _\mathrm{d} \\&+v_\mathrm{d} \dot{\sigma }_\mathrm{d} -\ddot{e}_\theta )+\dot{v}_\mathrm{d} \sin e_\theta +v_\mathrm{d} \cos e_\theta \cdot \dot{e}_\theta \end{aligned}$$

where \(\dot{v}_\mathrm{d} \sigma _\mathrm{d} +v_\mathrm{d} \dot{\sigma }_\mathrm{d} \!=\!\frac{\dddot{y}_{\!\!\mathrm d} \dot{x}_\mathrm{d} -\!\dddot{x}_{\!\!\mathrm d} \dot{y}_\mathrm{d} }{\dot{x}_\mathrm{d} ^{2}+\dot{y}_\mathrm{d} ^{2}}-\frac{2(\ddot{y}_\mathrm{d} \dot{x}_\mathrm{d} -\ddot{x}_\mathrm{d} \dot{y}_\mathrm{d} )(\dot{x}_\mathrm{d} \ddot{x}_\mathrm{d} +\dot{y}_\mathrm{d} \ddot{y}_\mathrm{d} )}{(\dot{x}_\mathrm{d} ^{2}+\dot{y}_\mathrm{d} ^{2})^{2}}\in \! L_\infty \). Thus \(\ddot{e}_y^{} \in L_\infty ,\dot{e}_y \) is uniformly continuous. As a result, \(\mathop {\lim }\limits _{t\rightarrow \infty } \dot{e}_y = \mathop {\lim }\limits _{t\rightarrow \infty } \;(-e_x v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}+ \quad v_\mathrm{d} \sin e_\theta )=\mathop {\lim }\limits _{t\rightarrow \infty } \;(-e_x v_\mathrm{d} \sigma _\mathrm{d} )=0\). From (20), \(\dot{e}_x =e_y v_\mathrm{pl} ^\mathrm{ext}\sigma _\mathrm{pl} ^\mathrm{ext}-v_\mathrm{d} (1-\cos e_\theta )\rightarrow 0\) and \(e_x \in L_\infty \), thus \(\mathop {\lim }\limits _{t\rightarrow \infty } e_x =0\) or \(\mathop {\lim }\limits _{t\rightarrow \infty } \sigma _\mathrm{d} =0\). In the assumption of theorem 1, \(\mathop {\lim }\limits _{t\rightarrow \infty } \sigma _\mathrm{d} \ne 0\), thus \(\mathop {\lim }\limits _{t\rightarrow \infty } e_x =0\) holds. Hence the proposed controller ensures that the planar motion of the system converges to \(\Gamma _\mathrm{d} \) asymptotically, i.e., \(\mathop {\lim }\limits _{t\rightarrow \infty } (x,y,\theta )= \quad (x_\mathrm{d} ,y_\mathrm{d} ,\theta _\mathrm{d} )\).\(\square \)

Remark 1

If \(\mathop {\lim }\limits _{t\rightarrow \infty } \sigma _\mathrm{d} =0\), \(\Gamma _\mathrm{d} \) will tend to a straight line. In the proof of theorem 1, we have obtained that \(\mathop {\lim }\limits _{t\rightarrow \infty } e_y =0\) and \(\mathop {\lim }\limits _{t\rightarrow \infty } e_\theta =0\). Therefore, we can deduce that \(-\sin \theta _\mathrm{d} \cdot (x_\mathrm{d} -x)+\cos \theta _\mathrm{d} \cdot (y_\mathrm{d} -y)=0\), i.e., \((x,y)\) lies on the desired straight line. In other words, when \(\mathop {\lim }\limits _{t\rightarrow \infty } e_y =0\) and \(\mathop {\lim }\limits _{t\rightarrow \infty } e_\theta =0\), the system converges to the desired straight line.

Remark 2

In the controller (19), the linear velocity of the system is chosen as the desired one, i.e., \(v_\mathrm{pl} ^\mathrm{ext}=v_\mathrm{d} \), thus it can drive the bicycle robot to track the desired trajectory in an identical direction all the time, and the backward behaviors can be avoided.

4.3 Controller for tracking with balance

Unlike the systems with stable internal dynamics, the nonminimum phase systems with given initial conditions cannot be made to exactly track arbitrary elements of an open set of the output desired trajectory while maintaining bounded internal dynamics. Instead, we will design a controller for approximate tracking of the desired trajectory while maintaining the balance of the robot.

To achieve tracking the desired planar trajectory, the real external control input \({{\varvec{u}}}^\mathrm{ext}=(\dot{v}^\mathrm{ext},\dot{\sigma }^\mathrm{ext})^{T}\) is designed as

$$\begin{aligned} \left\{ {{\begin{array}{l} {\dot{v}^\mathrm{ext}=\dot{v}_\mathrm{pl} ^\mathrm{ext}-k_5 (v^\mathrm{ext}-v_\mathrm{pl} ^\mathrm{ext})\;\;\; } \\ {\dot{\sigma }^\mathrm{ext}=\dot{\sigma }_\mathrm{pl} ^\mathrm{ext}-k_6 (\sigma ^\mathrm{ext}-\sigma _\mathrm{pl} ^\mathrm{ext})} \\ \end{array} }} \right. \end{aligned}$$
(21)

where \(k_5 \) and \(k_6 \) are positive constants.

Then, we compute the roll angle’s equilibrium compatible with \(v^\mathrm{ext}\) and \(\sigma ^\mathrm{ext}\) by submitting them into (3). The external vector field corresponding to \(v^\mathrm{ext}\) and \(\sigma ^\mathrm{ext}\) is

$$\begin{aligned} VF^\mathrm{ext}=\left[ {{\begin{array}{l} {v^\mathrm{ext}\cdot \cos \theta } \\ {v^\mathrm{ext}\cdot \sin \theta } \\ {v^\mathrm{ext}\cdot \sigma ^\mathrm{ext}} \\ \end{array} }} \right] \end{aligned}$$
(22)

For the robot balance system, we control the roll angle around its equilibrium manifold \(\varepsilon (t)\) while the planar motion of the robot tracks \(\Gamma _\mathrm{d} \). Thus we approximate the derivatives \(\dot{\varphi }_e \) and \(\ddot{\varphi }_e\) by using directional derivative along the vector field \(VF^\mathrm{ext}\). We introduce the Lie derivative as \(\bar{{L}}_{VF^\mathrm{ext}} \varphi _e = \quad L_{VF^\mathrm{ext}} \varphi _e +{\partial \varphi _e }/{\partial t}\) and \(\bar{{L}}^{2}_{VF^\mathrm{ext}} \varphi _e =\bar{{L}}_{VF^\mathrm{ext}} \bar{{L}}_{VF^\mathrm{ext}} \varphi _e \). If \(\varphi \) is close to \(\varphi _e \) and \((x,y,\theta )\) is approximately tracking its desired trajectory \((x_\mathrm{d} ,y_\mathrm{d} ,\theta _\mathrm{d} )\), then \(\bar{{L}}_{VF^\mathrm{ext}} \varphi _e \) and \(\bar{{L}}^{2}_{VF^\mathrm{ext}} \varphi _e\) will be close to \(\dot{\varphi }_e \) and \(\ddot{\varphi }_e\), respectively [4]. We now give a control input

$$\begin{aligned} \dot{\sigma }_e ^{int}&= \frac{1}{bv^\mathrm{ext}\cos \varphi }\left[ h\bar{{L}}^{ 2}_{VF^\mathrm{ext}} \varphi _e -k_1 \left( \dot{\varphi }-\bar{{L}}_{VF^\mathrm{ext}} \varphi _e \right) \right. \nonumber \\&-\,k_2 (\varphi -\varphi _e )-g\cdot \sin \varphi -\left( 1+h\sigma _e ^{int}\sin \varphi \right) \nonumber \\&\times \left. v^{\mathrm{ext}^2}\sigma _e^{int}\cos \varphi -b\dot{v}^\mathrm{ext}\sigma _e^{int}\cos \varphi \right] \end{aligned}$$
(23)

The final controller \({{\varvec{u}}}=(u_1 ,u_2 )^{T}=(\dot{v},\dot{\sigma })^{T}\)is achieved by combining \(\dot{v}^\mathrm{ext}\) in (21) and \(\dot{\sigma }_e ^{int}\) in (23) as

$$\begin{aligned} \left\{ {{\begin{array}{l} {\dot{v}=\dot{v}^\mathrm{ext}\; } \\ {\dot{\sigma }=\dot{\sigma }_e ^{int}} \\ \end{array} }} \right. \end{aligned}$$
(24)

Thus, for initial values of \(\varphi \) and \(\dot{\varphi }\) sufficiently close to \(\varphi _e \) and \(\bar{{L}}_{VF^\mathrm{ext}} \varphi _e \), the system state \((x,y,\theta ,\varphi )\) converges to an arbitrarily small neighborhood of \((x_\mathrm{d} ,y_\mathrm{d} ,\theta _\mathrm{d} ,\varphi _e )\) under the controller of (24).

5 Simulations

In the simulations, the parameters of the bicycle robot are \(h=1.0\,\mathrm{m}, p=1.0\,\mathrm{m}, b=0.5\,\mathrm{m}, m=20\,\mathrm{kg}\), and \(g=9.8\). The initial pose of the bicycle is \([x_0 ,y_0 ,\theta _0 ]^{T}=[0,0,0]^{T}, \varphi _0 =0, \dot{\varphi }_0 =0\). The control parameters are \(k_1 =1.5, k_2 =1.0, k_3 =1.5, k_4 =1.5, k_5 =5.0\), and \(k_6 =5.0\). The parameters of the PSO algorithm are \(\omega =1, c_1 =2\), and \(c_2 =2\).

Figure 2 shows a simulation result of trajectory planning, in which the desired final pose is \([x_\mathrm{f} ,y_\mathrm{f} ,\theta _\mathrm{f} ]^{T}=[10,10,0]^{T}\). We set the final time to be \(t_\mathrm{f} =5\,\mathrm{s}\). T1, T2, and T3 denote, respectively, three trajectories under different parameters, as shown in Table 1. T1 is the planned trajectory using the proposed method, where \(\lambda =[0.98,4.19]^{T}\) is determined by the PSO algorithm. T2 and T3 denote the trajectories whose parameters \(\lambda \) are given as \([10.0,10.0]^{T}\) and \([1.0,1.0]^{T}\), respectively. From this simulation, it can be seen that we can retain the balance of the bicycle around T1 more easily and reliably, since it has a smaller maximum of the desired roll angle.

Fig. 2
figure 2

Simulation result of trajectory planning for \([x_\mathrm{f} ,y_\mathrm{f} ,\theta _\mathrm{f} ]^{T}=[10,10,0]^{T}\)

Table 1 Simulation comparison with different parameters

Then, the trajectory tracking control is implemented, where T1 is chosen as the desired trajectory. The simulation result is shown in Fig. 3. Figure 3a shows the desired trajectory T1, as well as the resulting trajectory in the plane. Figure 3b shows the control inputs. Figure 3c shows the tracking errors of the system.

Fig. 3
figure 3

Simulation result of trajectory tracking control. a Motion trajectory of the bicycle. b Control inputs. c Errors of the system states

Figure 4 shows another simulation result of trajectory planning, in which the desired final pose is \([x_\mathrm{f} ,y_\mathrm{f} ,\theta _\mathrm{f} ]^{T}=[0,30,\pi ]^{T}\). The final time is \(t_\mathrm{f} =10s\). T4 denotes the planned trajectory using the proposed method, and T5 is a circular trajectory that connects the initial pose with the final pose. Table 2 shows the parameters of the two trajectories in detail. The curvature of T5 is a constant; thus, the robot can track T5 with a constant linear velocity, and the desired equilibrium of the roll angle is also a constant, that is \(\varphi _\mathrm{ed} =-0.15\). From this simulation, it can be seen that the maximum roll angle’s equilibrium of T4 is a bit larger than that of the circular trajectory T5, because the robot needs to make a bit sharper turn at the initial and final stages when it moves along T4. However, T4 is much shorter than T5, such that energy can be saved when the robot tracks T4. Figure 5 shows the simulation result of the trajectory tracking control, where T4 is chosen as the desired trajectory.

Fig. 4
figure 4

Simulation result of trajectory planning for \([x_\mathrm{f} ,y_\mathrm{f} ,\theta _\mathrm{f} ]^{T}=[0,30,\pi ]^{T}\)

Fig. 5
figure 5

Simulation result of trajectory tracking control. a Motion trajectory of the bicycle. b Control inputs. c Errors of the system states

Table 2 Simulation comparison between two different trajectories

6 Conclusions

In this paper, trajectory planning and tracking control have been solved comprehensively for a nonlinear, nonholonomic, and nonminimum phase bicycle robot. The planar motion trajectory of the system has been designed as a parameterized polynomial curve. The parameters of the polynomial curve have been calculated by the PSO algorithm to achieve an optimal desired trajectory, of which the maximum of the roll angle is minimal. A trajectory tracking controller has been designed for approximate tracking of desired trajectory while maintaining balance of the bicycle. The proposed method can generate a motion trajectory with superior performances, such as small roll angle and short path length. In addition, the designed controller can provide good tracking behaviors with good balance for tracking the planned trajectory. As a result, the moving performance of the bicycle robot is improved by the combination of the proposed trajectory planner and tracking controller.