• No results found

DEVELOPMENT OF A ROBUST CASCADE CONTROLLER FOR A RIDERLESS BICYCLE

N/A
N/A
Protected

Academic year: 2021

Share "DEVELOPMENT OF A ROBUST CASCADE CONTROLLER FOR A RIDERLESS BICYCLE"

Copied!
78
0
0

Loading.... (view fulltext now)

Full text

(1)

aster˚

as, Sweden

Thesis for the degree of Master of Science in Engineering - Robotics,

30.0 credits

DEVELOPMENT OF A ROBUST

CASCADE CONTROLLER FOR

A RIDERLESS BICYCLE

Tom Andersson

tan13005@student.mdh.se

Niklas Persson

npn13003@student.mdh.se

Examiner: Alessandro Papadopoulos

alardalen University, V¨

aster˚

as, Sweden

Supervisors: Anas Fattouh

alardalen University, V¨

aster˚

as, Sweden

Martin Ekstr¨

om

alardalen University, V¨

aster˚

as, Sweden

(2)

Abstract

A controlled riderless bicycle is desired for the purpose of testing autonomous vehicles ability to detect and recognise cyclists. The bicycle, which is a highly unstable system with complex dynamics have been subject to research for over a century, and in the last decades, controllers have been developed for autonomous bicycles. The controllers are often only evaluated in simulation, but some complex controllers have been developed on real-life bicycles as well. The goal of this work is to validate sensors and subsystems of an instrumented bicycle and to develop a robust controller which can balance a bicycle by using actuation on the steering axis alone. Using an iterative design process, the sensor measuring the lean angle and the steering system are improved and validated. By sensing the lean angle, the handlebar is manipulated to make the bicycle stable. For this purpose, a P, PD, two different PID, an LQR and a fuzzy controller are developed, evaluated and compared. The results show that the bicycle can ride without human interaction on a bicycle roller in different velocities. Additionally, numerous experiments are conducted in an outdoor environment in several different terrains, where the proposed control structure manages to balance and steer the bicycle.

(3)

Acknowledgements

We would like to thank our supervisors for pointing us in the right direction whenever we were lost, and for believing in us.

For his enthusiasm and for documenting the work with pictures and videos, we would like to thank Henrik Falk.

A big thank you to Hans Eriksson for his time and enthusiasm during some of the experiments conducted in the work.

Our gratitude also goes out to our examiner, Alessandro Papadopoulos for the valuable feedback provided in the end of the thesis work.

Additionally, we would like to thank the students with which we have shared the robotics labora-tory during this work. A special thank you to Ulrik ˚Akesson for all the endless discussion regarding the tiniest, and sometimes irrelevant, details.

Lastly, we would like to thank Vinnova for funding the research project, of which this thesis is a part of.

(4)

Abbreviations

AHRS Attitude and Heading Reference System. 5, 16–18 AI Artificial Intelligence. 11

CAD Computer-Aided Design. 11, 20 CoG Center of Gravity. 20, 26 DC Direct Current. 5, 6, 18 DIO Digital Input and Output. 36 EKF Extended Kalman Filter. 16, 18

FIS Fuzzy Inference System. 3, 11, 12, 32–34, 62 FOG Fiber Optic Gyroscope. 5

FPGA Field Programmable Gate Array. 15, 23, 25, 35, 65 GA Genetic Algorithm. 3, 12, 13

GPI Generalised Proportional Integral. 13 IAE Integrated Absolute Error. 4

IMU Inertial Measurement Unit. 5, 16, 18, 19, 29, 39, 40, 65 ISE Integrated Squared Error. 4, 17, 40, 51, 55, 62

LQR Linear Quadratic Regulator. 3, 4, 12, 31, 41, 51, 53, 62, 63, 65 LS Loop Shaping. 30, 41, 62, 63

MCU Micro Control Unit. 22 MDH M¨alardalens University. 1, 7

MEMS Micro-Electro-Mechanical System. 5 P Proportional. 29, 30, 39–41, 51, 62, 65

PD Proportional-Derivative. 2, 3, 11–13, 29, 30, 39–41, 48, 51, 52, 62, 63, 65 PI Proportional-Integral. 3, 14, 22, 23, 27

PID Proportional–Integral–Derivative. 2–4, 6, 11, 12, 23–25, 28–31, 39–41, 51, 52, 56, 57, 62–65 PSO Particle Swarm Optimisation. 12, 13

PWM Pulse Width Modulation. 22, 25, 38, 46, 61 RMSE Root Mean Square Error. 4, 17, 40, 51, 55, 62 UART Universal Asynchronous Receiver/Transmitter. 21 USB Universal Serial Bus. 36, 39, 41

(5)

Table of contents

1 Introduction 1 2 Background 2 2.1 Control theory . . . 2 2.2 Orientation sensors . . . 5 2.3 DC motor . . . 5 2.4 Related work . . . 6 3 Problem formulation 14 3.1 Hypothesis . . . 14 3.2 Research questions . . . 14 3.3 Limitations . . . 15 4 Method 16 4.1 Evaluation . . . 17 5 Hardware 18 5.1 Modifications . . . 18 6 Implementation 20 6.1 Forward speed range . . . 20

6.2 Lean angle sensor . . . 21

6.3 Steering control . . . 22 6.4 Simulation models . . . 25 6.5 Balancing controller . . . 28 6.6 Remote commands . . . 34 6.7 Software . . . 34 7 Experimental setups 36 7.1 Lean angle sensor . . . 36

7.2 Torque experiment . . . 38

7.3 Steering system . . . 38

7.4 Simulation . . . 39

7.5 Balancing controller . . . 39

8 Results 43 8.1 Whipple model analysis . . . 43

8.2 Lean angle experiments . . . 44

8.3 Steering system experiments . . . 46

8.4 Controller simulation . . . 49

8.5 Bicycle stability experiments . . . 50

8.6 Outdoor environment . . . 56 9 Conclusion 61 9.1 Whipple analysis . . . 61 9.2 Lean angle . . . 61 9.3 Torque experiment . . . 61 9.4 Steering system . . . 61 9.5 Simulation . . . 62 9.6 Bicycle stability . . . 62

9.7 Comparison of balance controllers . . . 62

9.8 Disturbance rejection . . . 63

9.9 Outdoor experiment . . . 63

9.10 Summary . . . 64

(6)

10 Discussion 65

(7)

1

Introduction

A bicycle is a very well-known and popular means of transportation. The bicycle is often configured to have two inline wheels which make the system inherently unstable and difficult to control. This requires whoever is riding the bicycle to have a bit of training to achieve balance. The bicycle dynamics and how to control a bicycle without any human rider, has been a subject for research for over a century as mentioned by Schwab and Mejiard [1]. A bicycles ability to stabilise is based on the simple notion, that the rider steers into the fall. The stabilisation of a freely coasting bicycle is according to Kooijman et al. dependent on the four features trail, gyroscopic torque, mass distribution, and forward velocity [2]. The challenges with developing riderless bicycles are not only the fact that it is problematic to develop a stabilising controller. The noise present in the system, as well as the sensors specifications also needs to be taken into consideration.

This master thesis is part of an ongoing research project between M¨alardalen University, Chalmers, Volvo, Cycleurope and AstaZero where the ultimate goal is to develop an autonomous bicycle which imitates a bicycle with a cyclist [3]. The bicycle should be able to balance, navigate and behave just like a real cyclist, and in the end, resemble a real bicycle when it comes to its radar cross section [4]. These attributes are important since the autonomous bicycle, developed in the collaboration, is to be recognised and classified by other autonomous vehicles on test tracks. The detection and recognition of bicycles is currently a problem for autonomous vehicles as discussed by Fairley [5]. EuroNCAP, which is a car safety performance assessment program, is currently testing autonomous vehicles bicycle detection with a bicycle mounted on a moving platform which is only moving in a straight direction [6]. A stabilised riderless bicycle which can manoeuvre realistically would resemble a cyclist to a larger extent compared to a bicycle on a moving platform. If the weight of the bicycle is small, the damage caused in a collision with another autonomous vehicle is reduced.

Prior to this thesis, an instrumented bicycle was developed at M¨alardalens University (MDH) in project AutoBike, it is equipped with sensors that measure the forward speed, lean angle and steering angle of the bicycle [7, 8]. The bicycle is based on a regular male sized electrical bicycle from Crescent [9]. As the main processing unit, National Instruments roboRIO was adopted [10]. In case of hardware faults, the developed bicycle should be composed of parts which are relatively low-cost and easy to replace. The instrumented bicycle developed in the project AutoBike was able to maintain a constant forward speed but was not able to stabilise. Therefore, one of the main goals of this thesis is to develop a control strategy to stabilise the instrumented bicycle at constant velocities. To achieve this, the sensors on instrumented bicycle need to be calibrated and the accuracy of the outputs need to be evaluated. In addition, a control algorithm needs to be developed and implemented in simulation and tested in real-life experiments.

The remaining of this report is structured as follows. Section 2, gives a background of the bicycle and its dynamics, with a focus on riderless bicycles and how control has been accomplished in the past. Additionally, background regarding control theory and orientation sensors are included as well. Next, the problem statement is addressed in section 3 along with research questions, a hypothesis, and the limitations of the thesis. The method is explained in section 4, where the evaluation process is presented as well. Thereafter comes section 5 that presents the bicycle and the hardware attached to it, as well as the modifications that are made during the thesis. In section 6 the implementations are covered. Section 7 and 8 includes the experimental setups and the results obtained from the experiments. The conclusions from the results are drawn in section 9 and the thesis is wrapped up in section 10 with discussion and future work.

(8)

2

Background

One of the earliest examples of a bicycle-like vehicle is the Velocipede in 1860 that featured active steering with pedal power front wheel drive. Since 1890, the bicycle design has not undergone any major changes to the present day as noted by Meijaard et al. [11]. Creating a mathematical model which represents a bicycle and its complex dynamics have been subject to research for more than 100 years. The Whipple model, developed by Francis John Welsh Whipple in 1899, is the first analytic model that in a correct way describes the dynamics of a bicycle [12]. McRuer and Krendel, in 1959, theorised the use of a closed loop method to control a dynamic system instead of a human operator [13]. But it was not until 1969 when a study conducted by Van Lunteren and Strassen showed a rider control of a bicycle in a self-made simulator [14]. A controller, equivalent to a time-delayed Proportional-Derivative (PD) controller, was developed to simulate the rider.

A human usually uses a combination of forward velocity, steer and lean regulation to balance and control a bicycle. When developing a controller for a riderless bicycle, there are, according to Huang et al., three common control methods to stabilise the bicycle [15]. All three methods are usually combined with an additional controller which regulates the velocity. The first alternative is to use only regulation of the steering torque as an output from the controller to balance the bicycle. Moore et al. has shown that when a human is riding a bicycle, the steering output is the primary input for balancing the bicycle [16]. The second method is to use the lean torque to keep the bicycle in an upright position. As a third method, a combination of the two former methods can be used, with actuation on both the steering torque and the lean torque as shown by Garcia et al. [17]. To control the lean angle through a direct actuator, the bicycle is often equipped with either a quite large flywheel or some sort of inverted pendulum mechanism. Both methods will alter the appearance of the bicycle a lot, and in extension its radar cross-section. The bicycle platform used in this thesis only have actuators on the rear wheel and the steering axis, and the goal of the research project is to developed a system which mimics a bicycle with a cyclist. Based on these restrictions, this thesis will focus on balancing a riderless bicycle using the first alternative, with actuation of the steering axis and the rear wheel.

The equations found in the dynamic bicycle model by Whipple were used to derive a set of linearised equations in the work by Meijaard et al. [11]. These equations have been used in many implementations regarding control of a riderless bicycle, such as in the work by Baquero-Suarez et al. and Shafiekhani et al. [18, 19]. A less complex dynamic model of a bicycle is the point mass model, as described by Liembeer and Sharp [20], where a set of assumptions allows the bicycle to be modelled as an inverted pendulum, with its mass as a point mass. More complex models have been derived as well, for example, the non-linear model presented by Hatano et al. [21].

To balance a riderless bicycle some sort of controller needs to be implemented on the bicycle. There are numerous different control alternatives as stated in the upcoming control theory section. The control theory section is followed by a section regarding different alternatives for obtaining the orientation of the bicycle. Next, some background on DC-motors are presented and the section is wrapped up with related work in the field of riderless bicycles and bicycle dynamics.

2.1

Control theory

A controller can be used to stabilise and control an unstable system, and to control a stable system. One of the most common controllers is the Proportional–Integral–Derivative (PID) controller which is used widely in both industry and in academia. In this section, the PID controller is introduced but also the concept of intelligent controllers, optimal controllers, adaptive controllers as well as robust controllers are presented. Some performance measurements for evaluating controllers are introduced as well.

PID

PID controllers have been used in various applications throughout history, and are often utilised to control both unstable and stable systems. The controller is continuously fed with an error between the reference value and current value and makes a correction based on proportional, integral, and derivative terms. Equation 1 is a parallel representation of the PID regulator.

(9)

u(t) = Kpe(t) + Ki Z t 0 e(τ )dτ + Kd de(t) dt , (1) where, e(t) = xref− x. (2)

The Kp, Ki, and Kd, is the respective controller gains for the proportional, integral, and derivative terms. By omitting the integral or the derivative term a PD or a Proportional-Integral (PI) controller is obtained. Putting two or more PIDs in a cascade structure can solve more demanding tasks according to Visioli and Piazzi [22].

Intelligent controller

As Passino mentions, the inspiration for intelligent controllers is often gathered from nature or human behaviour [23]. Such as the fuzzy control which is based on a humans expertise knowledge of a given task, or the Genetic Algorithm (GA), which is inspired by the natural selection. The field of intelligent controller is vast and can be used in numerous applications according to Passino, such as a fuzzy controller for ship steering.

Fuzzy logic controller or Fuzzy Inference System (FIS) is a classification method based on a human knowledgeable base and linguistic terms. The crisp input control variable is disassembled and analysed and then put together forming a crisp output according to the flow diagram in Figure 1. The crisp input is fuzzified using one or several input membership functions. Using the fuzzy membership function a membership degree is obtained to determine the firing strength of the linguistic rules. The rules fired is then translated or defuzzified using an output fuzzy membership function generating a crisp output variable [24–27].

Fuzzification Inference Defuzzification Rules

Input Output

Figure 1: A flow diagram where one or several crisp inputs are fuzzified and interpreted by an inference engine in combination of a rule base. The fired rules are defuzzified resulting in a crisp output.

Optimal controller

An optimal controller uses a cost function to optimise its state feedback for a given model [28]. One type of optimal controller is a Linear Quadratic Regulator (LQR) and as the name suggests, it is a linear control strategy which uses a quadratic cost function to stabilise a system. The LQR is set to minimise the cost function given in eq. 3 as explained in the work by Kumar et al [29]. Where the Q matrix defines the weights on the states and R defines the weights on the inputs.

J (u) = Z inf

0

(xTQx + uTRu)dt (3)

the feedback control law that minimises the value of the cost is

u = −Kx (4)

(10)

and the K is computed as

K = R−1(BTP(t)). (5)

Where P is obtained by solving the continuous time Riccati differential equation:

− ˙P(t) = ATP(t) + P(t)A − (P(t)B)R−1(BTP(t)) + Q. (6)

The matrices A and B, the state vector x, and the input u is given by the state space model of the system. A common starting point for choosing the Q and R matrices is by Bryson’s Rule [30], illustrated in eq. 7. Qii= 1 Maximum value of x2 i and Rii= 1 Maximum value of u2 i (7)

A drawback of the LQR is that non-linear systems need to be linearised before LQR can be applied. Besides, the computational time for computing the Riccati equation is proportional to the cube of the state dimension. Which implies that the minimised cost function becomes computational heavy when the system degrees increases [31].

Adaptive controller

If parameters of a dynamic system vary unpredictably over time, or if some parameters are un-known, adaptive control can be used to maintain a desired level of control as mentioned by Brogliato et al. [32]. Adaptive control constitutes techniques which allow for altering of control variables in real-time. Based on the changing conditions, the controller gains are updated online, and the controller adapts to the changes. For example, gain scheduling of a PID controller is an adaptive controller, where the gains of the PID is determined based on one or more scheduling variables. Adaptive controllers can be further divided into direct and indirect methods, where estimated parameters using the direct methods are utilised directly in the adaptive controller [33]. In the indirect methods, the estimated parameters are used to calculate the control parameters instead.

Robust controller

Since many systems, including bicycles, are simplified when modelled, there are some uncertainties present. A robust controller is specially designed to tune a system to have the desired behaviour, even with some uncertainties in the models [34]. Additionally, a controller which is robust should be able to reject disturbances to a certain degree. A robust controller differs from an adaptive controller in the sense that a robust controller is designed to work on variables that are unknown, but within a certain range. When designing a robust controller, there is typically a tradeoff between performance such as the response time of the controller and the robustness.

Evaluation of controllers

To evaluate the performance of different controllers for a given task there are numbers of different measurements that can be utilised. For example, the step response, overshoot and steady state error of the controller can be used for evaluation. Other performance measurements are the Root Mean Square Error (RMSE), Integrated Absolute Error (IAE), and Integrated Squared Error (ISE) as mentioned in the work by Halbaoui et al. [35]. The respective equations are given in eq. 8 - 10 where e is the error between the set point and the process variable. The ISE penalises larger errors more than smaller errors, and as stated by Halboaui et al. it is related to the energy of the error. The RMSE represents the performance of the controller and can be used to compare data sets with a varying number of samples. IAE reflects the cumulative absolute error.

(11)

RM SE = lim t→inf s 1 t Z t 0 e(τ )2 (8) IAE = Z t 0 |e(τ )|dτ (9) ISE = Z t 0 e(τ )2dτ (10)

2.2

Orientation sensors

There are several ways to calculate the angle between an object and its environment such as angle sensors, potentiometer, and rotary encoders. These types of sensors need to be attached to a movable object and a fixed reference point. Therefore, these types of sensor are not feasible to use for measuring the angle between a movable object and a static environment. Gyroscope, accelerometer, and magnetometer sensors use effects such as rotation, acceleration, and magnetism to extract its data, which makes them a good choice when measuring the lean angle of a bicycle.

Micro-Electro-Mechanical System (MEMS) gyroscopes senses rotations based on vibrations, it uses Coriolis acceleration to determine the energy between different vibrating states as mentioned by Dudek and Jenkin [36]. Additionally, the Fiber Optic Gyroscope (FOG) is explained, which uses a fibre-optic coil as a medium for a light source to travel through. The light source is induced in both edges of the optical fibre and the time is recorded for both pulses from start to finish, the time difference is dependent on the rotation of the coil based on the Sagnac effect [37]. The trade-offs between these sensors are the size, price, and accuracy. The MEMS gyroscope comes in a small package with a varying range in accuracy and price, in comparison the FOG have better accuracy but are larger and more expensive.

Inertial Measurement Unit (IMU) is a combination of sensors and usually includes a three-axis gyroscope, accelerometer, and magnetometer. For affordability and size requirements IMUs often uses a MEMS gyroscope. IMUs are widely used in a variety of applications such as mobile phones, tablets, and other compact devices [38]. The raw data from the IMU is usually noisy and to convert the raw data to Quaternions or Euler angles can be computational heavy. However, it has been used on riderless bicycles, for example in the work of Wang et al. [39] and also by Huang et al. [15]. If a high sample rate is needed the problem can be solved using an Attitude and Heading Reference System (AHRS). AHRS is an IMU combined with a microcontroller dedicated to filtering and converting the raw IMU data to readable orientation angles. AHRS has been used in several riderless bicycles such as the one developed by Baquero-Suarez et al. and in the bicycle project at Cornell University [18, 40].

One way to validate an orientation sensor was presented in the work of Kok et al. where an experimental setup was proposed for validating an IMU sensor [41]. The setup used several cameras for capturing the reference points on a wooden board. Using this method, the orientation of the board could accurately be estimated, gaining both the reference orientation and the IMU reading.

2.3

DC motor

In general, a Direct Current (DC) motor have armature voltage proportional to the motor speed. Additionally, the current running through the motor is proportional to the torque the motor generates. These relationships are shown in equation 11 and 12. Where S and T are the motor torque and speed, ksand ktis the motors speed and torque constant, U is the voltage of the motor, and I are the current running through the motor.

S =ks· U (11)

T =kt· I (12)

(12)

The amount of current running through the motor is dependent on the load of the motor and how much the motor controller can supply the motor with [42]. The relationship between speed and torque is an inverse function. In theory, the maximum torque a DC motor can produce is its stall torque, this value implies that the motor stalls i.e. not moving. However, the maximum speed is achieved when the motor is running at its maximum armature voltage with no load i.e. no load speed. At that point the motor is moving at its maximum velocity and produces its minimum torque, the only load applied to the motor is the internal friction within the motor acting on the rotor. Figure 2 illustrates a graph over the DC motors speed and torque relationship.

Figure 2: A graph over the relation between the motors speed S and motors torque T. s0is zero load speed

of the motor and the ts is the motors stall torque.

2.4

Related work

This section addresses the related work in riderless bicycle research. First, the accomplishments of a few research teams are presented. Next, some common models used to describe the bicycle dynamics are highlighted, followed by different control algorithms used to balance riderless bicy-cles. Additionally, different ways to measure and validate the measurement of the lean angle are presented.

2.4.1 Research teams

Research regarding bicycle dynamics and how to control riderless bicycles is conducted at several universities around the globe. Research teams at Cornell University, Tsinghua University, and Delft University are all involved in bicycle research in way or another.

Cornell University

At Cornell University bicycle research has been more or less active for decades, it began in 1985 with the collaboration between Jim Papadopoulos and Andy Ruina [43]. The collaboration has led to several well-known papers in bicycle dynamics, for example, the linearised equations of the Whipple model and the work where the caster and gyroscopic effects on a bicycle were investigated [2, 11]. Ruina is now a professor at Cornell University and supervises a multi-year, multi-student project where the goal is to build a self-balancing, self-navigating, robotic bicycle. The project began in 2014 and in 2018 the project reported a self-balancing bicycle, this is confirmed in the media presented on the Cornell Autonomous Bicycle website [40]. The bicycle developed at Cornell University is of a smaller size, and therefore the solution would be hard to generalise to fit onto the regular male sized bicycle used in this thesis. In addition to an autonomous bicycle, research is being done at Cornell University to develop a steer-by-wire bicycle which offers balance assistance features to the cyclist.

Tsinghua University

At the Tsinghua University, results of balancing a bicycle, in both simulation and real-life exper-iments, were presented in 2015 by He et al. [44]. In the implemented gain-scheduled controller, both the derivative and integral parts were omitted from three PID controllers. This resulted in

(13)

three proportional controllers and the gains changed depending on the velocity of the bicycle. The bicycle used in experiments was a regular sized male model with one motor to control the velocity, and one to control the steering axis. The results showed that the bicycle was able to move forward, make left and right turns while keeping its balance. Since 2015, obstacle detection and avoidance has been implemented on the bicycle as described in the work of Stasinopoulos et al. and Zhao et al. [45, 46]. A Lidar was installed on the bicycle to detect obstacles but also to evaluate the ground surface. The quality of the ground was evaluated so that the bicycle could avoid bumps and holes in its path. The riderless bicycle developed at Tsinghua University is impressive, however, expensive due to the component selection and heavy with a total mass of 52.5 kg. In the research project at MDH which this thesis is part of, the aim is to develop a relativity cheap riderless bicycle, with a mass kept to a minimum.

Delft University of technology

At Delft University the bicycle research has focused on bicycle dynamics and simulation. In 2002, Arend Schwab began the bicycle research at Delft and has since then presented a lot of work on the subject [1, 47, 48]. Schwab also contributed to the derivation of the linearised equations for the Whipple model presented in [11]. At Delft University, a bicycle lab has been established where the interaction between the rider and the bicycle is investigated. As a part of the research, a bicycle simulator has been developed and is presented in the work of Lee et al. and in the work of Dialynas et al. where the latter addresses the hardware used [49, 50]. Steer-by-wire bicycle research has also been conducted at Delft, which is presented in the work by Schwab and Appleman [51].

2.4.2 Dynamic bicycle model

Dynamic models are necessary for the understanding and development of bicycles as a dynamic system. A wide variety of different models exist including both linear and nonlinear systems, with holonomic and non-holonomic constraints. However, since this thesis work is based on an existing bicycle platform, only rear-wheel driven models with front-wheel steering are investigated. Figure 3 shows the different measurements used to define a bicycle along with a letter corresponding to a rigid bicycle body part.

Figure 3: An illustration of a bicycle with four rigid bodies. R is the rear-wheel, F is the front wheel, B and H is the corresponding back-frame and front-frame. h is the vertical offset from the rear-wheel contact point to the back-frame mass centre, a is the horizontal offset from the rear-wheel contact point to the back-frame mass centre. The length of the wheelbase is given by b. The c and λ are the corresponding trail distance and head angle.

Whipple model

The linearised equations of motion presented by Meijaard et al. are often put to use in research of bicycles’ dynamics and control [11]. The presented equations are based on the work of Whipple. The equations need 25 physical parameters to be described completely. The parameters are related to the mass, geometry, and mass moment of inertia of a bicycle. As a result, two coupled differential

(14)

equations are derived which calculates the lean and steer torques given the lean angle, steering angle and the forward velocity. The differential equations are presented in eq. 13.

M¨q + vC1q +˙ gK0+ v2K2q = f (13) The lean and steer angles constitutes the vector q as q = ϕ δT, and the torque applied to the steering and lean angles are represented by f =Tϕ Tδ

T

. The matrix M represents the inertia and mass properties of the bicycle and is a symmetric invertible matrix. The gyroscopic torques from the rear wheel acceleration, lean and steering rates of the bicycle are described in the damping matrix vC1. Forward velocity, gyroscopic and centrifugal forces as well as a gravitational term are all included in the stiffness matrixgK0+ v2K2. It is important to note that the model described by eq. 13 is linearised around the equilibrium point whereϕ δT =0 0T and with constant positive forward velocity. Therefore, if the bicycle is accelerating or have non-zero values for the lean or steering angle, the model is an approximation which becomes more precise as the acceleration and angles are approaching zero. By applying the M−1 to both sides of eq. 13, the following equation is obtained:

¨

q + M−1vC1q + M˙ −1gK0+ v2K2q = M−1f . (14) Which is rewritten in state space form as:

˙ x = AW(v)x + BWu, y = CWx + DWu, (15) with, AW(v) =  0 I M−1gK0+ v2K2  M−1vC1  , BW =  0 M−1  , CW =1 0 0 0 0 1 0 0  , DW =0 0 0 0  (16)

The lean angle, steering angle and their respective angular velocities constitutes the x vector as x = ϕ δ ϕ˙ ˙δT. In Figure 4, the steering and lean angle are given with respect to the coordinate system. The inputs to the system are the torques applied to the handlebar and frame of the bicycle and are represented by u =Tϕ Tδ

T

. To compute the matrices M, C1, K0, and K2 a set of equations, which are defined in [11, Appendix A] can be utilised.

The Whipple model is a fourth-degree bicycle model, where many assumptions are similar to those made in the point-mass model which is described in the next section. But, one big difference between the models is that the point-mass model adds all mass of the bicycle into a single point, while the Whipple model distributes the mass for each rigid body, giving each body inertia. Additionally, the Whipple model considers that the bicycle has a nonzero trail and head angle, as shown in Figure 3.

(15)

Figure 4: A representation of a bicycle according to the Whipple model. The origin is located at the rear wheel contact point, with a right-hand orientation when z-axis is pointing down. δ is the steering angle, ϕ is the lean angle, and ψ is the yaw- rotation angle.

The Whipple model has been validated in the work of Kooijman et al. through a series of experiments using a bicycle with various attached sensors [52]. The eigenvalues from the model were compared to the eigenvalues extracted from measurements in varied forward speed ranging from 0 to approximately 6 m/s. The bicycle was equipped with sensors to measure the lean angle, steering angle and the velocity of the bicycle. There were no motors attached to the bicycle so it had to be actuated by a human, running alongside the bicycle, to the desired velocity and then released in free coasting. The results showed that the linearised equations of motion, presented in [11], agrees well with the real-life bicycle used in the experiments. Additionally, for a bicycle in the forward speed range between 0 to 6 m/s, the tire slip and the small elasticity of the frame and fork does not have a noticeable impact on the lateral dynamics.

Point-mass model

Early examples of the point-mass model can be found in the book by Timoshenko and Young from 1948 [53]. The model has since then been modified and used in several studies, for example, H. Sharma and UmaShankar utilised the point-mass model to produce a fuzzy controller for stabil-ising a bicycle [54]. The point-mass model enabled Hauser et al. to develop a controller that tracks the trajectory of a bicycle, while the bicycle is in an upright position [55]. Additionally, A. Sharma et al. used the point-mass model to develop a multivariable proportional controller for balancing a bicycle in a simulation environment [56]. In the work, a comparison between the Whipple model and the point-mass model is made as well. The results suggest that the two models have a similar response to a control input.

The point-mass model is one of the more basic analytic bicycle models, it’s a simple second order linear model with a set of simplifications, see Figure 5. The model assumes that both the front and rear wheel along with the front frame is mass-less, giving these parts of the bicycle inertia of zero. However, their masses are included in the total mass of the bicycle, which is lumped together forming a point mass, hence the models’ name To further simplify the bicycle model, it is assumed that the forward velocity is constant and the heading angle, λ, and the trail distance is zero. However, according to ˚Astr¨om et al. there can not be any sort of self-stabilisation if the bicycle does not possess a positive trail and head angle of 90◦ [57]. This statement was proven to be wrong, as presented in the work by Kooijman et al. [2]. With simplifications made to the Whipple model, by removing the trail and the gyroscopic effects from the wheels, the 27 equations of the Whipple model were reduced to 8 equations. In the presented work, a bicycle was able to self stabilise in real-life experiments even though the bicycle did not possess those features.

(16)

Figure 5: A top-down and a back view of the point-mass model. The model’s coordinate system is located around the back wheel with the contact point with the ground being the origin. Additionally, δ is the steering angle and ϕ is the lean angle.

By using the measurements displayed in Figure 3 and the kinematics of planar motion, in combination with the bicycles yaw angular velocity, interacting with a trajectory curvature, a simple bicycle model can be obtained, see eq. 17.

h ¨ϕ = g sin ϕ − tan δ v 2 b + a ˙v b + tan ϕ va b ϕ −˙ hv2 b2 tan δ !! − av ˙δ b cos2δ (17)

Lineraising the equation 17 with the fact that the bicycle is moving with constant velocity and running in a straight line gives a second order differential equation, see eq. 18.

¨ ϕ = g hϕ − av bh˙δ − v2 bhδ (18)

Using the steering velocity, ˙δ, as the input u, the point-mass model can be rewritten in state space form as:

˙ x = A(v)x + B(v)u, y = Cx + Du, (19) where A(v) =   0 1 0 g h 0 − v2 bh 0 0 0  , B(v) =   0 −av bh 1  , C =1 0 0 0 0 1  , D =0 0  . (20)

The state vector x consists of lean angle ϕ, the lean angular velocity ˙ϕ, and the steering angle δ.

Software models / Non-linear models

The linear models are a simplification of a non-linear relationship, in reality, a bicycle is a set of elastic bodies coupled together and forming a non-linear system. The non-linear relationship according to Hatano et al. affects the behaviour of the model in low and high velocities [21]. By modelling a non-linear system to include rear wheel body frame, front wheel handlebar, a controller was developed that could control a wider stability range of a bicycle. However, as mention above by Kooijman, non-linear relations like the tire slip and elasticity from the frame does not have a noticeable effect on the systems lateral dynamics [52].

(17)

In more recent years computer aided simulation have been used to derive a bicycle model. Among the programs used are Mathworks Simulink and MSC Softwares Adams [58, 59]. To derive the equation of motions for a multibody design using Adams, the user can import a Computer-Aided Design (CAD) file. The Euler-Lagrange method is utilised in the software for these equations of motion. By using a multibody simulation, more complex systems can be modelled along with environmental conditions. In the work by Baquero-Suarez et al. Adams was used to model the instrumented bicycle, and co-simulate the model using Simulink [18]. Using the co-simulation between Adams and Simulink was also done in the work by Garcia et al. where an innovative design for a reaction wheel mounted on a bicycle was presented [17]. Instead of building the bicycle, the model was created in Adams and the model was used in a series of simulated experiments.

2.4.3 Controllers used for balancing bicycles

Many different types of controllers have been utilised to control and balance an unmanned bicycle. From the more traditional ones, such as the PID controller, to more complex ones which rely on various Artificial Intelligence (AI) methods. Many of these controllers have only been implemented in simulation and not tested on a physical bicycle. In the cases where the controller is implemented on a real bicycle, the model of the bicycle is almost exclusively of the male model with a diamond shaped frame. One explanation for this is that the frame elasticity is less noticeable in these models compared to the female model as mention by ˚Astr¨om et al. [57]. In this section, the control of riderless bicycles in both simulation and in a real-world environment using different control algorithms is addressed.

PID controller

Tanaka and Murakami, in 2004, presented one of the first riderless bicycles which managed to keep its balance while riding on a roller [60]. To control the bicycles steering axis, and by extension, the balance, a PD controller was utilised along with disturbance observers. From the results, it is possible to see how the steering angle follows the lean angle which makes the bicycle balanced. A PD controller was also implemented in the work by Suebsomran, where a bicycle, equipped with a reaction wheel, was kept stable [61]. The controller regulates the angle of the reaction wheel to produce a necessary torque for the bicycle to be able to balance. The PD controller manages to stabilise the bicycle, however, only in a simulated environment.

In the work by Wang et al. a cascade controller for balance and directional control of a bicycle-type two-wheeled vehicle is presented [39]. In the inner loop, a PD controller was used for balancing the vehicle by sensing the lean angle and output a steering torque to the plant. The outer loop, which composed of the directional control, also relied on a PD controller, but by sensing the yaw angle it outputs a reference lean angle which was fed to the inner loop. Experiments were made in simulation and on a real bicycle-type two-wheeled vehicle. Both the balance and the directional controller showed promising results. However, the platform used for testing was small and was some sort of hybrid between a kid bicycle model and small scooter. Because of the size and the structure of the platform, the presented results are hard to generalise to a regularly sized bicycle.

Intelligent controller

To stabilise a bicycle, Sharma presented a fuzzy controller [54]. The developed controller takes two inputs, the lean angle and the steering angle, and outputs a correction lean. Thus, the controller relies on direct regulation of the lean angle which would require a flywheel, an inverted pendulum or something similar. The controller developed by Sharma manages to stabilise the bicycle in a simulated environment but was never used in any real-life experiments. In the work of Shafiekhani et al. an adaptive critic-based neuro-fuzzy controller was developed [19]. A PID controller in the inner loop regulates the torque applied on the bicycles’ steering axis and an outer loop calculates the lean angle error and forwards it to the neuro-fuzzy controller. The output from the neuro-fuzzy controller was the desired steering angle. The neuro-fuzzy controller was divided into four layers and used as a critic agent to enforce a reinforcement learning method. A comparison was made between the neuro-fuzzy controller and a FIS controller, which concluded that the neuro-fuzzy offers more accurate performance in term of tracking the lean angle in both simulation and reality.

(18)

Abdolmalaki presented a control system that relies on a FIS, where the fuzzy sets were designed to generate the desired steering angle as a reference to an inner control loop powered by a PID controller [62]. Using an additional FIS, the system manages to track a reference lean angle other than zero, which implies that the bicycle can follow a given trajectory. The experimental result showed that the bicycle was able to balance along with a straight line, however with oscillations of ±5o. The oscillations were also present when a sinusoidal trajectory was followed, despite this, the proposed control was still able to keep the bicycle from falling over.

A drawback of using a direct regulation of the lean angle is the fact that the appearance of the bicycle is altered a lot. From a radar cross section point of view, a bicycle with a flywheel attached to it does not have the same radar cross section as a normal bicycle. Moreover, balancing the bicycle by solely lean actuation is often performed on smaller types of bicycles and in low velocities. According to He et al. these methods usually struggle when it comes to the balance of regular size bicycles, where the weight and velocity are often increased compared to a small bicycle [44].

Optimal controller

In the work presented by the Guo et al. a LQR is presented in order to balance a bicycle [63]. The linear bicycle model is derived from a non-linear Lagrange model, linearised around the estimation that roll angle is relatively small in high velocities. The proposed controller shows promising simulation result. However, when the controller was implemented on a real bicycle it was only able to stabilise for a while. The authors point out that disturbances such as the sensor noise, and wind might be a factor for instability.

Instead of developing a conventional controller with two control loops Vatanashevanopakorn and Parnichkun proposed a LQR controller optimised for a bicycle model coupled with the dynamics of an electrical steering motor [64]. If the inner loop of a conventional controller is not tuned in a proper way the control structure will suffer in terms of robustness as argued in the paper. The simulation result presented shows that the proposed LQR controller structure was capable of stabilising the bicycle with an initial lean angle and steering angle. However, no implementation on a physical bicycle nor any comparison with the conventional controller is presented.

Anjumol and Jisha proposed a LQR controller to control a second-degree bicycle model [65]. The results obtained was compared with a posture controlled proposed by Tanaka and Mu-rakami [66]. The result from the comparison showed that a LQR controller performed better than the posture controller in simulation. However, the LQR controller was not implemented or tested on a real bicycle.

In the work by Chen and Dao, a state feedback controller was proposed to track the bicycles roll angle [67]. The bicycle model was derived using an identification based approach where a non-linear model was controlled and its inputs and outputs were recorded. The recorded values were used in a system identification module which in turn generated the state space variables. The results showed that the bicycle was stable in 15km/h in a simulation environment. However, no real implementation or experiments was presented in the report.

Adaptive controller

In the work of Al-Buraiki and Ferik, an adaptive self-tuning regulator was developed [68]. The controller uses an estimation stage and a construction stage for the input signal, the first stage uses a weighted recursive least squares approach to estimate the models state-space, which is used in the second stage to construct the input signal. Additionally, in the second stage, a LQR controller is adapted for the online estimation. The proposed controller managed to balance a bicycle in a simulated environment.

Robust controller

Thanh and Parnichkun utilised a reaction wheel to balance a bicycle. A structure-specified mixed H2/H∞ controller is developed using a Particle Swarm Optimisation (PSO)-based algorithm and implemented on a bicycle robot called Bicyrobo [69]. The control structure was compared with a GA-based structure-specified mixed H2/H∞, and also with a traditional PD controller. The

(19)

simulation results showed that both the PSO and GA controller outperforms the PD controller looking at the controllers’ step response, the experimental result on the Bicyrobo confirmed the simulation results. In the conducted experiments the bicycle had zero forward velocity.

In 2018, Baquero-Su´arez et al. presented promising results where a regularly sized bicycle, of a male model, equipped with sensors and actuators, manage to balance itself while following a path using steering torque and forward velocity as the only control outputs [18]. Using two Generalised Proportional Integral (GPI) extended observers a cascade controller with two stages was developed. The outer controller kept track of the current lean angle of the bicycle and the applied torque to the steering angle and outputted the desired steering angle. The error between the desired steering angle and the bicycles current steering angle was calculated and fed to the tracking controller which in turn generated a steering torque. The results showed that the proposed system can balance even under small accelerations.

(20)

3

Problem formulation

A bicycle is a naturally unstable system which a human can learn to control given enough train-ing. A riderless bicycle, on the other hand, depends on several actuators, sensors, and a control algorithm to maintain balance. In this master thesis, control structures for a riderless bicycle are designed and implemented. The performances of the controllers are evaluated in simulation, but also in experiments on an instrumented bicycle. The bicycle is equipped with sensors to measure the lean and steer angles. Both the lean angle sensor and the steering system are calibrated and validated to ensure the correct data are fed to the control algorithms. To maintain the bicycle balanced, two controllers are needed. One, which controls the speed of the rear wheel using a PI controller that has been implemented prior to this thesis. The second one, which is developed in this thesis, regulates the angular velocity of the steering axis, thus, there is no direct regulation of the lean angle.

3.1

Hypothesis

Based on the problem formulation the hypothesis for this thesis is formulated as:

By developing a control algorithm first in simulation, and then implement it on National Instruments roboRIO, it is possible to balance an instrumented

bicycle while moving at a constant forward speed.

3.2

Research questions

Taking into consideration the problem formulation and the hypothesis, the following research questions are addressed in this thesis:

RQ1. What can be done to improve the lean angle measurements of the instrumented bicycle, and how should an experimental setup be designed to evaluate the ac-curacy of these measurements?

RQ2. How can the steering system of a bicycle be configured and controlled to ensure accurate and fast response?

RQ3. How can an instrumented bicycle and its dynamics be modelled in a simulated environment?

RQ4. Given regulation of the steering angle, how can a controller be designed to bal-ance an instrumented bicycle in both simulation and in real life experiments? RQ5. How do a set of different control algorithms compare to each other in terms of

balancing an instrumented bicycle?

A mapping between the research questions and the sections which address each research question is shown in Table 1.

Table 1: This table maps the research questions to the respective sections where the research question is addressed. It aims to help the reader to gain a better understanding of the conducted work.

Section

Implementation Experimental setups Results Conclusion

RQ1 6.2 7.1 8.2 9.2

RQ2 6.3 7.3 8.3 9.4

RQ3 6.4 7.4 8.4 9.5

RQ4 6.4.4, 6.5 7.5.1, 7.5.3 8.4, 8.5, 8.6 9.6, 9.9

(21)

3.3

Limitations

There are some constraints and limitations to the work of this thesis. The instrumented bicycle at MDH is supported by a National Instruments roboRIO which have multiple inputs and output channels, support for different data communication protocols, a real-time module and a Field Programmable Gate Array (FPGA) module running at 1 and 40 MHz respectively.

• The maximum forward speed considered is 15 km/h. The theoretical minimum forward speed is 2.63 km/h, however, no experiments are conducted below 8 km/h.

• To resemble a bicycles radar cross section, only two motors will be used, one which controls the rear wheel and in extension the forward velocity, the second motor regulates the steering angle and in extension the lean angle

• The steering motor has a maximum speed of 7000 rpm • Handlebar movements are limited to ±45◦

• Only constant forward velocity is considered during stabilisation, no reverse driving of the bicycle or zero velocity. Where constant velocity is defined as a velocity ν ± 0.5 km/h. • The lack of sufficient test area for the bicycle, which could cause problems during experiments • The allocated time for the thesis work is limited to 20 weeks

(22)

4

Method

In this thesis, the iterative engineering design process is followed as a methodology, described by Tayal [70]. The process is divided into five stages as illustrated in Figure 6. From a set of limitation, requirements, and goals, different designs are brainstormed and investigated. This is the initial stage of the iterative process, based on the brainstorming stage, a design is selected that fits all the requirements. From the design stage, an analysis is performed to determine how the design should be built, which includes to plan what tools and materials that need to be used. The final two stages are the build and test stage. During these stages the physical prototype is built and tested, the discussion on improvements and viable solutions is also performed. If the construction does not meet the design requirements then the method starts over.

Figure 6: An abstract representation of the iterative engineering design process. The brainstorming phase is the initial state in the process, in this phase, various designs are considered that fits a set of limitation and goals the problem requires. From the brainstorming phase, a design is selected that meets the requirements. The selected design is then further analysed and implemented in theory before it is built and tested. If the system requirement is not meet, the design process iterates.

A literature study is performed to investigate what has been done in the field of bicycle mod-elling, riderless control, and also what type of sensors are available to measure the lean angle of the bicycle. The validation and evaluation process is done in a bottom-up approach, starting with the sensors and finishing off with the controllers implemented on the bicycle. The equations of the linearised Whipple model is put in use as a first step to design control strategies for the riderless bicycle. These equations have previously been validated by Kooijman et al. with experiments performed on a similar bicycle as the one considered in this thesis [52]. As an alternative, the point-mass model can be utilised. The point-mass model implies more simplifications, which could resolve in a less accurate model. However, it has the advantage of not using the steering torque as an input, since the torque can be difficult to measure. The two coupled differential equations from the Whipple model are also used to analyse the velocity regions of self-stabilisation of the riderless bicycle. Additionally, the velocity range for which the bicycle is easier to control by using actuation only on the steering axis is extracted from the equations. A similar analysis is done in the work by Schwab et al. [48].

The bicycle platform is equipped with National Instruments roboRIO as the main processing unit. To program the roboRIO, National Instruments provide an integrated development environ-ment named LabVIEW [71]. Furthermore, MathWorks MATLAB and Simulink are utilised during the prototype phase for the development controller, and also for evaluation purpose [58, 72]. The bicycle platform is equipped with three sensors, one for steering angle measurements, a hall effect sensor together with 12 magnets are used to measure the speed of the rear wheel. The last sensor is an IMU to measure the lean angle of the bicycle. To improve the accuracy of the lean angle measurement in a dynamic environment, the IMU is replaced with an AHRS sensor which uses an Extended Kalman Filter (EKF) to calculate the Euler angles and outputs these directly. In comparison, the IMU outputs the raw data from the accelerometer, gyroscope and magnetometer and from these values the Euler angles have to be computed on the roboRIO.

(23)

4.1

Evaluation

To validate the lean angle measurements an experimental setup is developed which can measure both the delay and the accuracy of the angle computed from the AHRS, and empirical data is collected from experiments. The steering system is evaluated using time domain metricise such as overshoot, rise time and steady-state error. The real-life experiments are conducted on a bicycle roller and in several outdoor environments. During experiments, both in a real and in a simulated environment, constant velocity of the rear wheel is considered. At what velocities the experiments are conducted is determined based on the analysis of linearised equations of the Whipple model. To compare and evaluate the different control algorithms, the behaviour of the bicycle using different controllers are compared in both a simulated environment and on the real bicycle. The RMSE and ISE are used to evaluate the controllers performance. Additionally, the execution time of the different control structures, implemented on the roboRIO, is measured. Experiments are also done to evaluate the robustness of some of the proposed controllers by inducing a disturbance in the system.

(24)

5

Hardware

The bicycle platform considered in this thesis is presented in detail in the project AutoBike re-port [7]. The bicycle is equipped with a rear wheel motor from Bafang [73] and an 11.6 Ah 36V battery. To measure the lean angle, a MPU-9250 [74] was mounted on top of the seat post. The steering system consisted of a brushed DC motor from Maxon [75], gearbox [76], encoder [77], and a Junus motor controller from Copley Controls to control the motor [78]. The velocity measure-ments of the bicycle were realised by 12 magnets attached to the rear wheel, and a hall effect sensor measured the time between the magnets. The main processing unit was a National Instruments roborRIO strapped on the side of the bicycle. To enable remote control of the bicycle, a radio controller was utilised and a receiver was put on the bicycle and connected to the roboRIO [79], [80]. The instrumented bicycle from project AutoBike is shown in Figure 7.

Figure 7: The instrumented bicycle from project AutoBike. Inside the yellow box is the steering motor with encoder and gearbox, the pink box highlights the radio control receiver which enables the user to send wireless commands to the bicycle. The battery of the bicycle is displayed inside the red box and the green box surrounds the roboRIO. Mounted on top of the seat post, inside the black box, is the IMU. The blue and the white circle surrounds the rear wheel and brake motor respectively.

5.1

Modifications

As stated in the project AutoBike report, the accuracy of the lean angle sensor on the bicycle is troublesome. Additionally, the MPU-9250 only outputs raw gyroscope, accelerometer, and magnetometer data which requires a lot of processing on the roboRIO to produce lean angle measurements. To solve the issue with the accuracy, and also to off-load the roboRIO, the MPU-9250 is replaced with a VN-100 from VectorNAV [81]. The VN-100 is an AHRS which uses an EKF to compute roll, pitch, and yaw angles from raw data obtained from the built-in gyroscope, accelerometer and magnetometer. The computed roll and pitch angle has an accuracy of ±1◦ in dynamic conditions and can produce outputs at a speed of 400 Hz. Using the VN-100 the angles are fed directly to the roboRIO and no further processing is needed to obtain the lean angle.

The VN-100 is mounted on a sheet of plexiglas and placed underneath the bottom bracket shell. Considering that the orientation estimations using accelerometer data from an IMU is accurate in long periods of time, but noisy in short periods of time, it is beneficial if the magnitude of the accelerometer is kept as small as possible [41]. The benefits of the new location for the lean angle sensor is that the sensor is exposed to less acceleration compared to if it is placed in a position further away from the rotational centre. This can be confirmed using eq. 21 where r is the radius, α is the angular acceleration and a is the linear acceleration.

(25)

Another issue with the bicycle platform was that the cord of the rear wheel motor got damaged when the bicycle fell over during testing. To protect the cord a pair of BMX footpegs are mounted on the rear wheel axis. A hole is drilled through one of the pegs, and the cord is wired through the hole. Additionally, a kickstand is installed and a relay switch is attached to the bicycle to control the power of the IMU. The modified bicycle is shown in Figure 8

Figure 8: The modified bicycle where the blue box indicates the relay which controls the power to the IMU. Inside the white box is the new placement for the IMU and the red box highlights the mounted kickstand. The green box surrounds a BMX peg, another peg is located on the opposite side of the rear wheel and through that peg the rear motor cord is wired.

(26)

6

Implementation

In this section, the implementations are discussed in detail. Firstly, the physical parameters of the instrumented bicycle are used to compute the forward speed regions for which self-stability occurs. Thereafter the lean angle sensor is explained and how the data is interpreted and used on the instrumented bicycle. Next, the steering system is addressed with the structure of the control loops and how these loops interfere with each other. In the succeeding section the different controllers, used for balancing the bicycle, are given. The remote controller and its assign functions are presented next. In the final section, software is addressed and a block diagram which illustrates how the code is distributed on the roboRIO is presented.

6.1

Forward speed range

The equations found in [11, Appendix A], are implemented in a MATLAB script. The equations are composed out of 25 design parameters which are extracted from the instrumented bicycle and shown in Table 2. In the table, the total mass and the gravitational term are included for convenience reasons and are not included in the 25 design parameters. To determine the inertia of the bicycle, the CAD model developed in SolidWorks [82] during project AutoBike is altered according to the modifications presented in Section 5. Furthermore, in the CAD model from the project, the motor controller as well as the roboRIO are missing. These are now included in the CAD model with their respective mass. The inertia, Center of Gravity (CoG), and head angle are extracted from the updated CAD model.

Table 2: Physical parameters of the instrumented bicycle. The measurements are obtained from both direct measures of the bicycle, but also from the detailed CAD model. The first section of the table corresponds to the assembled bicycle followed by sections which address the rear wheel, rear frame, front frame and the front wheel respectively.

Bicycle parameters

Part Parameter and symbol Unit Value

Bicycle

Total mass (mtot) [kg] 23.720

Wheelbase (w) [m] 1.081

Trail (c) [m] 0.087

Gravity (g) [m/s2] 9.820

Head angle (λ) [deg] 72.950

Rear wheel (R)

Radius (rR) [m] 0.349

Mass (mR) [kg] 6.780

Moments of inertia (IRxx, IRyy) [kg · m2] 0.244, 0.485 Rear

frame (B)

CoG position with respect to O (xB, zB) [m] 0.520, -0.589

Mass (mB) [kg] 11.840

Moments of inertia (IBxx, IByy, IBzz, IBxz) [kg · m2] 0.517, 1.362, 0.891, -0.483 Front

frame (H)

CoG position with respect to O (xH, zH) [m] 0.933, -0.703

Mass (mH) [kg] 3.110

Moments of inertia (IHxx, IHyy, IHzz, IHxz) [kg · m2] 0.115, 0.119, 0.025, 0.037 Front

wheel (F)

Radius (rF) [m] 0.349

Mass (mF) [kg] 1.990

Moments of inertia (IF xx, IF yy) [kg · m2] 0.100, 0.200

Executing the previously mentioned MATLAB script with the bicycle parameters found in Table 2 yields the following M, C1, K0, K2 matrices which are based the physical parameters of the bicycle: M =7.690 0.563 0.563 0.239  , C1=  0 6.886 −0.696 0.860  , K0= −12.221 −0.890 −0.890 −0.275  , K2= 0 12.485 0 0.940  (22)

(27)

The state space form presented in eq. 15 in section 2.4.2 is reproduced here for readability: ˙ x = AW(v)x + BWu, y = CWx + DWu, (23) with, AW(v) =  0 I M−1gK0+ v2K2 M−1vC1  , BW =  0 M−1  , CW =1 0 0 0 0 1 0 0  , DW =0 0 0 0  (24)

By plotting the real part of the eigenvalues of AW(v) in eq. 15 for a velocity interval between 0 and 10 m/s it is possible to determine in what region the bicycle system is asymptotically stable. In this region, the bicycle is self-stabilised, i.e all eigenvalues are negative, as explained in detail by Meijaard et al. [11]. On the other hand, by plotting the zeros of the transfer function of eq. 15 from Tδ to ϕ with the varying velocity it is possible to determine where the system is a non-minimum phase system as explained in the work by Baquero-Suarez et al. [18]. If there is a positive zero, then the system is a non-minimum phase system which results in a system that is more difficult to control.

6.2

Lean angle sensor

As mentioned in Chapter 5, the sensor used for lean angle measurements is a VN-100. To configure the sensor, VectorNavs’ Control Center software is utilised [83]. The baud rate is configured to 230400 bps, which matches the roboRIOs maximum baud rate. The sensor can be configured to output both raw data or computed angles including Quaternions, Euler angles, and rotation matrix. Since the bicycles lean angle is measured with the sensor, the Euler angles are set as the output and the sensors coordinate system is chosen with the positive x-axis in the forward direction of the bicycle and positive z-axis pointing downwards. By alignment of the coordinate systems, the roll angle of the sensor is the same as the lean angle of the bicycle. The sensor is configured to an output rate of 200 Hz, and some initial testing is performed using Control Center.

The communication between the roboRIO and the VN-100 is realised using Universal Asyn-chronous Receiver/Transmitter (UART) communication. Each message is received as a string of 38 characters on the real-time module of roboRIO, and from each message, the roll angle is extracted and converted from a string to a double precision floating point. The procedure is illustrated in Figure 9. Convert from string  to double  $VNYPR,+102.371,­000.767,­006.117*6B 38 characters message ­6.117 Extracted roll angle Roll angle

Figure 9: The messages from the VN-100 are composed out of 38 characters, from each message the roll angle is extracted and converted to a double precision floating point which represents the lean angle of the bicycle.

Initial testing of the communication between roboRIO and the sensor showed that some mes-sages are lost in the communication, which would compromise the reliability of the lean angle measurements. All messages start with the $ sign and the characters of the messages are sent from right to left so the $ sign will be last character in each message. This is used when checking for missed messages. If the left most character of the string does not contain the $ sign the complete message has not been received and the message is classified as a lost message. By decreasing the output sample of the sensor to 100 Hz the number of miss messages is diminished.

(28)

6.2.1 Improvements

The conclusion, found in section 9.2, from the third lean angle experiment, entails that some messages are still lost even though the sample rate is decreased to 100 Hz. As a second safety precaution, a software function is implemented to deal with missed messages. If a message is lost, the previous lean angle measurement is used. However, if more than five consecutive messages are lost, the bicycle is powered down. Additionally, how the measurements are logged is modified. Instead of writing each signal separately to a file in every sampling period, the signals are gathered in a 2-dimensional array and the whole array is written in every sampling period. By doing this, the log file size is reduced by approximately 88%.

6.3

Steering control

The overall steering controller is a combination of several nested control loops, implemented on both a Micro Control Unit (MCU) and in the motor controller see Figure 10. The inner loop is implemented on the motor controller which sends a voltage to the motor in the form of a Pulse Width Modulation (PWM). The outer loop is developed on the MCU and outputs the desired steering velocity.

Figure 10: A general overview of the bicycles steering controller. The inner control loop is the motor controller which applies a PWM voltage to the steering motor. The outer loop is the position controller which control the steering velocity according to a position. The communication between the inner and outer loop is done through the PWM signal.

6.3.1 Motor controller

The Junus motor controller uses a velocity controller in series with a current controller. The inputted desired steering velocity in the form of a PWM signal is first saturated through a velocity limiter and then used to compose the error eδ˙. The error is then fed to a PI controller which in turn outputs the desired current. The current controller also employs an input limiter and a PI controller, the result is a voltage input to the motor. A block diagram over the Junus motor controller including the velocity and current controller can be viewed in Figure 11.

Figure 11: A block diagram of the Junus internal control structure. The inner loop controls the current to the motor and the outer loop controls the motor velocity. The current control loop frequency is 20 kHz and the velocity control loop frequency is 4 kHz.

The current controller is a PI regulator where the Cp, and Ci gains are obtained through an relay auto-tuning process tuned to 0.5 Ampere using the accompanied CME 2 software [84]. In the work by Berner et al. the relay auto-tuning process is explained in detail [85]. The velocity controller is tuned manually through the CME 2 built-in oscilloscope, the corresponding PI gains Vp and Vi can be viewed in Table 3.

(29)

Table 3: Table (a) is the current control PI gains along with loop speed and an input limit. Table (b) is the velocity controller corresponding values.

(a) Current controller Cp 70 Ci 81 Limit [A] 4.12 Speed [kHz] 20 (b) Velocity controller Vp 700 Vi 200 Limit [RPM] 7000 Speed [kHz] 4 6.3.2 Position controller

The position controller uses the signals from the encoder which is decoded on the roboRIOs Field Programmable Gate Array (FPGA) target. The decoded steering angle is compared to the desired steering angle. The resulting error is regulated through a PID controller. To minimise settling time in large vs. small steering angle errors a PID gain scheduler is adopted. Meaning that the PID parameters are swapped out depending on the magnitude of the steering angle error eδ. The control structure can be seen in Figure 12.

Figure 12: A block diagram of the roboRIOs internal position control structure. The position controller input error is fed to a gain scheduler which in turn effects the PID controllers gains in the context of what magnitude the input error is.

The PID regulator is implemented on roboRIOs FPGA target, and uses the following control law:

u(k) = uP(k) + uI(k) + uD(k) (25)

where uP, uI, and uDare,

uP(k) = Kpep(k) (26) uI(k) = Ki k X n e(n) + e(n − 1) 2 (27) uD(k) = Kd[ed(k) − ed(k − 1)] + F ud(k − 1) (28) 23

(30)

The error e, ep, and ed are defined as

e(k) = δ∗(k) − δ(k) (29)

ep(k) = δ∗(k)β − δ(k) (30)

ed(k) = δ∗(k)γ − δ(k). (31)

Where the β and γ are proportional and derivative weights, added to the desired angle. Kp, Ki, and Kd are the proportional, integral and derivative gains of the controller in this parallel based structure. Additionally, F is the derivative filter coefficient, see Table 4.

Table 4: Description table for the variables in equations 25 to 31.

Constants description δ∗ Desired steering angle δ Actual steering angle Kp Proportional gain Ki Integral gain Kd Derivative gain F Filter coefficient β Proportional weight γ Derivative weight Omin Minimum output limit Omax Maximum output limit

The PID.VI handles saturation using the following algorithm.

if u(k) ≥ Omax then u(k) = Omax if u(k) ≤ Omin then u(k) = Omin

Additionally, windup is dealt with using the following anti-windup algorithm [86], where limit is either Omax or Omin.

if |uP(k) + uI(k)| > |limit| then uI(k) = limit − uP(k)

The gain scheduler uses the schedule displayed in Table 5, where the gain schedule is divided into four distinct phases. The systems’ scheduling phases are of the crisp type meaning that the transition between each phase is discontinuous. Additionally to the PID gains the scheduler also limits the output of the controller.

Table 5: The scheduling scheme for the gain scheduler regulator. The different phases are determined based on the magnitude of the controllers input.

Gain scheduler

Phase [deg] Kp Ki Kd F β γ Omin Omax

[0-3) 0.15 0 1500 0.85 1 0 -0.5 0.5

[3-10) 0.22 0 1300 0.83 1 0 -0.5 0.5

[10-20) 0.25 0 1100 0.83 1 0 -0.9 0.9

References

Related documents

To the question “The game provides a lot of stimuli from different sources" we have an average value of 3.9 for subjects with Oculus Rift, compared to 3.6 for users who have used

De kritiska framgångsfaktorer som identifierats för att utveckla hållbarhetsarbetet på operativ nivå inom byggbranschen genom att applicera affärsmodellen som strategiskt verktyg

Comparing the VANMOOF bicycle with our design we argue that our bicycle will be cheaper and made for the different genders (man/woman). The VANMOOF bicycle uses a lot of material

Värme- priset har satts till 41,65 öre/kWh, vilket är det pris Plönninge betalar för värme producerad från olja. Resultatet redovisas i tabell 17, se även

Med stöd utav den tidigare forskningen kunde vi slå fast en del indikatorer som visar på denna utveckling, bland annat Volgstens teori om användandet av citat som en indikator

Anledningen till att filtrering och stabilisering avstås från är för att behålla mer doft- och smakaromer samt pigment för att vinet ska kunna vara mer orört (Suárez et al., 2007)

This thesis outlines a modular controller design based on a physical model of the SEAL Carrier consisting of an observator, a PI controller for the forces and torque and a mapping

Below are listed the most relevant features that will feed the mode choice model: • Individual’s bicycle and electric bicycle ownership, which allows modelling their probability of