GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik...

112
Uppsala University Embedded Control Systems, spring 2008 Instructors: Prof. Alexander Medvedev, Karl Marklund GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström

Transcript of GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik...

Page 1: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Uppsala University Embedded Control Systems, spring 2008Instructors: Prof. Alexander Medvedev, Karl Marklund

GoAIBO

Ulla DahlbäckMarcus Ericsson

Madelene NilssonFredrik Olsson

Jing YaoAnders Åström

Page 2: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Abstract

An AIBO can walk in many various ways, some gaits are faster and some more stable. In this project a gait-generating tool has been developed. The purpose of the tool is to evaluate different walking styles of the AIBO giving the user an opportunity to find a walk according to his or her needs. The tool lets the user choose which parameters to vary, generates the different walking styles and produces evaluation graphs showing the AIBO’s speed, shakiness and how much the AIBO strays of its path. The gait-developer tool (GDT1) is constructed of seven Java files, one Matlab file and some URBI (Universal Real-time Behaviour Interface) script. Many walking styles make the AIBO walk crooked, therefore as part of the tool an algorithm for making AIBO walk straight has been developed. The evaluation part of the tool is made in Matlab.

Page 3: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Table of contents

INTRODUCTION ........................................................................................................... 5

PREVIOUS WORK ........................................................................................................ 5

PROBLEM DESCRIPTION ........................................................................................... 6

GAIT DEVELOPER TOOL ............................................................................................ 6

THE MAIN COMPUTER PROGRAM ............................................................................ 7 Overview of the different files .............................................................................................................................. 8 Why Java? ............................................................................................................................................................ 9 Why URBI? .......................................................................................................................................................... 9 Laika.java ............................................................................................................................................................. 9 GUI1.java & GUI2.java ...................................................................................................................................... 9 Parameters.java ................................................................................................................................................... 10 AIBO.java ........................................................................................................................................................... 11

Telnet .............................................................................................................................................................. 11 The test course ............................................................................................................................................... 11 Java + URBI .................................................................................................................................................. 12 Problems with URBI ...................................................................................................................................... 12 Pseudo code for the test run program ............................................................................................................ 13

Store.java ............................................................................................................................................................ 13 Matlab.java ......................................................................................................................................................... 15 startup.m ............................................................................................................................................................. 15

CHANGING WALKING STYLES ................................................................................ 16

CONSTRAINTS ON PARAMETERS .......................................................................... 17

CREATING NEW URBI-FILES AND SENDING THEM TO THE AIBO ..................... 17

DISCUSSION ............................................................................................................. 18

FUTURE WORK ......................................................................................................... 18

REFERENCES ............................................................................................................ 20

APPENDIX .................................................................................................................. 21 Appendix I; Table 1, Limitation ......................................................................................................................... 23 Appendix II; Manual for compile and copy files to memory stick .................................................................... 24 Appendix III; TELNET, telecommunication network ........................................................................................ 25 Appendix IV; List of GDT files .......................................................................................................................... 26 Appendix V; Code .............................................................................................................................................. 27

Laika.java ....................................................................................................................................................... 27 GUI1.java ....................................................................................................................................................... 29 GUI2.java ....................................................................................................................................................... 36

Page 4: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Parameters.java .............................................................................................................................................. 60 AIBO.java ...................................................................................................................................................... 84 Store.java ....................................................................................................................................................... 95 Matlab.java .................................................................................................................................................... 99 startup.m ...................................................................................................................................................... 100 motion.u ....................................................................................................................................................... 103 normalCode.txt ............................................................................................................................................ 110

Page 5: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Introduction

Robots are today going through a change. Traditional robots are constructed to do specific tasks while modern robots are more and more adaptive and programmed to solve unexpected problems by themselves. To encourage this development the project RoboCup started in 1997. RoboCup is an attempt to promote Artificial Intelligence and robotics research by providing a standard problem where a wide range of technologies can be integrated and examined. The goal for the RoboCup project is to create a soccer team of autonomous robots who can beat the FIFA world champions by the year 2050.

AIBO (Artificial Intelligence roBOt) is a robotic pet designed and manufactured by Sony. There have been several different models since their introduction in 1999. AIBOs are considered to be autonomous robots since they have the ability to walk, "see" their environment via camera and recognize spoken commands, as well as being able to learn and mature based on external stimuli from their owner, other AIBOs or the environment. AIBO robots were earlier used as the official robot in RoboCup but have now been replaced by a new type of robot since Sony has discontinued the production of AIBO. Even though AIBO no longer is used in RoboCup we will try to improve its football skills. Soccer-dogs need a variety of different skills such as walking, shooting, communicating and the ability to interpret the environment. In this study we have focused on developing AIBOs gait.

In 2004 a project group at Uppsala University focused on improving AIBO’s speed on different surfaces. A problem that occurred was that AIBO did not walk straight. Due to vibrations AIBO’s walk was disturbed and therefore AIBO drifted randomly from its path. A project group in 2006 solved this problem by creating a method to make AIBO walk towards a predetermined target.

We want to develop AIBO’s ability to adapt its gait to the current surface, to optimize its walk considering both speed and stability.

Previous work

Two groups from Uppsala University have worked on the task of developing AIBO’s gait before us. In 2004 a group of students investigated the possibilities of speeding up AIBO’s gait by changing different parameters that affect the movement patterns of the legs. They discovered that softer surfaces with high friction require a higher and taller front leg locus. They also found out that the key to a fast gait is to have a body motion with a high resonance frequency combined with a long effective step length. The main problem that occurred during their work was the fact that the AIBO strayed from its course. The quadratic gait they used could not compensate for AIBO’s drifting from its original path caused by its shaky walk.

A solution to this problem was implemented by another group of students in 2006 by introducing a method which compensates for misdirection. To begin with the group used a five cornered polygon gait instead of the four cornered polygon gait that the 2004 group used. The fifth corner was introduced to make AIBO be able to adjust the movement sideways. To make AIBO walk straight the group gave AIBO a target, in shape of a big red column, to walk towards. They implemented an algorithm that made AIBO adjust its course if the column was not in the middle of AIBO’s field of vision. The algorithm used the camera in AIBO’s head to photograph its current view. AIBO tried to localize the borders of the column by measuring the amount of sequential red color valued pixels in relation to the non-red valued pixels.

Page 6: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

When the borders were estimated AIBO calculated its new direction and also the width of the column. If AIBO found the width of the column to be greater than a certain value, i.e. if it was close enough to the target, the algorithm would tell the AIBO to turn 180 degrees.

The group in 2004 used a two-dimensional space for the paw-motion, not considering AIBO’s sideways movement. This was one of the reasons to why AIBO could not adjust its path when straying from its course. The 2006 group used three parameters to be able to refer to the paw in three dimensions, and thereby also being able to control AIBO’s sideways movement. In 2006 they also added a step parameter to be able to control the overall speed of AIBO.

The method developed in 2006 allows automatic evaluation of pre-programmed gaits. However this process is time-consuming and for a large number of gaits it is almost impossible to carry out. A better way would be to have a tool that creates gaits on its own, based on some human inputs.

Problem description

Our aim for this project is to create a gait-developer-tool. This tool can be used for many purposes, for example to evaluate different walking styles of the AIBO and for automatic fine-tuning of the parameters.

With a combination of the group in 2006’s work, a solution to be able to charge the batteries while the robot is walking and an algorithm that automatically generates walking-styles, the AIBO and the computer could together test and evaluate an infinite number of different walking-styles without human presence. A style contains different parameters that regulate how the robot walks. Depending of what the user wants to achieve, different parameters choices can be regarded as the best. If the user wants a fast walk it is necessary to measure the time it takes to walk a known distance. The results from the accelerometer have to be recorded to calculate how steady the walk is. To evaluate how straight the walk is, the activity of the compensation loop has to be measured (ref. group 2006’s report). All data will continuously be transmitted to the computer during the test run. AIBO prints the specific sensor values that the Java program then reads and saves in a text file. The most primitive automatic gait-generator will randomly choose parameters and then send them to the robot. A more sophisticated one will both ask the user for directives and try to learn from previous test-runs.

Instead of measuring the time it takes for the AIBO to walk a specific distance, it may be possible to measure the speed momentarily by integrating the accelerometer results or using the vision in some way. This year’s group number 3 has chosen to work on this task. Therefore we will develop our tool in a way that it can easily be combined with theirs. If both projects are successful, and successfully combined, the AIBO will be able to change its walking-style itself depending on the outside climate.

Gait Developer Tool

The purpose with our project is, as stated above, to make a tool for automatic gait construction and evaluation. The tool will rely on the user to provide it with some useful inputs, like which parameters to vary, the interval for these parameter values, parameter step length and evaluation parameter:

Page 7: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Parameters to varyThe tool should accept different kinds of parameters that can be varied, and let the user choose any combination of these parameters that he or she prefers.

Intervals for the parametersDetermines the minimum and maximum value of each parameter.

Parameter step lengthDetermines the increase of a parameter value after each iteration, i.e. after the AIBO has completed one test walk.

Evaluation parameters Determines which aspect to be optimized, i.e. time of test run, shakiness etc.

When all test runs are completed the tool will send the acquired data to a Matlab script for evaluation.

Outputs will include:

Plots of the evaluation parameter contra the set of walking parameters

Ranking lists of the tested parameter sets

Codes for the different parameter sets

The main computer program

The first edition of the Gait Developers Tool (GDT1) is a platform for automated testing and evaluation of different gait-parameters. We never intended to create a perfect tool but rather offer the next generation of AIBO-developers a basic program that contains all necessary functions for automated testing and evaluation. Our intensions were to create a program that is easy to develop and extend with new functions. This framework can optimize sinusoidal wave-based gaits in respect of minimizing the shakings, need for compensation for misdirection or maximizing the speed. The framework should however be easy to extend with functions to optimize movement to reduce energy consumption, optimize camera handling or any other purposes that future AIBO-developers might consider interesting. To make it easier for others to add new functions to the tool an overview of the different code files and a brief discussion of why the GDT1 has been constructed in this way follows:

Page 8: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Figure 1. Overview of the Gait Developer Tool

Overview of the different files

Laika.javaThis is the main file which controls the flow of data between the different classes and makes sure that previous functions have finished before starting a new one.

GUI1.java + GUI2.javaThese files contain all the functions used for communication with the user. They build up the graphical user interfaces and make sure that all inputs are valid. GUI1.java controls which parameters to adjust, and constructs GUI2 according to the received inputs. GUI2.java takes care of the values for each parameter.

Parameters.javaParameters.java gets the user inputs from the GUI files and calculates all different sets of parameter values.

AIBO.java All code needed for communication with the dog is located in this file. AIBO.java also controls most of the dogs actions, only a few basic functions are written in URBI and located on the dogs memory stick.

Store.javaStore.java collects all evaluation data from AIBO.java, converts it from strings to doubles and writes the data to files in a format that Matlab can read. Store also writes files containing the code for each gait.

Matlab.javaThis file launches Matlab from the GDT directory and executes the Matlab script startup.m.

Page 9: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

startup.mstartup.m reads the output files from Store and presents it to the user in an illustrative way.

Why Java?

Java Developers Kit (JDK6.9) provides necessary packages to easily create a reasonable good-looking graphical user interface (GUI) as well as a good platform for handling sub processes in a convenient way. Furthermore Sun Microsystems provides very good documentation and programmer’s guides, which facilitate the understanding of the code for future users of the GDT1. The main reason for using Java is that most of the engineering students at Uppsala learn Java during their time at the university. By using Java we make it easier for future students to understand and develop our project.

Why URBI?

Based on previous years’ reports we got the understanding that the best way to program AIBO for our project was with OPEN-R and C++. However, since nobody in our group had previous experience of C++ the programming turned out to be quite difficult. As we did not make any progress we changed our approach. URBI, a Universal Real-time Behaviour Interface turned out to be the solution.

URBI is a robotic platform based on a scripting language that can interact with several operating systems and programming languages. URBI is designed to control not only the AIBO but any robot or any kind of complex system. It is constructed to work over client/server architecture. (URBI forge) We have used URBI combined with Java when creating our test run program.

The main advantage with URBI is in our case foremost the simplicity, compared to OPEN-R it is very easy to use and understand. URBI also came with a few sample programs or basic functions that we could alter according to our specific needs. One of the functions, the walk function, gave us much help as to understand how we could implement different kinds of walks. Though URBI was much easier to understand and implement than OPEN-R we still faced some difficulties. Even though the programming language was pretty straight forward, it was still a new programming language, and some time was spent dealing with learning the basics. We also had quite some problems with built in functions in URBI that did not work as they should.

Laika.java

This file connects all other .java-files to one complete program set. It contains starting up GUI1 and GUI2 and computes the total set of test runs depending of the parameter-sets. The parameters are then used to start the AIBO.java and StoreData.java. When the test runs are finished Matlab is started to evaluate the results. So as a whole Laika works as the “spider in the net” and keeps all the pieces together.

GUI1.java & GUI2.java

These files may look a bit messy but they are well commented and we have done our best to make them easy to understand. GUI1 contains everything needed to create and show the first

Page 10: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

window that appears when the GDT is started. GUI2 contains all code needed to create and show the second window and to check whether input values are valid or not. How GUI2 will look depends on the parameters that have been selected in GUI1.

In the first window (Fig 2) the user will be asked to select a number of check boxes. It is not possible to press “next” without selecting at least one check box. Parameters belonging to unchecked checkboxes will get a default value according to NormalGait.txt, which contains a standard gait for AIBO. To set a parameter to a static value different from the default value, its checkbox has to be selected and both its maximum- and minimum value be set to the same value.

The second window (Fig 2) has been created with three selected checkboxes according to Figure 1. After entering a new value in a square the enter key have to be pressed to store the value. If the entered value is valid the word inside the box will be replaced by the new value. If the value is not valid the original text will be shown again. A valid value must be an integer, or a decimal number where “.” is used as separator between integer and decimals. Values cannot exceed the boundary conditions determined in GUI2. The limitations are shown in table 1, see Appendix A. The limitations can be changed in the GDT code, in the method “okNumber” in GUI2. Click “ready” and “start” when all values have been entered. If not all squares have got a value a text will show under the start button explaining what is missing before it is possible to start the tests.

Figure. 2 GUI1 on the left, GUI2 on the right

Parameters.java

Parameters.java calculates all different sets of parameter values. Only the parameters selected as variables by the user will be handled in this file. All the other parameters will be constant and do not need to be changed. Maybe it is more intuitive to think of this file as ChangingParameters instead of Parameters since the resulting vector “allParameters” only contains the changing parameters. The first set of values will be the minimum value for each variable parameter; the second set will contain all minimum values except one which is the minimum plus delta etc. This way each parameter can take a specific number of different

Page 11: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

values (equation 1) and the total number of sets will be all possible combinations of these values (equation 2), where P is the number of variable parameters.

NumberOfValuesp=MaximumValuep−MinimumValuep

StepLength p

(1)

NumberOfSets=∏k=1

P

NumberOfValuesk

(2)

Each parameter value starts at its minimum and is increased by the StepLength, delta, until it reaches its maximum. Note that if the maximum value does not equal the minimum value plus an integer multiplied with delta, the maximum value will never be reached.

AIBO.java

A part of this project was to redo the 2006 years GoAIBO project where AIBO walks straight. This part of the project is done in what is called the test run program or AIBO.java. The test run program makes AIBO walk towards a target, continuously send data to the computer, turn around when the target has been reached and then walk back again with a somewhat changed walk.

In 2006 the GoAIBO group used OPEN-R and C++ to program the test run. AIBO.java instead uses both URBI and Java combined. Therefore the programs differ, but the underlying concept is the same. All program specific functions; the commands to AIBO, are written in URBI script and saved onto the memory stick that is put into the AIBO. But it is the program AIBO.java that operates the AIBO by sending the commands to it.

TelnetThe commands are sent from the computer to the AIBO through the terminal using telnet (TELecommunication NETwork). The Telnet program runs on your computer and connects your PC to a server on the network. You can then enter commands through the Telnet program and they will be executed as if you were entering them directly on the server console. This enables you to control the server and communicate with other servers on the network. (www.webopedia.com)

The test courseOur test course consists of a walking path between two red targets (see fig 3 below). The target consists of the backs of two red chairs lying on the floor. All other red objects in the room must be covered so that they will not disturb AIBO.

Page 12: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Figure 3. The test course

Java + URBIThe original plan was to build the complete test run program code in URBI and then load it to AIBO. A full test run includes tests of the complete sets of different walks chosen by the user. However after some problems with URBI and the construction of the test run program the main test run program was written in Java using functions written in URBI. The URBI functions makes the AIBO walk, search for and turn towards a target turn 180 degrees when close to the target and send data from the accelerometer and the head.

The Java program AIBO.java clocks the time it takes for AIBO to walk from start to the target. If the time exceeds a certain value AIBO will cancel the current test run. This means that the specific walk parameters of the run will be aborted and AIBO will walk the remaining distance with a standard built in walk. When AIBO reaches the target, it will turn around and wait for the next set of parameters to test.

Problems with URBIWhen creating the test run program some problems with URBI occurred. Some of the built in functions like for example “at”, “waituntil”, “stopif” and loops did not work as expected. Because of these problems compromises in the algorithm had to be made and the end result did not turn out according to the original plan.

The initial goal was to make AIBO continuously search for and steer towards a target while walking. However the problems that occurred with URBI resulted in a big compromise. Instead of continuously searching for the target AIBO will stop its walk every five seconds to search and turn towards the target if needed.

To make AIBO search for the target a function called “lookFor” was constructed in which the camera in the AIBO is used to turn AIBO’s head towards the target. Using the function called “turnTowards” AIBO then lines up the rest of its body with its head making itself face the

Page 13: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

target. If the head pan value is too small AIBO will not turn correctly, this problem was solved by overcompensating the head pan values before lining the head up with the rest of the body. If the head pan value is exactly zero the turning function ends up in an infinitive loop, this was easily corrected by adjusting the algorithm so that AIBO should not turn if the head pan value was zero.

Pseudo code for the test run program

Start up the communication with AIBO;

for (int i=0; i<antaltest; i++){while(battery < 30% ){

motors off;}

motors on;get new parameters;while(distance > 40cm){

walk & send data;search & turn toward target;

}turn(180degrees); send # to notify ready;

}

To start a test run the battery level in AIBO must exceed 30% of the maximum value. The first thing the program does is to check whether or not the battery level is high enough. If not all motors and LEDs in AIBO will be shut down so that AIBO can reload itself. Otherwise the robot will assume starting position aka standing position. The computer then sends parameters for a specific walk to AIBO and when AIBO receives the parameters it starts walking. Every five seconds AIBO will search for a target, turn its head toward the middle of the target and thereafter turn the body so that it lines up with the head and therefore faces the target. When AIBO gets as close as 40 cm to the target it will turn around and then send “ready” to the java program. Then the procedure starts over again beginning with the battery check.

Continuously throughout the test run program AIBO sends data consisting of values from the accelerometer and head to the Java program Store that store them in files. These values will then be evaluated using Matlab. The Java program AIBO also clock the time it takes for AIBO to walk each test run, from when AIBO first starts walking until it reaches within 40 cm of the target.

Store.java

The easiest way to send data to a Matlab script is to store the data in separate files, structured in a way that it can easily be read by some built in-functions in Matlab and then let the Matlab script read the files. It is possible to make the URBI-program in the robot write the string with accelerometer values in a way that Matlab can read and then simply let the main program write the strings to a file. However that way the code is less flexible for changes, for example if future users want to evaluate the data using other programs than Matlab it would be handy to have the values converted into the type double. To meet such wishes the Store class converts all values to doubles before writing them to different files.

Page 14: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

The user of the GDT starts by setting the gait parameters for AIBO. The results are then evaluated by Matlab so the user manually can choose the optimized gait depending on the user’s demands. Three different possible choices are available for evaluation; these are speed, shakings and stray out of course. All results are then shown in three different plots. For now the program evaluate all parameters, however the code for adding the evaluation choice has not been deleted. If future developers of the tool come up with more evaluations choices and want to go back to the previous version they only have to remove the /* and */ marked with “Commented1”. To evaluate the speed of a gait a clock is started when the dog starts moving and stops when it reaches the opposite side of the test course. The time for each test run is stored in a file named TimeOutputX.txt where X is the number of the test run starting from one. To evaluate how much the dog strays out of course the absolute value of the angel of the neck is stored each time the dog has to turn its head to see the target. These numbers are stored in a file named CompOutputX.txt. The last evaluation parameter is the shakings of the dog. The dog has a built in accelerometer which measures the instantaneous acceleration in three directions: X, Y and Z. How to best calculate how much the dog is shaking from these three values is not trivial. Is the sum of the accelerations in all three directions what best describes how much the dog is shaking or does it depend on the reason future gait developers have for minimizing the shakings? Either way we have chosen to store the raw data in Matrix A (see below) where every sample is a row vector. By this we mean;

Matrix A = [ X1 Y1 Z1 X2 Y2 Z2 : : : XN YN ZN ]

The name of this file is AccOutputX.txt.

A list of all TimeOutputX.txt files is created in a file called TimeOutput00.txt. The files CompOutput00.txt and AccOutput00.txt are generated accordingly. The purpose of these files is to let the evaluation program startup.m know which files that exist.

When AIBO.java makes the AIBO walk it calls the URBI function walkOsearch, located on the dogs memory stick. In turn walkOsearch calls the functions walk and sample where sample is the function that collects data from the accelerometer and sends it back to the computer. sample consists of a loop in which the momentaneous values of the accelerometer is collected and sent to the computer, it then waits for 10 milliseconds before collecting new data. One sample each 10 milliseconds should result in a sample frequency of 100 Hz but it turns out that this is not the case. The processor in AIBO ERS210A is an old MIPS R5200 384 MHz Processor and to walk, sample and send data simultaneously is to computational heavy. The real sample frequency is approximately 18 Hz when the URBI-command wait(10) is used inside the sample-loop. It is possible to increase the sample frequency by adjusting or removing the wait-command inside the sample-loop and increasing the number of iterations. However, pressing the processor to its limit may result in faulting gaits and unreliable test results. At a sample frequency of 18 Hz the gait seems not to be affected and a higher frequency is rarely needed. Although, remember that the number of iterations in the sample loop represents the number of samples in five seconds since that is the duration of each call to the walk function.

Page 15: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

If the AIBO does not reach the opposite end of the test course it is probably because the test-gait parameter does not generate a functioning walk. To avoid infinite long test runs the computer will send new gait parameters, representing the dog’s standard gait, to the dog and the Boolean validTry will be set to false. If validTry is set to false when the dog reaches the finish line the output files for that specific test run will be replaced. For invalid test runs the AccOutputX file will only contain “0, 0, 0”, CompOutputX contains “1000”, TimeOutputX contains “0” and CodeX will contain the line “Invalid try”. If validTry on the other hand equals true the recently tested parameters were ok and all evaluation data will be written to the different output files located in the GDT folder. In this folder a file named CodeX.u can be found. This file contains the URBI code for a gait with the parameter setup from test number X. Please note that old output- and code files will not be erased when a new set of tests is started. Old files will be replaced with the new ones but if the new set of tests is smaller than previous ones a mix of new and old files will be obtained.

Matlab.java

This Java file creates a sub process which starts Matlab. If Matlab is started from the terminal its working directory will automatically be the directory from where the call is made. The file matlabrc.m executes automatically when Matlab is started and contains the following lines:

if exist('startup')==2 startupend

By naming our Matlab script, which performs the graphs visualizing the results from the test runs, startup.m and putting it in the same folder in which the Matlab start up call is made, it will automatically be executed. Another way to automatically execute scripts on start up is to add more filenames to the list in matlabrc.m. By adding directory paths to the filename it is possible to automatically execute scripts which are not stored in the start up directory or when Matlab is not started from the terminal. To be able to run GDT on any computer we have chosen to name our script to startup.m. In this way users do not need to bother with administration permissions and such to alter matlabrc. The startup file is located in the GDT folder, which is why the whole path is included to the call to the ProcessBuilders constructor.

startup.m

startup.m is a matlab file that reads the output files from the Java program, plots the data and presents sorted lists. Each list has the number of the best gait, with respect to one of the evalu-ation parameters, as its first value. A user that prefers a gait which is good in all three senses may want to look at the plots instead of the lists. Three plots are presented after a set of tests; one showing how long time each test run took, one presenting the shakings of the dog and one illustrating the need to compensate for missdirection. The blue peaks represent valid test runs and the red dots with value zero represent invalid test runs. A test run is classified invalid if the dog has not reached the target in the maximum amount of time and therefore has switched to the normal gait to reach the target.

When startup.m is launched it first reads the files AccOutput00.txt, CompOutput00.txt and TimeOutout00.txt which contains lists of created output files. Then the absolute values of all values in each output file, listed in the previous mentioned files, are summerized. Thereafter the time values are scaled to be presented in seconds instead of milliseconds. When this is

Page 16: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

done all test runs with values that equals the “invalid try”-values are moved to a separate vec-tor to be plotted in another color. The y-axes in the plots are scaled after the maximum value in each plot and the x-axes are scaled so that the number of test runs fit.

Changing walking styles

A file called motion.u is found within the URBI-package, containing the different basic functions for moving the AIBO. Some of these functions include walk, turn, stand and such. By partly modifying existing functions and partly writing new ones, we were able to make the AIBO behave according to our goals and needs.

The walk function is the main function for moving the AIBO forward. It works by making the different joints move in a sinusoidal fashion, according to some preset parameters. By changing the different parameters, different types of walking styles are obtained. At present we have chosen to vary the following parameters:

walk.mean[i][j]

walk.ampli[i][j][k]

walk.phase[i][j][k]

walk.speed

The walk.mean[i][j] parameter specifies the mean value around which the motion is performed. The i corresponds to either the front or hind legs, a value of 1 being the front and 2 being the hind legs. For symmetry purposes, no difference is made between left and right legs. Furthermore, the j corresponds to the joint of the leg, a value of 1 or 2 being the shoulder forward/backward and in/out respectively, and 3 meaning the elbow (see Fig 4 below). These values will then determine at around which angle of each joint, in degrees, the movement will occur.

The next set of parameters, walk.amp[i][j][k], determines the amplitude of the sinusoidal motion, i.e. the maximum deviation from the mean value determined in walk.mean[i][j]. Here, i and j again corresponds to front/back and joint respectively, working in the same manner as described above. The k index however, being either a 1 or a 2, represents two different sinusoidal where the first one changes the main motion style and the second is used to make the motion smoother. We have chosen not to let the user change the parameters where k=2, since there are already 20 for the user to vary, and the k=2 parameters would give another 12 to choose from.

The file motion.u also contains parameters called walk.phase[i][j][k] for changing the phase of the legs and joints. We have not yet investigated the impact of changing these at any depth, but have decided anyway to let the user change these as well.

The final parameter to vary is walk.speed. This parameter simply tells AIBO how long a period of the sinusoidal movement should be. In other words, a low value will make the

Page 17: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

motors in AIBO move the joints at a higher speed, and vice versa. This value is expressed in seconds.

Figure 4. Graphic representation of AIBOs joints. Position of joint 1 is represented by the angle β, joint 2 is the shoulder moving towards or away from the body (not visible in this figure) and α is the angle of joint 3, the elbow joint.

Constraints on parameters

To allow new and inexperienced users to make good use of the GDT, some constraints have to be made on certain parameters. For example, the joints of the AIBO cannot rotate 360 degrees, and entering a value which exceeds the physical constraints of the robot may cause damage to it. Therefore it is natural to have these physical constraints as a first set of constraints. As a second set, some more sophisticated aspects need to be considered. Setting the front and hind legs too strangely might result in the AIBO falling over or in the knees of front and hind legs colliding with each other, which may damage the AIBO. These conditions resulted in adding some additional constraints on the joint angles. Continuing on, setting the periodical speed of the movement too high may result in bad performance since the motors cannot adjust angles with infinite speed. This may also cause damage to the robot. To cope with this, an interval between 0.8 and 2 seconds for walk.speed has been chosen. For a more detailed table of limitations see Appendix A.

Creating new URBI-files and sending them to the AIBO

In this section of the project a serious problem occurred. After the user had chosen which parameters to vary, and the new values corresponding to his or her choices, the main program would write a new motion.u-file. This was done by a sort of search-and-replace kind of algorithm. The intention was then to have the program send the new files to the AIBO via FTP continuously after each test run was completed, without human interference. The problem with this approach was that no FTP program had been made for URBI, or at least no program was found. Since the whole project was built on automatic generation and testing of gaits, this

Page 18: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

was a big letdown. A solution could have been to use OPEN-R for the file transfers, but this would mean that the OPEN-R environment also had to be included on the AIBO’s memory stick. As the capacity of the memory stick is somewhat limited, this seemed to be a poor, if even feasible, solution. Another solution was therefore investigated, namely if one could use the telnet interface directly to change parameters. As it turns out, a telnet-command to change parameters overruns the parameters contained in motion.u on the memory-stick for that session, making it possible to have the main program change parameters via telnet “on the fly”. This was agreed to be a superior solution to the “double environment” one, being both straightforward and easy to implement without having to change the code too much.

Discussion

The tool we have developed is almost in compliance with the problems description we set out with. However, there are some problems that must be solved to make the tool work perfectly. One problem is that the batteries are not very good. A fully charged battery will only make AIBO walk for a few minutes, making testing of many different walking styles impossible. Our intention was to solve this by using a method that allows the battery in AIBO to be charged while the AIBO is walking. The idea was to put a small piece of tape over one of the metallic pins in the charger which was supposed to make AIBO walk while the charger was attached. However though AIBO was able to walk with the charger plugged in, it did not actually charge the battery at all.

If the problem with the battery is solved we think that this tool is a quite good instrument for creating new gaits optimized for a specific task.

One goal with the tool was that it should evaluate and determine the best gait according to the users’ preferences. In this version of the tool the user will receive graphs showing the different values and ranked lists of the gaits according to each evaluation parameter, making it easy for the user to find for example the fastest gait.

Our intentions were that the GDT1 should be a first version, a platform for further development of the tool. We feel that we have reached this goal. All code is thoroughly commented and can be found in Appendix V. Hopefully future developers will find our tool helpful when trying to find a optimal gait for a specific surface or purpose. Naturally the code must be modified if it is to be used for other robot models, but we still think our tool would make a good foundation even for that purpose.

Future work

One of the biggest compromises in our test run algorithm resulted in AIBO having to stop every once in a while to search for the target instead of continuously updating its direction while walking. Therefore, one suggestion for future work is to make the AIBO continuously search for the target and let it compensate for the misdirection when a given limit is exceeded. This version of the GDT uses a very basic algorithm for calculating the next set of parameter values. In the future, developers of the GDT could implement smarter algorithms. An idea is to first perform a few tests using a long step length and then use the results from these tests to

Page 19: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

locate interesting regions where more tests will be performed with a smaller step length. This would dramatically reduce the number of test runs and thereby also the testing time making it possible to extend the testing.

In this project we have not identified the parameters that are the most significant when creating new gaits. In future work one could try to identify exactly how the parameters effect the gait of AIBO, which would reduce the number of test runs that has to be done to find new better gaits.

The effect that the sinusoidal parameters have on the gaits is still not totally clear. Every joint has two different sinusoidal indexes for phase and amplitude. In this project the focus has been on the index that has the main effect on the gait. The parameter of the second index is mostly used to make the AIBO walk smoother. Future work could be to exactly find out how the parameters are related to each other and how a change in the parameter with the second index affects the gait. This could be used to optimize AIBO’s gait regarding booth speed and smoothness.

In this project no solution was found making the AIBO continuously load its batteries while running. That was a problem since the batteries used only lasted a short time, which made it impossible to make test runs that could try more than a few gaits at the time. This made the testing part very slow and someone always had to watch the AIBO during the testing phase. A solution to this problem would dramatically enhance this gait generation tool since test runs with several hundred different gaits then could be done.

Page 20: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

References

2004 GoAIBO project

2006 GoAIBO project

Online dictionary, http://www.webopedia.com/TERM/T/Telnet.html, 2008-06-03

URBI forge, www.urbiforge.com, 2008-04-13

Page 21: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Appendix

Appendix I; Table 1, Limitations

Appendix II; Manual for “Teaching dog”

Appendix III; TELNET, telecommunication network

Appendix IV; List of GDT files

Appendix V; Code

Page 22: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some
Page 23: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Appendix I; Table 1, Limitation

Min Max

Walk speedTurn speed

800800

20002000

Front joint 1 amplitud -15 45

Front joint 2 amplitud -28 32

Front joint 3 amplitud -17 44

Back joint 1 amplitud -15 44

Back joint 2 amplitud -28 32

Back joint 3 amplitud -18 44

Front joint 1 phase -28 32

Front joint 2 phase -32 28

Front joint 3 phase -32 28

Back joint 1 phase -32 28

Back joint 2 phase -32 28

Back joint 3 phase -32 28

Front joint 1 mean -40 20

Front joint 2 mean -20 40

Front joint 3 mean 51 110

Back joint 1 mean -60 2

Back joint 2 mean -20 40

Back joint 3 mean 60 120

Page 24: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Appendix II; Manual for compile and copy files to memory stick

1. Put memory stick in mouse

2. Delete all files from memory stick

3. Empty trash can

4. go to: /usr/local/OPEN_R_SDK/OPEN_R/MS_ERS200/BASIC/nomemprot (or memprot)

5. write: cp –r ./* /media/AIBO80

6. go to: /home/group1/Desktop/sample/ers200/MovingLegs/

7. write: make

8. write: make install (if 7 was ok)

9. go to: /home/group1/Desktop/sample/ers200/MovingLegs/MS

10. write: cp -r ./* /media/AIBO80

11. write: sudo umount /media/AIBO80

12. write password: *****

13. put the memory stick into the dog

Note: Search path depends on where the files are located

Page 25: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Appendix III; TELNET, telecommunication network

Communicating with Laika using URBI

In the Terminal window write:o route -n

If no route to 192.168.0.0 exists type:o sudo route add -net 192.168.0.0 netmask 255.255.255.0 gw 130.238.15.149

then type:o telnet 192.168.0.10 54000

If you want to check the connection try:o ping 192.168.0.10

Note: IP addresses depends on router setup

Page 26: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Appendix IV; List of GDT files

JavaLaika.javapackage aibo{

GUI1.javaGUI2.javaParameters.javaAIBO.javaStore.javaMatlab.Java

}

Matlabstartup.m

URBImotion.u

Page 27: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Appendix V; Code

Laika.java

import aibo.*;import java.util.*;import java.io.IOException;

public class Laika {// This is the main file of the program. Run this file to start

the GDT.

public static void main(String[] args) throws Exception{

// Open GUI-oneGUI1 g1 = new GUI1();g1.createAndShowGUI();// Let the thread sleep while waiting for GUI-one to

finish to avoid wasting resourseswhile(g1.getFinished()==false){

// Check wheter GUI-one has finished or not once every 1000 milliseconds

Thread.sleep(1000);

}// Open GUI-two when GUI-one has finished.GUI2 g2 = new GUI2(g1.getSelected());g2.createAndShowGUI();// Let the thread sleep while waiting for GUI-two to

finish to avoid wasting resourseswhile(g2.getFinished()==false){

Thread.sleep(1000); }

// Compute all parameter setupsVector<Vector<String>> allParameters=Parameters.para-

meterSetup(g1, g2);// Print out the number of testrunsSystem.out.println("Number of testruns: " + allPara-

meters.size());

//Start AIBO & storeDataAIBO laika = new AIBO();laika.start(allParameters);// Let the thread sleep while waiting for the test

runs to finish to avoid wasting resourses while(laika.getFinished() == false){

Thread.sleep(1000);

}// Launch matlabMatlab result = new Matlab();result.start();// Let the thread sleep while waiting for the calcu-

lations to finish to avoid wasting resourses while(result.getFinished() == false){

Thread.sleep(1000);

}

Page 28: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

// Print out "finished" and terminate the programSystem.out.println("finished");System.exit(0);

} }

Page 29: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

GUI1.java

package aibo;

import java.awt.BorderLayout;import java.awt.Component;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.util.Vector;import javax.swing.BorderFactory;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;

// The first GUI - where the user gets to choose which joints to experiment with public class GUI1 extends JFrame {

// Initiate parametersJFrame frame;JCheckBox joint11CB, joint12CB, joint13CB, joint21CB, joint22CB,

joint23CB, speedsCB;JButton nextB;boolean joint11S, joint12S, joint13S, joint21S, joint22S,

joint23S, speedsS;boolean finished=false;String eval;

// 'createAndShowGUI' is the method called from Laika.javapublic void createAndShowGUI() {

// Create the basic GUI (without any components) and set layout

JFrame.setDefaultLookAndFeelDecorated(true);frame = new JFrame("AIBO-developer tool");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Container C=frame.getContentPane();C.setLayout(new GridLayout(0,1));// Set size of the GUI and if it should be possible

to change or notInsets insets = frame.getInsets();frame.setSize(420 + insets.left + insets.right, 400 +

insets.top + insets.bottom);frame.setResizable(false);// Add components to the GUIVector<Component> Comp = new Vector<Component> ();

// Create a vector to keep track of the componentsComp= getComponents(Comp);// Create and add components to the vectoraddComponentsToContainer(C, Comp);// Add the components to the GUI// Repaint and make GUI visible

Page 30: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

frame.repaint();frame.setVisible(true);

}// Returns a vector containing the names of the parameters to

changepublic Vector<String> getParameters(){

Vector<String> ans = new Vector<String>();

// Add the parameter names for the selected jointsif(joint11S){

//[front/back][jointnumber][sinnumber] ans.add("walk.amp[1][1][1]");ans.add("walk.phase[1][1][1]");//[front/back][jointnumber]ans.add("walk.mean[1][1]");

}if(joint12S){

//[front/back][joint][sinnumber] ans.add("walk.amp[1][2][1]");ans.add("walk.phase[1][2][1]");//[front/back][jointnumber]ans.add("walk.mean[1][2]");

}if(joint13S){

//[front/back][joint][sinnumber]ans.add("walk.amp[1][3][1]");ans.add("walk.phase[1][3][1]");//[front/back][jointnumber]ans.add("walk.mean[1][3]");

}if(joint21S){

//[front/back][joint][sinnumber]ans.add("walk.amp[2][1][1]");ans.add("walk.phase[2][1][1]");//[front/back][jointnumber]ans.add("walk.mean[2][1]");

}if(joint22S){

//[front/back][joint][sinnumber]ans.add("walk.amp[2][2][1]");ans.add("walk.phase[2][2][1]");//[front/back][jointnumber]ans.add("walk.mean[2][2]");

}if(joint23S){

//[front/back][joint][sinnumber]ans.add("walk.amp[2][3][1]");ans.add("walk.phase[2][3][1]");//[front/back][jointnumber]ans.add("walk.mean[2][3]");

}if(speedsS){

ans.add("robot.turnspeed");ans.add("robot.walkspeed");

}return ans;

}// Add components to the GUIpublic void addComponentsToContainer(Container C, Vector<Compon-

ent> Comp) {Insets insets = C.getInsets();

Page 31: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

C.setLayout(null); // Allows the pro-grammer to freely decide the positions of the components

// (Not recomended together with frame.setResizable(true);)

// Iterate for each componentfor(int i=0; i<Comp.size(); i++){

if(i<1){ // Component 0 is the instruction (Position 50,50)

Dimension prefSize = Comp.get(i).getPreferredSize();

Comp.get(i).setBounds(50 + in-sets.left, 50 + insets.top, prefSize.width, prefSize.height);

C.add(Comp.get(i));}else if(i<4){ // Components 1-3 are front

jointsDimension prefSize =

Comp.get(i).getPreferredSize();Comp.get(i).setBounds(50+100*(i-

1) + insets.left, 100 + insets.top, prefSize.width, prefSize.height);C.add(Comp.get(i));

}else if(i<7){ // Components 4-6 are back

jointsDimension prefSize =

Comp.get(i).getPreferredSize();Comp.get(i).setBounds(50+100*(i-

4) + insets.left, 150 + insets.top, prefSize.width, prefSize.height);C.add(Comp.get(i));

}else if(i<8){ // Component 8 is the speeds

Dimension prefSize = Comp.get(i).getPreferredSize();

Comp.get(i).setBounds(50+100*(i-7) + insets.left, 200 + insets.top, prefSize.width, prefSize.height);

C.add(Comp.get(i));}

/* Commented 1else if(i<9){

Dimension prefSize = Comp.get(i).getPreferredSize();

Comp.get(i).setBounds(50 + in-sets.left, 250 + insets.top, prefSize.width, prefSize.height);

C.add(Comp.get(i));}

else if(i<10){Dimension prefSize =

Comp.get(i).getPreferredSize();Comp.get(i).setBounds(25 + in-

sets.left, 275 + insets.top, prefSize.width, prefSize.height);C.add(Comp.get(i));

}Change 10 below to 11

*/ else if(i<10){ // Component 10 is the

"Next"-buttonDimension prefSize =

Comp.get(i).getPreferredSize();Comp.get(i).setBounds(295 + in-

sets.left, 295 + insets.top, prefSize.width, prefSize.height);

Page 32: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

C.add(Comp.get(i));}

}}// Create the componentspublic Vector<Component> getComponents(Vector<Component> Comp){

// InstructionJTextField instruction1;Comp.add(instruction1=new JTextField("Choose which

joints and speeds to vary",30));instruction1.setEditable(false);

// FrontJointsCheckBoxListener CBL = new CheckBoxListener();

Comp.add(joint11CB=new JCheckBox("FrontJoint1")); joint11CB.addItemListener(CBL);Comp.add(joint12CB=new JCheckBox("FrontJoint2"));joint12CB.addItemListener(CBL);Comp.add(joint13CB=new JCheckBox("FrontJoint3")); joint13CB.addItemListener(CBL);

// BackJointsComp.add(joint21CB=new JCheckBox("BackJoint1")); joint21CB.addItemListener(CBL);Comp.add(joint22CB=new JCheckBox("BackJoint2"));joint22CB.addItemListener(CBL);Comp.add(joint23CB=new JCheckBox("BackJoint3")); joint23CB.addItemListener(CBL);

// SpeedsComp.add(speedsCB=new JCheckBox("Speeds")); speedsCB.addItemListener(CBL);

/* Commented 1// IntructionJTextField instruction2;Comp.add(instruction2=new JTextField("... and then

choose an evaluation parameter and click 'Next'",30));instruction2.setEditable(false);

// Evaluation parameterevalChoise eC=new evalChoise();Comp.add(eC);

*/// Next buttonComp.add(nextB = new JButton("Next"));nextB.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

// The next-button can only be pressed if at least one of the checkboxes are selected

if(startable()==true){

frame.setVisible(false);finished = true;

}}

});return Comp;

}// Returns true if at least one checkbox is selected

Page 33: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

public boolean startable(){if(joint11S==true || joint12S==true || joint13S==true

|| joint21S==true || joint22S==true || joint23S==true || speedsS==true){/* Commented 1

if(eval=="Vibration" || eval == "Speed"){return true;

}else{System.out.println("No selected

eval parameter");return false;

}}else{

*/return true;

}else{System.out.println("No selected boxes");return false;

}}// Returns the value of 'finished'public boolean getFinished(){

return finished;}

/* Commented 1// Returns the eval-choisepublic String getEval(){

return eval;}

*/// Returns a vector with the names of all selected checkboxespublic Vector<String> getSelected(){

Vector<String> selected = new Vector<String>();if(joint11S==true){

selected.add("joint11S");}if(joint12S==true){

selected.add("joint12S");}if(joint13S==true){

selected.add("joint13S");}if(joint21S==true){

selected.add("joint21S");}if(joint22S==true){

selected.add("joint22S");}if(joint23S==true){

selected.add("joint23S");}if(speedsS==true){

selected.add("speedsS");}return selected;

}// This method sets the joint-booleans to true when the check-

boxes are selected and false when they are deselectedpublic class CheckBoxListener implements ItemListener {

public void itemStateChanged(ItemEvent e) {Object source = e.getSource();

Page 34: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

if (source == joint11CB && e.getState-Change() == ItemEvent.DESELECTED){

joint11S=false; }else if (source == joint11CB && e.getStat-

eChange() == ItemEvent.SELECTED){ joint11S=true;

}if (source == joint12CB && e.getState-

Change() == ItemEvent.DESELECTED){ joint12S=false;

}else if (source == joint12CB && e.getStat-

eChange() == ItemEvent.SELECTED){ joint12S=true;

}if (source == joint13CB && e.getState-

Change() == ItemEvent.DESELECTED){ joint13S=false;

}else if (source == joint13CB && e.getStat-

eChange() == ItemEvent.SELECTED){ joint13S=true;

}if (source == joint21CB && e.getState-

Change() == ItemEvent.DESELECTED){ joint21S=false;

}else if (source == joint21CB && e.getStat-

eChange() == ItemEvent.SELECTED){ joint21S=true;

}if (source == joint22CB && e.getState-

Change() == ItemEvent.DESELECTED){ joint22S=false;

}else if (source == joint22CB && e.getStat-

eChange() == ItemEvent.SELECTED){ joint22S=true;

}if (source == joint23CB && e.getState-

Change() == ItemEvent.DESELECTED){ joint23S=false;

}else if (source == joint23CB && e.getStat-

eChange() == ItemEvent.SELECTED){ joint23S=true;

}if (source == speedsCB && e.getState-

Change() == ItemEvent.DESELECTED){ speedsS=false;

}else if (source == speedsCB && e.getState-

Change() == ItemEvent.SELECTED){ speedsS=true;

} }

} /* Commented 1

// This class handles the Eval-Choise componentpublic class evalChoise extends JPanel {

Page 35: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

JLabel jlbPicture;public evalChoise() {

// String array containing the different choises

String[] evalChoises = { "Choose an evalu-ation parameter", "Speed", "Vibration"};

JComboBox evalChoiseList = new JComboBox(evalChoises);

// Which choise should be selected from start

evalChoiseList.setSelectedIndex(0);evalChoiseList.addActionListener(new Ac-

tionListener() {// What should happen when the

value is changedpublic void actionPerformed(Ac-

tionEvent e) {JComboBox jcmbType =

(JComboBox) e.getSource();String s = (String)

jcmbType.getSelectedItem();

jlbPicture.setIcon(new ImageIcon("" + s.trim().toLowerCase() + ".jpg"));

// Set eval to the current choise

if(s.equals("Choose an evaluation parameter"))

eval="Choose an evaluation parameter";else

if(s.equals("Speed"))

eval="Speed";else if(s.equals("Vi-

bration"))eval="Vib-

ration";}

});// Set up the picturejlbPicture = new JLabel(new ImageIcon(""

+ evalChoises[evalChoiseList.getSelectedIndex()] + ".jpg"));

jlbPicture.setBorder(BorderFactory.cre-ateEmptyBorder(10, 0, 0, 0));

jlbPicture.setPreferredSize(new Dimension(177, 122 + 10));

// Layout the demosetLayout(new BorderLayout());add(evalChoiseList, BorderLayout.NORTH);add(jlbPicture, BorderLayout.SOUTH);

setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));}

}*/}

Page 36: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

GUI2.java

package aibo;

import java.awt.BorderLayout;import java.awt.Component;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Vector;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JTabbedPane;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;//import aibo.GUI.TextHandler;

// This class creates and shows GUI 2 - where the user gets to choose the values for the choosen parameterspublic class GUI2 extends JFrame{

// Initiate parametersJFrame frame;JButton start;JLabel disp6;TextHandler handler = null;boolean finished=false;Vector<String> selected;

// Max, Min and Delta (= step length) componentes and values for each parameter

// SpeedsJTextField TSpeedMin, WSpeedMin, TSpeedMax, WSpeedMax, TSpeed-

Delta, WSpeedDelta;double tSpeedMin, wSpeedMin, tSpeedMax, wSpeedMax, tSpeedDelta,

wSpeedDelta;// AmplitudesJTextField Aj11min, Aj12min, Aj13min, Aj21min, Aj22min, Aj23min;JTextField Aj11max, Aj12max, Aj13max, Aj21max, Aj22max, Aj23max;JTextField Aj11delta, Aj12delta, Aj13delta, Aj21delta, Aj22del-

ta, Aj23delta;double aj11min, aj12min, aj13min, aj21min, aj22min, aj23min;double aj11max, aj12max, aj13max, aj21max, aj22max, aj23max;double aj11delta, aj12delta, aj13delta, aj21delta, aj22delta,

aj23delta;// PhasesJTextField Pj11min, Pj12min, Pj13min, Pj21min, Pj22min, Pj23min;JTextField Pj11max, Pj12max, Pj13max, Pj21max, Pj22max, Pj23max;JTextField Pj11delta, Pj12delta, Pj13delta, Pj21delta, Pj22del-

ta, Pj23delta;double pj11min, pj12min, pj13min, pj21min, pj22min, pj23min;double pj11max, pj12max, pj13max, pj21max, pj22max, pj23max;double pj11delta, pj12delta, pj13delta, pj21delta, pj22delta,

pj23delta;// Mean valuesJTextField Mj11min, Mj12min, Mj13min, Mj21min, Mj22min, Mj23min;JTextField Mj11max, Mj12max, Mj13max, Mj21max, Mj22max, Mj23max;

Page 37: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

JTextField Mj11delta, Mj12delta, Mj13delta, Mj21delta, Mj22del-ta, Mj23delta;

double mj11min, mj12min, mj13min, mj21min, mj22min, mj23min;double mj11max, mj12max, mj13max, mj21max, mj22max, mj23max;double mj11delta, mj12delta, mj13delta, mj21delta, mj22delta,

mj23delta;

// Constructorpublic GUI2(Vector<String> s){

selected=s;}// 'createAndShowGUI' is the method called from Laika.javapublic void createAndShowGUI() {

// Create the basic GUI (without any components) and set layout

JFrame.setDefaultLookAndFeelDecorated(true);frame = new JFrame("AIBO-developer tool");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Container C=frame.getContentPane();C.setLayout(new GridLayout(0,1));// Set size of the GUI and if it should be possible

to change or notInsets insets = frame.getInsets();frame.setSize(420 + insets.left + insets.right, 400 +

insets.top + insets.bottom);frame.setResizable(false);// Add components to the GUIaddComponent(C);// Repaint and make GUI visibleframe.repaint();frame.setVisible(true);

}// Adds components to the GUIpublic void addComponent(Container C){

// Create the main component - in which all other components will be placed

JTabbedPane TPane = new JTabbedPane();// Create the inner panels - one for each selected

joint and one named "ready"Vector<Component> inner = new Vector<Component>();inner=createInnerPanels(inner);// Create the tabs - one for each selected joint and

one named "ready"TPane=addTabs(TPane, inner);C.add(TPane, BorderLayout.CENTER);

}// Returns a vector containing the inner panelspublic Vector<Component> createInnerPanels(Vector<Component> in-

ner){// One inner pane for each selected joint...for(int i=0; i<selected.size(); i++){

JPanel innerPanel = new JPanel();// Add the components to each inner panelVector<Component> inComp= new Vector<Com-

ponent>();inComp=innerComponents(inComp, i);

innerPanel=addInnerComp(innerPanel, in-Comp);

inner.add(innerPanel);}

Page 38: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

// ... and one for the Start buttonstart = new JButton("Start");start.addActionListener(new ActionListener() {

// Defines what should happend when the button is pressed

public void actionPerformed(ActionEvent e) {

// Check wether it should be posible to press the button or not

String svar=startable();if(svar=="true"){

// If startable set finished to true and make the frame invisible

frame.setVisible(false);finished = true;

}else{// If not statable

display an explanation why below the buttondisp6.setText(svar);disp6.repaint();

}}

});// Add the last paneldisp6 = new JLabel("

");JPanel innerPanel = new JPanel();innerPanel=addReady(innerPanel, start, disp6);inner.add(innerPanel);return inner;

}// Returns a JTabbedPane with the tabs addedpublic JTabbedPane addTabs(JTabbedPane TPane, Vector<Component>

inner){// For each joint-tab...for(int i=0; i<selected.size(); i++){

TPane.addTab(selected.get(i), inner.get(i));

}// ... and the ready-tabTPane.addTab("Ready", inner.get(inner.size()-1));return TPane;

}// Returns the string "true" if the button start should be

pressable - otherwise an explanaition why is returnedpublic String startable(){

// Check that all Max-values are higher or equal to the Min-values under each tab

for(int i=0; i<selected.size(); i++){if(selected.get(i)=="speedsS"){

if(tSpeedMin>tSpeedMax || wSpeedMin > wSpeedMax){

return " Speed: min>max";

}}else if(selected.get(i)=="joint11S"){

if(aj11min>aj11max || pj11min>pj11max || mj11min>mj11max){

Page 39: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

return " joint11S: min>max";

}

}else if(selected.get(i)=="joint12S"){

if(aj12min>aj12max || pj12min>pj12max || mj12min>mj12max){

return " joint12S: min>max";

}

}else if(selected.get(i)=="joint13S"){

if(aj13min>aj13max || pj13min>pj13max || mj13min>mj13max){

return " joint13S: min>max";

}

}else if(selected.get(i)=="joint21S"){

if(aj21min>aj21max || pj21min>pj21max || mj21min>mj21max){

return " joint21S: min>max";

}

}else if(selected.get(i)=="joint22S"){

if(aj22min>aj22max || pj22min>pj22max || mj22min>mj22max){

return " joint22S: min>max";

}

}else if(selected.get(i)=="joint23S"){

if(aj23min>aj23max || pj23min>pj23max || mj23min>mj23max){

return " joint23S: min>max";

}

}}// Return "true" if all requirements have been metreturn "true";

}// Returns a vector containing the Min-values for all selected

jointspublic Vector<Double> getMin(){

Vector<Double> ans = new Vector<Double>();for(int i=0; i<selected.size(); i++){

if(selected.get(i)=="speedsS"){ans.add(tSpeedMin);ans.add(wSpeedMin);

}else if(selected.get(i)=="joint11S"){

ans.add(aj11min);ans.add(pj11min);

Page 40: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

ans.add(mj11min);}else if(selected.get(i)=="joint12S"){

ans.add(aj12min);ans.add(pj12min);ans.add(mj12min);

}else if(selected.get(i)=="joint13S"){

ans.add(aj13min);ans.add(pj13min);ans.add(mj13min);

}else if(selected.get(i)=="joint21S"){

ans.add(aj21min);ans.add(pj21min);ans.add(mj21min);

}else if(selected.get(i)=="joint22S"){

ans.add(aj22min);ans.add(pj22min);ans.add(mj22min);

}else if(selected.get(i)=="joint23S"){

ans.add(aj23min);ans.add(pj23min);ans.add(mj23min);

}

}return ans;

}// Returns a vector containing the Max-values for all selected

jointspublic Vector<Double> getMax(){

Vector<Double> ans = new Vector<Double>();for(int i=0; i<selected.size(); i++){

if(selected.get(i)=="speedsS"){ans.add(tSpeedMax);ans.add(wSpeedMax);

}else if(selected.get(i)=="joint11S"){

ans.add(aj11max);ans.add(pj11max);ans.add(mj11max);

}else if(selected.get(i)=="joint12S"){

ans.add(aj12max);ans.add(pj12max);ans.add(mj12max);

}else if(selected.get(i)=="joint13S"){

ans.add(aj13max);ans.add(pj13max);ans.add(mj13max);

Page 41: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

}else if(selected.get(i)=="joint21S"){

ans.add(aj21max);ans.add(pj21max);ans.add(mj21max);

}else if(selected.get(i)=="joint22S"){

ans.add(aj22max);ans.add(pj22max);ans.add(mj22max);

}else if(selected.get(i)=="joint23S"){

ans.add(aj23max);ans.add(pj23max);ans.add(mj23max);

}

}return ans;

}// Returns a vector containing the Delta-values for all selected

jointspublic Vector<Double> getDelta(){

Vector<Double> ans = new Vector<Double>();for(int i=0; i<selected.size(); i++){

if(selected.get(i)=="speedsS"){ans.add(tSpeedDelta);ans.add(wSpeedDelta);

}else if(selected.get(i)=="joint11S"){

ans.add(aj11delta);ans.add(pj11delta);ans.add(mj11delta);

}else if(selected.get(i)=="joint12S"){

ans.add(aj12delta);ans.add(pj12delta);ans.add(mj12delta);

}else if(selected.get(i)=="joint13S"){

ans.add(aj13delta);ans.add(pj13delta);ans.add(mj13delta);

}else if(selected.get(i)=="joint21S"){

ans.add(aj21delta);ans.add(pj21delta);ans.add(mj21delta);

}else if(selected.get(i)=="joint22S"){

ans.add(aj22delta);ans.add(pj22delta);ans.add(mj22delta);

}

Page 42: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

else if(selected.get(i)=="joint23S"){ans.add(aj23delta);ans.add(pj23delta);ans.add(mj23delta);

}

}return ans;

}// Returns the value of "finished"public boolean getFinished(){

return finished;}// Returns a vector containing all inner components for tab jpublic Vector<Component> innerComponents(Vector<Component> in-

Comp, int j){handler = new TextHandler();// If tab j is the speeds-tab - create the inner com-

ponents and add then to the vectorif(selected.get(j)=="speedsS"){

// TurnspeedJLabel disp1 = new JLabel("TurningSpeed");

inComp.add(disp1);TSpeedMin= new JTextField("Min",3);

TSpeedMin.addActionListener(handler);

inComp.add(TSpeedMin);

TSpeedMax= new JTextField("Max",3);

TSpeedMax.addActionListener(handler);inComp.add(TSpeedMax);

TSpeedDelta= new JTextField("Delta",3);

TSpeedDelta.addActionListener(handler);inComp.add(TSpeedDelta);// WalkspeedJLabel disp2 = new JLabel("WalkingSpeed");

inComp.add(disp2);WSpeedMin= new JTextField("Min",3);

WSpeedMin.addActionListener(handler);inComp.add(WSpeedMin);

WSpeedMax= new JTextField("Max",3);

WSpeedMax.addActionListener(handler);inComp.add(WSpeedMax);

WSpeedDelta= new JTextField("Delta",3);

WSpeedDelta.addActionListener(handler);inComp.add(WSpeedDelta);

// If tab j is the joint11-tab - create the inner components and add then to the vector

}else if(selected.get(j)=="joint11S"){

Page 43: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

// AmplitudeJLabel disp3 = new JLabel("Amplitude");

inComp.add(disp3);Aj11min= new JTextField("Min",3);

Aj11min.addActionListener(handler);inComp.add(Aj11min);Aj11max= new JTextField("Max",3);

Aj11max.addActionListener(handler);inComp.add(Aj11max);Aj11delta= new JTextField("Delta",3);

Aj11delta.addActionListener(handler);inComp.add(Aj11delta);// PhaseJLabel disp4 = new JLabel("Phase");

inComp.add(disp4);Pj11min= new JTextField("Min",3);

Pj11min.addActionListener(handler);inComp.add(Pj11min);Pj11max= new JTextField("Max",3);

Pj11max.addActionListener(handler);inComp.add(Pj11max);Pj11delta= new JTextField("Delta",3);

Pj11delta.addActionListener(handler);inComp.add(Pj11delta);// MeanJLabel disp5 = new JLabel("Mean");

inComp.add(disp5);Mj11min= new JTextField("Min",3);

Mj11min.addActionListener(handler);inComp.add(Mj11min);Mj11max= new JTextField("Max",3);

Mj11max.addActionListener(handler);inComp.add(Mj11max);Mj11delta= new JTextField("Delta",3);

Mj11delta.addActionListener(handler);inComp.add(Mj11delta);

// If tab j is the joint12-tab - create the inner components and add then to the vector

}else if(selected.get(j)=="joint12S"){// AmplitudeJLabel disp3 = new JLabel("Amplitude");

inComp.add(disp3);Aj12min= new JTextField("Min",3);

Aj12min.addActionListener(handler);inComp.add(Aj12min);

Page 44: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Aj12max= new JTextField("Max",3);

Aj12max.addActionListener(handler);inComp.add(Aj12max);Aj12delta= new JTextField("Delta",3);

Aj12delta.addActionListener(handler);inComp.add(Aj12delta);// PhaseJLabel disp4 = new JLabel("Phase");

inComp.add(disp4);Pj12min= new JTextField("Min",3);

Pj12min.addActionListener(handler);inComp.add(Pj12min);Pj12max= new JTextField("Max",3);

Pj12max.addActionListener(handler);inComp.add(Pj12max);Pj12delta= new JTextField("Delta",3);

Pj12delta.addActionListener(handler);inComp.add(Pj12delta);// MeanJLabel disp5 = new JLabel("Mean");

inComp.add(disp5);Mj12min= new JTextField("Min",3);

Mj12min.addActionListener(handler);inComp.add(Mj12min);Mj12max= new JTextField("Max",3);

Mj12max.addActionListener(handler);inComp.add(Mj12max);Mj12delta= new JTextField("Delta",3);

Mj12delta.addActionListener(handler);inComp.add(Mj12delta);

// If tab j is the joint13-tab - create the inner components and add then to the vector

}else if(selected.get(j)=="joint13S"){// AmplitudeJLabel disp3 = new JLabel("Amplitude");

inComp.add(disp3);Aj13min= new JTextField("Min",3);

Aj13min.addActionListener(handler);inComp.add(Aj13min);Aj13max= new JTextField("Max",3);

Aj13max.addActionListener(handler);inComp.add(Aj13max);Aj13delta= new JTextField("Delta",3);

Aj13delta.addActionListener(handler);inComp.add(Aj13delta);// Phase

Page 45: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

JLabel disp4 = new JLabel("Phase");

inComp.add(disp4);Pj13min= new JTextField("Min",3);

Pj13min.addActionListener(handler);inComp.add(Pj13min);Pj13max= new JTextField("Max",3);

Pj13max.addActionListener(handler);inComp.add(Pj13max);Pj13delta= new JTextField("Delta",3);

Pj13delta.addActionListener(handler);inComp.add(Pj13delta);// MeanJLabel disp5 = new JLabel("Mean");

inComp.add(disp5);Mj13min= new JTextField("Min",3);

Mj13min.addActionListener(handler);inComp.add(Mj13min);Mj13max= new JTextField("Max",3);

Mj13max.addActionListener(handler);inComp.add(Mj13max);Mj13delta= new JTextField("Delta",3);

Mj13delta.addActionListener(handler);inComp.add(Mj13delta);

// If tab j is the joint21-tab - create the inner components and add then to the vector

}else if(selected.get(j)=="joint21S"){// AmplitudeJLabel disp3 = new JLabel("Amplitude");

inComp.add(disp3);Aj21min= new JTextField("Min",3);

Aj21min.addActionListener(handler);inComp.add(Aj21min);Aj21max= new JTextField("Max",3);

Aj21max.addActionListener(handler);inComp.add(Aj21max);Aj21delta= new JTextField("Delta",3);

Aj21delta.addActionListener(handler);inComp.add(Aj21delta);// PhaseJLabel disp4 = new JLabel("Phase");

inComp.add(disp4);Pj21min= new JTextField("Min",3);

Pj21min.addActionListener(handler);inComp.add(Pj21min);Pj21max= new JTextField("Max",3);

Page 46: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Pj21max.addActionListener(handler);inComp.add(Pj21max);Pj21delta= new JTextField("Delta",3);

Pj21delta.addActionListener(handler);inComp.add(Pj21delta);// MeanJLabel disp5 = new JLabel("Mean");

inComp.add(disp5);Mj21min= new JTextField("Min",3);

Mj21min.addActionListener(handler);inComp.add(Mj21min);Mj21max= new JTextField("Max",3);

Mj21max.addActionListener(handler);inComp.add(Mj21max);Mj21delta= new JTextField("Delta",3);

Mj21delta.addActionListener(handler);inComp.add(Mj21delta);

// If tab j is the joint22-tab - create the inner components and add then to the vector

}else if(selected.get(j)=="joint22S"){// AmplitudeJLabel disp3 = new JLabel("Amplitude");

inComp.add(disp3);Aj22min= new JTextField("Min",3);

Aj22min.addActionListener(handler);inComp.add(Aj22min);Aj22max= new JTextField("Max",3);

Aj22max.addActionListener(handler);inComp.add(Aj22max);Aj22delta= new JTextField("Delta",3);

Aj22delta.addActionListener(handler);inComp.add(Aj22delta);// PhaseJLabel disp4 = new JLabel("Phase");

inComp.add(disp4);Pj22min= new JTextField("Min",3);

Pj22min.addActionListener(handler);inComp.add(Pj22min);Pj22max= new JTextField("Max",3);

Pj22max.addActionListener(handler);inComp.add(Pj22max);Pj22delta= new JTextField("Delta",3);

Pj22delta.addActionListener(handler);inComp.add(Pj22delta);// MeanJLabel disp5 = new JLabel("Mean");

inComp.add(disp5);

Page 47: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Mj22min= new JTextField("Min",3);

Mj22min.addActionListener(handler);inComp.add(Mj22min);Mj22max= new JTextField("Max",3);

Mj22max.addActionListener(handler);inComp.add(Mj22max);Mj22delta= new JTextField("Delta",3);

Mj22delta.addActionListener(handler);inComp.add(Mj22delta);

// If tab j is the joint23-tab - create the inner components and add then to the vector

}else if(selected.get(j)=="joint23S"){// AmplitudeJLabel disp3 = new JLabel("Amplitude");

inComp.add(disp3);Aj23min= new JTextField("Min",3);

Aj23min.addActionListener(handler);inComp.add(Aj23min);Aj23max= new JTextField("Max",3);

Aj23max.addActionListener(handler);inComp.add(Aj23max);Aj23delta= new JTextField("Delta",3);

Aj23delta.addActionListener(handler);inComp.add(Aj23delta);// PhaseJLabel disp4 = new JLabel("Phase");

inComp.add(disp4);Pj23min= new JTextField("Min",3);

Pj23min.addActionListener(handler);inComp.add(Pj23min);Pj23max= new JTextField("Max",3);

Pj23max.addActionListener(handler);inComp.add(Pj23max);Pj23delta= new JTextField("Delta",3);

Pj23delta.addActionListener(handler);inComp.add(Pj23delta);// MeanJLabel disp5 = new JLabel("Mean");

inComp.add(disp5);Mj23min= new JTextField("Min",3);

Mj23min.addActionListener(handler);inComp.add(Mj23min);Mj23max= new JTextField("Max",3);

Mj23max.addActionListener(handler);inComp.add(Mj23max);

Page 48: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Mj23delta= new JTextField("Delta",3);

Mj23delta.addActionListener(handler);inComp.add(Mj23delta);

}return inComp;

}// Returns an inner panel containing the components a and bpublic JPanel addReady(JPanel innerPanel, Component a, Component

b){innerPanel.setLayout(null);

Dimension prefSize = a.getPreferredSize();a.setBounds(175, 150, prefSize.width, prefS-

ize.height);innerPanel.add(a);

Dimension prefSize2 = b.getPreferredSize();b.setBounds(137, 185, prefSize2.width,

prefSize2.height);innerPanel.add(b);

return innerPanel;}// Returns an inner panel with the components in the vector in-

Comppublic JPanel addInnerComp(JPanel innerPanel, Vector<Component>

inComp) {innerPanel.setLayout(null);// For each component in inCompfor(int i=0; i<inComp.size(); i++){

if(i<1){ // Header 1Dimension prefSize =

inComp.get(i).getPreferredSize();inComp.get(i).setBounds(50, 25,

prefSize.width, prefSize.height);innerPanel.add(inComp.get(i));

}else if(i<4){ // min - max - delta

Dimension prefSize = inComp.get(i).getPreferredSize();

inComp.get(i).setBounds(50+100*(i-1), 50, prefSize.width, prefS-ize.height);

innerPanel.add(inComp.get(i));}else if(i<5){ // Header 2

Dimension prefSize = inComp.get(i).getPreferredSize();

inComp.get(i).setBounds(50, 100, prefSize.width, prefSize.height);

innerPanel.add(inComp.get(i));}else if(i<8){ // min - max- delta

Dimension prefSize = inComp.get(i).getPreferredSize();

inComp.get(i).setBounds(50+100*(i-5), 125, prefSize.width, pref-Size.height);

innerPanel.add(inComp.get(i));}

Page 49: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

else if(i<9){ // Header 3Dimension prefSize =

inComp.get(i).getPreferredSize();inComp.get(i).setBounds(50, 175,

prefSize.width, prefSize.height);innerPanel.add(inComp.get(i));

}else if(i<12){ // min - max - delta

Dimension prefSize = inComp.get(i).getPreferredSize();

inComp.get(i).setBounds(50+100*(i-9), 200, prefSize.width, pref-Size.height);

innerPanel.add(inComp.get(i));}

}return innerPanel;

}// This method defines what shoould happend when the values in

the textfields are changedprivate class TextHandler implements ActionListener {

// If all requirements are met for the current text field - set the corresponding double to the new value

// If not change the text in the textfield to the original text.

public void actionPerformed(ActionEvent e) {// Do(ActionCommand, corresponding double,

original text, field number)// Speed fieldsif (e.getSource() == WSpeedMin){

Do(e.getActionCommand(), WSpeed-Min, "Min", 1);

}else if (e.getSource() == TSpeedMin) {

Do(e.getActionCommand(), TSpeed-Min, "Min", 2);

}else if (e.getSource() == WSpeedMax) {

Do(e.getActionCommand(), WSpeed-Max, "Max", 3);

}else if (e.getSource() == TSpeedMax) {

Do(e.getActionCommand(), TSpeed-Max, "Max", 4);

}else if (e.getSource() == WSpeedDelta) {

Do(e.getActionCommand(), WSpeed-Delta, "Delta", 5);

}else if (e.getSource() == TSpeedDelta) {

Do(e.getActionCommand(), TSpeed-Delta, "Delta", 6);

}// Min fieldselse if (e.getSource() == Aj11min) {

Do(e.getActionCommand(), Aj11-min, "Min", 10);

}else if (e.getSource() == Aj12min) {

Page 50: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Do(e.getActionCommand(), Aj12-min, "Min", 11);

}else if (e.getSource() == Aj13min) {

Do(e.getActionCommand(), Aj13-min, "Min", 12);

}else if (e.getSource() == Aj21min) {

Do(e.getActionCommand(), Aj21-min, "Min", 13);

}else if (e.getSource() == Aj22min) {

Do(e.getActionCommand(), Aj22-min, "Min", 14);

}else if (e.getSource() == Aj23min) {

Do(e.getActionCommand(), Aj23-min, "Min", 15);

}else if (e.getSource() == Pj11min) {

Do(e.getActionCommand(), Pj11min, "Min", 16);

}else if (e.getSource() == Pj12min) {

Do(e.getActionCommand(), Pj12min, "Min", 17);

}else if (e.getSource() == Pj13min) {

Do(e.getActionCommand(), Pj13min, "Min", 18);

}else if (e.getSource() == Pj21min) {

Do(e.getActionCommand(), Pj21min, "Min", 19);

}else if (e.getSource() == Pj22min) {

Do(e.getActionCommand(), Pj22min, "Min", 20);

}else if (e.getSource() == Pj23min) {

Do(e.getActionCommand(), Pj23min, "Min", 21);

}else if (e.getSource() == Mj11min) {

Do(e.getActionCommand(), Mj11-min, "Min", 22);

}else if (e.getSource() == Mj12min) {

Do(e.getActionCommand(), Mj12-min, "Min", 23);

}else if (e.getSource() == Mj13min) {

Do(e.getActionCommand(), Mj13-min, "Min", 24);

}else if (e.getSource() == Mj21min) {

Do(e.getActionCommand(), Mj21-min, "Min", 25);

}else if (e.getSource() == Mj22min) {

Page 51: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Do(e.getActionCommand(), Mj22-min, "Min", 26);

}else if (e.getSource() == Mj23min) {

Do(e.getActionCommand(), Mj23-min, "Min", 27);

}// Max fieldselse if (e.getSource() == Aj11max) {

Do(e.getActionCommand(), Aj11max, "Max", 30);

}else if (e.getSource() == Aj12max) {

Do(e.getActionCommand(), Aj12max, "Max", 31);

}else if (e.getSource() == Aj13max) {

Do(e.getActionCommand(), Aj13max, "Max", 32);

}else if (e.getSource() == Aj21max) {

Do(e.getActionCommand(), Aj21max, "Max", 33);

}else if (e.getSource() == Aj22max) {

Do(e.getActionCommand(), Aj22max, "Max", 34);

}else if (e.getSource() == Aj23max) {

Do(e.getActionCommand(), Aj23max, "Max", 35);

}else if (e.getSource() == Pj11max) {

Do(e.getActionCommand(), Pj11max, "Max", 36);

}else if (e.getSource() == Pj12max) {

Do(e.getActionCommand(), Pj12max, "Max", 37);

}else if (e.getSource() == Pj13max) {

Do(e.getActionCommand(), Pj13max, "Max", 38);

}else if (e.getSource() == Pj21max) {

Do(e.getActionCommand(), Pj21max, "Max", 39);

}else if (e.getSource() == Pj22max) {

Do(e.getActionCommand(), Pj22max, "Max", 40);

}else if (e.getSource() == Pj23max) {

Do(e.getActionCommand(), Pj23max, "Max", 41);

}else if (e.getSource() == Mj11max) {

Do(e.getActionCommand(), Mj11max, "Max", 42);

}else if (e.getSource() == Mj12max) {

Page 52: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Do(e.getActionCommand(), Mj12max, "Max", 43);

}else if (e.getSource() == Mj13max) {

Do(e.getActionCommand(), Mj13max, "Max", 44);

}else if (e.getSource() == Mj21max) {

Do(e.getActionCommand(), Mj21max, "Max", 45);

}else if (e.getSource() == Mj22max) {

Do(e.getActionCommand(), Mj22max, "Max", 46);

}else if (e.getSource() == Mj23max) {

Do(e.getActionCommand(), Mj23max, "Max", 47);

}// Delta fieldselse if (e.getSource() == Aj11delta) {

Do(e.getActionCommand(), Aj11-delta, "Delta", 50);

}else if (e.getSource() == Aj12delta) {

Do(e.getActionCommand(), Aj12-delta, "Delta", 51);

}else if (e.getSource() == Aj13delta) {

Do(e.getActionCommand(), Aj13-delta, "Delta", 52);

}else if (e.getSource() == Aj21delta) {

Do(e.getActionCommand(), Aj21-delta, "Delta", 53);

}else if (e.getSource() == Aj22delta) {

Do(e.getActionCommand(), Aj22-delta, "Delta", 54);

}else if (e.getSource() == Aj23delta) {

Do(e.getActionCommand(), Aj23-delta, "Delta", 55);

}else if (e.getSource() == Pj11delta) {

Do(e.getActionCommand(), Pj11-delta, "Delta", 56);

}else if (e.getSource() == Pj12delta) {

Do(e.getActionCommand(), Pj12-delta, "Delta", 57);

}else if (e.getSource() == Pj13delta) {

Do(e.getActionCommand(), Pj13-delta, "Delta", 58);

}else if (e.getSource() == Pj21delta) {

Do(e.getActionCommand(), Pj21-delta, "Delta", 59);

}else if (e.getSource() == Pj22delta) {

Page 53: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Do(e.getActionCommand(), Pj22-delta, "Delta", 60);

}else if (e.getSource() == Pj23delta) {

Do(e.getActionCommand(), Pj23-delta, "Delta", 61);

}else if (e.getSource() == Mj11delta) {

Do(e.getActionCommand(), Mj11-delta, "Delta", 62);

}else if (e.getSource() == Mj12delta) {

Do(e.getActionCommand(), Mj12-delta, "Delta", 63);

}else if (e.getSource() == Mj13delta) {

Do(e.getActionCommand(), Mj13-delta, "Delta", 64);

}else if (e.getSource() == Mj21delta) {

Do(e.getActionCommand(), Mj21-delta, "Delta", 65);

}else if (e.getSource() == Mj22delta) {

Do(e.getActionCommand(), Mj22-delta, "Delta", 66);

}else if (e.getSource() == Mj23delta) {

Do(e.getActionCommand(), Mj23-delta, "Delta", 67);

}}// If all requirements are met - set the correspond-

ing double to the new value// If not - change the text in the textfield to the

original text.// Do(ActionCommand, corresponding double, original

text, field number)public void Do(String temp, JTextField source, String

text, int t){// If the current text is a numberif(isNumber(temp)==true){

// Convert to doubledouble number=toNumber(temp);// If the double is within the

limitations stated in okNumberif(okNumber(t, number)==true){

// Set the value the corresponding double and change the text in the textfield

source.setText("" + number);

setT(t, number);// If not an ok number - Change

the text to the original text}else{

source.setText(text);}

// If not a number - Change the text to the original text

}else{ source.setText(text);

Page 54: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

}}// Set a new value to the double which corresponds to

the field number public void setT(int t, double number){

if(t==1)wSpeedMin=number;

else if(t==2)tSpeedMin=number;

else if(t==3)wSpeedMax=number;

else if(t==4)tSpeedMax=number;

else if(t==5)wSpeedDelta=number;

else if(t==6)tSpeedDelta=number;

else if(t==10)aj11min=number;

else if(t==11)aj12min=number;

else if(t==12)aj13min=number;

else if(t==13)aj21min=number;

else if(t==14)aj22min=number;

else if(t==15)aj23min=number;

else if(t==16)pj11min=number;

else if(t==17)pj12min=number;

else if(t==18)pj13min=number;

else if(t==19)pj21min=number;

else if(t==20)pj22min=number;

else if(t==21)pj23min=number;

else if(t==22)mj11min=number;

else if(t==23)mj12min=number;

else if(t==24)mj13min=number;

else if(t==25)mj21min=number;

else if(t==26)mj22min=number;

else if(t==27)mj23min=number;

else if(t==30)aj11max=number;

else if(t==31)

Page 55: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

aj12max=number;else if(t==32)

aj13max=number;else if(t==33)

aj21max=number;else if(t==34)

aj22max=number;else if(t==35)

aj23max=number;else if(t==36)

pj11max=number;

else if(t==37)pj12max=number;

else if(t==38)pj13max=number;

else if(t==39)pj21max=number;

else if(t==40)pj22max=number;

else if(t==41)pj23max=number;

else if(t==42)mj11max=number;

else if(t==43)mj12max=number;

else if(t==44)mj13max=number;

else if(t==45)mj21max=number;

else if(t==46)mj22max=number;

else if(t==47)mj23max=number;

else if(t==50)aj11delta=number;

else if(t==51)aj12delta=number;

else if(t==52)aj13delta=number;

else if(t==53)aj21delta=number;

else if(t==54)aj22delta=number;

else if(t==55)aj23delta=number;

else if(t==56)pj11delta=number;

else if(t==57)pj12delta=number;

else if(t==58)pj13delta=number;

else if(t==59)pj21delta=number;

else if(t==60)pj22delta=number;

else if(t==61)pj23delta=number;

Page 56: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

else if(t==62)mj11delta=number;

else if(t==63)mj12delta=number;

else if(t==64)mj13delta=number;

else if(t==65)mj21delta=number;

else if(t==66)mj22delta=number;

else if(t==67)mj23delta=number;

}// Returns true if the string is an numberpublic boolean isNumber(String temp){

int counter=0;// Remove the first character if it's a

minus signif(temp.charAt(0) == 45){

temp=temp.substring(1, tem-p.length());

}// Chech each character in the remaining

string// If one or more is not an integer - re-

turn falsefor(int i=0; i<temp.length(); i++){

String a = temp.substring(i, i+1);

if(a.equals("0") || a.equals("1") || a.equals("2") || a.equals("3") || a.equals("4")

|| a.equals("5") || a.equals("6") || a.equals("7") || a.equals("8") || a.equals("9") || a.equals(".")){

if(a.equals("."))counter++;

}elsereturn false;

}// Return false if there are more than one

.if(counter<2){

return true;}else{

return false;}

}// Convert a string to a numberpublic double toNumber(String temp){

return Double.parseDouble(temp);}// Returns true if 'number' is within the limitations

stated for field number 't'public boolean okNumber(int t, double number){

if(t==1 && number>500) //walkspeed min

return true;else if(t==2&& number>500) //turnspeed

min

Page 57: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

return true;

else if(t==3&& number<2000) //walkspeed max

return true;else if(t==4&& number<2000) //turnspeed

maxreturn true;

else if(t==5&& number<=1000 && number>=100) //walkspeed delta

return true;else if(t==6&& number<=1000 &&

number>=100) // turnspeed deltareturn true;

else if(t==10&& number>-15) //min amp front joint 1

return true;else if(t==11&& number>-28) //joint 2

return true;else if(t==12&& number>-17) //3

return true;else if(t==13&& number>-15) //min amp back

joint 1return true;

else if(t==14&& number>-28) //2return true;

else if(t==15&& number>-18) //3return true;

else if(t==16&& number>-28) //min pha fron joint 1

return true;

else if(t==17&& number>-32) //2return true;

else if(t==18&& number>-32) //3return true;

else if(t==19&& number>-32) //min pha back joint 1

return true;else if(t==20&& number>-32) //2

return true;else if(t==21&& number>-32) //3

return true;else if(t==22&& number>-40) //min mean

front joint 1return true;

else if(t==23&& number>-20) //2return true;

else if(t==24&& number>51) //3return true;

else if(t==25&& number>-60) //min mean back joint1

return true;

else if(t==26&& number>-20) //2return true;

else if(t==27&& number>60) //3return true;

Page 58: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

else if(t==30&& number<45) //max amp fron joint 1

return true;else if(t==31&& number<32) //2

return true;else if(t==32&& number<44) //3

return true;else if(t==33&& number<44) //max amp back

joint 1return true;

else if(t==34&& number<32) //2return true;

else if(t==35&& number<44) //3return true;

else if(t==36&& number<32) //max pah front joint 1

return true;

else if(t==37&& number<28) //2return true;

else if(t==38&& number<28) //3return true;

else if(t==39&& number<28) //max pha back joint 1

return true;else if(t==40&& number<28) //2

return true;else if(t==41&& number<28) //3

return true;else if(t==42&& number<20) //max mean fron

joint 1return true;

else if(t==43&& number<40) //2return true;

else if(t==44&& number<110) //3return true;

else if(t==45&& number<2) //max mean back joint 1

return true;

else if(t==46&& number<40) //2return true;

else if(t==47&& number<120) //3return true;

else if(t==50&& number>=1 && number<50) //amp front joint 1

return true;else if(t==51&& number>=1 && number<50)

//2return true;

else if(t==52&& number>=1 && number<50) //3

return true;else if(t==53&& number>=1 && number<50)

//amp back joint 1return true;

else if(t==54&& number>=1 && number<50) //2

return true;

Page 59: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

else if(t==55&& number>=1 && number<50) //3

return true;else if(t==56&& number>=1 && number<50)

//pha front joint 1return true;

else if(t==57&& number>=1 && number<50) //2

return true;else if(t==58&& number>=1 && number<50)

//3return true;

else if(t==59&& number>=1 && number<50) //pha back joint 1

return true;else if(t==60&& number>=1 && number<50)

//2return true;

else if(t==61&& number>=1 && number<50) //3

return true;else if(t==62&& number>=1 && number<50)

//mean fron joint 1return true;

else if(t==63&& number>=1 && number<50) //2

return true;else if(t==64&& number>=1 && number<50)

//3return true;

else if(t==65&& number>=1 && number<50) // back joint 1

return true;

else if(t==66&& number>=1 && number<50) //2

return true;else if(t==67&& number>=1 && number<50)

//3return true;

elsereturn false;

}}

}

Page 60: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Parameters.java

package aibo;

import java.util.*;import java.util.Arrays.*;

// This class calculates all possible parameter setups from the user defined values in GUI2public class Parameters {

// 'parameterSetup' is the method called from Laika.javapublic static Vector<Vector<String>> parameterSetup(GUI1 dog1,

GUI2 dog2){// Initiate vectorsVector allValues = new Vector<Vector<Double>>();Vector<String> parameters = new Vector<String>();Vector<Double> pm = new Vector<Double>();Vector <Vector>parameterValues = new

Vector<Vector>();Vector<Double> min = new Vector<Double>();Vector<Double> max = new Vector<Double>();Vector<Double> step = new Vector<Double>();

// Collect informations from GUI1 and GUI2parameters=dog1.getParameters();min=dog2.getMin();max=dog2.getMax();step=dog2.getDelta();

// Calculate the number of different values for each parameter and add them to the vector parameterValues

int[] V= new int[parameters.size()];for(int i=0; i<parameters.size(); i++){

V[i]=antalVarv(min, max, step, i);for(int j=0; j<V[i]; j++){

pm.add(min.get(i)+j*step.get(i));}parameterValues.add((Vector)pm.clone());pm.clear();

}// Calculate all possible combinations and add them

to the Vector allValues// If only one parameter is selectedif(parameters.size()==1){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

pm.add((Double)parameterValues.-get(0).get(i0));

allValues.add(pm.clone());pm.clear();

}}// If 2 parameters are selectedelse if(parameters.size()==2){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

Page 61: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)para-meterValues.get(0).get(i0));

pm.add((Double)para-meterValues.get(1).get(i1));

allValues.add(pm.clone());pm.clear();

}}}// If 3 parameters are selectedelse if(parameters.size()==3){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));allVal-

ues.add(pm.clone());

pm.clear();}}}}// If 4 parameters are selectedelse if(parameters.size()==4){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

allValues.add(pm.clone());

pm.clear();}}}}}// If 5 parameters are selectedelse if(parameters.size()==5){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

Page 62: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

allValues.add(pm.clone());

pm.clear();}}}}}}// If 6 parameters are selectedelse if(parameters.size()==6){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

allValues.add(pm.clone());

pm.clear();}}}}}}}// If 7 parameters are selectedelse if(parameters.size()==7){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

Page 63: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

pm.add((Double)parameterValues.-get(0).get(i0));

pm.add((Double)parameterValues.-get(1).get(i1));

pm.add((Double)parameterValues.-get(2).get(i2));

pm.add((Double)parameterValues.-get(3).get(i3));

pm.add((Double)parameterValues.-get(4).get(i4));

pm.add((Double)parameterValues.-get(5).get(i5));

pm.add((Double)parameterValues.-get(6).get(i6));

allValues.add(pm.clone());

pm.clear();}}}}}}}}// If 8 parameters are selectedelse if(parameters.size()==8){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

Page 64: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)para-meterValues.get(0).get(i0));

pm.add((Double)para-meterValues.get(1).get(i1));

pm.add((Double)para-meterValues.get(2).get(i2));

pm.add((Double)para-meterValues.get(3).get(i3));

pm.add((Double)para-meterValues.get(4).get(i4));

pm.add((Double)para-meterValues.get(5).get(i5));

pm.add((Double)para-meterValues.get(6).get(i6));

pm.add((Double)para-meterValues.get(7).get(i7));

allValues.add(pm.clone());

pm.clear();}}}}}}}}}// If 9 parameters are selectedelse if(parameters.size()==9){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

Page 65: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}// If 10 parameters are selectedelse if(parameters.size()==10){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

pm.add((Double)parameterValues.get(0).get(i0));

Page 66: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}// If 11 parameters are selectedelse if(parameters.size()==11){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

Page 67: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}// If 12 parameters are selectedelse if(parameters.size()==12){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

Page 68: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

allVal-ues.add(pm.clone());

Page 69: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.clear();}}}}}}}}}}}}}// If 13 parameters are selectedelse if(parameters.size()==13){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

Page 70: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}}}// If 14 parameters are selectedelse if(parameters.size()==14){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

Page 71: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

pm.add((Double)parameterValues.get(13).get(i13));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}}}}// If 15 parameters are selectedelse if(parameters.size()==15){

Page 72: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

for(int i14=0; i14<parameterValues.get(14).size(); i14++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

Page 73: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

pm.add((Double)parameterValues.get(13).get(i13));

pm.add((Double)parameterValues.get(14).get(i14));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}}}}}// If 16 parameters are selectedelse if(parameters.size()==16){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

Page 74: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

for(int i14=0; i14<parameterValues.get(14).size(); i14++){

for(int i15=0; i15<parameterValues.get(15).size(); i15++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

Page 75: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(13).get(i13));

pm.add((Double)parameterValues.get(14).get(i14));

pm.add((Double)parameterValues.get(15).get(i15));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}}}}}}// If 17 parameters are selectedelse if(parameters.size()==17){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

for(int i14=0; i14<parameterValues.get(14).size(); i14++){

Page 76: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i15=0; i15<parameterValues.get(15).size(); i15++){

for(int i16=0; i16<parameterValues.get(16).size(); i16++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

pm.add((Double)parameterValues.get(13).get(i13));

pm.add((Double)parameterValues.get(14).get(i14));

pm.add((Double)parameterValues.get(15).get(i15));

pm.add((Double)parameterValues.get(16).get(i16));

allVal-ues.add(pm.clone());

Page 77: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.clear();}}}}}}}}}}}}}}}}}}// If 18 parameters are selectedelse if(parameters.size()==18){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

for(int i14=0; i14<parameterValues.get(14).size(); i14++){

for(int i15=0; i15<parameterValues.get(15).size(); i15++){

for(int i16=0; i16<parameterValues.get(16).size(); i16++){

for(int i17=0; i17<parameterValues.get(17).size(); i17++){

pm.add((Double)parameterValues.get(0).get(i0));

Page 78: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

pm.add((Double)parameterValues.get(13).get(i13));

pm.add((Double)parameterValues.get(14).get(i14));

pm.add((Double)parameterValues.get(15).get(i15));

pm.add((Double)parameterValues.get(16).get(i16));

pm.add((Double)parameterValues.get(17).get(i17));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}}}}}}}}// If 19 parameters are selectedelse if(parameters.size()==19){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

Page 79: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

for(int i14=0; i14<parameterValues.get(14).size(); i14++){

for(int i15=0; i15<parameterValues.get(15).size(); i15++){

for(int i16=0; i16<parameterValues.get(16).size(); i16++){

for(int i17=0; i17<parameterValues.get(17).size(); i17++){

for(int i18=0; i18<parameterValues.get(18).size(); i18++){

pm.add((Double)parameterValues.get(0).get(i0));

pm.add((Double)parameterValues.get(1).get(i1));

Page 80: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

pm.add((Double)parameterValues.get(13).get(i13));

pm.add((Double)parameterValues.get(14).get(i14));

pm.add((Double)parameterValues.get(15).get(i15));

pm.add((Double)parameterValues.get(16).get(i16));

pm.add((Double)parameterValues.get(17).get(i17));

pm.add((Double)parameterValues.get(18).get(i18));

allVal-ues.add(pm.clone());

pm.clear();}}}}}}}}}}}}}}}}}}}}// If 20 parameters are selectedelse if(parameters.size()==20){

for(int i0=0; i0<parameterValues.get(0).size(); i0++){

Page 81: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i1=0; i1<parameterVal-ues.get(1).size(); i1++){

for(int i2=0; i2<parameterValues.get(2).size(); i2++){

for(int i3=0; i3<parameterValues.get(3).size(); i3++){

for(int i4=0; i4<parameterValues.get(4).size(); i4++){

for(int i5=0; i5<parameterValues.get(5).size(); i5++){

for(int i6=0; i6<parameterValues.get(6).size(); i6++){

for(int i7=0; i7<parameterVal-ues.get(7).size(); i7++){

for(int i8=0; i8<parameterValues.get(8).size(); i8++){

for(int i9=0; i9<parameterValues.get(9).size(); i9++){

for(int i10=0; i10<parameterValues.get(10).size(); i10++){

for(int i11=0; i11<parameterValues.get(11).size(); i11++){

for(int i12=0; i12<parameterValues.get(12).size(); i12++){

for(int i13=0; i13<parameterValues.get(13).size(); i13++){

for(int i14=0; i14<parameterValues.get(14).size(); i14++){

for(int i15=0; i15<parameterValues.get(15).size(); i15++){

for(int i16=0; i16<parameterValues.get(16).size(); i16++){

for(int i17=0; i17<parameterValues.get(17).size(); i17++){

for(int i18=0; i18<parameterValues.get(18).size(); i18++){

for(int i19=0; i19<parameterValues.get(19).size(); i19++){

pm.add((Double)parameterValues.get(0).get(i0));

Page 82: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.add((Double)parameterValues.get(1).get(i1));

pm.add((Double)parameterValues.get(2).get(i2));

pm.add((Double)parameterValues.get(3).get(i3));

pm.add((Double)parameterValues.get(4).get(i4));

pm.add((Double)parameterValues.get(5).get(i5));

pm.add((Double)parameterValues.get(6).get(i6));

pm.add((Double)parameterValues.get(7).get(i7));

pm.add((Double)parameterValues.get(8).get(i8));

pm.add((Double)parameterValues.get(9).get(i9));

pm.add((Double)parameterValues.get(10).get(i10));

pm.add((Double)parameterValues.get(11).get(i11));

pm.add((Double)parameterValues.get(12).get(i12));

pm.add((Double)parameterValues.get(13).get(i13));

pm.add((Double)parameterValues.get(14).get(i14));

pm.add((Double)parameterValues.get(15).get(i15));

pm.add((Double)parameterValues.get(16).get(i16));

pm.add((Double)parameterValues.get(17).get(i17));

pm.add((Double)parameterValues.get(18).get(i18));

pm.add((Double)parameterValues.get(19).get(i19));

allVal-ues.add(pm.clone());

Page 83: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

pm.clear();}}}}}}}}}}}}}}}}}}}}}// Convert all the doubles in the Vector allValues to

Strings ready to send to the dogVector ans=new Vector<Vector<String>>();ans=doublesToStrings(allValues, ans, parameters);return ans;

}// Returns a matrix of strings converted from the matrix of

doublesprivate static Vector<Vector<String>>

doublesToStrings(Vector<Vector<Double>> in, Vector ans, Vector<String> parameters){

Vector<Double> inner = new Vector<Double>();Vector<String> inner2 = new Vector<String>();// For each row in the matrixfor(int i=0; i<in.size(); i++){

inner=in.get(i);inner2.clear();// For each column in the matrixfor(int j=0; j<inner.size(); j++){

// Buld up the string with "parameter name" + "=" + "double value" + ";"

inner2.add(parameters.get(j)+" = "+inner.get(j)+";");

}ans.add(inner2.clone());

}return ans;

}// Calculates the number of posible values for each parameterprivate static int antalVarv(Vector<Double> min, Vector<Double>

max, Vector<Double> step, int a){int b=(int)((max.get(a)-min.get(a))/step.get(a));return b+1; //avrundar upp till narmsta heltal

}}

Page 84: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

AIBO.java

package aibo;

import java.io.*;import java.util.*;import java.io.BufferedReader;import java.io.IOException;

public class AIBO {// Declare variablesboolean finished;

// Constructorpublic AIBO(){

finished=false;}// "start" is the method called from the main program Laika.java

public void start(Vector<Vector<String>> allParameters) throws IOException{

try{// Create a Store-object and the files

listing the comming output-files Store store=new Store();store.StartA();store.StartC();store.StartT();

// Create and start a subprocess to commu-nicate with the dog

ProcessBuilder p = new ProcessBuilder("telnet", "192.168.0.10", "54000");

Process process = p.start();

// Declare stream objects used for commu-nicating with the subprocess p (= the dog)

InputStream is = process.getInputStream();// InputStream is used for receiving data from the

subprocessInputStreamReader isr = new InputStream-

Reader(is);BufferedReader br = new

BufferedReader(isr);OutputStream os =

process.getOutputStream(); // OutputStream is used for sending data to the subprocess

FileReader fr = new FileReader("normal-Code.txt"); // FileReader is used to read model later used to create the fileOutputs

BufferedReader br2= new BufferedReader(fr);

// Create a Vector containing the paramet-ers used when 'returning to normal gait'

Vector<String> normalParameters = new Vec-tor<String>();

normalParameters.add("robot.walkspeed=1s;");

normalParameters.add("robot.turnspeed=1s;");

Page 85: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

normalParameters.add("walk.turnamount = 0;");

normalParameters.add("walk.coef[1] = 1;");normalParameters.add("walk.coef[2] =

1/2;");normalParameters.add("walk.mean[1][1] =

-17.36;");normalParameters.add("walk.mean[1][2] =

9.96;");normalParameters.add("walk.mean[1][3] =

80.5;");normalParameters.add("walk.mean[2][1] =

-28.8;");normalParameters.add("walk.mean[2][2] =

11.1;");normalParameters.add("walk.mean[2][3] =

90.3;");normalParameters.add("walk.amp[1][1][1]=

14.63;");

normalParameters.add("walk.phase[1][1][1]=1.81;");normalParameters.add("walk.amp[1][1][2]=

2.49;");normalParameters.add("walk.phase[1][1][2]=

-1.09;");normalParameters.add("walk.amp[1][2][1]=

2.20;");

normalParameters.add("walk.phase[1][2][1]=-2.33;");normalParameters.add("walk.amp[1][2][2]=

0.88;");normalParameters.add("walk.phase[1][2][2]=

1.78;");normalParameters.add("walk.amp[1][3][1]=

13.50;");

normalParameters.add("walk.phase[1][3][1]=-1.73;");normalParameters.add("walk.amp[1][3][2]=

5.31;");normalParameters.add("walk.phase[1][3][2]=

1.26;");normalParameters.add("walk.amp[2][1][1]=

14.65;");

normalParameters.add("walk.phase[2][1][1]=0.16;"); normalParameters.add("walk.amp[2][1][2]=

3.38;");normalParameters.add("walk.phase[2][1][2]=

-1.09;");normalParameters.add("walk.amp[2][2][1]=

2.35;");

normalParameters.add("walk.phase[2][2][1]=-2.55;");normalParameters.add("walk.amp[2][2][2]=

1.05;");normalParameters.add("walk.phase[2][2][2]=

2.01;");normalParameters.add("walk.amp[2][3][1]=

11.56;");

normalParameters.add("walk.phase[2][3][1]=-2.55;");

Page 86: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

normalParameters.add("walk.amp[2][3][2]= 5.27;");

normalParameters.add("walk.phase[2][3][2]= 2.75;");

// Read startup message from the dog

startUp(br);

// Iterate for the number of test runs for(int i=0; i<allParameters.size(); i++){

// Create output files for the current test run

store.StartAcc(i);store.StartComp(i);store.StartTime(i);store.StartCode(i);// Initiate parameters

double compensate =0;boolean validTry=true;

// Wait until batteries are loaded

while(battCheck(br, os)==false){// Shut down

everything except the WLan and the processor in the dog

Off(br, os);// Wait one minute

before checking the batteries again

Thread.sleep(60*1000);}// Turn on the motors and leds

in the dogOn(br, os);// Send new test parameters to

the dognewParameters(br, os, allPara-

meters.get(i));

// Create and start the timerClock c = new Clock();c.start();

// Start the test runwhile(getDistance(br,

os)==false){ // run test while distance to target is large enough// Tell the dog to

walk and search for target and store the returned compensation value

compensate=walkOsearch(br, os, store);// Write compensation

value to output file store.WriteComp(com-

pensate);// If the dog has not

reached the target in 30 seconds

if(c.getElapsedTime()>30*1000 && validTry==true){

Page 87: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

// Return-in to normal gait and set validTry to false

backToNor-mal(br, os, normalParameters);

validTry=false;}

}// Stop the timer and turn the

dog 180 degreesc.stop();

turn(br, os);

// If test run is valid - write collected data to output files

if(validTry==true){store.WriteCode(all-

Parameters.get(i), br2);store.WriteTime(c.-

getElapsedTime());// Store the output

filesstore.StopAcc();store.StopComp();store.StopTime();store.StopCode();

}else{ // If test run is in-valid - replace data with 'invalid values' in output files

// Close current out-put files

store.StopAcc(); store.StopComp();// Over write latest

output filesstore.StartAcc(i);store.StartComp(i);// Write 'invalid

values' to output filesstore.WriteAcc("0, 0,

0");

store.WriteComp("1000");store.WriteTime("0");store.WriteCode("In-

valid try");// Store the output

filesstore.StopAcc();store.StopComp();store.StopTime();store.StopCode();

}// Ask the dog if it's ready for

a new test runready(br, os);

} // All test runs are finished// Store the files containing lists of

output files and set finished to "true"store.StopA();

Page 88: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

store.StopC();store.StopT();finished = true;

}catch (Exception ex){ ex.printStackTrace(); }

}// Return the value of finished

public boolean getFinished(){ return finished; }

// Send next set of parameters to the dog private static void newParameters(BufferedReader br, Output-Stream os, Vector<String> param) throws IOException{

// the number of parameters to be changed for(int i=0; i<param.size(); i++){ String out = param.get(i); os.write(out.getBytes()); os.flush(); } }

// Send parameters repressenting 'normal gait' to the dog private static void backToNormal(BufferedReader br, OutputStream os, Vector<String> normalParameters) throws IOException{

try{ System.out.println("Invalid try - Original

parameters will be sent to the dog"); // Stop the dog String out = "robot.stopRun();";

os.write(out.getBytes());os.flush();

// Send new parameters for(int i=0; i<normalParameters.size(); i++){ out = normalParameters.get(i); os.write(out.getBytes()); os.flush(); }

// Make the dog stand upout = "robot.stand();"; os.write(out.getBytes());os.flush();Thread.sleep(1000);

}catch (Exception ex){ ex.printStackTrace(); } }

// Make the dog walk for 5000 milliseconds and then search for the target.

// This method writes accelerometer values to output file and returns compensation value

private static double walkOsearch(BufferedReader br, Output-Stream os, Store store) throws IOException{

// Initiate parametersdouble compensate=0;boolean Xminus=false;boolean Yminus=false;boolean Zminus=false;String line;// Make the dog walk

Page 89: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

String out = "robot.walkSecondSearch();"; os.write(out.getBytes());os.flush();// Read the respons from the dogwhile ((line = br.readLine()) != null) {

// If the 21st character on this line is @ the values belong to AccOutput

if(line.charAt(21)==64){ //ascii for @// X-direction// If the character to the right

of the first X-sign is a minus -// Set Xminus to true and read

next characterint x=line.indexOf(88);

// 88 is ascii for Xif(line.charAt(x+1)==45){

// 45 is ascii for minusXminus=true;x=x+1;

}// Make a new string of the

first 5 characters to the right of X (or the minus sign) String

xstring=line.substring(x+1,x+6);// Convert the 5 character

string to a double valuedouble

X=stringToDouble(xstring);// Multiply the obtained value

with -1 if Xminus is set to "true"if(Xminus)

X=-X;

// Y-direction - For details see X-direction

int y=line.indexOf(89);// 89 is ascii for Y

if(line.charAt(y+1)==45){Yminus=true;y=y+1;

}String

ystring=line.substring(y+1,y+6);double

Y=stringToDouble(ystring);if(Yminus)

Y=-Y;

// Z-direction - For details see X-direction

int z=line.indexOf(90);// 90 is ascii for Z

if(line.charAt(z+1)==45){Zminus=true;z=z+1;

}String

zstring=line.substring(z+1,z+6);double

Z=stringToDouble(zstring);if(Zminus)

Page 90: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Z=-Z;// Write values to output filestore.WriteAcc(X, Y, Z);

} // Else if the 21st character is % - value

belongs to CompOutputelse if(line.charAt(21)==37){

// 37 is ascii for %int a=line.indexOf(37);

// The location of the first %-signif(line.charAt(a+1)==45){

//45 is ascii for -a=a+1;

}int dec=6;

// Number of decimals wantedif(line.length()<a+dec){

// If the actual number is less - change 'dec'dec=line.length()-a;

}// Make a substring of 'dec'

number of characters and convert to doubleString

Tstring=line.substring(a+1,a+dec);double

T=stringToDouble(Tstring);compensate=compensate+T;

}// Break the while-loop if the last char-

acter on a line is & (= end of message)

if(line.charAt(line.length()-1)==38){ //ascii for &

break;}

}return compensate;

}// Check distance to target - returns true if closer than 40 cmprivate static boolean getDistance(BufferedReader br, Output-

Stream os) throws IOException{// Clear the message que from the dogreadAll(br, os);// Check distanceString out = "distance;";os.write(out.getBytes());os.flush();// Throw away all data up to the first ]-signint a=br.read();while(a!=93){ //reads until ascii for ]

a=br.read();}br.read(); // ... and one more// Read the following two chracters and convert them

to integersint b1=br.read();int b2=br.read();System.out.print("Distance: " + charToInt(b1)+char-

ToInt(b2));// Throw away the following 8 characters

Page 91: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for(int i=0; i<8; i++){br.read();

}if(b1>47 && b1<53) // If distance is lower than 40 cm

(ascii code) return truereturn true;

elsereturn false;

}// Turn the dog 180 degreesprivate static void turn(BufferedReader br, OutputStream os)

throws IOException{// Turn the dogString line;String out="robot.turnDegree();";os.write(out.getBytes());os.flush();// Read and throw away the received messageswhile ((line = br.readLine()) != null) {

if(line.charAt(line.length()-1)==38){ //ascii for & (= end of message)

break;}

}}// Check wheter the dog is ready for a new test run or notprivate static void ready(BufferedReader br, OutputStream os)

throws IOException{// Ask if readyString line;String out="robot.sendReady();";os.write(out.getBytes());os.flush();// Read and throw away the received messageswhile ((line = br.readLine()) != null) {

if(line.charAt(line.length()-1)==35){ //ascii for # (= end of message)

break;}

}}// Print out the startup-text from the dogprivate static void startUp(BufferedReader br) throws IOExcep-

tion{String line;while ((line = br.readLine()) != null) {

System.out.println(line);// Break the loop when line ends with a %-

signif(line.charAt(line.length()-1)==37){ //37

= ascii for %break;

}}

}// Check the battery level on the dog - returns true of batter-

ies are okprivate static boolean battCheck(BufferedReader br, OutputStream

os) throws IOException{// Initiate parameters

Page 92: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

boolean battOk=false;// Check battery levelString out="power();"; os.write(out.getBytes());os.flush();// Read and throw away all characters up to the first

[-signint a=br.read();while(a!=93){ // 93 is ascii for [

a=br.read();}br.read(); // .. and one more (a space)// Read and store the following character int b=br.read();if(b==49){ // If b=1

(ascii=49) batteries are at 100%System.out.println("Battery level: 100%");battOk=true;

}else if(b==48){ // Else if b=0 (as-cii=48) batteries are at 0.xxxxxx

b=br.read(); // Read and throw away the .-sign

b=br.read(); // reads the first sign after the dot

if(b>50 && b<58){ // If between 3-9 (30-99 %) return true

battOk=true;

}else{ // Return false if lower than 30%

battOk=false;}// Print out the battery levelSystem.out.println("Battery level: "+

charToInt(b) + charToInt(br.read()) + "%");}return battOk;

} // Convert a char to a integerprivate static int charToInt(int a){

if(a>47 && a<58){ // Ascii for 0-9return a-48;

}else{System.out.println("charToInt - Not a num-

ber");return 0;

}}// Shuts down motors and leds to save energy in the dogprivate static void Off(BufferedReader br, OutputStream os)

throws IOException{System.out.println("Turns off to reload batteries");String out="motors off;"; os.write(out.getBytes());os.flush();out="ledEML=0;"; os.write(out.getBytes());os.flush();out="ledEMR=0;"; os.write(out.getBytes());os.flush();

Page 93: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

}// Turns on the motors and leds in the dogprivate static void On(BufferedReader br, OutputStream os)

throws IOException{try{

System.out.println("Turns on. Batteries ok");

String out="motors on;";os.write(out.getBytes());os.flush();out="robot.stand();";os.write(out.getBytes());os.flush();out="ledEML=1;"; os.write(out.getBytes());os.flush();out="ledEMR=1;";os.write(out.getBytes());os.flush();Thread.sleep(2000);

}catch(Exception ex){}}// Reads and throws away all messages from the dogprivate static void readAll(BufferedReader br, OutputStream os)

throws IOException{try{

String out="robot.cleanChannel();"; os.write(out.getBytes());os.flush();int a=br.read();while(a!=38){ //reads

until ascii for & (= end of last message)a=br.read();

}}catch(Exception ex){}

}// Convert String to doubleprivate static double stringToDouble(String line){

return Double.parseDouble(line);}// The methods needed for the timerpublic class Clock {

// Initiate parameters private long startTime = 0;private long stopTime = 0;private boolean running = false;

// Start the timerpublic void start() {

this.startTime = System.currentTimeMillis();

this.running = true;} // Stop the timerpublic void stop() { this.stopTime = System.currentTimeMillis(); this.running = false;}// Return elaspsed time in millisecondspublic long getElapsedTime() { long elapsed;

Page 94: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

if (running) { elapsed = (System.currentTimeMillis() -

startTime); } else { elapsed = (stopTime - startTime); } return elapsed;}// Return elaspsed time in secondspublic long getElapsedTimeSecs() {

long elapsed; if (running) {

elapsed = ((System.currentTimeMillis() - startTime) / 1000);

} else { elapsed = ((stopTime - startTime) / 1000);

} return elapsed;}

}}

Page 95: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Store.java

package aibo;

import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.IOException;import java.util.Vector;

// This class creates, writes and stores the output filespublic class Store{

// Initiate parametersBufferedWriter bw1, bw2, bw3, bw4, bw5, bw6, bw7;Vector<Integer> iiAcc = new Vector<Integer>();Vector<Integer> iiComp = new Vector<Integer>();

// Empty constructorpublic Store(){}

// Create a new AccOutput filepublic void StartAcc(int i)throws IOException{

String filename= "AccOutput" + (i+1) + ".txt";FileWriter fw = new FileWriter(filename);bw1 = new BufferedWriter(fw);// If iiAcc do not contain i - add it and add the fi-

lename to the list of files in AccOutput00.txtif(iiAcc.contains(i)){

}else{WriteA(i);iiAcc.add(i);

}}// Save and close the current AccOutput filepublic void StopAcc()throws IOException{

bw1.close();}// Write values on a new line in the current AccOutput filepublic void WriteAcc(double X, double Y, double Z)throws IOEx-

ception{String s = ""+X+", "+Y+", "+Z;

bw1.write(s, 0, s.length());bw1.newLine();

}// Write a string on a new line in the current AccOutput filepublic void WriteAcc(String S)throws IOException{

bw1.write(S, 0, S.length());}

// Create a new CompOutput filepublic void StartComp(int i)throws IOException{

String filename= "CompOutput" + (i+1) + ".txt";FileWriter fw = new FileWriter(filename);bw2 = new BufferedWriter(fw);// If iiComp do not contain i - add it and add the

filename to the list of files in CompOutput00.txtif(iiComp.contains(i)){

Page 96: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

}else{WriteC(i);iiComp.add(i);

}}// Save and close the current CompOutput filepublic void StopComp()throws IOException{

bw2.close();}// Write values on a new line in the current CompOutput filepublic void WriteComp(double compensate)throws IOException{

String store2 = ""+compensate;bw2.write(store2, 0, store2.length());bw2.newLine();

}// Write a string on a new line in the current AccOutput filepublic void WriteComp(String S)throws IOException{

bw2.write(S, 0, S.length());}

// Create a new TimeOutput filepublic void StartTime(int i)throws IOException{

WriteT(i);String filename= "TimeOutput" + (i+1) + ".txt";FileWriter fw = new FileWriter(filename);bw3 = new BufferedWriter(fw);

}// Save and close the current AccOutput filepublic void StopTime()throws IOException{

bw3.close();}// Write values on a new line in the current TimeOutput filepublic void WriteTime(long T)throws IOException{

String store3 = ""+T;bw3.write(store3, 0, store3.length());

}// Write a string on a new line in the current TimepOutput filepublic void WriteTime(String S)throws IOException{

bw3.write(S, 0, S.length());}

// Create a new Code filepublic void StartCode(int i)throws IOException{

String filename= "Code" + (i+1) + ".u";FileWriter fw = new FileWriter(filename);bw4 = new BufferedWriter(fw);

}// Save and close the current Code filepublic void StopCode()throws IOException{

bw4.close();}// Reads the file which br2 is connected to and replaces the

lines containing the strings in // parameters with a new line containign the same parameter but

a new valuepublic void WriteCode(Vector<String> parameters, BufferedReader

br2)throws IOException{String line;String line2;boolean equal;// Read a new line from the file

Page 97: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

while ((line = br2.readLine()) != null) {equal=false;// Check if the line conatins one of the

selected parametersfor(int i=0; i<parameters.size(); i++){

line2=getPartOf(parameters.get(i));// if yes - replace with string

from the vector parametersif(line.indexOf(line2)!=-1){

bw4.write(paramet-ers.get(i));

bw4.newLine();equal=true;

}

}// If not - write what was read in the

code fileif(equal==false){

bw4.write(line);bw4.newLine();

}}

}// Write values on a new line in the current Code filepublic void WriteCode(String S)throws IOException{

bw4.write(S, 0, S.length());}// Return a substring containing the original string from the

start up to the first =-signprivate static String getPartOf(String parameter){

String part;int index=parameter.indexOf(61); // 61 is '=' (ascii)part=parameter.substring(0, index);return part;

}// Create a new file containing a list of AccOutput files cre-

atedpublic void StartA()throws IOException{

String filename= "AccOutput00.txt";FileWriter fw5 = new FileWriter(filename);bw5 = new BufferedWriter(fw5);

}// Save and close AccOutput00.txtpublic void StopA()throws IOException{

bw5.close();}// Write a string on a new line in AccOutput00.txtpublic void WriteA(int i)throws IOException{

String s= "AccOutput" + (i+1) + ".txt";

bw5.write(s, 0, s.length());bw5.newLine();

}// Create a new file containing a list of CompOutput files cre-

atedpublic void StartC()throws IOException{

String filename= "CompOutput00.txt";FileWriter fw6 = new FileWriter(filename);bw6 = new BufferedWriter(fw6);

Page 98: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

}// Save and close CompOutput00.txtpublic void StopC()throws IOException{

bw6.close();}// Write a string on a new line in CompOutput00.txtpublic void WriteC(int i)throws IOException{

String s= "CompOutput" + (i+1) + ".txt";

bw6.write(s, 0, s.length());bw6.newLine();

}// Create a new file containing a list of TimeOutput files cre-

atedpublic void StartT()throws IOException{

String filename= "TimeOutput00.txt";FileWriter fw7 = new FileWriter(filename);bw7 = new BufferedWriter(fw7);

}// Save and close TimeOutput00.txtpublic void StopT()throws IOException{

bw7.close();}// Write a string on a new line in TimeOutput00.txtpublic void WriteT(int i)throws IOException{

String s= "TimeOutput" + (i+1) + ".txt";

bw7.write(s, 0, s.length());bw7.newLine();

}}

Page 99: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

Matlab.java

package aibo;// This class launches Matlab from the directory where startup.m is locatedpublic class Matlab {

// Initiate parametersboolean finished;

// Constructorpublic Matlab(){

finished=false;}// 'start' is the method called from Laika.javapublic void start(){

try{// Since Matlab is not installed on the

presentaton computer a number of instructions are printed instead of launching Matlab

System.out.println("Matlab is not in-stalled on the computer");

System.out.println("Type 'ssh -X -l <user-name> hamberg.it.uu.se' and enter your personal password");

System.out.println("Then type 'matlab'");/* Comment 2: Remove if matlab is in-

stalled on the computer//ProcessBuilder p = new

ProcessBuilder("matlab");Process process1 = p.start();Thread.sleep(3000);process1.waitFor();*/finished = true;

}catch (Exception ex){ ex.printStackTrace(); }}// Returns the value of 'finished'public boolean getFinished(){

return finished;}

}

Page 100: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

startup.m

% Script that plots all data collected during the testrunsclear all;close all; % Initializingvalid=[];invalid=[];xvalid=[];xinvalid=[];time=[];comp=[];Acc=[]; %%%%%%%%% Time %%%%%%%%%fid=fopen('TimeOutput00.txt');tline = fgetl(fid);while tline ~= -1 time=[time load(tline)]; % Read next filename from TimeOutput00.txt tline=fgetl(fid);end% Convert to secondstime=time/1000;% Prepare to plotfor i=1:length(time) if time(i)~=0 valid=[valid time(i)]; xvalid=[xvalid i]; else invalid=[invalid time(i)]; xinvalid=[xinvalid i]; endend%Plotsubplot(3,1,1)hold onstem(xvalid, valid, 'b');stem(xinvalid, invalid, 'r'); AXIS([0, length(time)+1, 0, max(valid)])xlabel('Testrun number')ylabel('Time (s)')hold off %%%%%%%%%%%%%%%%% Compensation %%%%%%%%%%%%%%%%%valid=[];invalid=[];xvalid=[];xinvalid=[]; fid=fopen('CompOutput00.txt');tline = fgetl(fid);while tline ~= -1 c=abs(load(tline));

Page 101: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

% Sum the values co=0; for i=1:length(c) co=co+c(i); end comp=[comp co]; tline=fgetl(fid);end% Prepare to plotfor i=1:length(comp) if comp(i)~=1000 valid=[valid comp(i)]; xvalid=[xvalid i]; else invalid=[invalid 0]; xinvalid=[xinvalid i]; endend%Plotsubplot(3,1,2)hold onstem(xvalid, valid, 'b');stem(xinvalid, invalid, 'r');AXIS([0, length(comp)+1, 0, max(valid)])xlabel('Testrun number')ylabel('Degrees')hold off %%%%%%%%%%%%%%%%%% Accelerometer %%%%%%%%%%%%%%%%%%valid=[];invalid=[];xvalid=[];xinvalid=[]; fid=fopen('AccOutput00.txt');tline = fgetl(fid);while tline ~= -1 a=abs(load(tline)); acc=0; [M,N]=size(a); for i=1:length(M) acc=acc+a(i,1); end Acc=[Acc acc]; tline=fgetl(fid);end% Prepare to plotfor i=1:length(Acc) if Acc(i)~=0 valid=[valid Acc(i)]; xvalid=[xvalid i]; else invalid=[invalid 0]; xinvalid=[xinvalid i]; endend%Plotsubplot(3,1,3)hold on

Page 102: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

stem(xvalid, valid, 'b');stem(xinvalid, invalid, 'r');AXIS([0, length(Acc)+1, 0, max(Acc)])xlabel('Testrun number')ylabel('Shakings')hold off %%%%%%%%%%%% Numbers %%%%%%%%%%%%number=[1:length(time)];Res=[number; time; comp; Acc]

Page 103: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

motion.u

/***************************************************************Walk and turn movement URBI code.

Contributors: * Laboratory of Robotics in Versailles (original walk) (if you have other walks, contact us) * Matthieu Nottale (Fourier extraction) * Assif Mirza (incremental turn) * Frederic Lettelier (adaptation of the inc. turn for walk)

Functions: robot.walk(duration) : walk for duration milliseconds. => Walk backward if duration is negative robot.stopwalk() : interrupt the walk robot.turn(duration) : turn couterclockwise for duration milliseconds. => Turn clockwise if duration is negative robot.stopturn() : interrupt the turn

robot.initial() : initial position sitting down (strech and lay) robot.stretch() : stretching like in the morning... robot.lay() : laying (sitting down) robot.sit() : sit on the back robot.beg() : stand up with knees bent robot.stand() : stand up

Variables: robot.walkspeed : speed of walk, the smaller the faster: period of a step. Defaults to 1s robot.turnspeed : speed of turn, the smaller the faster: period of a step. Defaults to 1s***************************************************************/

########### WALK ##############

legs.val->blend = mix;

robot.walkspeed = 1s ; // how long for a walk cycle

walk.turnamount = 0;

// periodswalk.coef[1] = 1;walk.coef[2] = 1/2;

// mean valueswalk.mean[1][1] = -17.36,walk.mean[1][2] = 9.96,walk.mean[1][3] = 80.5,walk.mean[2][1] = -28.8,walk.mean[2][2] = 11.1,walk.mean[2][3] = 90.3,

//amp and phase:: [front/back][joint][sinnumber] walk.amp[1][1][1]= 14.63,walk.phase[1][1][1]=1.81 ,walk.amp[1][1][2]= 2.49,walk.phase[1][1][2]= -1.09,

walk.amp[1][2][1]= 2.20,

Page 104: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

walk.phase[1][2][1]=-2.33 ,walk.amp[1][2][2]= 0.88,walk.phase[1][2][2]= 1.78,

walk.amp[1][3][1]= 13.50,walk.phase[1][3][1]=-1.73 ,walk.amp[1][3][2]= 5.31,walk.phase[1][3][2]= 1.26,

walk.amp[2][1][1]= 14.65,walk.phase[2][1][1]=0.16 ,walk.amp[2][1][2]= 3.38,walk.phase[2][1][2]= -1.09,

walk.amp[2][2][1]= 2.35,walk.phase[2][2][1]=-2.55 ,walk.amp[2][2][2]= 1.05,walk.phase[2][2][2]= 2.01,

walk.amp[2][3][1]= 11.56,walk.phase[2][3][1]=-2.55 ,walk.amp[2][3][2]= 5.27,walk.phase[2][3][2]= 2.75,

for |(x=1;x<=2;x++) for |(y=1;y<=2;y++)

for |(j=1;j<=3;j++) for |(d=1;d<=2;d++) walk.phase[x][y][j][d] = walk.phase[x][j][d]+pi/2; //sin and not cos

//front-back phase shiftfor |(x=1;x<=2;x++) for |(y=1;y<=2;y++)

for |(j=1;j<=3;j++) for |(d=1;d<=2;d++)

walk.phase[x][y][j][d] = walk.phase[x][y][j][d] - walk.phase[x][1][1]*d;

//left-right phase shiftfor &(x=1;x<=2;x++) for &(j=1;j<=3;j++) walk.phase[x][2][j][1] = walk.phase[x][2][j][1] + pi;

// Incremental Walk Function (by Frederic Lettelier, based on work by Assif Mirza)// A modification of the walk script that will save the current phase // so that subsequent walks continue where they left off. // We require 1 additional global variable// walk.direction : saves which direction the last walk was in

walk.direction=1;

function robot.walk(duration){ direction = 1;

Page 105: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

if (duration < 0) { duration = - duration, direction = -1 };

// if we are changing direction then switch the phase modifier phasemod = 1; if (walk.direction != direction) { phasemod = -1, walk.direction = - walk.direction };

walk: {timeout(duration) { for &(x=1;x<=2;x++) for &(y=1;y<=2;y++) for &(j=1;j<=3;j++) for &(d=1;d<=2;d++)

global.leg[x][y][j] = walk.mean[x][j]

sin:robot.walkspeed*walk.coef[d]

ampli:walk.amp[x][j][d]*4 phase: phasemod * (static walk.phase[x][y][j][d])+pi*(phasemod-1)/2

getphase:walk.phase[x][y][j][d] } }

};// robot.stopwalk functionfunction robot.stopwalk(){ stop walk};

// ***********************************************// OUR OWN FUNCTIONS STARTS HERE// ***********************************************// **** Send accelerometer values ****function robot.sample(){

for (x=1;x<=90;x++) {wait(10) | echo

"@X"+accelX.val+"Y"+accelY.val+"Z"+accelZ.val;};

};// **** Moving head to look for red target ****function robot.lookFor() { loop { headPan'n = 90 smooth:5s | headPan'n = -90 smooth:5s; }; };// **** Turn toward where the red target is with both body and head ****function robot.turnToward() {

// Turn head toward target headPan.val = headPan.val + camera.xfov * ball.x;

// Send headPan value for evaluationecho "%" + headPan.val;// If headPan not equal to zero, compensate more if small head-

Pan value. if(headPan.val != 0) {

Page 106: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

if(headPan.val<15 && headPan.val > 0){headPan.val = headPan.val*4;

};if(headPan.val < 0 && headPan.val > -15){

headPan.val = headPan.val*3;};if(headPan.val < 30 && headPan.val > 15){

headPan.val = headPan.val*2;};if(headPan.val < -15 && headPan.val > -30){

headPan.val = headPan.val*3;};if(headPan.val < 50 && headPan.val > 30){

headPan.val = headPan.val*1.25;};if(headPan.val < -30 && headPan.val > -50){

headPan.val = headPan.val*3;};// Align body with head robot.turn(headPan.val * -50) & headPan.val = 0

smooth:1000; };

//reset headPan value to zero headPan.val = 0 smooth:100;};// **** Search for target, if found: stop search and turn toward ****function robot.searchTarget() { if(!ball.visible) {

// If found red target, stop the lookFor loop (search) at(ball.visible) stop search; search: robot.lookFor(); }; robot.turnToward();};// **** Walk and search ****function robot.walkSecondSearch() {

// When <40cm to target, stop run loop, otherwise runat(distance<40) { stop run };

run: { robot.walk(5000) & robot.sample();robot.searchTarget() };

echo "&";};// **** Turn 180 degrees ****function robot.turnDegree() { robot.turn(7000);

robot.searchTarget(); echo "&";};// **** Send # to notify ready ****function robot.sendReady() { robot.stopwalk(); robot.stand();

echo "#";};// **** Send & to easily remove characters in the channel ****function robot.cleanChannel() {

echo "&";};// **** Stop, turn toward target and wait for new parameters ****function robot.stopRun() {

Page 107: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

robot.stopwalk();robot.searchTarget();robot.stand();

};// ***********************************************// OUR OWN FUNCTIONS ENDS HERE// ***********************************************

######### TURN #############

robot.turnspeed = 1s, // How long for a turn cycle

turn.coef[1] = 1,turn.coef[2] = 1/2,turn.coef[3] = 1/3,

// mean valuesturn.mean[1][1] = -19.4,turn.mean[1][2] = 17.833,turn.mean[1][3] = 82.18,turn.mean[2][1] = -19.98,turn.mean[2][2] = 12.82,turn.mean[2][3] = 89.27,

//amp and phase:: [front/back][joint][sinnumber] turn.amp[1][1][1] = 7.704,turn.phase[1][1][1] = -0.518,turn.amp[1][1][2] = 2.689,turn.phase[1][1][2] = 1.058,turn.amp[1][1][3] = 0.739,turn.phase[1][1][3] = 2.923,

turn.amp[1][2][1] = 8.025,turn.phase[1][2][1] = 2.970,turn.amp[1][2][2] = 2.916,turn.phase[1][2][2] = -1.697,turn.amp[1][2][3] = 1.007,turn.phase[1][2][3] = -0.055,

turn.amp[1][3][1] = 10.758,turn.phase[1][3][1] = 1.933,turn.amp[1][3][2] = 4.527,turn.phase[1][3][2] = -2.750,turn.amp[1][3][3] = 0.266,turn.phase[1][3][3] = -1.373,

turn.amp[2][1][1] = 5.945,turn.phase[2][1][1] = 0.720,turn.amp[2][1][2] = 1.546,turn.phase[2][1][2] = -1.259,turn.amp[2][1][3] = 0.968,turn.phase[2][1][3] = 2.654,

turn.amp[2][2][1] = 6.715,turn.phase[2][2][1] = -2.507,turn.amp[2][2][2] = 1.819,turn.phase[2][2][2] = 1.978,turn.amp[2][2][3] = 1.016,turn.phase[2][2][3] = 0.024,

Page 108: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

turn.amp[2][3][1] = 10.518,turn.phase[2][3][1] = -1.445,turn.amp[2][3][2] = 4.13,turn.phase[2][3][2] = -2.898,turn.amp[2][3][3] = 0.061,turn.phase[2][3][3] = 1.539,

//sin<=>cos conversionfor |(x=1;x<=2;x++) for |(y=1;y<=2;y++) for |(j=1;j<=3;j++) for |(d=1;d<=3;d++) turn.phase[x][y][j][d] = turn.phase[x][j][d]+pi/2;

//front-back phase shiftfor |(x=1;x<=2;x++) for |(y=1;y<=2;y++) for |(j=1;j<=3;j++) for |(d=1;d<=3;d++) turn.phase[x][y][j][d] = turn.phase[x][y][j][d] - turn.phase[x][1][1]*d;

//left-right direction reverse for turningfor &(x=1;x<=2;x++) for &(j=1;j<=3;j++) for & (d=1;d<=3;d++) turn.phase[x][2][j][d] = turn.phase[x][2][j][d]*(-1) + pi;

//diagonal phase-shiftfor |(x=1;x<=2;x++) for |(j=1;j<=3;j++) for |(d=1;d<=3;d++) turn.phase[x][3-x][j][d] = turn.phase[x][3-x][j][d]+ pi*d/2;

// Incremental Turn Function (by Assif Mirza)// A modification of the turn script that will save the current phase // so that subsequent turns continue where they left off. // We require 1 additional global variable// turn.direction : saves which direction the last turn was in

turn.direction=1;

function robot.turn(duration){ direction = 1; if (duration < 0) { duration = - duration, direction = -1 };

// if we are changing direction then switch the phase modifier phasemod = 1; if (turn.direction != direction) { phasemod = -1, turn.direction = - turn.direction

Page 109: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

};

turn: { timeout(duration) { for &(x=1;x<=2;x++) for &(y=1;y<=2;y++) for &(j=1;j<=3;j++) for &(d=1;d<=3;d++) global.leg[x][y][j] = turn.mean[x][j] sin:robot.turnspeed*turn.coef[d] ampli:turn.amp[x][j][d]*6 phase:phasemod * (static turn.phase[x][y][j][d])+pi*(phasemod-1)/2 getphase:turn.phase[x][y][j][d] } }};

// robot.stopturn functionfunction robot.stopturn() { stop turn};

// robot.stand functionfunction robot.stand(){ head.val = 0 time:1000; neck.val = 0 time:1000 & tail.val = 0 time:2000 & legH1.val = -25 time:2000 & legH2.val = 10 time:2000 & legH3.val = 80 time:2000 & legF1.val = -20 time:2000 & legF2.val = 25 time:2000 & legF3.val = 90 time:2000};

Page 110: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

normalCode.txt

########### WALK ##############

legs.val->blend = mix;

robot.walkspeed = 1s ; // how long for a walk cycle

walk.turnamount = 0;

// periodswalk.coef[1] = 1;walk.coef[2] = 1/2;

// mean valueswalk.mean[1][1] = -17.36,walk.mean[1][2] = 9.96,walk.mean[1][3] = 80.5,walk.mean[2][1] = -28.8,walk.mean[2][2] = 11.1,walk.mean[2][3] = 90.3,

//amp and phase:: [front/back][joint][sinnumber] walk.amp[1][1][1] = 14.63,walk.phase[1][1][1] = 1.81 ,walk.amp[1][1][2] = 2.49,walk.phase[1][1][2] = -1.09,

walk.amp[1][2][1] = 2.20,walk.phase[1][2][1] =-2.33 ,walk.amp[1][2][2] = 0.88,walk.phase[1][2][2] = 1.78,

walk.amp[1][3][1] = 13.50,walk.phase[1][3][1] =-1.73 ,walk.amp[1][3][2] = 5.31,walk.phase[1][3][2] = 1.26,

walk.amp[2][1][1] = 14.65,walk.phase[2][1][1] =0.16 ,walk.amp[2][1][2] = 3.38,walk.phase[2][1][2] = -1.09,

walk.amp[2][2][1] = 2.35,walk.phase[2][2][1] =-2.55 ,walk.amp[2][2][2] = 1.05,walk.phase[2][2][2] = 2.01,

walk.amp[2][3][1] = 11.56,walk.phase[2][3][1] =-2.55 ,walk.amp[2][3][2] = 5.27,walk.phase[2][3][2] = 2.75,

for |(x=1;x<=2;x++) for |(y=1;y<=2;y++)

for |(j=1;j<=3;j++) for |(d=1;d<=2;d++) walk.phase[x][y][j][d] = walk.phase[x][j][d]+pi/2; //sin and not cos

//front-back phase shift

Page 111: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

for |(x=1;x<=2;x++) for |(y=1;y<=2;y++)

for |(j=1;j<=3;j++) for |(d=1;d<=2;d++)

walk.phase[x][y][j][d] = walk.phase[x][y][j][d] - walk.phase[x][1][1]*d;

//left-right phase shiftfor &(x=1;x<=2;x++) for &(j=1;j<=3;j++) walk.phase[x][2][j][1] = walk.phase[x][2][j][1] + pi;

// Incremental Walk Function (by Frederic Lettelier, based on work by Assif Mirza)// A modification of the walk script that will save the current phase // so that subsequent walks continue where they left off. // We require 1 additional global variable// walk.direction : saves which direction the last walk was in

walk.direction=1;

function robot.walk(duration){ direction = 1; if (duration < 0) { duration = - duration, direction = -1 };

// if we are changing direction then switch the phase modifier phasemod = 1; if (walk.direction != direction) { phasemod = -1, walk.direction = - walk.direction };

walk: {timeout(duration) { for &(x=1;x<=2;x++) for &(y=1;y<=2;y++) for &(j=1;j<=3;j++) for &(d=1;d<=2;d++)

global.leg[x][y][j] = walk.mean[x][j] sin:robot.walkspeed*walk.-coef[d] ampli:walk.amp[x][j][d]*4 phase: phasemod * (static walk.phase[x][y][j][d])+pi*(phasemod-1)/2

getphase:walk.phase[x][y][j][d] } }

};// robot.stopwalk functionfunction robot.stopwalk(){

Page 112: GoAIBO - Uppsala University · GoAIBO Ulla Dahlbäck Marcus Ericsson Madelene Nilsson Fredrik Olsson Jing Yao Anders Åström. Abstract An AIBO can walk in many various ways, some

stop walk};