1 / 20

AIBO Tutorial

AIBO Tutorial. CS 4631 – Spring 2004 Ram Ravichandran. Outline. Introduction Basic OPENR Program Constructs Code Development Executing and Debugging Flow of Development Parting advice. Introduction. Environment Code developed using C++, OPENR API

Download Presentation

AIBO Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AIBO Tutorial CS 4631 – Spring 2004 Ram Ravichandran

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

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

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

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

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

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

  8. Core Class (2) • Continued… 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 • Control Method • Used by the Subject to receive a connection result • Connect Method • Used by observer to receive a connection result • Notify Method • Used by Observer to receive a message • Ready Method • Used by Subject to receive the ASSERT_READY and DEASSERT_READY signals from Observer.

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

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

  12. More Message Passing • Observer first sends all its subjects an AssertReady void SampleObserver::SendAssertReady() { observer[obsfunc1]->AssertReady( ); } • 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) • 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 • Used to define member functions that receive messages • 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 • Make 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. • Copy the directory OPEN-R from /usr/OPENR_SDK/MS into Output. • Copy Makefile-parent from /usr/OPENR_SDK/MS to <Parent dir>/Makefile • Copy Makefile-child from /usr/OPENR_SDK/MS to <src file dir>/Makefile • Edit both makefiles. • type make;make install in the parent directory.

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

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

  18. Executing and Debugging • Insert the memory stick in the laptop. • At the prompt, type mount /sony • Once the memory stick has been mounted, then copy the files from /MS/OPEN_R to /sony cp –rf <parent dir>/MS/OPEN_R /sony • un-mount the memory stick. umount /sony • Put the memory stick in the dog and press the power button on the dog. • DEBUGGING 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 • Design your objects • Decide on the data type for the inter-object communication • Write the stub.cfg file • Write the core class with the necessary member functions • Write connect.cfg file • Write your .ocf file • Build • Write object.cfg file • Execute on AIBO • Debug (perhaps)

  20. Parting Advice • See sample programs • Do NOT let the AIBO walk on hard surfaces. This will break the joints. Use the robocup field or a similar carpet like surface. • Do 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. • You will PAY for any broken part. • This tutorial is available online (by tonight) at http://www.cc.gatech.edu/~borg/robotsoccer/aibotut.html • Programming the dogs for the first time can be frustrating. Do not hesitate to use the mailing list to ask questions.

More Related