Presentation is loading. Please wait.

Presentation is loading. Please wait.

AIBO Tutorial CS 4631 – Spring 2004 Ram Ravichandran.

Similar presentations


Presentation on theme: "AIBO Tutorial CS 4631 – Spring 2004 Ram Ravichandran."— Presentation transcript:

1 AIBO Tutorial CS 4631 – Spring 2004 Ram Ravichandran

2 Outline z Introduction z Basic OPENR Program Constructs z Code Development z Executing and Debugging z Flow of Development z Parting advice

3 Introduction z Environment y Code developed using C++, OPENR API y Installed under /usr/OPENR_SDK y available from www.jp.aibo.com/openr/www.jp.aibo.com/openr/ z Documentation (available under /usr/OPENR_SDK/documentation ) y AIBO Programming manual y ERS-210 Information y API Specifications (Level II reference Guide)

4 Introduction z Sample Programs y Best way to learn writing code y All sample programs are available under /usr/OPENR_SDK/sample x Copy to your home directory and change permissions. x run using make PREFIX=/usr/OPENR_SDK

5 OPENR Objects z True OO (very similar to Squeak/SmallTalk) z Similar to a UNIX process z Communication through message passing. y Object waits for message {selector,data} to arrive. y Once a message arrives, objects call the method based on the selector specified in stub.cfg. y Arguments to the method is the data in the message y Wait for more messages.

6 Inter-object communication z Brief overview y Subject x Object that sends a message y Observer x Object that receives the message y Every observer has a message queue. y Subject sends Observer a ‘NotifyEvent’. y Observer replies with a ‘ReadyEvent’ x ASSERT_READY x DEASSERT_READY

7 Core Class z Each Object has a Core Class z A Sample Core Class #include #include "def.h“ class SampleClass : public OObject { public: SampleClass(); virtual ~SampleClass() {} OSubject* subject[numOfSubject]; OObserver* observer[numOfObserver];

8 Core Class (2) zContinued… virtual OStatus DoInit(const OSystemEvent& event); virtual OStatus DoStart(const OSystemEvent& event); virtual OStatus DoStop(const OSystemEvent& event); virtual OStatus DoDestroy(const OSystemEvent& event); //Describe the member functions corresponding to Notify, //Control, Ready, Connect method. };

9 Inter-object Communication z Control Method y Used by the Subject to receive a connection result z Connect Method y Used by observer to receive a connection result z Notify Method y Used by Observer to receive a message z Ready Method y Used by Subject to receive the ASSERT_READY and DEASSERT_READY signals from Observer.

10 DoXXXX() Method Macros z DoInit y NEW_ALL_SUBJECT_AND_OBSERVER x Registers the necessary number of Subjects & Observers. y REGISTER_ALL_ENTRY x registers the connection to services offered by other objects y SET_ALL_READY_AND_NOTIFY_ENTRY x This registers all entry points. z DoStart y ENABLE_ALL_SUBJECT x Enables all the Subjects y ASSERT_READY_TO_ALL_OBSERVER x This sends ASSERT_READY to all subjects.

11 DoXXXX() Method Macros (2)  DoStop() y DISABLE_ALL_SUBJECT x This disables all subjects of core class. y DEASSERT_READY_TO_ALL_OBSERVER x This sends a DEASSERT_READY to all connecting subjects. z DoDestroy() y DELETE_ALL_SUBJECT_AND_OBSERVER x This deletes all observer and subjects.

12 More Message Passing z Observer first sends all its subjects an AssertReady void SampleObserver::SendAssertReady() { observer[obsfunc1]->AssertReady( ); } z When Subject receives AssertReady, it sends the data. void SampleSubject::Ready(const OReadyEvent& event) { char str[32]; strcpy(str, “Some Text Message”); subject[sbjFunc2]->SetData(str,sizeof(str)); subject[sbjFunc2]->NotifyObservers( ); }

13 More Message Passing (2) z When observer receives the data, it sends an ASSERT_READY again void SampleObserver::Notify(const ONotifyEvent& event) { const char* text = (const char*)event.Data(0); observer[sbjFunc1]->AssertReady(); }

14 Stub File z Used to define member functions that receive messages z A sample Stub File (stub.cfg) ObjectName : SampleClass NumOfOSubject : 1 NumOfOObserver : 2 Service : “SampleClass.Func1.Data1.S”,Control(),Ready() Service : “SampleClass.Func2.Data2.O”,Connect(),Notify1() Service : “SampleClass.Func3.Data2.O”,Control(),Notify2() Extra : WakeUpOnLan() Extra : UpdateBatteryStatus()

15 Building zMake a Directory (let’s call it Output) in the parent directory of the directory where you have the source files. We will put the final output executables in this directory. zCopy the directory OPEN-R from /usr/OPENR_SDK/MS into Output. zCopy Makefile-parent from /usr/OPENR_SDK/MS to /Makefile zCopy Makefile-child from /usr/OPENR_SDK/MS to /Makefile zEdit both makefiles. ztype make;make install in the parent directory.

16 Building (2) z A picture is worth a thousand words

17 Editing Configuration Files. z.ocf file y Has one line in it of the following format. object NAME STACK_SIZE HEAP_SIZE SCHED_PRIORITY cache tlb user zconnect.cfg file y This file is in /MS/OPEN-R/MW/CONF y Dictates who talks to who using what services (registered in stub.cfg) y Contains lines similar to : object1.sendStream.datatype1.S object2.recvStream.dataType1.O zobject.cfg file y contains a list of.bin files (objects) y add the objects you have compiled  do not erase tinyftpd.bin and powermon.bin

18 Executing and Debugging zInsert the memory stick in the laptop. zAt the prompt, type mount /sony zOnce the memory stick has been mounted, then copy the files from /MS/OPEN_R to /sony cp –rf /MS/OPEN_R /sony zun-mount the memory stick. umount /sony zPut the memory stick in the dog and press the power button on the dog. zDEBUGGING For debugging information see chapter 5 in the programmer’s manual. The explanation in the chapter is very clear and extensive.

19 Flow of Development zDesign your objects zDecide on the data type for the inter-object communication zWrite the stub.cfg file zWrite the core class with the necessary member functions zWrite connect.cfg file zWrite your.ocf file zBuild zWrite object.cfg file zExecute on AIBO zDebug (perhaps)

20 Parting Advice zSee sample programs zDo NOT let the AIBO walk on hard surfaces. This will break the joints. Use the robocup field or a similar carpet like surface. zDo NOT use joint values greater than the ones in the manual. The software does not impose a limit on the joint angles. Thus you can BREAK the joints by putting in arbitrary values. zYou will PAY for any broken part. zThis tutorial is available online (by tonight) at http://www.cc.gatech.edu/~borg/robotsoccer/aibotut.html http://www.cc.gatech.edu/~borg/robotsoccer/aibotut.html zProgramming the dogs for the first time can be frustrating. Do not hesitate to use the mailing list to ask questions.


Download ppt "AIBO Tutorial CS 4631 – Spring 2004 Ram Ravichandran."

Similar presentations


Ads by Google