how to make aibo do tricks - ruggert/as/download/bachelor/thesis_monet.pdf · how to make aibo do...

26
How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1

Upload: vuhuong

Post on 25-May-2018

222 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

How To Make AIBO Do Tricks

Anton WijbengaMart van de Sanden

August 23, 2004

1

Page 2: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

1 About This Document

We are not responsible for errors or omissions in technical or editorial aspectsconcerning the contents described in this document. We also are not respon-sible for technical measures, execution according to this document, as wellas for the results occurred by them such as inevitable, indirect or incidentaldamages.

1.1 Trademarks

• AIBO and OPEN-R is a trademark or a registered trademark of SonyCorporation.

• ”Memory Stick” is a trademark of Sony Corporation. ”TM” is notdescribed in this document.

• Microsoft and Windows are a registered trademark of Microsoft Cor-poration in the United States and/or other countries.

• Linux is a registered trademark of Linus Torvalds.

• Other system names, product names, service names and firm namescontained in this document are generally trademarks or registered trade-marks of respective makers.

2

Page 3: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

Contents

1 About This Document 21.1 Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Introduction 5

3 What is MoNet 6

4 MoNet Agent Overview 64.1 MoNet Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . 64.2 MotionAgents Agent . . . . . . . . . . . . . . . . . . . . . . . 7

5 From Idea to Motion 75.1 The Motion Editor . . . . . . . . . . . . . . . . . . . . . . . . 7

5.1.1 KFM Files . . . . . . . . . . . . . . . . . . . . . . . . . 105.1.2 PSE Files . . . . . . . . . . . . . . . . . . . . . . . . . 115.1.3 The limits of the Motion Editor . . . . . . . . . . . . . 11

5.2 A Small Example . . . . . . . . . . . . . . . . . . . . . . . . . 115.2.1 The No-No Move . . . . . . . . . . . . . . . . . . . . . 115.2.2 Some things to keep in mind . . . . . . . . . . . . . . . 12

5.3 MTN Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.4 ODA Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.5 Editing The Configuration Files . . . . . . . . . . . . . . . . . 14

6 MoNet Class Structure Overview 146.1 MoNet Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6.1.1 MoNet . . . . . . . . . . . . . . . . . . . . . . . . . . . 146.1.2 DirectedGraph . . . . . . . . . . . . . . . . . . . . . . 156.1.3 CommandNode . . . . . . . . . . . . . . . . . . . . . . 166.1.4 CommandArc . . . . . . . . . . . . . . . . . . . . . . . 166.1.5 MoNetCommandInfo . . . . . . . . . . . . . . . . . . . 16

6.2 MotionAgents Agent . . . . . . . . . . . . . . . . . . . . . . . 166.2.1 MotionAgents . . . . . . . . . . . . . . . . . . . . . . . 166.2.2 MoNetAgentManager . . . . . . . . . . . . . . . . . . . 176.2.3 NeutralAgent7 . . . . . . . . . . . . . . . . . . . . . . 176.2.4 MTNAgent7 . . . . . . . . . . . . . . . . . . . . . . . . 17

6.3 Global Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.3.1 ODA . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.3.2 MTN . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

7 MoNet Inter Agent Communication 18

3

Page 4: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

8 The Configuration Files 198.1 monet.cfg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198.2 monetcmd.cfg . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

9 Using MoNet inside Your Own Agent 21

10 The Making of the Turn Motion 24

11 Suggestions of Improvement 25

A Contents of the CD-ROM 26

4

Page 5: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

2 Introduction

This document has been written by us as part of a project to complete ourbachelor program. The idea is that this project and document and perhapseven MoNet itself is to be expanded by future research, since in our opiniona lot more can be done with this technology.

In this document you can read about how to use MoNet and the MotionEditor to create nice motions for Sony’s AIBO. The purpose of this documentis to make you understand how MoNet works and to use the Motion Editor.After you understand this document it should be easy to do more advancedexperiments with the AIBO, since motions are not that difficult to createanymore.

We expect the reader to have some prior experience with C++ and theOPEN-R architecture.

All important files are available on the CD-ROM accompanying this doc-ument. In appendix A an overview of the contents of this CD-ROM will begiven.

5

Page 6: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

3 What is MoNet

MoNet stands for Motion Network, and it is basically just that. It is aprogram designed by Sony which lets you run motions constructed using amotion editor, on an AIBO.

Internally MoNet constructs a directed graph of data, the motion network,describing transitional motions between the four possible generic postures.These postures are: sleep, sit, stand and walk. The motion data for allintermediate transitions between these postures is already available insideMoNet’s main motion data file and can be used in combination with yourown motions. This means that you can construct your own motions startingand ending with one of these four postures. This is a very powerful feature,because now you only have to focus on the special move that you want AIBOto perform.

This in combination with the fact that you can use MoNet as a part ofyour own program, makes it a very useful system.

4 MoNet Agent Overview

The MoNet system contains two important agents: MoNet and MotionA-gents.

4.1 MoNet Agent

The MoNet agent is the part of the MoNet system with which your ownagent communicates. Through this agent your own agent is able to utilizethe motions contained inside the MoNet system.

The agent loads all the configuration and motion files and communicateswith the MotionAgents agent which in its turn, takes care of the physicalmotions by communicating with the OVirtualRobotComm agent.

MoNet agent is a higher level agent of the MoNet system, because italso builds the motion network, which is used for the intermediate posturetransition.

After the agent gets a command to execute a motion it, prior to passingthat command along to the MotionsAgents agent, will compare the currentposture to the start posture of the specified motion. If the postures arenot the same, it will first command the MotionAgents agent to perform anintermediate transition motion. This transition motion will get AIBO intothe start posture of the commanded motion. After which it will pass thecommanded motion along.

6

Page 7: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

4.2 MotionAgents Agent

This agent represents a lower level. It first initializes the joints for movement.After initialization, it waits for the MoNet agent to send a command. Thiscommand specifies which motion data to feed to the OVirtualRobotCommagent. Which it happily does.

5 From Idea to Motion

In this section we will describe how to realize a motion. There are a fewsteps required to do this. First you have to think carefully about the motionyou want to create. This seems obvious but the reason we mention it here isbecause of the fact that the Motion Editor is not very forgiving. When youhave a good idea how to perform your motion, you can continue with thesteps described below.

• First (obviously) you have to create the motion using the motion editor.

• Next you have to save it as a KFM file.

• Then when the KFM file is saved you will have the option to export aMTN file.

• This MTN file must be copied to a linux computer where the MoNetprogram is installed.

• A perl script can be used to create the ODA file which is a package ofMTN files.

• Finally you will have to edit the configuration files in order to makeMoNet work.

Please make sure the motion you created starts at one of the four postures;sleep, sit, stand or walk. Also make sure the motion ends in one of thesepostures. You can now copy MoNet to a memory stick and use MoNetTestto perform the motion or you can build an interface in your own programand communicate with the MoNet agent from there.

5.1 The Motion Editor

The Motion Editor mainly uses the PSE and KFM files. The PSE files arepostures which can be linked together to create a motion. The KFM file

7

Page 8: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

basically just contains a list of these PSE files. For further details see thesubsections below.

The editor has four windows. The main window, which contains a nice3D view of AIBO. The title bar of this window, displays the name of theselected posture. There are also some click-able icons, which are not reallyimportant, except for the one in the view section with the label ’Jump ToUser View Point’, which might be useful. This brings the view of AIBO backto convenient angle.

The only important menu in this window is the File(F) menu. Here youcan save and open KFM and PSE files. You can also chose to export themotion of all limbs, or just one limb, to a MTN file. It is also possible, withjust a mouse click, to export all limbs to separate MTN files, including onewith all limbs, using the ’Export All sort of Mtn(X)’ menu-item.

But the only one you are likely to use, will probably be the ’Export MtnAll(A)’ item, which creates the MTN file which is useful for the MoNetsystem. This MTN file contains motion data for all the limbs.

Other options in this menu are ’Install Motion(I)’, which creates thedirectories PSE and KFM and respectively puts the appropriate motion filesin these directories.

The button ’Symmetric Convert(Y)’ converts left limb motions to theright limbs and vice versa.

’Make Mtns from Kfms(K)’ does the same as ’Export All sort of Mtn(X)’,but now for all KFM files in a specified directory.

The rest of the buttons are not really important.

Motion Control is the second window we will describe. The four buttonsin the upper-left corner of this window, can be used to create a list of PSEfiles or postures. ’Add Pose’ adds a posture to the list. ’Insert Pose’ insertsa posture above the currently selected one. ’Delete Pose’ deletes a posture(the first posture cannot be deleted unless it is the only one in the list).’Delete All’ clears the posture list.

Next to these are the buttons ’Copy’ and ’Paste’. You can copy andinsert a posture using these buttons. Because the ’Paste’ button inserts aposture and does not add the posture, it can not be used when the firstposture is selected.

In the list of postures, to the right of the name of the posture, in thecolumn called int, stands a number. This number is the amount of framesused to interpolate between one posture and the next. Each frame takesexactly sixteen milliseconds; thus the sum of the frames times sixteen is thetime in milliseconds the motion takes to finish.

The button ’Change Speed’ can be used to change the overall speed of a

8

Page 9: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

motion. The factor is 1000 by default. To make the motion twice as slow usea factor of 2000 and to make it twice as fast use a factor 500. This meansthe factor is divided by a thousand and multiplied with the interpolationnumbers shown in the list. The time for the motion to complete is always amultiple of sixteen milliseconds.

When you click on the button: ’Check’, the program will check the speedof the motion. If the speed of some limb movements is too fast, the editorwill give the message “Oops! It seems Too Fast Motion”. It will also specifybetween which postures the speed is too high.

The function of the button ’Make Key-frame’ is yet to be uncovered.There is now only one important button left in the Motion Control win-

dows, which is the ’Set’ button. This button can be used to set the ‘motionroot’. The motion root specifies where the files which you are working withare stored. Only when you open a KFM file, this information is used.

The KFM files store the exact path of the postures. Therefore it is im-portant that you keep the postures in there original directories. If you stillwant to move them, we suggest you use the ’Install Motion’ menu-item fromthe File(F) menu, or edit the KFM file by hand.

There is also a section which looks like a media player. You can use thissection to play the motions you have created. It has the possibility to pause,slow forward/backward, go frame by frame or you can drag the marker alongthe time line.

The Save button simply saves the KFM file.

The third window named Contents Control, can be used to copy files tothe AIBO and probably also for some other network related features, whichhowever, since we only used the memory stick and did this under linux, wehave not explored.

The last window is the Pose Control Window. The items here are quiteobvious. The list contains all of AIBO’s joints specifying the position ofthese joints in degrees. To find out what AIBO’s limits of movement areand which joint is which we suggest to look at the Sony - OPEN-R SDK,Model Information for ERS-7 available on the open-r website. Another wayof course is to experiment.

The ’Reset’ button sets all joint values to zero, except for the Head:Mouthand Tail:Tilt values (these values become -3).

The ’Pose Capture’ button is used to capture the joint values from a lifeAIBO, again however a network connection is required, so we did not explorethis option.

There are now some buttons left near the little AIBO figure. These

9

Page 10: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

buttons can be used to copy the left and right limbs, to there respectivebetter half on the other side. Also it is possible to swap all left and rightjoint values.

Finally all windows have a ’Close’ button which of course closes theselected window.

5.1.1 KFM Files

The KFM file is a plain text file which contains the following text/structure:

9

\A_Motion_sox_sample\Pse\sit#sit_sox_bye_00.pse

-0.698133 0.000000 0.087267 -0.087267 0.000000 0.000000

-0.436333 -0.069813 0.349067 -1.361360 0.349067 1.919867

-0.436333 -0.069813 0.349067 -1.361360 0.349067 1.919867

0.087267 0.000000

40

\A_Motion_sox_sample\Pse\sit#sit_sox_bye_01.pse

-1.047200 0.271785 0.131841 -0.523600 0.000000 0.000000

-0.436333 -0.069813 0.349067 -1.361360 0.349067 1.919867

-0.436333 -0.069813 0.349067 -1.361360 0.349067 1.919867

0.698133 0.523600

30

\A_Motion_sox_sample\Pse\sit#sit_sox_bye_02.pse

-0.855213 0.174533 0.436333 -0.139627 0.000000 0.000000

-0.436333 -0.069813 0.349067 -1.361360 0.349067 1.919867

-0.436333 -0.069813 0.349067 -1.361360 0.349067 1.919867

0.698133 0.000000

.........

......

...

As you can see the KFM file is a list of postures/PSE files. Each blockcontains a number, the first one is 9, the path and filename and the degreesof each joint in radians. The numbers 9, 40 and 30 are the number of in-terpolation frames used in the motion, from one posture to the next. If youchange the directory where your PSE files are stored you would need to editthe path of every posture inside the KFM file. You could also use the methoddescribed above, using the ’Install Motion(I)’ menu-item.

As you might have noticed, the filenames of the poses are not just random.They must have the following structure: name1#name2 something.pse. Es-pecially the name1 and name2 are important and can only be one of fournames; sleep, sit, stand or walk (name1 and name2 do not need to be thesame). This is because MoNet constructs a motion-net using these names.

The first one name1 is the starting posture and the second one name2 isthe end posture. If you chose different names the net would fall apart andsmooth transitions between all types of motions become impossible.

10

Page 11: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

The other part of the filename is not important except for the underscorebetween name and something, because this underscore is a delimiter used byMoNet when parsing the configuration files.

For the same reason, you must name the KFM and MTN files, respectivelyname1#name2 something.kfm and a name1#name2 something.mtn.

5.1.2 PSE Files

The PSE file is also a plain text file and has the following text/structure:

#OPENRPF V1.2

0 37 0 -500 0 0

20

/r1/c1-Joint2:11 ,

-61.000000

/r1/c1/c2-Joint2:12 ,

5.000000

/r1/c1/c2/c3-Joint2:13 ,

9.000000

.........

......

...

This time the file is not a list of postures, but a list of joints. You can seethe joint-address /r1/c1-Joint2:11 and below that you see the joint values indegrees (not radians!).

5.1.3 The limits of the Motion Editor

Earlier we mentioned that the motion editor is not very forgiving. We willnow explain what we meant by that. Imagine you have created a motionwhich does not work too well and you want to change motion of one leg. Thejoint values of that leg have to be edited for each posture which is a very timeconsuming process. It would be nice if you could select a range of posturesin which you could edit the desired joint values at once. We really missedthis feature.

Also the Motion Root idea seems a bit unnecessary. If the Editor wouldassume that the PSE files, that a KFM file uses, are in the same directoryas the KFM file itself. Then the motion root would be obsolete. This wouldavoid a lot of confusion and make the editor more robust.

5.2 A Small Example

5.2.1 The No-No Move

First you need to create a directory, within the motion root, where you storethe files for this example.

11

Page 12: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

Next copy the file sleep#sleep sox givetouch 00.pse from the directory/A Motion sox sample/Pse/. This can be found inside the sample contents ver1.ziparchive available on the CD-ROM or open-r website.

Rename this file to sleep#sleep example 00.pse.Next open the editor using medit.exe. Now open sleep#sleep example 00.pse

using the ’Add Pose’ button from the Motion Control window.In the Pose Control window, change the value for Head:Pan to 45 degrees

and press the ’Save’ button inside the same window. Save the posture assleep#sleep example 01.pse in the same directory as sleep#sleep example 00.pse.

In the Motion Control window, use the ’Add Pose’ button to add the poseyou just have created. This time you have to enter a interpolation frame ratefirst; enter 40.

Next change the value for Head:Pan to -45 degrees. And again, save theposture in the same directory naming it sleep#sleep example 02.pse.

Use ’Add Pose’ to add the sleep#sleep example 02.pse posture with aframe rate of 80. We use this frame-rate, because the distance of this motionis twice as far, therefore, it should take twice as long.

Finally also add the sleep#sleep example 00.pse posture to the end, witha interpolation time of 40 frames, in the usual way.

Now there are four postures. Press the play button to see AIBO performthe motion.

To save this motion to a KFM file, use the File(F) menu of the firstwindow or the ’Save’ button of the Motion Control window. It is easier touse the latter.

Name the file sleep#sleep example.kfm. After the KFM file is saved, somemore options become available.

Experiment with the ’Symmetric Convert(Y)’ menu-item inside the File(F)menu. If click on it, you will see that all of a sudden, the head moves fromright to left, instead of from left to right, as it previously did.

Be aware that when you have converted the motion you do not need tosave it. The KFM file already has been saved as the symmetric conversion.Also the PSE files are changed.

After the KFM file is saved it is possible to use ’Export Mtn All(A)’ insidethe File(F) menu. Save the MTN file as a sleep#sleep example.mtn. ThisMTN file is a binary file which MoNet can use. For more information aboutMTN files, see sections below.

5.2.2 Some things to keep in mind

One major disadvantage of the editor is, that it does not take the laws ofphysics into account. This means that when two limbs should bump into

12

Page 13: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

each other, they will just pass trough one another. So when you design yourmotion, you will have to check visually, if none of the limbs is breaking thelaws of physics.

Also, there is no (virtual) gravity inside the editor. This means you willnever know if the AIBO, for example, is going to tip over when standing onthree legs. There is no solid floor either inside the editor, so when you movea leg, you do not know if it is going to kick into the floor.

When you want to lower the AIBO by bending it’s legs, it is hard to seewhether all legs stay at the same position on the ground. One of the legscould be scraping the ground or just be hovering in the air.

One example is when you want to move a leg from a backward angle to aforward angle (maybe to change the balance so you can lift another leg). Todo this, first you have to lift the leg, then move it forward and after that, putit back on the floor. The problem here is that, again, you will not know whenthe leg is on the ground. You could of course just test it in the real world,but there is a more scientific method. The upper and lower legs are aboutthe same size. Knowing this, it is not too difficult to calculate the anglesneeded between each part of the leg. Calculating the angles is also necessarywhen you want to bend a leg, but do not want to change the position of thatleg on the floor.

We have constructed a turning motion for the AIBO. How we accom-plished this turning motion is also documented in the section ’The Makingof the Turn Move’. There you can read more details about how to create amotion and deal with the lack of physics. This motion is of course availableon the CD-ROM.

5.3 MTN Files

MTN Files are files that can be used by MoNet. They contain joint primitivenames in combination with motion data and are almost equivalent with KFMfiles.

If you are interested in the specifics, we suggest you read MTN-FFORM-E.txt, which is distributed with MoNet.

5.4 ODA Files

Before MoNet can use MTN files, they have to be packed in an ODA file. Inother words an ODA file is a sort of archive.

The ODA file used by MoNet is called MOTION7.ODA and should bepresent on the memory stick in the directory ’MS/OPEN-R/MW/DATA/P/ERS-7 ’.

13

Page 14: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

Inside this ODA file all the motions you want to use with MoNet shouldbe available. With these, logically, we also mean all implicit transitionalmotions.

The default transitional motions are available in the MOTION7.ODA filedistributed with MoNet.

There is a perl script available with MoNet, named oda in the tools di-rectory. With this script you can pack and unpack ODA files, also you canadd MTN files to an ODA file. For further details we suggest you look atthe help (-h) information of the script.

5.5 Editing The Configuration Files

Finally, now you have constructed your motion using the editor, createda MTN file and added it to the MOTION7.ODA file, the only thing thatremains to be done is (do you here the triumph music?), to add a few linesto the configuration file!

This is not as hard as it sounds. Here follow the lines needed to add theexample motion. As you can see, it has a command id of 15 and the MTNfiles is named a sleep#sleep example.mtn.

15 1 0

monetagentMTN a_sleep#sleep_example -1

For more detailed information see section ’The Configuration Files ’.

6 MoNet Class Structure Overview

6.1 MoNet Agent

In the this sections we will describe the workings of some of the more impor-tant classes inside the MoNet agent.

6.1.1 MoNet

Like the name suggest, this is the main agent for the motion network pro-gram.

When it executes, first of all it reads the configuration files monet.cfgwhich specifies all the implicit motions, and monetcmd.cfg which specifiesall the explicit motions and command-ids thereof. It also reads the file MO-TION7.ODA which contains motion data. The file SOUND.ODA, which

14

Page 15: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

MoNet

CommandArc

CommandNode

MoNetCommandInfo

MoNetAgentCommand

MoNetCommandInfoManager

ODA

DirectedGraph

NodeArc

0..inf.

0..inf.

0..inf.

Figure 1: MoNet class structure

contains sound data, is also read but this part of MoNet’s behavior will notbe further discussed in this document.

With this information it creates a network of motions, which contains allthe possible transitions between postures. This network is contained insidean instantiation of the class DirectedGraph.

After the initialization phase the agent will wait for command input fromanother agent by means of the Client Command service. When a commandis received, it is immediately executed.

In the first step of the command execution phase, MoNet checks if thecurrent posture matches the first posture of the motion to be performed.If this is not the case it tries to find the shortest path of implicit motionswhich will bring it to the right posture. Then the motion path is send to theMotionAgents agent.

6.1.2 DirectedGraph

This class holds the actual motion network, which is used by MoNet to findthe shortest path from one posture to another.

An important function in this class is Search(), which searches for theshortest distance path of motions between the specified source and destina-tion postures. This is then returned in the path argument variable.

15

Page 16: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

6.1.3 CommandNode

This class holds one variable of the type MoNetPosture which holds an idto one of the five basic postures (undefined, any, neutral, stand, sit, sleep orwalk).

6.1.4 CommandArc

An object of this class contains a source and destination CommandNodeand a MoNetCommandInfo object.

6.1.5 MoNetCommandInfo

Contains the ids of up to two commands, which specify the location of themotion data inside the motion file. It also contains a boolean value specifyingthe use of synckeys. Synckey is an open-r sdk system, used to synchronizemultiple output devices.

6.2 MotionAgents Agent

MotionAgents

NeutralAgent7

MoNetAgentManager

MoNetAgent

MTNAgent7

MTNODA MoNetAgentCommand

Figure 2: MotionAgents class structure

In the this section we will describe some of the more important classesinside the MotionAgents agent.

6.2.1 MotionAgents

Contains all the important objects, like MoNetAgentManager which doesall the magic stuff and MTNAgent7 and NeutralAgent7, which are used byMoNetAgentManager.

16

Page 17: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

6.2.2 MoNetAgentManager

This is where, the communication with the OVirtualRobotComm agent takesplace, and subsequently the joints are being moved. Also it opens the prim-itive locators and creates the regions, used to control the joints.

As the name suggests it also manages the two different types of agents,which are MTNAgent7 and NeutralAgent7.

It receives commands from MoNet, which are relayed by the MotionAgentsobject.

A command is a structure called MoNetAgentCommand, which containsa start and end posture id, a motion file index and an agent id.

The agent id can hold the values monetagentNEUTRAL and moneta-gentMTN. This indicates which of the two agents are to be used to performthe motion.

6.2.3 NeutralAgent7

This class is used to get AIBO into the sleep posture using the universalmotion. This is the reason why the first entry into the monet.cfg file shouldbe of the type monetagentNEUTRAL. It retrieves a free region and the usedjoint ids form the MoNetAgentManager object.

6.2.4 MTNAgent7

This class performs all other motions. It gets the MoNetAgentCommand fromMoNetAgentManager. It then retrieves the motion data, which is specified bythe command index, from the motion file. Then performs the motion usingthe InterpolateCommandVectorData() method from the MTNFile class.

6.3 Global Classes

6.3.1 ODA

The class that is used to read ODA files.An ODA file is an archive of one or more other files. In the case of MoNet

usually MTN files.The motion index, used throughout the MoNet system and also present

in the configuration files, represents the number of files prior to the specifiedMTN file, inside the main ODA file.

17

Page 18: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

6.3.2 MTN

Used to read MTN files, which are files containing per joint motion data, inform of key frames.

The file format is described in the text file MTN-FFORM-E.txt.

7 MoNet Inter Agent Communication

MoNet

MoNetTest

MotionAgents

SoundAgent

ClientResult Result

ClientCommand Command

MotionAgentCommand Command

AgentResult Result

SoundAgentCommand Command

AgentResult Result

NotifyResult

ReadyCommand

NotifyCommand

X

NotifyCommand

X

MoNetResult

MoNetCommand

MoNetAgentCommand

MoNetAgentResult

MoNetAgentCommand

MoNetAgentResult

X

NotifyClientCommand

X

NotifyAgentResult

X

NotifyAgentResult

OVirtualRobotComm

Effector EffectorOCommandVectorData

ReadyEffector

OVirtualRobotAudioComm

SpeakerOSoundVectorData

SpeakerReadyPlay

?

?

Figure 3: MoNet class structure

Figure 3 describes the communication pathways between the various agents.In this schema, agents are represented using boxes. The arrows between theseboxes are communication services. Services are named on the left and rightside of an arrow and belong to the respective agents. In the middle above thearrow the data type is listed, and to the left and right of the arrows insidethe agent boxes, the connected class methods are named.

So for example. There exists a subject and observer service betweenrespective MoNet and MoNetTest, with data type MoNetResult. On the sideof MoNet it is called ClientResult and on the side of MoNetTest it is calledResult.

This means that the stubs.cfg file of the MoNet agent has the followingline.

Service : "MoNet.ClientResult.MoNetResult.S", null, null

The stubs config file of the agent MoNetTest has this one.

Service : "MoNetTest.Result.MoNetResult.O", null, NotifyResult()

And the CONNECTION.CFG file has a line that looks like this one.

MoNet.ClientResult.MoNetResult.S MoNetTest.Result.MoNetResult.O

18

Page 19: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

8 The Configuration Files

Here we will give some quick reference information on the specifics of themonet.cfg and monetcmd.cfg configuration files. These are both needed forthe MoNet system and are used to specify the motions that are availableinside the MOTION7.ODA file.

8.1 monet.cfg

First lets talk about the monet.cfg file. This configuration file is used tospecify all the implicit motions, that do not have a command id and areused for automatic intermediate motions, to get from the end posture of onemotion to the start posture of all other motions. This ensures MoNet canperform every commanded motion from every posture, all of the time. Forthis reason as might be clear already, this file needs to hold all intermediatemotions between the four basic postures (sleep, sit, stand and walk) andone for the motion between the neutral posture to the sleep posture. Thelast motion always needs to be performed by the monetagentNeutral agent,because it involves the universal motion, which is hard coded into the neutralagent.

The file has the following format. Every line that is started with ’#’ willbe considered a comment. All other line should look like this: “agent namemotion name motion id”. The spaces between the values can be either aspace or a tab character.

The value of agent name can be: monetagentNEUTRAL, monetagentMTNand monetagentSOUND. But except for the first one which should be mon-etagentNEUTRAL, it only makes sense to use monetagentMTN.

Motion name specifies the name of the MTN file inside the MOTION7.ODAfile. And should always be of the format: “a startposture#endposture name”.startposture and endposture specify one of the four basic postures, nt, sleep,sit and stand.

Motion id should have a value of 0 or higher, specifying the index ofthe MTN file, into the MOTION7.ODA file (where the first is 0 and thesecond is 1, and so on). But it can also hold the value ’-1’, which makesMoNet lookup the index using the motion name. Usually only the first linecontaining the neutral motion, will have a value other than ’-1’, because theneutral motion is not contained inside the MOTION7.ODA file. Thus, alookup for “a nt#sleep whatever” will always fail.

Here follows an example. This is what the file usually looks like.

monetagentNEUTRAL a_nt#sleep_standard 0

19

Page 20: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

monetagentMTN a_sit#sleep_standard -1

monetagentMTN a_sit#stand_standard -1

monetagentMTN a_sleep#sit_standard -1

monetagentMTN a_sleep#stand_standard -1

monetagentMTN a_stand#sit_standard -1

monetagentMTN a_stand#sleep_standard -1

As you can see, it hold transitional motions between all basic postures.

8.2 monetcmd.cfg

Now lets talk about the monetcmd.cfg file. This configuration file holds allthe explicit motions. These motions also have a command id specified withthem.

For this file again, a ’#’ at the beginning of a line means it is a commentand values are delimited using space or tab characters.

This file consists of line with the values: ’command id number of agentssynckey ’, followed by number of agents times a line with this format: ’agent namecommand name command index ’. For the last line, see the subsection aboutthe monet.cfg file. One difference is that monetagentSOUND can also beused and the use of monetagentNEUTRAL would be a bit strange (but it ispossible, you could for instance specify a motion you can call after unfinishedmotions, to always get back to the sleep posture in a noninvasive way).

About the first line.Command id can have any 32 bit signed integer value you want. It is

the same command id your agent can give MoNet to perform the specifiedmotion.

Number of agents can hold the value ’1’ or ’2’. It specifies the number ofagent lines that follow the header line.

SyncKey is a boolean value of ’0’ meaning false and ’1’ meaning true. Ifit is true a open-r system called SyncKey is used. For more information wesuggest you read the open-r reference manual.

And an example.

###########################################################

#

# TURN motion

#

###########################################################

monetagentMTN a_stand#stand_rightturn -1

16 1 0

monetagentMTN a_stand#stand_leftturn -1

20

Page 21: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

In this example, there are two motions specified. One with command id’15’ and one with command id ’16’. They both only use one agent line andno synckey.

9 Using MoNet inside Your Own Agent

In here we are going to explain how to use the MoNet system from insideyour own agents. This is conveniently, thanks to the open-r architecture,not very difficult. All you really need to do is setup the subject/observerservice in the right way and update the connection.cfg file. Finally add somecommunication methods to your agent and your done. Now you can easilylet your own program make AIBO do complicated motions.

This tutorial assumes you have read the sections above and are familiarwith the workings of MoNet. Also it assumes that all the original motions,which are distributed with MoNet, are available and configured with theoriginal ID’s. For an example we will direct you to the MoNetTest agent,distributed with the MoNet system.

First lets setup your agent class. Next to your own and the normal open-r methods, you will have to add one more observer and one more subjectmethod.

The name of the subject method is ’void ReadyMoNetCommand(constOSystemEvent &event)’. When the connect.cfg and the stubs.cfg files are cor-rectly configured, this method is called whenever the subject service MoN-etCommand receives a message from MoNet. The only relevant time thishappens is at start time, when MoNet for the first time, is ready to receive acommand. When this happens you should usually give MoNet the commandto get AIBO in its sleep posture using the universal motion. To accomplishthis insert the following code.

if (state == STATE_MONET_START) {

MoNetExecute(0); // Execute command zero.

\\ Here you probably want to change the state of your agent

\\ to something like ‘‘state = STATE_WAITING_MONET_RESULT;’’.

}

Command zero will, if you hold to the rules describe in the configurationsection, always be the universal, from undefined to sleep posture motion.

You will also want to run the code above if MoNet is already initialized,when open-r runs your agents DoStart() method. This would look somethinglike.

OStatus

YourAgent::DoStart(const OSystemEvent &event)

21

Page 22: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

{

// Bla bla bla...

if (subject[sbjMoNetCommand]->>IsReady() == true) {

// above code...

} else {

// Change your agents state to something else,

// like ‘‘state = STATE_MONET_START;’’

}

// End some more: bla, bla, bla...

}

The name of the more important observer method is ’void NotifyMoN-etResult(const ONotifyEvent &event)’. After the initial MoNetCommandevent, all the communication with MoNet will go through the MoNetResultobserver service. This is what this method is to handle for us. The code forthis method will probably look something like this.

void

YourAgent::NotifyMoNetResult(const ONotifyEvent &event)

{

switch(state) {

case STATE_IDLE: break;

case STATE_MONET_START:

// Some non fatal error message.

observer[event.ObsIndex()]->>AssertReady()’

break;

case STATE_WAITING_MONET_RESULT:

MoNetResult *result = (MoNetResult*)event->>Data(0);

MoNetExecute(2); // Make AIBO do something, like standing up...

observer[event.ObsIndex()]->>AssertReady()’

break;

};

}

Now the code for the MoNetExecute() method. This method sends acommand to MoNet.

void

YourAgent::MoNetExecute(MoNetCommandID cmdID)

{

22

Page 23: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

MoNetCommand cmd(0);

subject[sbjMoNetCommand]->>SetData(&cmd, sizeof(cmd));

subject[sbjMoNetCommand]->>NotifyObservers();

}

OK, now to setup the almighty stubs.cfg file. Add the following subjectand observer to it.

Service : "MoNetTest.MoNetCommand.MoNetCommand.S", null,\

ReadyMoNetCommand()

Service : "MoNetTest.MoNetResult.MoNetResult.O", null,\

NotifyMoNetResult()

And last but not least, the CONNECTION.CFG configuration file. Thisfile needs some more complicated lines, because it will also need to knowhow the communication between the three agents contained inside the MoNetsystem is handled. Here follows the complete content of that file.

#

# YourAgent <<-->> MoNet

#

YourAgent.MoNetCommand.MoNetCommand.S MoNet.ClientCommand.MoNetCommand.O

MoNet.ClientResult.MoNetResult.S YourAgent.MoNetResult.MoNetResult.O

#

# MoNet <<-->> MotionAgents

#

MoNet.MotionAgentCommand.MoNetAgentCommand.S MotionAgents.Command.MoNetAgentCommand.O

MotionAgents.Result.MoNetAgentResult.S MoNet.AgentResult.MoNetAgentResult.O

#

# MoNet <<-->> SoundAgent

#

MoNet.SoundAgentCommand.MoNetAgentCommand.S SoundAgent.Command.MoNetAgentCommand.O

SoundAgent.Result.MoNetAgentResult.S MoNet.AgentResult.MoNetAgentResult.O

#

# MotionAgents -->> OVirtualRobotComm

#

MotionAgents.Effector.OCommandVectorData.S OVirtualRobotComm.Effector.OCommandVectorData.O

#

# SoundAgent -->> OVirtualRobotAudioComm

#

SoundAgent.Speaker.OSoundVectorData.S OVirtualRobotAudioComm.Speaker.OSoundVectorData.O

Well, now you are done. Its that easy. Last but not least, do not forgetthat the compiled MoNet system also need to be on the memory stick, if youwant AIBO to run properly.

23

Page 24: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

10 The Making of the Turn Motion

First we made AIBO lean to the left by adjusting all the J2 joints. The leftlegs to -10 degrees and the right legs to 16 degrees. Next we lifted the rightrear leg and placed it more to the left by setting the J2 joint of this leg to-10 degrees. Then the left rear leg was also lifted and positioned to the left.This time by setting J2 to 16.

Now AIBO has his front legs as far as possible to the right and his rearlegs as far as possible to the left. To turn the AIBO we move the rear legsto the right and the front legs to the left, but this time not by lifting any ofthe legs. This makes the body of the AIBO turn. This part was the mostdifficult and some calculations were necessary.

First we measured the distance between the points where the legs touchedthe ground. Next the distance the legs would move from left to right andvice versa was measured. Now we drew the four points of the legs on paperand drew a circle through those points. Then we drew the points where thelegs would be positioned when only moved sideways. It is not possible toonly move the legs sideways since the legs would be scraping the ground.

That is why we drew a circle. From the point where the left-fore leg wouldbe we go up until we hit the circle, this is the new position for the left-foreleg. For the other legs we do about the same, but in a different direction.This results in figure 4.

Figure 4: Turn

The movement in the direction of the x-axis is now compensated by theJ2 joints and the movement in the direction of the y-axis is compensated bythe J1 joints. By adjusting all these joints at the same time the legs remainat exactly the same position on the ground (because this time we did not liftany of the legs) while the body of the AIBO is turning.

24

Page 25: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

After this turn is complete we have to move the legs to the positions onthe ground where they are when the AIBO is just standing. We do this bylifting and repositioning the legs. To do this the balance of the AIBO needsto be shifted from time to time. This way AIBO almost seems to be dancing.

To reposition the legs, we see another figure 5.

Figure 5: Leg

Here you can see an angle alpha and beta. The length of the lines aresimilar, designated by ’x’. You can now use your basic mathematics to keepthe distance between ’A’ and ’B’ the same while changing the angle of theleg relative to the body (repositioning). Also you can keep the position of’B’ the same relative to the ground and alter the distance between ’A’ and’B’ (lifting or lowering the body). Actually you always want to calculate oneof these two possibilities, because otherwise a leg would be hovering in theair or scraping the ground.

The AIBO is now again in the standing position and can repeat the turnmove or do an other move from the standing position. Hence the turn moveis a stand#stand turn file.

The AIBO is now turning to the right. The turn to the left is just asymmetric copy made by using ’Symmetric Convert(Y)’ in the File(F) menu.

11 Suggestions of Improvement

It would be nice if the set of the basic postures (sleep, sit, stand and walk)could be expanded. For instance when we created the turn move, we wouldhave liked a turn#turn motion. Then the AIBO would not have to straitenup after each turn. This would have resulted in a more efficient movement.

25

Page 26: How To Make AIBO Do Tricks - RUGgert/as/download/bachelor/thesis_monet.pdf · How To Make AIBO Do Tricks Anton Wijbenga Mart van de Sanden August 23, 2004 1. 1 About This Document

A Contents of the CD-ROM

• MoNet.tar.gz MoNet

• Medit.zip The Motion Editor

• sample contents ver1.zip The sample postures and motions needed tocreate other motions

• AIBOProgrammersGuide E.pdf The AIBO Programmers Guide

• ReferenceGuide E.pdf The AIBO Open-R Reference Guide

• ModelInformation 7 E.pdf AIBO’s Physical specifications

• rightturn.tar.gz The right-turn motion created by us

• leftturn.tar.gz The left-turn motion created by us

• MoNetdocs.pdf This document

26