Sunteți pe pagina 1din 25

FRT090 Projects in Automatic Control

Control of a full scale Segway

Date: 7-6-2010

By:
Erik Torstensson, F06
Babak Rajabian, E06
Johan Andersson, E06
Kujtim Iljazi, E00

Advisor: Erik Johannesson


Acknowledgments
We would like to thank our supervisor Mr. Erik Johannesson for the valuable advice and
support he has given us in this project.
We would also like to thank Mr. Johan Åkesson and Mr. Daria Madjidian for their
encouragement and guidance.
Special thanks to Mr. Anders Robertsson who always showed his interest for the project and
always in any time helped us through obstacles that made the project to stand still. He also
gave us valuable advice and support during the project.

1
Abstract
This project was to investigate and implement different possible controllers for the Segway
(ElektorWheelie) to stabilize the process. In order to find the most efficient controller we
started with investigate LQR controller. The main findings were that the most effective
controller was an LQR-controller with Kalman-filtering.

2
Contents
Acknowledgments .................................................................................................................................... 1
Abstract .................................................................................................................................................... 2
1. Introduction .......................................................................................................................................... 4
1.1 The hardware ................................................................................................................................. 4
1.1.1 Motors .................................................................................................................................... 4
1.1.2 Energy source ......................................................................................................................... 4
1.1.3 Sensors and CPU ..................................................................................................................... 4
1.1.4 Software .................................................................................................................................. 4
1.2 How does it work?.......................................................................................................................... 5
2. Objectives ............................................................................................................................................. 6
2.1 Analyze ........................................................................................................................................... 6
2.2 Research ......................................................................................................................................... 6
2.3 Computing ...................................................................................................................................... 6
2.4 Programming .................................................................................................................................. 6
3. Theory ................................................................................................................................................... 7
3.1 inverted pendulum ......................................................................................................................... 7
4. The model ............................................................................................................................................. 9
4.1 mat mod ......................................................................................................................................... 9
4.2 Matlab/Simulink model ................................................................................................................ 14
4.3 Motor identification ..................................................................................................................... 14
5. Methodology ...................................................................................................................................... 17
5.1 Safety during experiments ........................................................................................................... 17
5.2 State Estimation ........................................................................................................................... 17
5.3 LQR ............................................................................................................................................... 18
5.4 Filters ............................................................................................................................................ 19
6. Time plan ............................................................................................................................................ 20
7. Findings............................................................................................................................................... 21
7 .1 State estimation .......................................................................................................................... 21
7.2 LQR results ................................................................................................................................... 21
7.3 Filters ............................................................................................................................................ 22
8. Discussion ........................................................................................................................................... 23
8.1 Future improvements .................................................................................................................. 23
8.2 Sidetracks ..................................................................................................................................... 23
Reference ............................................................................................................................................... 24

3
1. Introduction

A Segway is a modern two-wheeled, self-balancing electric transport vehicle. The architect


construction and the technical architecture make the usage for the Segway very simple. To
make it go forward the user leans forward and to go backwards the user leans back.
Furthermore there is a so-called “lean steer”-handlebar that makes it possible for the user to
turn left or right by leaning it. (Websource1)

The ElektorWheelie is a Segway developed and produced by the German company “Elektor”.
ElektorWheelie is an open source product and makes it possible to reprogram and fill in with
new features. (ElektorWheelie - Elektor’s DIY self-balancing vehicle)

1.1 The hardware


The construction of the ElektorWheelie is a rigid metal chassis. Inside this metal chassis
there are rechargeable cells and compact control electronics. (ElektorWheelie - Elektor’s DIY
self-balancing vehicle)

1.1.1 Motors
Inside the ElektorWheelie we find two 24V DC electric motors with an effect of 1 kW that
gives a maximum speed of 12 km/h (7.5 mph). The manufacturer of the motors is “Zhejiang
Unite Motor Co., Ltd” 1. (ElektorWheelie - Elektor’s DIY self-balancing vehicle)

1.1.2 Energy source


The energy source is two 12V rechargeable lead-acid gel cells 2 . The capacity varies
depending on driving style and road gradient. With full charged battery you can expect 1
hour to 1.5 hours of usage before recharging the batteries again. The manufacturer of the
batteries is unknown. The only fact there is “CTM in China”. (ElektorWheelie - Elektor’s DIY
self-balancing vehicle)

1.1.3 Sensors and CPU


The only sensor necessary is a 2-axis acceleration sensor and a gyro give the controllers
input data. The CPU is an Atmel AVR-mega32 and supplies commands to the motors to
maintain the correct inclination of the ElektorWheelie. The manufacturer for the 2-axis
acceleration sensor is “Analog Devices” and for the gyro it is “Invensense”. Atmel AVR is the
manufacturer for the CPU.

1.1.4 Software
The microcontroller, Atmel AVR-mega32, is programmed in BASCOM-AVR.

1
http://unitemotor.ec51.com/
2
http://en.wikipedia.org/wiki/VRLA_battery

4
1.2 How does it work?

Figure 1 - Simplified overview of the controlsystem

The process is very simple and this section will describe the model the very simple way it is.
When the user stands on the ElektorWheelie the process, the sensors gyro and
accelerometer, starts to give output data into the controller. Although the output depends
on the users balance and lean-angel, make left, right, forward or backwards. When the
controller have received the output data from the process as an input. It starts to calculate
the changes that have occurred, the different states3, and gives an output to the process,
which will be the input, as seen Figure 1. The input signal will be the changed variables,
which furthermore will make it possible to balance and perform the usage of the
ElektorWheelie.

3
For more information see section 4.1

5
2. Objectives
The main objective for this project was to find a feasible controller that stabilizes the
ElektorWheelie in the best possible way. To be able to find the best feasible controller the
project was divided into several main objectives.

2.1 Analyze
To be able to gathering information about what to determine and perform is to analyze the
Segway. Without analysis there is no information to build up any conclusions. Without
conclusions it’s hard to be able to make any decisions.

2.2 Research
The objective for the research area was to understand the different parts in the Segway. The
main objective for the research part was to understand the technical information that was
given and try to find out some more. What includes for the technical information is for
instance how the sensors works, how the motors works, programming, mathematical
models for the Segway and analyze valuable data. Furthermore the given information given
during the research helped us to compute new information by our own knowledge.

2.3 Computing
The computing is the most important objective. The purpose is to compute the values that
matters and affect the Segway. This part shows how the Segway acts depending on how the
values differ. Furthermore a precision on the computing is very important to make the
process as accurate as possible.

2.4 Programming
To be able to use the ElektorWheelie it’s necessary to express all the computed and
determined parts into, in our case, BASIC with the BASCOM AVR language. So basically if
there is none computed parts there will not be any code to program since the programming
is based on the computed parts.

6
3. Theory
To understand how the Segway works in detail it’s important to introduce the inverted
pendulum.

3.1 inverted pendulum


You may have seen different kinds of implemented inverted pendulums i.e. Johan Åkessons
Two wheeled robot, Design and Control of YAIP4, but all gets to the same theory. An
inverted pendulum is a pendulum with its mass above its pivot point, see figure 2
(Websource2).

Figure 2 - Inverted pendulum on a linear chart - http://www-


srt.upb.de/fileadmin/SRT_Images/Rundgang/Pendel/pendulum_inv.gif

Compared to a normal pendulum whereas it’s stable when hanging the inverted pendulum is
normally unstable, therefore it must be actively balanced in order to remain the mass above
its pivot point. To be able to balance it you can either apply a torque at the pivot point or
move the pivot point horizontally, for example on a chart as part of a feedback system.

Figure 3 - Inverted pendulum on chart with wheels - http://en.wikipedia.org/wiki/File:Cart-pendulum.png

4
http://www.control.lth.se/documents/2006/ake+06cca.pdf

7
The inverted pendulum is a classic problem in control theory. The problem maintains the
same interest, i.e. used as a benchmark for testing control algorithms and therefore as
described above there is many variations. Furthermore the experimentations are wide
because of the widely usage of this problem, but except the Segway there is other areas of
the daily usage. For example the lifting cranes on shipyards during the transportation of
containers. The cranes move the box in such a precision that the containers never swings,
they are even perfectly positioned under the operator when moving or stopping the
containers quickly5 (Websource2).

5
http://en.wikipedia.org/wiki/Inverted_pendulum

8
4. The model

4.1 mat mod

Figure 4 - Simplified overview of the Segway-states



x
  x

  
 
   
   
 
     A    B
   
   
   
 
 y  Cx  D

The kinetic energy equals to:

v2 (rw) 2 w2 w2
Er   2
dm   2
dm 
2
 r 2dm  2
I


With I  r 2 dm ,which is the body’s moment of inertia



9
The Lagrangian function will be L = Kinetic Energy – Potential Energy, following:

L  Ek  E p
1 
mv2
L  IM  2   m l gcos( )
2 2
With : IM  M r 2

We have that:

d 2 d 2   


 v 2   (l cos( ))   (r   lsin( ))  (l  sin( )) 2  (r  l  cos( )) 2
dt  dt 
   
v 2  l 2  2 (sin 2 ( )  cos 2 ( ))  r 2  2  2 r l   cos( )

As we can see: sin2 ( )  cos 2 ( ) , equals to one: sin2 ( )  cos2 ( ) 1

 Therefore we get:

2  2 2  2   
v  l   r   2 r l   cos( )
2

We now get:

 1 
m      
L  Mr 2  2  l 2  2  r 2  2  2rl  cos( ) m g lcos( )
2 2  
1  ml2 2  
L  r 2  2 (M  m)    m r l   cos( )  m g lcos( )
2 2
We now use Euler-Lagrange:

 d L L
dt     
 

d L  L  
dt  




10
We simplify the equations:

L  
   m l   m r l  cos( )
2


L   d L    

 m r l   sin( )  m l gsin( ) dt   m l 2


  m r l(  cos( )    sin( ))

  
L  
d L  r 2  (M  m)  m r l(  cos( )   2 sin( ))
    
   r 2  (M  m)  m r l  cos( )
 dt 
 
L  0



d L    

dt   m l   m r l(  cos( )    sin( ))


2

 
 
d L  r 2  (M  m)  m r l(  cos( )   2 sin( ))
  

dt 


d L L      
dt    m l 2
  m r l(  cos( )    sin( ))  m r l   sin( )  m l gsin( )  
  

d L  L  r 2  (M  m)  m r l(  cos( )   2 sin( ))  0  
  

dt  


d L L  

dt    m l 2
  m r l  cos( )  m l gsin( )  
 

d L  L  r 2  (M  m)  m r l  cos( )  m r l  2 sin( )  
  

dt  


We now have:

 d L L  
dt     m l   m r l  cos( )  m l gsin( )  
2

 

d L  L  r 2  (M  m)  m r l  cos( )  m r l  2 sin( )  
  

dt  


For small angles we have:

 sin( )  
and
cos( )  1


11
Therefore we can rewrite the equations as:

d L L  

dt    m l 2
  m r l   m l g   
 

d L  L  r 2  (M  m)  m r l   m r l  2   
  

dt  


Furthermore we have:

  2  
m l   m r l   m l g   
   

r  (M  m)  m r l   m r l   
2 2

When we linearize we have:

  2  
m l     m r l   m l g  (1)
  

r  (M  m)    m r l 
2
(2)

 
If we now solve  and put into (1) we get:

  m r l 
  
r (M  m)
2
r (M  m)
2

 Now insertion in (1) will give us:

   m r l 
m l 2     m l g   m r l  2  2  
r (M  m) r (M  m) 

  m 2 r 2 l 2   m r l 
 m l 2   m l g     2 1
 r (M  m) 
2
r (M  m) 

m l 2 r 2 (M  m)  m 2 r 2 l 2  r 2 (M  m)  m r l 
   m l g     
 r 2 (M  m)   r (M  m) 
2

 (M  m)g r(M  m)  m l 
     2 
Ml  r l M m 

 12

Now, insertion of  into (2) will give us:

 (M  m)g r(M  m)  m l 


r 2  (M  m)    m r l      2 
 M l  r l M m 

  m r l (M  m)g r(M  m)  m l 


       
r (M  m)
2
r (M  m)  M l
2 2
 r l M m 



We can simplify this:

  1 mrl r(M  m) mrl ml  m g


     2 2  2  
r (M  m) r (M  m) Mmrl
2
r (M  m) Mmrl2  M r

 M m r l 2  m r 2 l(M  m)  m 2 r l 2  m g
     
 r 2 (M  m)M m r l 2  M r

 M l 2  M rl m r l  m l 2  m g
     
 r 2 (M  m)M l 2  M r

 l 2 (M  m) (M  m)r l  m g


     
 r (M  m)M l
2 2
  M r

 (l 2  r l)(M  m)  m g
    2 2  
 r (M  m)M l  M r

 (l 2  r l)  m g
    2 2  
 r M l  M r

 l  r  m g
   2  
r M l  M r

 lr mg
 2  
r lM Mr


13
So, now we have:

 (M  m)g r(M  m)  m l



  
 Ml r l2 M m

  l  r   m g 


 2
 r l M Mr

If we introduce:

  
x1   x
 1  x 2  
    
x 2   x 2  
   
x 3  

x  x  
    
3 4

x 4   
x 4  

We can rewrite:

  (M  m)g r(M  m)  m l



  
 Ml r l2 M m

  l  r   m g 


 2
 r l M Mr

Into a state-space form:

  
x1   0 1 0 0  0 
   (M  m)g x1   (M r  m r  m l) 
0 0 0  
x 2   M l x2 M m l 2r 
    0    
0 0 1x 3   0
x 3   m g   rl 
   


Mr

0 0 0 x 4 


 M l r2


x 4 

Which is x  A x  B 

4.2 Matlab/Simulink model
The statespace model and the motor model of the Elektor Wheelie where combined and

added to a Matlab script. This made it easy to develop and test the LQED estimater, LQRD
controller and the moving average filters on real data from the sensors and motors PWM
from the Wheelie. Being able to get nice plots.

4.3 Motor identification


A DC motor model relating the applied voltage to the motor and parameters in the state
space to the resulting torque of the motor

𝜏 = −𝛽1 𝜑 − 𝜃 + 𝛽2 𝑢

14
To estimate 2 a voltage to the motor was applied and then measuring the torque required
stopping the wheel from spinning. This was done for different voltages. The resulting points
are interpolated with a first degree linear polynomial. The resulting figure for the Elektor
Wheelie motor is in Figure 5 for 2. With a 2 = 3.6136 Nm/Volts.

Torque vs Voltage: Torque = 3.6136 * Volt - 1.4411


90

80

70

60

50
Torque [Nm]

40

30

20

10

-10
0 5 10 15 20 25
Voltage [Volt]

Figure 5 - Plot of the resulting torque versus applied voltage of the Elektor Wheelie DC motor

The parameter 1 in the DC motor model is estimated by measuring the revolutions of the
wheel in radianse after applying a voltage to the DC motor. Having a estimate of 2 and
letting the wheel spinn without applying a stopping torque the parameter 1 can be solved
for. The results after experiments are in Figure 6.

15
Scatterplot of Beta1: Mean value = 0.3626
1.6

1.4

1.2

0.8
Beta1

0.6

0.4

0.2

-0.2
0 5 10 15 20 25
Measurement

Figure 6 - ters

16
5. Methodology
The methods were in general to derive controller offline using Matlab, and later test the
controller on the real process, with some safety measures.

5.1 Safety during experiments


Because the Elektor Wheelie weighs 35kg and has two 450W DC motor it is a dangerouse
thing and can hurt people. This is why the power to the DC motors goes through a relay
controlled by the rider of the Wheelie with a handbrake switch. It is a mechanical solution
not affected by the firmware in the Wheelie. In parallel to the handbrake was also a
killswitch button serving as a dual killswitch for the power to the motors. This killswitch can
be removed manually. During motorparameter identification the Wheelie was raised from
the ground to make it safe and easy to measure the parameters. When developing the
controller the serialport data from the wheelie displaying the motor PWM is a must to be
safe.

5.2 State Estimation


To be able to control the segway it is crucial to know the angle and the angle velocity
for the segway body. The only two sensors that were used were a gyroscope and an
accelerometer. A number of different ways of estimating these states were
considered during the project. The first way was a complementary function where
the accelerometer is used for low frequencies and the gyroscope is used for high
frequencies. In that way each sensor is used in the area in which they have good
properties. The second way is to use a kalman filter on the mathematical model with
the gyroscope as an input for angle velocity and the accelerometer as an input for
the angle. The third and last way and the way that was chosen for this project is to
use the fact that the accelerometer and gyroscope can be described by the following
equations.

𝑦𝑔𝑦𝑟𝑜 = 𝛩 + 𝑑 + 𝑤1 (1)

𝑦𝑎𝑐𝑐 = 𝛩 + 𝑣1 (2)

𝛩 = 0 −1 𝛩 1 𝑤1
+ 𝑦𝑔𝑦𝑟𝑜 + 𝐺 𝑤
d 0 0 𝑑 0 2
𝛩
𝑦𝑎𝑐𝑐 = 1 0 + 𝑣1
𝑑
This is a system with the gyroscope signal as input and accelerometer signal as
output and hence a kalman filter can be derived to estimate the states. Equation (1)
describes the signal from the gyroscope really good, the angle velocity but with a
drift is exactly what this signal is. Equation (2) is not that good as the accelerometer
is really measuring both the angle and the acceleration when the segway is going
backwards and forwards. The acceleration is because of this considered as noise.

17
The next thing to be done is to make a kalman filter for this system. As this system is
written in normal state space form this is not very hard to achieve. Below are the
system equations for a kalman filter.

𝑥 = 𝐴𝑥 + 𝐵𝑢 + 𝐾(𝑦 − 𝐶𝑥 )
𝑦 = 𝐶𝑥

This can be written as

𝑥 = (𝐴 − 𝐾𝐶)𝑥 + 𝐵𝑢 + 𝐾𝑦
𝑦 = 𝐶𝑥

The estimation of the states angle and drift from the kalman filter is then actually the
output from the following system.

𝛩 = 𝐴𝑒 𝛩 + 𝐵𝑒 𝑦𝑔𝑦𝑟𝑜
𝑦𝑎𝑐𝑐 𝐴𝑒 = 𝐴 − 𝐾𝐶 𝐵𝑒 = 𝐵 𝐾
𝑑 𝑑 With 1 0
𝐶𝑒 =
𝑦 = 𝐶𝑒 𝛩 0 1
𝑑
The only thing that is needed know to get this system is the K which completes this
kalman filter. The Matlab command lqe was used to get a good K. After this the
continuous system has to be discretizised which was done with the Matlab command
c2d. Actually these two commands were used over and over again and the kalman
filter was then tested in Matlab with some data which was collected from the actual
process. This way the inputs to the lqe command was tuned to get a good kalman
filter.

5.3 LQR
To control the process, state feedback was used where the gain on different states was
calculated with a discrete linear quadratic regulator in Matlab, based on the mathematical
model of the process and the motor. The feedback gains on different states are calculated
offline in Matlab with the command lqrd. This control gives feedback on all the three states
(body angle, body angle rate, and wheel angle rate).The lqrd needs some design parameters
on the weighting matrices for both the importance of states, and the cost of the control
signal. The feedback vector L is then used to close the loop with the feedback law

(1) 𝑢 = −𝐿𝑥

Where L minimizes the cost function



(2) 𝐽 = 0
𝑥 𝑇 Q 𝑥 + 𝑢𝑇 𝑅 𝑢 𝑑𝑡

Q is the weighting of the states and R is the cost of control signal.

18
5.4 Filters
Sensors often have some kind of noise and sometimes it is needed to filter the
signals. On the process concerned in this project there are three sensors. The
gyroscope, the accelerometer and the rocker. All three of them needed some kind of
low pass filter because of some high frequency noise. Especially the accelerometer
had to be filtered as the signal also consists of the acceleration which is considered
as noise. The acceleration was seen as big spikes in the signal and these spikes
occurred because of some backlash in the motors making the segway to shake while
standing still. There is almost an infinite amount of low pass filters to choose from
but some sophisticated filter is not needed in this case. The reason for this is that a
perfect signal is not needed and it will be implemented in a microcontroller. The kind
of filter chosen was an easy moving average filter.

19
6. Time plan
The project was lagging behind the original time plan quite early due to mathematical model
taking a bit longer then we thought. This made us abandon our plans on testing different
kind of controllers and we went straight for LQR. A lot of time was spent trying to derive and
implement a controller in Simulink. After a couple of weeks we were more and more lacking
behind our time plans, we realized that we were travelling down a sidetrack. In study week 7
we made a big breakthrough and the segway could stabilize. We had thus used up both of
our reserve weeks and still got a report to finish. Testing different controllers, as well as
improving steering and start up did not get the time that we had wished.

20
7. Findings

7 .1 State estimation
We tuned the kalman filter quite a bit to get a good estimation. To tune the filter
there is three weights that are changed to get a good explanation of how much noise
there is on each signal. We knew that we should trust the gyroscope more than the
accelerometer because the accelerometer has dynamics not described in the model.
The weight on the drift was known to be quite small as the drift is a slow change in
the gyroscope. After some tuning we got the following.

𝛩 = 0 −1 𝛩 1 𝑤1
+ 𝑦𝑔𝑦𝑟𝑜 + 𝐺 𝑤
𝑑 0 0 𝑑 0 2
𝛩
𝑦𝑎𝑐𝑐 = 1 0 + 𝑣1
𝑑
1 0
𝐸(𝑤𝑤 𝑇 ) = 𝑄 = 𝐸(𝑣𝑣 𝑇 ) = 𝑅 = 10
0 4

Here the first element in Q is saying how big the noise is on the gyroscope; the last
element in Q is how big the noise is on the drift, i.e. how fast the drift is changing. R
is saying how big the noise is on the accelerometer. As can be seen the parameters
we finally settled for is kind of expected with a large noise on the accelerometer, this
is basically saying that we trust more on the gyroscope. With these inputs to the lqe
command we get 𝐾 = (1.1683 − 0.6325)𝑇 which get the following kalman filter.

𝛩 = −1.1683 −1 𝛩 1 1.1683 𝑦𝑔𝑦𝑟𝑜


+ 𝑦𝑎𝑐𝑐
𝑑 0.6325 0 𝑑 0 −0.6325
1 0 𝛩
𝑦=
0 1 𝑑
When this system is discretizised with the sample time of ten milliseconds we get the
following system.

𝛩 = 0.9884 −0.009942 𝛩 0.009942 0.01165 𝑦𝑔𝑦𝑟𝑜


+ 𝑦𝑎𝑐𝑐
𝑑 0.006288 1 𝑑 3.15e − 005 −0.006288
1 0 𝛩
𝑦=
0 1 𝑑
This system was then implemented in the microcontroller.

7.2 LQR results


In the end, feedback was only used on two of the three states. The reason for not using
feedback on the wheel angle rate is both that a sensor for good measurement was lacking to

21
do so. Estimation of the wheel velocity was made based on the mathematical model and the
estimation of 𝛩 and 𝛩 that was made in the LQE kalman filter, these estimation seemed
however to be a bit unreliable and was disregarded in the feedback loop after some testing.
Another reason to not use the third state in the feedback is that the controller would then
like to force the segway to stand still, which apparently is not optimal for a transportation
vehicle.

The weightings were made so that the body angle 𝛩 was most important to control to the
reference value (upright position), and the weighting on the third state was put to zero.

The Q matrix was chosen as

700 0 0
𝑄= 0 0.01 0
0 0 0

and R = 0.05 which resulted in the gain matrix

𝐿 = −155.9850 −28.5053 −0.7061

(only first two states used).

7.3 Filters
As said before we chose a moving average filter for our sensors. A moving average
filter can be implemented in a number of different ways but as this is done online we
can only use old data for filtering. There is also different ways to implement an online
moving average filter with for example different weights for older data and so on. We
chose the easiest one with the weight one for every old data. To save memory in the
microcontroller we did not save all the old data but instead we had a sum which we
updated in the following way.

𝑛−1
𝑆 𝑘 = 𝑆 𝑘−1 +𝑦 𝑘
𝑛

Where n is the number of data points we take the average over.

𝑆(𝑘)
𝑦𝑎𝑣𝑔 (𝑘) =
𝑛
We averaged the gyroscope and the accelerometer over twenty data points and the
rocker over ten data points. As a moving average filter like this actually delays the
real signal, we had to find a number where we had a good low pass filtering and at
the same time not a too long delay. We found out that as we had a delay on the
signals with this filter we really had to have the same length both on the gyroscope
and the accelerometer. If we did not have this the signals was not working together
and we did not get a good estimation.

22
8. Discussion
The segway ended up with a state feedback controller where two out of three states was
used. The final code did succeed with both the balancing problem, and even removed a big
part of the “backlashing”-like effect that occur. The segway now demands more tilt to get to
same speeds as the original code did. We spent a lot of time on the mathematical model
aswell as the simulink models. However our simulink models were build with two Kalman
filters, a method we later threw away. After that sidetrack was corrected, it went quite fast
and only fine tuning remained.

The things that have made the biggest improvements in comparison to prior code are the
filtering that we applied to the steering, and the ramping of the control signal during the
start up.

8.1 Future improvements


There are still elements in our controller that can be improved. For example how aggressive
the steering should be at different speeds and how much the speed changes when you lean
forward and backwards. The startup could also be improved further to make it easy when
stepping on the Wheelie. Hardware to simplify adding these features would be an encoder
giving a voltage proportional to the wheel. An extra step-on button for detecting when both
feet are on the segway. That would be nice. A means to measure the voltage and current to
the motors would be a nice added feature. Right now you can only receive RS232 data from
the Wheelie. A nice feature would be to also send data to the Wheelie.

8.2 Sidetracks
For quite some time in the middle of the project we tried to use two different Kalman filters,
one that was based on the Kalman filter in YAIP by Johan Åkesson, and one that calculated
all three states based on the mathematical model we had derived. The original reason for
these attempts where that we wanted to estimate the wheel angular velocity as well as the
two other states. Our simulink models used this method. When we finally removed this filter
and only used the feedback that was calculated from the mathematical model we
implemented it on the real process due to time limit.

Another sidetrack we explored was how the different states were declared. More specifically
we initially used 𝛳 ,𝛳 , x and 𝑥 where x and 𝑥 is the forward position and velocity.
It is of course closely related to wheel angle, and wheel angle rate, and the reason we chose
wheel angle was mainly to make the comparison of our mathematical model with known
models easier.

23
Reference

Websource1: (2010-06-08) - http://en.wikipedia.org/wiki/Segway_PT

Websource2: (2010-06-08) - http://en.wikipedia.org/wiki/Inverted_pendulum

24

S-ar putea să vă placă și