Since the aim of this work is to test the roll angle estimation in different conditions and scenarios, the motorcycle model has to be able to perform in a wide variety of circumstances. To achieve that, several controllers were implemented. First, longitudinal control manages accelerating and braking phases. Secondly, lateral control guarantees the lateral dynamic equilibrium while following the specified trajectories. The longitudinal controller has to be able to keep the velocity, which allows the lateral controller to perform the desired maneuver.
Lastly, a torso controller is used to perform maneuvers with a lean relative angle between torso and motorcycle, inside and outside the turns, as an option.
2.3.1. Path Tracking
In order to follow a predetermined path, it is necessary to use a curve definition system that can encode the trajectory that the motorcycle has to follow. In this work, splines are employed. Each scenario has a finite number of splines. They are drawn using the Blender software (Blender Foundation, Amsterdam, The Netherlands), and then their parameters are exported to a text file to be read by the simulation program.
Then, a point referred to the chassis frame is defined, and its position is compared to the path previously defined. This point is not necessarily coincident with the chassis. In this work, it is ahead of the chassis position to evaluate the deviation with respect to the trajectory in advance, as a human driver would do. This reference point position is speed-dependent: the faster the motorcycle goes, the farther and higher the point is found, as shown in Equations (
2) and (
3), where
and
stand for chassis velocity components, and
and
are the coordinates of the reference point expressed in the local reference system of the chassis (in SI units). In this work, the position of this reference point has an important effect on the overall behavior of the controller.
The constants were adjusted by trial and error. The height of the reference point is also variable with speed. This height is relevant in tilting vehicles, since it produces a lateral displacement of the reference point when the vehicle is tilted. Once this point is defined, it is necessary to calculate the distance between the point and the nearest spline of the track. In this work, we calculate the distance to the spline perpendicular to the longitudinal axis of the motorcycle model.
With this information, the position, velocity, and orientation errors can be calculated, in order to correct the motorcycle position with respect to the desired path. These error values are the data that the lateral controller needs to calculate the roll angle target required to correct the motorcycle trajectory respect to the desired path. This will be addressed in
Section 2.3.3.
2.3.2. Longitudinal Controller
This controller manages the acceleration and braking phases. The longitudinal control is designed to perform the maneuver as fast as possible, taking into account the curvature of the trajectory and the power limits of the motorcycle. The controller evaluates the path ahead the motorcycle 10 s in advance with respect to the reference point described on the previous section, and thus there is enough time to start braking before arriving too fast at a turn. This value is translated into a distance variable by means the Equation (
4), which means the position in advance is calculated taking into account the current speed of the motorcycle.
Once the position in the spline is known, the maximum speed is obtained in relation to the curvature of the path (
), by means of the steady-state cornering equilibrium equation [
19], expressed in Equation (
5), where
stands for the maximum roll angle the motorcycle can achieve, which is a configuration parameter for the controller.
The value of
cannot achieve infinite values and is limited to a max value, which is a configuration parameter. Once known, the current speed is evaluated against it, and the controller will accelerate if the current speed value is lower than
, or will brake if the motorcycle speed is too high. Both of the actions are managed by proportional controllers, as shown in Equations (
6) and (
7).
When accelerating, the value of is translated into a rear wheel torque, taking into account tabulated torque values and the wheel angular rate. When braking, the value of is transformed into brake torque in both wheels, but with different values, since the brake power capabilities are different, as mentioned before.
2.3.3. Lateral Controller
In order to obtain full stability during maneuvers, a lateral controller was implemented. For this purpose, a Linear Quadratic Regulator (LQR) controller [
20] was used, and a good behavior was achieved. Since the LQR controller requires a dynamic model in state-space form, the motorcycle multibody model was adapted into a Whipple model, and thus the initial seven-solid model is transformed into a four-solid model, as described in [
21]. Model adaptation is shown in
Figure 3. From the Whipple model, only the lateral dynamics are used.
Linearized dynamic equations of the model are expressed by Equation (
8), where
,
,
and
are obtained from a set of 25 parameters of the motorcycle (see
Table 2),
is a vector that contains roll (
) and steer (
) angles,
is a vector that contains roll and steer torques (the roll torque is considered to be null in this work), and
g and
v stand for gravity acceleration and forward velocity, respectively. The employed values are shown in
Table 2.
Equation (
8) can be expressed in state-space form as shown in Equations (
9) and (
10), where
u is the input vector,
is the state vector and
y is the system output.
As Equation (
8) is second order with respect to time and Equation (
9) is first order, some changes are necessary. Taking
,
and its derivative as
, Equation (
11) is obtained.
Once the parameters of
Table 2 are calculated,
,
,
and
can be obtained. The following values are the ones employed on this work.
To ensure system stability, state feedback is used, defining the system input as a negative feedback of the state, as in Equation (
14), finding a
matrix that stabilizes the system.
Stabilization is achieved if the real parts of all eigenvalues of the system matrix are negative. Thus, Equation (
9) can be combined with Equation (
14), obtaining:
Now, system stability is determined by the eigenvalues of
, and thus a
matrix can be calculated with the values that ensure stability, since
and
are constants. In LQR controllers, the value of
is the one that minimizes the following cost function:
The function combines the quadratic values, integrated over time, of the magnitudes that should be minimized: the states and the control inputs. Each of them is weighted by a term, for the states and R for the input. The values of this terms can be adjusted in order to assign more weight to the control effort (increasing R value), or penalizing more the state errors by increasing the values of .
The trajectory of the motorcycle can be controlled through its roll angle
, and thus we need to set it to a certain value at every time step. However, the LQR controller defined thus far is only a regulator, i.e., it drives the states to zero. Since the resulting system is of type 0 [
20], we need to transform it into a type 1 system, in order to make it capable to track a reference value of the roll angle. This can be achieved by adding an integrator at the input. Therefore, the system size increases, as a new state is added,
, which is the integral of the tracking error, which means the integral of the difference between the controller target (
r) and its output (
). The input
u changes its value to:
and the value of
should be calculated during the runtime as shown in Equation (
18), where
is the simulation time step.
Hence, the system turns into Equation (
19):
where
is the augmented state vector, and
is its derivative:
We can now define
. Therefore, we can rewrite Equation (
17) as follows:
The values of
and R used in this work for Equation (
16) are:
These values were adjusted by trial and error to obtain a realistic behavior.
The
values obtained for a 20 m/s forward velocity can be seen in Equation (
23). It was not necessary to calculate
values for different velocities, as could be expected, since the controller works fine with the values obtained for the forementioned velocity for all the speed range used in this work.
Now, the controller target, which represents the control input (
u), should be assigned. Hence, some terms are calculated, such as position (
), velocity (
), and angular errors (
) between the motorcycle position and the spline curve:
where
stands for the yaw motorcycle angle,
and
are the spline coordinates,
and
are the reference point coordinates mentioned in Equations (
2) and (
3),
is the spline normal vector,
is the reference point velocity, and
is the angle of the spline tangent vector. With these values,
Finally, the roll target expression is obtained:
The steer torque expression becomes:
The second term in Equation (
31) acts as a steer damper, in order to minimize all the small instabilities coming from different sources (contact forces, tire forces, controller, etc.), achieving a better performance without becoming slow on response. The variable
refers to the steer velocity, while
is a damping coefficient, which, in our case, takes a value of 10 Ns/rad.
2.3.4. Torso Controller
Torso roll movement has a capital influence on the motorcycle dynamics, since it changes the center of mass of the vehicle. If the torso goes inside a turn, the motorcycle lean angle can be reduced, whereas going outside instead forces the motorcycle to increase its roll angle to tackle the same turn at the same speed. In order to analyze this effect in the estimator, a torso controller was implemented. The controller allows to configure three different positions as seen in
Figure 4: inside position, neutral position, and outside position.
In the neutral position, the torso has no influence in the maneuver, since it stays aligned with the motorcycle. On the other hand, the inside and outside positions modify the relative angle between the torso and the motorcycle, changing the center of mass position. The input angle for the controller is defined by Equation (
32).
where
is the vehicle roll angle,
F is a factor that can take three values: 0 for a neutral position, 1 for an inside position, and −1 for an outside position. The
was used in this work, but other values could be used if more or less rider lean is desired. Once obtained, a PD controller can be defined as:
Proportional (K) and derivative (C) term values used in this work are 1.5 × 10 and 1 × 10.