• No results found

Institutionen för systemteknik Department of Electrical Engineering

N/A
N/A
Protected

Academic year: 2021

Share "Institutionen för systemteknik Department of Electrical Engineering"

Copied!
97
0
0

Loading.... (view fulltext now)

Full text

(1)

Institutionen för systemteknik

Department of Electrical Engineering

Examensarbete

LEAP

A Platform for Evaluation of Control Algorithms

Examensarbete utfört i Datorseende vid Tekniska högskolan i Linköping

av

Kristoffer Öfjäll LiTH-ISY-EX--10/4370--SE

Linköping 2010

Department of Electrical Engineering Linköpings tekniska högskola

Linköpings universitet Linköpings universitet

(2)
(3)

LEAP

A Platform for Evaluation of Control Algorithms

Examensarbete utfört i Datorseende

vid Tekniska högskolan i Linköping

av

Kristoffer Öfjäll LiTH-ISY-EX--10/4370--SE

Handledare: Fredrik Larsson

isy, Linköpings universitet

Examinator: Michael Felsberg

isy, Linköpings universitet

(4)
(5)

Avdelning, Institution

Division, Department

Computer Vision Laboratory Department of Electrical Engineering Linköpings universitet

SE-581 83 Linköping, Sweden

Datum Date 2010-06-01 Språk Language  Svenska/Swedish  Engelska/English   Rapporttyp Report category  Licentiatavhandling  Examensarbete  C-uppsats  D-uppsats  Övrig rapport  

URL för elektronisk version http://www.cvl.isy.liu.se http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-56733 ISBNISRN LiTH-ISY-EX--10/4370--SE

Serietitel och serienummer

Title of series, numbering

ISSN

Titel

Title

Labyrintbaserad plattform för algoritmutvärdering LEAP

A Platform for Evaluation of Control Algorithms

Författare

Author

Kristoffer Öfjäll

Sammanfattning

Abstract

Most people are familiar with the brio labyrinth game and the challenge of guiding the ball through the maze. The goal of this project was to use this game to create a platform for evaluation of control algorithms. The platform was used to evaluate a few different controlling algorithms, both traditional automatic control algorithms as well as algorithms based on online incremental learning.

The game was fitted with servo actuators for tilting the maze. A camera together with computer vision algorithms were used to estimate the state of the game. The evaluated controlling algorithm had the task of calculating a proper control signal, given the estimated state of the game.

The evaluated learning systems used traditional control algorithms to provide initial training data. After initial training, the systems learned from their own actions and after a while they outperformed the controller used to provide initial training.

Nyckelord

(6)
(7)

Abstract

Most people are familiar with the brio labyrinth game and the challenge of guiding the ball through the maze. The goal of this project was to use this game to create a platform for evaluation of control algorithms. The platform was used to evaluate a few different controlling algorithms, both traditional automatic control algorithms as well as algorithms based on online incremental learning.

The game was fitted with servo actuators for tilting the maze. A camera together with computer vision algorithms were used to estimate the state of the game. The evaluated controlling algorithm had the task of calculating a proper control signal, given the estimated state of the game.

The evaluated learning systems used traditional control algorithms to provide initial training data. After initial training, the systems learned from their own actions and after a while they outperformed the controller used to provide initial training.

Sammanfattning

Många känner till och har provat labyrintspelet från brio. Målet med detta projekt var att skapa en plattform baserat på detta spel för att utvärdera styralgoritmer. För att visa några av möjligheterna med plattformen har olika styralgoritmer implementerats och utvärderats.

Styralgoritmen som utvärderas har möjlighet att styra spelet genom två servon. En kamera tillsammans med datorseendealgoritmer används för att skatta tillståndet hos spelet.

Bland de utvärderade styralgoritmerna finns några som är baserade på självlärande system. Dessa är designade för att startas helt olärda. En traditionell styralgoritm används för att generera träningsdata i början varefter det lärande systemet tar över kontrollen och fortsätter lära. Efter en stunds träning presterar det lärande systemet bättre än styralgoritmen som genererat träningsdata.

(8)
(9)

Acknowledgments

Many people have contributed, directly or indirectly, to this work. I would like to thank my examiner Michael Felsberg and my supervisor Fredrik Larsson for supporting the idea of the labyrinth platform and for providing many new ideas. As the number of possible ways of using the platform seem to far outweigh the time available, the help of selecting what to do and what not to do, has been greatly appreciated.

I would also like to thank my fellow masters students and all people at the Com-puter Vision Laboratory for fruitful discussions in the masters’ room as well as in the fika1room. The people of the Automatic Control group also deserves

mention-ing albeit most of the ideas related to automatic control were not implemented. Finally, I would like to thank all my new and old friends making my time spent at the university really enjoyable.

1A verb indicating ingestion of coffee, tea or such in combination with pastries and/or cookies,

often in a social context. The word may also be used as a noun referring to an occurrence of the said act.

(10)
(11)

Contents

1 Introduction 5 1.1 Goal . . . 6 1.2 Outline . . . 6 2 System Overview 9 2.1 Hardware . . . 9 2.1.1 Terminology . . . 10 2.2 Software . . . 12

2.2.1 The Leap Software . . . . 12

2.2.2 The User Interface . . . 14

2.2.3 The Record Viewer . . . 14

3 Background Theory 17 3.1 Control . . . 18

3.1.1 Dynamic Systems . . . 18

3.1.2 Traditional Automatic Control . . . 19

3.1.3 Learning System . . . 19

3.1.3.1 Locally Weighted Projection Regression . . . 19

3.2 Estimation . . . 22

3.2.1 Motivation . . . 22

3.2.2 Homography Estimation . . . 22

3.2.3 Marker Detection and Tracking . . . 24

3.2.3.1 Detection . . . 24

(12)

3.2.3.2 Tracking . . . 25

3.2.4 Background Model . . . 25

3.2.4.1 Approximate Median Background Model . . . 25

3.2.4.2 Gaussian Mixture Model . . . 26

3.2.5 Kalman Filter . . . 28

4 Hardware 31 4.1 Controlling the Game . . . 32

4.1.1 Controlling the Servos . . . 33

4.2 Vision Hardware . . . 34 4.3 Alternative Maze . . . 35 4.4 Hardware Model . . . 36 4.4.1 Physical Modeling . . . 36 4.4.2 Identification . . . 38 5 Experimental Setup 41 5.1 Performance Measure . . . 42

5.2 The Target Point Algorithm . . . 43

5.3 Adapting the Pid Controller . . . . 44

5.4 Mappings for the Learning System . . . 44

5.5 Evaluation Scenarios . . . 46

5.5.1 Scenario 1: Simple Trajectory . . . 46

5.5.2 Scenario 2: Simple Trajectory with Modified Behavior . . . 46

5.5.2.1 Scenario 2a: Offset Change . . . 48

5.5.2.2 Scenario 2b: Reverse Control . . . 48

5.5.3 Scenario 3: The Brio Maze . . . . 48

6 Results and Discussions 51 6.1 Data Presentation . . . 51

6.2 Scenario 1: Simple Trajectory . . . 52

6.2.1 Discussion . . . 52

6.3 Scenario 2: Simple Trajectory with Modified Behavior . . . 54

(13)

Contents xi

6.3.1.1 Scenario 2a . . . 54

6.3.1.2 Scenario 2b . . . 55

6.4 Scenario 3: The Brio Maze . . . . 59

6.4.1 Discussion . . . 59

6.5 Final Results . . . 62

7 Conclusions and Future Work 65 7.1 The Platform . . . 65

7.2 The Evaluated Controlling Algorithms . . . 66

7.3 Future Work . . . 67

Bibliography 69 A Software 71 A.1 The Leap Software . . . 72

A.1.1 Multithreading . . . 72

A.1.2 The Frame . . . 74

A.1.3 The Frame Cycle . . . 74

A.1.4 The Leap Interface . . . . 76

A.1.5 The Data Logging Subsystem . . . 76

A.1.5.1 The Message Queue . . . 76

A.1.5.2 The Frame Queue and Frame Writing . . . 77

A.1.5.3 The Timing Module . . . 77

A.1.6 The Image Source Subsystem . . . 78

A.1.6.1 The Camera Module . . . 78

A.1.6.2 The Vision Routines . . . 79

A.1.7 The Controller Subsystem . . . 80

A.1.7.1 The State Estimation Filter . . . 81

A.1.7.2 The Controller Container . . . 81

A.1.7.3 Controlling Algorithms . . . 81

A.1.7.4 The Control Signal Output Module . . . 82

A.2 The User Interface . . . 82

(14)
(15)

List of Figures

2.1 The system . . . 10 2.2 Terminology . . . 11 2.3 System overview . . . 13 2.4 User interface . . . 15 3.1 Pid controller . . . 18 3.2 Learning controller . . . 20 3.3 Image rectification . . . 24 4.1 The game . . . 32 4.2 Servo installation . . . 33 4.3 Vision marker . . . 34 4.4 Alternative maze . . . 35 5.1 Rmsoe illustration . . . 42

5.2 Illustration of the target point algorithm . . . 43

5.3 Target trajectory for scenarios 1, 2a and 2b . . . 47

5.4 Target trajectory for scenario 3 . . . 49

6.1 Scenario 1 results . . . 53

6.2 Scenario 1 raw results . . . 53

6.3 Scenario 2a results . . . 56

6.4 Scenario 2b results . . . 56

6.5 Lwpr-4 trajectories for runs 200-203, scenario 2b . . . 57

6.6 Lwpr-4 trajectory for run 204, scenario 2b . . . 57

6.7 Pid controller trajectories, scenario 2a . . . . 58

6.8 Scenario 3 results . . . 60

6.9 Lwpr-4 trajectories for early runs, scenario 3 . . . 61

6.10 Lwpr-4 trajectories for late runs, scenario 3 . . . 61

(16)
(17)
(18)
(19)

1

Introduction

The brio labyrinth game has challenged humans since 1946. The objective is simple: guide the ball through the maze by tilting the plane while avoiding the holes. Most people who have tried it can tell that in practice, the game is really not that simple. By means of computer vision and servo actuators, the challenge can now be handed over to the machines.

There exist numerous algorithms for learning systems and automatic control. The Labyrinth Evaluation of Algorithms Platform, leap, is able to test how well these algorithms cope with reality. If the evaluated algorithm fail to complete the orig-inal maze, the difficulty can be adjusted by using alternative mazes.

(20)

1.1

Goal

The stated goal of this project has been to develop an evaluation platform for learning systems and automatic control algorithms. In order to achieve this, two main issues have been addressed. First, the evaluated algorithm has had to know the position of the ball. Secondly, this algorithm has had to be able to affect the game. Additionally, everything has had to be done in real time.

To achieve the stated goal, the labyrinth game has been fitted with computer controlled actuators. Computer vision has been used to enable the algorithm-at-test to receive information regarding the position of the ball. In addition to the software necessary to extract the position of the ball from the camera images, a few different control algorithms have been implemented.

Another goal has been to enable almost arbitrarily positioning of the camera rel-ative to the labyrinth, only requiring that the maze should be visible from the camera position and cover a significant part of the image.

1.2

Outline

Chapter 2 contains a brief overview of the system and its main components. Terms used to refer to specific parts of the system are introduced.

In chapter 3, a summary of the main algorithms used in the system is provided.

A thorough description of the system hardware is available in chapter 4. The system software is thoroughly described in appendix a. The software appendix is intended for the reader interested in implementation details and is not necessary in order to understand the remainder of this thesis.

The experimental setup used when evaluating the controlling algorithms is pre-sented in chapter 5. Results and discussions regarding these experiments can be found in chapter 6.

Finally, in chapter 7, conclusions regarding the performed experiments and the evaluation platform itself are presented. The chapter also contains ideas for future work.

(21)
(22)
(23)

2

System Overview

In this chapter an overview of the system is presented. This chapter is divided into two sections presenting the hardware and software respectively. The terminology used to refer to specific hardware parts of the system is introduced in section 2.1.1. An image of the system is shown in figure 2.1 and a schematic view of the system is presented in figure 2.3.

2.1

Hardware

The leap1 hardware consists of a Labyrinth game, servo actuators and a camera.

A desktop computer is used to run the software. The game is based on a standard brio labyrinth game which has been slightly modified in order to allow a com-puter to control the game. More details regarding the hardware can be found in chapter 4.

The modification of the labyrinth game consists of adding two standard servos usually used in radio controlled vehicles. Instead of using a radio receiver to control the servos, the servos are connected to a controller card that directly interface the computer.

A camera is used to capture images of the game from which the state of the game can be estimated.

1Labyrinth Evaluation of Algorithms Platform

(24)

Figure 2.1. The leap system.

2.1.1

Terminology

The different parts of the system are denoted as follows. In this section, numbers within parentheses refer to labels in figure 2.2.

The game frame(1) of the labyrinth consists of the red part of the game which has contact with the supporting surface, normally a table, and in its turn supports the other parts of the game.

Attached to the game frame is the outer gimbal ring(2) or just outer gimbal. The outer gimbal is attached to them game frame in a way that allows rotation of the ring relative to the game frame around an axis parallel to the supporting surface.

Attached to the outer gimbal ring is in its turn the inner gimbal ring(3) or simply the inner gimbal. The inner gimbal is free to rotate relative to the outer gimbal around an axis orthogonal to the axis of rotation between the frame and the outer gimbal. When the outer gimbal ring is in its neutral position, the axis of rotation between the inner and outer gimbals is parallel to the supporting surface.

The maze(4) is the part of the game that may contain holes and obstacles. This is where the ball will move unless it falls through a hole. The maze is rigidly attached to the inner gimbal ring. The maze may be exchanged with mazes of different difficulty. The two gimbal rings allow the normal of the maze to obtain an arbitrary orientation relative to the game frame.

(25)

2.1 Hardware 11 1 2 3

4

5 5 5 5 6 7 8 1 2 3 4 5 6 7 8 Frame Outer gimbal Inner gimbal Maze Marker Outer servo Inner servo Ball collector

Figure 2.2. The game with some of its parts marked. See section 2.1.1.

dimensional cartesian coordinate system in a plane coinciding with the maze. The origin is fixed in one of the corners of the maze and the coordinate system uses millimeters as units of length. To estimate the orientation of the maze relative to the camera, there are four markers, each marked with number 5 in figure 2.2. Attached to the frame are also the two servos controlling the tilt of the gimbal rings by means of ball joints and control rods. Each of the two servos are connected to one of the outer and inner gimbal ring respectively. When it is necessary to distinguish between the two servos, they are called the outer servo(6) and the inner servo(7) respectively. The outer servo is the servo controlling the outer gimbal ring while the inner servo control the inner gimbal ring.

When referring to the axes of the maze plane coordinate system, the terms outer direction and inner direction are used. All these outer and inner terms have a logical connection. As an example, changing the deflection of the outer servo causes the outer gimbal ring to move relative to the frame. Depending on the position of the ball, this will probably change the component in the outer direction of the acceleration of the ball .

A servo controller card is used to generate control pulses to the servos.

The ball ejection plate is a tilted plate attached inside the frame making the ball travel to the ball collector (8) if the ball falls through a hole in the maze.

(26)

2.2

Software

The software in the system may be further divided into the leap software, the user interface and the record viewer. Note that the user interface, which enables the user to interact with the leap software, is dependent on the operating system, and not a part of the leap software. More details regarding the software can be found in appendix a.

Within the leap software resides the controlling algorithm, that is, the algorithm being evaluated.

In this section and in appendix a, the term frame is used frequently. In the context of the software, a frame refers to an image with some additional data belonging to that image.

2.2.1

The L

EAP

Software

The leap software is the central part of the system performing tasks such as capturing and analyzing images, estimating the state of the system as well as calculating the control signal and sending this to the servo controller.

The controlling algorithm is one of the core components within the leap software. The purpose of the controlling algorithm is to calculate the appropriate control signal given the estimated state of the system.

By changing controlling algorithms, the performance of different algorithms may be measured and compared. In the leap system, there might be several controlling algorithms loaded at the same time. The algorithm actually controlling the game is called the active controlling algorithm. The active controlling algorithm may be changed at any time while the system is running.

As a part of the image analysis needed to estimate the state of the game, the images acquired from the camera are rectified. This means that the images are resampled to a grid aligned with the maze. To do this, the positions of four markers in the image are found and tracked. If these markers can not be found automatically, their initial positions may be supplied from the user interface.

The leap system uses mulithreading to be able to do several things simultaneously. This is primarily needed in order to be able to capture and process new frames while waiting for old frames to be written to disk. Writing old frames to disk provides for offline analysis of data and offline training of learning systems.

(27)

2.2 Software 13 UI SoftwareLEAP RV File SCC RV UI SSC Record Viewer User Interface Servo Controller Card Software

Hardware

(28)

2.2.2

The User Interface

As the name suggests, the user interface acts as an interface between the leap software and the user. Starting the user interface will start the rest of the leap system. The user interface can be seen in figure 2.4.

Via this graphical interface the user may control the leap software to: • Start and stop capturing of images.

• Start and stop writing of images, control signal and state data to file.

• Load and save controlling algorithms.

• Change the active controlling algorithm.

• Change parameters in the loaded controlling algorithms.

• View the image captured by the camera as well as the rectified image. In-formation regarding the state of the system is superimposed on the images.

• Manually initialize the marker tracker.

2.2.3

The Record Viewer

When running the system, images and data may be saved to disk. Using the record viewer, these data can be played back and analyzed. The images may also be exported as bit mapped pictures.

As the recorded data also contain the full state of the system as well as the ap-plied control signal, the record viewer may use the recorded data to train learning systems offline. As the data files usually are of considerable size (approximately 15 megabytes per recorded second), image data may be removed to reduce the file size and facilitate faster training.

(29)

2.2 Software 15

(30)
(31)

3

Background Theory

To play the game, some kind of control signal has to be applied. The proper control signal is dependent on the current as well as the desired state of the game. In section 3.1, a few methods able to generate the control signal, given the current and the desired state, are presented.

To estimate the current state, methods from section 3.2 may be used.

How the desired state is generated depends on the performed experiment. The generation of the desired states used in the performed experiments in this thesis are described in chapter 5.

(32)

System

+

-

PID y(t) u(t) e(t) Reference

Figure 3.1. A system controlled by means of a pid controller.

3.1

Control

The platform is designed to be used for evaluating different ways of controlling the game. To demonstrate the functionality of the platform, a few different controlling algorithms are implemented. In addition to the automatic control algorithms described below, it is also possible to control the game manually by means of a joystick.

3.1.1

Dynamic Systems

Consider a system currently in state x, applying a control signal u will put the system in another state x+. A system is said to be dynamic if the new state x+

does not only depend on the applied control signal u but also on the old state x.

One first approach to control such a system might be to consider the difference between the output of the system and a desired output from the system. This difference is called the control error. The control signal can be choosen propor-tional to the control error. By considering how the control error change over time, a better control algorithm may be created. This is done, to some extent, in the pid controller described in section 3.1.2.

A model of the system can be used to predict the resulting new state x+, given

the current state x and the applied control signal u. Using the system model, a controller more tuned to the current system can be calculated.

If the system model is invertible, the so called inverse dynamics can be calculated. This can be used to directly calculate the control signal given the curret state and a desired state. Another option is to directly estimate the inverse dynamics from measured system data. This is the approach used by the learning system in section 3.1.3.

(33)

3.1 Control 19

3.1.2

Traditional Automatic Control

The traditional automatic control is in this thesis represented by a pid controller. An introduction to pid controllers and control theory in general can be found in [6]. A general pid controller is described by

u(t) = P e(t) + Dde(t) dt + I

t Z

0

e(τ ) dτ (3.1)

where u(t) is the control signal and e(t) is the control error.

The parameters P , I and D are used to adjust the influence of the proportional part, the derivative part and the integrating part respectively. A schematic view of a system containing a pid controller can be seen in figure 3.1.

The derivative part usually stabilizes the system as the control signal is reduced when the system moves toward the reference. The integrating part may remove any static control error. In the case of the leap system, the integrating part applies the control signal needed to keep the maze horizontal.

3.1.3

Learning System

Using learning systems, the inverse dynamics might be learned instead of modeled.

Consider a system currently in state x, applying a control signal u will put the system in another state x+. Learning the inverse dynamics means that given the current state x and a desired state x+, the learning system should be able to estimate the required control signal u bringing the system from x to x+. In figure 3.2, the learning system in the left box should produce a control signal based on the current and desired state of the system.

This can be seen as approximating the mapping

 x x+



→ u . (3.2)

There are several ways of expressing the system state as well as there are several algorithms useful for learning the mapping in equation (3.2).

3.1.3.1 Locally Weighted Projection Regression

For learning the mappings above, Locally Weighted Projection Regression, lwpr, may be used [11]. The idea is to use the output from several local linear models weighted together to form the output. The parameters of these models are adjusted online by the algorithm to fit the training examples presented to the learning system.

(34)

u=f(x,x+)

System

Desired state Current state

Output Control signal

Figure 3.2. A system controlled by a learning system.

In lwpr, the output from the K local models are weighted together as ˆ y = PK k=1wkyk PK k=1wk (3.3)

to form the output of the system. In the equation yk and wk are the output and weight for each local model. The output of the whole system is denoted ˆy. In this section, k will be used to index the local linear models.

The weight, wk, for each local model is determined by the distance from the input to the center of the respective local model in input space. Each local model has its own distance metric described by the matrix Dk. The distance metric is subject to change as the area of validity of the local model is discovered.

The center of the local model, ck, is set when the local model at hand is created whereafter it does not change. Employing a Gaussian kernel, the weight for a certain local model k when presented with the input x is calculated as

wk= exp  −1 2(x − ck) T Dk(x − ck)  . (3.4)

When creating a new local model, the matrix Dkis usually set to a diagonal matrix and the lwpr algorithm may be set to keep the distance matrix diagonal. Each local model consists of a few linear one-dimensional function approximations along different directions in the input space. Each projection direction and its corresponding linear coefficient is adjusted to fit the training examples.

The output of each local model is calculated as

yk = βk0+ rk

X i=1

βk,iuTk,i(xk,i− x0k) (3.5) where rk is the number of projection directions in the current model k, βk0and x0k is the mean of input and output training data seen so far, uk,i are the projection directions and βk,i the corresponding regression variables.

(35)

3.1 Control 21

The input is in xk,i, where xk,1= x is the unaltered input and xk,i+1is generated from xk,i by removing the part of the input-output relation explained by the projection regression i.

When the system has several outputs, one independent lwpr network is created for each output. The lwpr algorithm is more thoroughly described in [11]. The choice of variable names in this short presentation is mostly consistent with the mentioned paper. Some exceptions have been made where this makes the variables more easily distinguishable.

Partial Least Squares

To find the projection directions ui and the linear coefficients βi used in lwpr,

Partial Least Squares, pls, is used. The basic idea of pls is presented below. A more compact description of the algorithm using matrix notation is available in [11].

Given a set of input vectors x1, . . . , xn and corresponding outputs y1, . . . , yn, pls projects and regresses the data along r orthogonal directions. For i = 1, . . . , r, the following steps are performed:

First, the direction, ui, within the input space with maximum correlation with the output is found as

ui= n X j=1

yjxj. (3.6)

Note that any non-spherical distribution of the input vectors xj will bias the projection direction. The input vectors are projected onto ui according to

si,j = xTjui, j = 1, . . . , n. (3.7)

The parameter βi in the linear model y = βis is fitted to the projections in a least squares1 manner according to

βi= Pn j=1yjsi,j Pn j=1s 2 i,j . (3.8)

Finally, the residual error is calculated and used as data for the next iteration. This is done according to

yj = yj− si,jβi j = 1, . . . , n (3.9)

xj= xj

si,jui |ui|2

j = 1, . . . , n. (3.10)

In lwpr, this algorithm is implemented in an incremental fashion. Also, (3.10) is modified to make the distribution of x1, . . . , xn more spherical each iteration.

1Minimizing 

i=P n

j=1(yj− βisi,j)

(36)

3.2

Estimation

For the controllers to be of any use, the state of the system has to be known or at least estimated. In this section, some algorithms used to estimate the state of the game are presented. A short motivation for the use of these algorithms is presented in 3.2.1.

3.2.1

Motivation

The state of the system might, among other variables, contain the position and velocity of the ball. These should preferably be expressed in a coordinate system fixed to the maze, as the maze move when the game is played. To estimate the state, images of the game are captured.

Assuming the maze is approximately planar and that the used camera can be described well enough by the pinhole camera model, a homography may be es-timated and used to transform the image to the maze plane coordinate system. As expressed in section 3.2.2, this requires four points and their corresponding projections on the camera sensor to be known.

The maze is fitted with four markers and a method for finding the projections of the markers is described in section 3.2.3.

Given these rectified images, the position of the ball has to be found. This may be done by creating a model of the background and look for any difference between the rectified image and the background model. Different ways of creating a background model are presented in section 3.2.4.

Finally, given the position of the ball, the remaining state variables have to be estimated. This is possible using a Kalman filter and a model of the system. The Kalman filter is described in section 3.2.5.

3.2.2

Homography Estimation

A homography may be used to describe the mapping of points on a plane to an image sensor in a camera. This is shown in [4]. In this case, the hyperplanes have two dimensions. Using homogenous coordinates, the homography may be described by a three by three matrix H as

  x y 1  ∼ H   u v 1  =   ˆ h11 ˆh12 ˆh13 ˆ h21 ˆh22 ˆh23 ˆ h31 ˆh32 ˆh33     u v 1  . (3.11)

In the equation, (u, v) is the coordinates in the image of the projection of a point (x, y) on the plane. This is illustrated in figure 3.3. The point (u, v) in the camera image corresponds to the point (x, y) in the maze.

(37)

3.2 Estimation 23

The notation a ∼ b is used to indicate that a and b represent the same element in a projective space. In this case, that is,

a ∼ b ⇐⇒ a =   a1 a2 1  =   b1s b2s s  = bs (3.12)

holds for some s 6= 0.

From above it is apparent that scaling all elements in H with a nonzero constant will result in the same relation. H thus have eight degrees of freedom and (3.11) can be expressed according to

  xs ys s  =   h11 h12 h13 h21 h22 h23 h31 h32 1     u v 1  . (3.13)

Carrying out the matrix multiplication yields

xs = h11u + h12v + h13

ys = h21u + h22v + h23

s = h31u + h32v + 1.

(3.14)

Substituting s in the two first equations results in

h31ux + h32vx + x = h11u + h12v + h13

h31uy + h32vy + y = h21u + h22v + h23

s = h31u + h32v + 1.

(3.15)

Note that the equations are linear in the elements of the homography matrix and that the third equation is linearly dependent on the first two. Skipping the last equation, the relations can be expressed according to

u v 1 0 0 0 −ux −vx 0 0 0 u v 1 −uy −vy              h11 h12 h13 h21 h22 h23 h31 h32             =x y  . (3.16)

Stacking the equations from four known points and their known projections, the elements of H may be solved for, and the homography may be used to calculate the position of any point in the plane given its projection in the image. Inverting the homography enables the opposite.

A proof that a homography actually may be used to describe the relation men-tioned as well as an introduction to projective geometry, projective spaces and homogenous coordinates is given in [4].

(38)

Camera image

Rectified image (u,v)

(x,y)

Figure 3.3. An example of image rectification using a homography.

Figure 3.3 shows an example of image rectification using an estimated homography. The camera image of the maze is transformed to the maze plane coordinate system.

3.2.3

Marker Detection and Tracking

In this context marker detection and tracking is about finding a specified number of markers in an image and tracking these markers in temporally subsequent images. The algorithm can be divided into two parts, initialization and tracking. The first part concerns finding the markers when the location of the markers in the previous frame is not known. This is described in the detection section 3.2.3.1. The second part tracks the found markers. This is described in the section 3.2.3.2. To be robust against changes in light intensity, the marker detection and tracking is based on color rather than intensity.

3.2.3.1 Detection

A distance image, D, is created as

D(x) = ||I(x) − cm|| . (3.17)

The position x varies over the whole input image I, cmis the color of the marker and the norm ||·|| is the euclidean distance in the color plane.

A filter enhancing local minima of the same size as the expected size of the markers is applied to the distance image. This is followed by marker detection. Searching for n markers, the following is performed.2

2The suggested pseudocode include traversing the image at least n + 1 times. The algorithm

(39)

3.2 Estimation 25

for i = 1 to n+1

find and save position of global minimum, z, in image I for all pixels x in I where distance(x, z) < r

set x to positive infinity end

end

The parameter r is the minimum spatial distance between two markers. The detections, xi, are sorted such that D(xi) < D(xi+1).

By detecting one more minimum than asked for, a certainty measure may be calculated as

C =D(xn+1) − D(xn) D(xn)

. (3.18)

Simply put, when the relative difference between D(xn) and D(xn+1) is small, it is an indication that either less than n markers or more than n markers were detected. In either way, the detected marker positions are uncertain.

3.2.3.2 Tracking

If the position of a marker is known in the previous frame, the search in the current frame may be limited to a small area centered around the previous known location of the marker. This assumes that the markers move with limited speed.

Calculating the distance image and minima enhancing filtering is only done in this small area, for each marker. The new marker positions can now be found by finding the minimum in each area, assuming that the areas do not overlap.

3.2.4

Background Model

With a model of the background, a captured image may be compared to the model to detect anything in the image that is not a part of the background, that is, foreground. A few examples of different background models can be found in [2].

3.2.4.1 Approximate Median Background Model

For a long enough time interval, the median value over time for each pixel belongs, with high probability, to the background.3 This can be used to create a background

model from a sequence of images without the need of a specific image known to contain only background.

(40)

As calculating the median requires some computational effort and also cannot be done without all images available, an approximate median background model, as in [12], may be used.

Every time a new image is available, the background model is updated as follows.

for each pixel i

if new_value(i) > model(i) model(i) += alpha else model(i) -= alpha end end

When the model converges, approximately half of the new values will be greater then the model (and the other half will be smaller). That is, the model is close to the median of the data.

The parameter alpha controls the rate of convergence of the background model. Using a small value makes the model react very slowly to changes in the back-ground. The downside of using a large value is that if the foreground remain stationary for some time, the background model may adapt to the foreground.

3.2.4.2 Gaussian Mixture Model

Sometimes, the median background model will not be sufficient. This might be the case when the background contains moving boundaries, where the pixels close to the edge periodically change. In that case, the background model should be a mixture of two models, each describing the conditions on either side of the bound-ary. Using normal distributions to model each side of the edge, the background model ends up being a Gaussian Mixture Model, gmm, [8], also described in [12]. When using gmm to model image background, each pixel has its own model as described by P (I|Γ) = K X k=1 wkPk(I|Γk) (3.19)

where P (I|Γ) is the probability of the pixel attaining the intensity I given that it belongs to the background Γ. The model is a mixture of K normal distributions each weighted with wk ≥ 0 subject to

K X k=1

wk= 1. (3.20)

The weights wk can be interpreted as the probability of the pixel being generated by the submodel Γk, given that the pixel belong to the background. That is

(41)

3.2 Estimation 27

wk= P (Γk|Γ). Assuming that the pixel value is generated by one and only one of the submodels, equation (3.19) is a variation of the law of total probability. The last factor in equation (3.19), Pk(I|Γk), is the probability of a pixel attain-ing the intensity I given that it belongs to the submodel Γk. Assuming normal distributions of the submodels, the probability can be expressed as

Pk(I|Γk) = I+0.5 Z I−0.5 1 σk2πe(i−µk)2 2σ2 k di. (3.21)

Note that the intensity values, I, are assumed to be integers. This, in combination with the integral in (3.21), is necessary for expressions like P (I|Γ) to represent probabilities. Otherwise, these would be probability density functions. In practice, the integral is usually approximated using the value of the integrand in the middle of the interval, that is, sampling the density.

Using an incremental update algorithm, the parameters wk, µk and σk can be adjusted to fit the data seen so far. Usually K, the number of submodels, is fixed. The background models, one for each pixel, may be used to create a probability image B(x) when presented with a new image I(x). The probability image can be generated according to

B(x) = Px(I(x)|Γ) (3.22)

where Px is the background model for pixel x.

The probability image contains the probability of every pixel attaining the current value given that the pixel belongs to the background. Pixels having an intensity with a low probability in the corresponding background model may be seen as potential foreground pixels.

This might seem strange. Estimating Px(Γ|I(x)), that is, the probability of the pixel belonging to the background given the current pixel value, would be closer to the intended purpose of the model.

Using Bayes’ rule, P (A ∩ B) = P (A)P (B|A), the relation between Px(I(x)|Γ) and Px(Γ|I(x)) may be expressed as

Px(Γ|I(x)) =

Px(Γ) Px(I(x))

Px(I(x)|Γ). (3.23)

It may be noted that the authors of [8] model both the foreground and background using a Gaussian mixture model. The classifying decision is then made by com-paring the probability of the current value of the pixel being generated from a background or foreground distribution.

(42)

3.2.5

Kalman Filter

Given a state space model of a system and some observations dependent on the state of this system, a Kalman filter [5], may be used to estimate the full state of the system. This is possible even if some state variables can not be directly measured, as long as the system is observable.

For more information on time continuous and time discrete state space models see [6] and [3]. The latter also contain a thorough description of the Kalman filter. The filter used in this thesis is based on a time discrete system of the form presented in (3.24) where n is the time index, x is the state vector, u is the input and y is the output. The process noise is represented by w with covariance matrix Qn while the measurement noise is represented by v with covariance matrix Rn. The noise is assumed to be white and all terms are assumed to have zero mean. In this version of the Kalman filter, the process noise is assumed to be uncorrelated with the measurement noise, that is, E[w(t)v(τ )T] = 0. The matrices A, B and C are used to represent the state space model of the system.

xn+1 = Axn + Bun + wn

yn = Cxn + vn

(3.24)

The Kalman filter can be shown to give the optimal linear estimation of the state vector with respect to the variance of the state error. If the noise is both Gaussian and white, the Kalman filter provides the optimal state estimation, that is, there is no non-linear filter providing better estimations [3].

Subscripts on the form n|k will be used to denote an estimation of the value at time n given measured data until time k. Additionally ˆxn|k is the estimated state and Pn|k is the covariance matrix of the estimated state. Using the covariance information Pn|k, Qn and Rn for weighting, the Kalman filter fuses information from measurements and the system model to estimate the state of the system. When the control signal un is available, the next state may be estimated as

ˆ

xn+1|n = Aˆxn|n+ Bun

Pn+1|n = APn|nAT + Qn.

(3.25)

When the measurement at n + 1 is available the prediction is updated as

ˆ

xn+1|n+1 = xˆn+1|n+ Ln+1(yn+1− Cˆxn+1|n)

Pn+1|n+1 = Pn+1|n− Ln+1CPn+1|n

(3.26)

where the Kalman gain L is

(43)
(44)
(45)

4

Hardware

In this chapter, a detailed description of the hardware is given. The platform is based on a Brio labyrinth game acquired from the local toy store. The game is shown in figure 4.1.

The game is slightly modified to allow controlling the game from a computer. Provisions for easier estimation of the game state have been added. An alternative maze, completely free of holes and obstacles, has also been created.

In addition to the game, the system employs a camera and means of directing it toward the game, that is, a tripod.

The modifications made to control the game are presented in section 4.1 together with a description of the control hardware. In section 4.2, the vision hardware is described as well as the modifications made to simplify tracking.

Section 4.3 describes the alternative maze while section 4.4 present a state space model of the hardware.

(46)

Figure 4.1. The game.

4.1

Controlling the Game

The original means of control consists of two knobs each controlling the tilting of the maze in one of the two directions by pulling cables attached to the middle of each of the four sides of the maze.

This controlling mechanism has been removed and replaced with two standard rc1

servos with linkage to the gimbal rings. The installation is shown in figure 4.2. Two Hitec hs-475hb servos are used [10].

In the figure, the servos are shown with large deflections from the neutral position. When the servos are in their neutral position, all parts of the linkage are at right angles resulting in an approximately linear transformation from servo deflection angle to maze tilt angle.

There are two reasons to remove the original means of control. First, the servos would render the original control useless. Secondly, the original control might interfere with the servos making the whole system less responsive.

(47)

4.1 Controlling the Game 33

Figure 4.2. Servo installation.

4.1.1

Controlling the Servos

The servos are controlled by sending pulses to the servos. The servo arm tries to maintain an angular position proportional to the width of the pulse. A pulse width of 1500 µs makes the servo attain its central position. By changing the width of the pulse up to ±600 µs, the servo moves from its central position.

An ordinary rc receiver demodulates a signal consisting of one pulse for each servo stacked after each other with a small pause between each pulse. After the pulse to the last servo, a longer pause inform the receiver that the following pulse should be directed to the first servo. The receiver just split the signal during the pauses and forward the correct pulse to the correct servo.

In this case, a controller card is used to generate the pulses directly. The controller card receives the desired pulse widths for each servo from the computer. The controller then generates pulses with the correct width until new pulse width information is received.

The used controller card is of type ssc-32 from Lynxmotion [7]. It is based on an Atmega16 one chip computer from Atmel and communicates with the desktop computer via a standard rs-232 link. The controller card is in its turn controlled by sending simple ascii2character strings telling which servo, or which servos, to

move and their corresponding new positions. These ascii-strings are sent by the output part of the leap software.

(48)

Figure 4.3. One of the markers.

4.2

Vision Hardware

For viewing the game, an ieee-1394 Marlin f145c2 camera from Allied Vision Technologies is used [1]. At the current configuration, the camera delivers 15 color images per second with a resolution of 800 by 600 pixels. The camera driver makes the frames available to the leap software in yuv422 format.

The camera, mounted on a tripod, is directed towards the game. The game board is modified in order to simplify the estimation of the homography between the maze plane coordinate system and the image coordinate system. The modifications consist of four spherical, colored markers recessed into some of the obstacles in the maze, see figure 4.3.

The markers have known positions in the maze plane coordinate system. One of the markers has a different color to distinguish it from the others. This odd colored marker makes it possible to resolve which of the four possible orientations of the maze plane coordinate system is correct.

(49)

4.3 Alternative Maze 35

Figure 4.4. Alternative maze.

4.3

Alternative Maze

The original maze contains a lot of holes and obstacles. Due to the small distances between these objects in the maze relative to the size of the ball, there might be a problem detecting any significant behavior of the controlling algorithm. To accom-modate better possibilities of observing progress by the controller, an alternative maze has been made.

The surface of the original maze is also quite uneven. This is especially evident in some places where large dents in the surface appears. These dents are the result of casting the obstacles. To spread the obstacle material to all obstacles from one point, there are paths of obstacle material under the maze base. These paths result in recession of the maze base wooden fiber plate visible where there are no obstacles on the upper side.

The alternative maze consists of a transparent plastic board that can be placed on top of the original maze with a tight fit inside the inner gimbal. In addition to being free of holes and obstacles, the alternative maze has a much smoother surface than the original maze. The game with the alternative maze in place can be seen in figure 4.4.

(50)

4.4

Hardware Model

To estimate the state of the system using a Kalman filter, a linear state space model of the system is needed. System identification was performed to generate such a model.

The system with the original maze contains severe nonlinearities where the ball hits the obstacles. Therefore the model was created using the hole and obstacle free alternative maze and the model is not expected to be valid where the ball is in contact with the edges of the maze.

One of the requirements on the filter is to estimate the ball velocity. In order to make sure that ball velocity is one of the states, a gray box3 model is used. Physical relations are used to set up the equations in the model while system identification is used to estimate certain parameters. The model is divided into two submodels, each is derived the same way describing motion in the outer and inner direction respectively.4

4.4.1

Physical Modeling

In this section, a model for one of the directions is derived. The model for the other direction is similar, only the values of the parameters differ.

The servo is modeled as a proportionally controlled motor with a gearbox. The servo motor (dc-motor) and gearbox is modeled as

¨

θ = −a ˙θ + bv (4.1)

where θ is the output axis angle and v is the input voltage. The model has two parameters a and b. The dots represent derivation with respect to time.

The servo motor is controlled by means of a proportional controller with a pulse width modulated output. As the pulse frequency is very fast compared to the servo dynamics, the output may be viewed as controlling the voltage. The feedback is thus modeled as v = K(K2u − θ) where u is the reference signal, proportional to

the desired servo angle. K and K2 are free parameters. In the finished model, u

will be the input from the servo controller card.

Inserting the controller into equation (4.1) yields ¨

θ = −bKθ − a ˙θ + bKK2u. (4.2)

Note that this is a general second order system.

If one would derive the equation describing the relation between servo angle, maze tilt and finally ball acceleration, one would end up with an equation containing

3A gray box model is something between a model fully derived from physical relations

(some-times called a white box model) and a model created by just considering input and output relations (a black box model), hence the term gray box model.

(51)

4.4 Hardware Model 37

a few trigonometric functions. The physical layout of the control linkage enables the relation to be approximately described as linear for small deflections but with an additional offset. The offset is necessary as setting the control signal to zero may not cause the maze to be horizontal.

The model used for ball motion is

¨

y = c(θ + θ0) − d ˙y (4.3)

where y is the ball position and θ0 is the maze offset. In the equation, d model

friction and c is the linearized relation between maze tilt and ball acceleration. Both parameters contain the ball mass.

Using the state vector

x =       x1 x2 x3 x4 x5       =       y ˙ y θ ˙ θ θ0       (4.4)

the combination of equations (4.2) and (4.3) can be expressed as the continuous time state space model

˙ x =       0 1 0 0 0 0 −d c 0 c 0 0 0 1 0 0 0 −bK −a 0 0 0 0 0 0       x +       0 0 0 bKK2 0       u y = 1 0 0 0 0 ˙x . (4.5)

Finally using forward difference approximation of the derivative ˙x ≈ xn+1−xn

T

xn+1≈ xn+ T ˙x the time discrete model

xn+1 =       1 T 0 0 0 0 1 − dT cT 0 cT 0 0 1 T 0 0 0 −bKT 1 − aT 0 0 0 0 0 1       xn +       0 0 0 bKK2T 0       u (4.6)

(52)

4.4.2

Identification

To identify the unknown parameters in the model, data was collected by manually controlling the game while recording the ball position and servo control signal. The game was controlled as to avoid the ball hitting the edges of the maze while making inputs of varying amplitude and frequency. The identification data was thus collected under the influence of manual feedback rendering the control signal somewhat dependent on the output.

The nonlinearity at the maze edges made it inappropriate to use a completely random control signal. It may be noted that the sampling interval T is fixed and dependent on the frame rate of the camera. Also, some of the parameters in (4.6) are grouped together before identification as all of them cannot be identified in-dividually. Validation of the model was done both by comparing with validation data and manually by playing a simulation of the game based on the model.

(53)
(54)
(55)

5

Experimental Setup

To evaluate the performance of the different controlling algorithms, a few experi-ments have been carried out. The experiexperi-ments are described in this chapter and the results are presented in chapter 6.

Each controlling algorithm has been evaluated by letting it guide the ball along different trajectories. The deviations from these target trajectories have been mea-sured and a single performance measure for each run through one trajectory has been calculated. This measure, the Root Mean Squared Orthogonal Error, rmsoe, represent how well the target trajectory has been followed. The controlling algo-rithms have been evaluated using a few different scenarios. The scenarios have used different setups and target trajectories.

The trajectory error measure, rmsoe, is described in section 5.1. The scenarios are described in section 5.5. Three controlling algorithms were evaluated. They are denoted pid, lwpr-2 and lwpr-4. The controlling algorithms are described in sections 5.3 and 5.4. The evaluated controlling algorithms were supplied with target points along the desired trajectory. The algorithm generating these points is described in section 5.2.

(56)

Figure 5.1. Illustration of the rmsoe. The bold line is the target trajectory, the circles

are the measured ball positions and the thin lines are the measured distances.

5.1

Performance Measure

The ability of the evaluated control algorithms to follow a given trajectory is measured and compared.

This path following ability is measured as the root of the mean squared distance from the actual trajectory to the desired trajectory. The distance is measured orthogonal to the desired trajectory every frame. This measure is abbreviated rmsoe, Root Mean Squared Orthogonal Error. Figure 5.1 illustrates the measure. This metric is designed with a few properties in mind. It provides one single value for each run. Using L2 instead of L1

, the rmsoe put more weight on large deviations than on small. When using the real maze, small deviations would be acceptable while large deviations would risk the ball falling through a hole. The rmsoe is also designed not to favor any specific speed along the trajectory. On the negative side, it may be noted that the ball stopping on the target trajectory for a considerable time results in a lower value than might be expected from the rest of the run since one measurement is obtained for each frame. It may also be noted that rmsoe is not a metric in mathematical sense. As the distance is measured orthogonal to the target trajectory, switching the actual and target trajectories may not produce the same result.

In the experiments, the desired trajectory is followed back and forth several times. At each end of the trajectory, the rmsoe for the last leg is calculated and stored.

(57)

5.2 The Target Point Algorithm 43

Figure 5.2. Illustration of the target point algorithm. The bold black line is the

target trajectory directed in the direction of the arrow. The gray dashed circle is the previous target point and the solid line circle is the new target point. The filled circle is the current ball position and the black dashed circle illustrate the search radius. Two different scenarios are shown.

5.2

The Target Point Algorithm

As the evaluated algorithms expect a reference point or reference velocity for the ball, this has to be calculated given the target trajectory and the current ball position. In the performed experiments, this desired position, called the target point, is supplied by a deterministic algorithm.

When a new trajectory is first activated, the point on the target trajectory closest to the current ball position is found. This point is the target point. When a current target point exist, the target point is moved along the trajectory until outside a specified radius from the current ball position. Note that if the current target point already is farther away from the current ball position than the specified radius, the target point does not change. The two latest scenarios are illustrated in figure 5.2.

If the end of the trajectory is found before finding a point outside the search radius, a direction flag is toggled to follow the trajectory in the other direction.

The mentioned search radius is set by the controlling algorithm. In the performed experiments, the search radius is set to 15 mm.

(58)

5.3

Adapting the P

ID

Controller

The pid controller described in section 3.1.2 only handles one dimensional inputs and outputs. Two of these controllers are used to control the game, one for each direction. The two controllers have no interconnection.

The control error for each direction is calculated as the difference between the current ball position and the target point. The target point is provided by the algorithm described in section 5.2. The output from the controllers are sent to the respective servo.

Dividing this two dimensional system into two parts assumes that the outer servo does not affect the position of the ball in the inner direction and vice versa. Fur-ther, only considering the relation between the ball position and the target point, not the absolute ball position, assumes that the system behavior does not change with the position of the ball. As a result of this, the pid controller is not expected to perform well when the ball is in contact with the edges of the maze.

The p, i and d parameters were manually adjusted by the author. In the following chapters, this pid based controlling algorithm will be referred to as the pid.

5.4

Mappings for the Learning System

The idea behind the controller based on a learning system is described in sec-tion 3.1.3. As mensec-tioned, there are several different ways to describe the current and desired state of the game.

Two options on how to describe the current state have been evaluated. One is based on velocities and the other uses both velocities and the absolute position of the ball. The first option is similar to the pid with respect to what kind of information is available to the controlling algorithm. For the pid, the ball position relative to the target point, that is, the control error, can be seen as indicating the desired state.

The desired state of the game is expressed as a desired velocity of the ball in all the conducted experiments involving learning systems. This desired velocity has a constant speed and is directed towards the target point.

The learning systems are trained online. The current state and a desired state is fed into the learning system and the control signal calculated by the learning system is used. When the resulting state of this action is known, the triple old state, applied control signal and the resulting state is used for training. The learning systems are thus able to learn from their own actions.

In this section, the representation of the current and the desired state is denoted input. The control signal predicted by the learning system is the output. In the following equations, p, v and u denote position, velocity and control signal respectively. A subscript, o or i, indicates if the aforementioned value correspond

(59)

5.4 Mappings for the Learning System 45

to the outer or inner direction (see the terminology section 2.1.1).

The superscript plus sign has a twofold interpretation. The interpretation of the superscript plus sign depend on if the learning system is currently used to calculate the control signal or if the learning system is being trained. In the first case, the superscript indicate that the corresponding value is a desired value, that is, the control signal output from the learning system should bring the corresponding part of the state close to the value supplied as the desired value. In the second case, that is, when the learning system is trained, the superscript plus sign values are replaced with the corresponding values resulting from the action taken. If not enough examples close to the input data has been seen by the learning system, the system can not make a prediction. In that case, a pid controller will be used instead. Thus, when starting an untrained system, the pid controller will control the game completely. As the learning system gets trained, it will start to decide the control signal more and more often. It is also possible to control the game manually to provide training data.

The different evaluated learning systems will be denoted lwpr-n, where lwpr indicate that Locally Weighted Projection Regression is used to learn the mapping and n is the dimension of the input. Lwpr is described in section 3.1.3.1. The first alternative, lwpr-2 is

 vo v+ o  → uo  vi v+i  → ui . (5.1)

This setup makes the same assumptions regarding the system as those made for the pid controller. First, the ball can not behave differently in different parts of the maze. Secondly, the outer servo should not affect the ball position in the inner direction and vice versa.

By adding the absolute position to the input vectors, lwpr-4 is obtained. The resulting mappings are

    vo po pi v+ o     → uo      vi po pi v+i     → ui . (5.2)

This learning system should have the possibility to handle different dynamics in different parts of the maze. Still it is assumed that the control signal in one direction has little effect on the ball movement in the other.

(60)

Depending on the framerate of the camera and the dynamics of the system, the correlation might be low between the applied control signal and the state of the game in the frame acquired directly after the change in control signal. To increase the correlation, the state resulting from a certain action can be measured a few frames later. In the performed experiments, the resulting state has been measured four frames later.

To find proper values for the parameters in the lwpr algorithm, a simple exper-iment was conducted. Some training and evaluation data was gathered from the system. A computer was set to train several learning systems offline with different parameter values using the training data. The learning systems were then evalu-ated offline using the evaluation data. The parameters of the learning system with the best result was used.

5.5

Evaluation Scenarios

In this section, the scenarios used to evaluate the algorithms are presented. Each scenario is given a number to be referenced in chapter 6. To avoid the need of picking up the ball manually, all scenarios use the hole and obstacle free alternative maze.

5.5.1

Scenario 1: Simple Trajectory

The trajectory of the first scenario is one period of a sine wave. The wave length is 150 mm and the amplitude is 50 mm. The trajectory is shown in figure 5.3. All controlling algorithms are expected to be able to pass this scenario with rea-sonable results.

5.5.2

Scenario 2: Simple Trajectory with Modified Behavior

The second scenario uses the same trajectory as in the first scenario. However the behavior of the system is changed in one half of the maze, the modified area.

This change consists of modifying the control signal to the outer servo when the ball is in the lower half of the maze, below the dotted line in figure 5.3. The control signal modification is performed just before the signal is sent to the servo controller card. Seen from the controlling algorithm, this modification seem to be a part of the system to be controlled.

The purpose of this scenario is to evaluate the controlling algorithms aware of absolute position. These are expected to perform better than the controlling al-gorithms only aware of relative position or velocity. Two versions of the scenario exist.

(61)

5.5 Evaluation Scenarios 47 0 50 100 150 200 250 0 50 100 150 200 Outer direction [mm] Inner direction [mm]

Figure 5.3. The target trajectory for scenarios 1, 2a and 2b (dashed line). The dotted

line indicate the border between the normal area and the modified area used in scenarios 2a and 2b.

References

Related documents

För att uppskatta den totala effekten av reformerna måste dock hänsyn tas till såväl samt- liga priseffekter som sammansättningseffekter, till följd av ökad försäljningsandel

The increasing availability of data and attention to services has increased the understanding of the contribution of services to innovation and productivity in

Generella styrmedel kan ha varit mindre verksamma än man har trott De generella styrmedlen, till skillnad från de specifika styrmedlen, har kommit att användas i större

Närmare 90 procent av de statliga medlen (intäkter och utgifter) för näringslivets klimatomställning går till generella styrmedel, det vill säga styrmedel som påverkar

I dag uppgår denna del av befolkningen till knappt 4 200 personer och år 2030 beräknas det finnas drygt 4 800 personer i Gällivare kommun som är 65 år eller äldre i

På många små orter i gles- och landsbygder, där varken några nya apotek eller försälj- ningsställen för receptfria läkemedel har tillkommit, är nätet av

Detta projekt utvecklar policymixen för strategin Smart industri (Näringsdepartementet, 2016a). En av anledningarna till en stark avgränsning är att analysen bygger på djupa

DIN representerar Tyskland i ISO och CEN, och har en permanent plats i ISO:s råd. Det ger dem en bra position för att påverka strategiska frågor inom den internationella