home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2003 March / VPR0303A.ISO / AIBO / MoNet / MotionAgents / MoNetAgentManager.h < prev    next >
C/C++ Source or Header  |  2002-12-19  |  3KB  |  96 lines

  1. //
  2. // Copyright 2002 Sony Corporation 
  3. //
  4. // Permission to use, copy, modify, and redistribute this software for
  5. // non-commercial use is hereby granted.
  6. //
  7. // This software is provided "as is" without warranty of any kind,
  8. // either expressed or implied, including but not limited to the
  9. // implied warranties of fitness for a particular purpose.
  10. //
  11.  
  12. #ifndef MoNetAgentManager_h_DEFINED
  13. #define MoNetAgentManager_h_DEFINED
  14.  
  15. #include <list>
  16. using namespace std;
  17.  
  18. #include <OPENR/OSubject.h>
  19. #include <OPENR/OObserver.h>
  20. #include <MoNetData.h>
  21. #include "MoNetAgentManager.h"
  22.  
  23. const int NUM_JOINTS         = 15;
  24. const int NUM_FRAMES         =  4;
  25.  
  26. const int HEAD_TILT  =  0;
  27. const int HEAD_PAN   =  1;
  28. const int HEAD_ROLL  =  2;
  29. const int RFLEG_J1   =  3;
  30. const int RFLEG_J2   =  4;
  31. const int RFLEG_J3   =  5;
  32. const int LFLEG_J1   =  6;
  33. const int LFLEG_J2   =  7;
  34. const int LFLEG_J3   =  8;
  35. const int RRLEG_J1   =  9;
  36. const int RRLEG_J2   = 10;
  37. const int RRLEG_J3   = 11;
  38. const int LRLEG_J1   = 12;
  39. const int LRLEG_J2   = 13;
  40. const int LRLEG_J3   = 14;
  41.  
  42. static const char* const JOINT_LOCATOR[] = {
  43.     "PRM:/r1/c1-Joint2:j1",             // HEAD TILT
  44.     "PRM:/r1/c1/c2-Joint2:j2",          // HEAD PAN
  45.     "PRM:/r1/c1/c2/c3-Joint2:j3",       // HEAD ROLL
  46.     "PRM:/r4/c1-Joint2:j1",             // RFLEG J1 (Right Front Leg)
  47.     "PRM:/r4/c1/c2-Joint2:j2",          // RFLEG J2
  48.     "PRM:/r4/c1/c2/c3-Joint2:j3",       // RFLEG J3
  49.     "PRM:/r2/c1-Joint2:j1",             // LFLEG J1 (Left Front Leg)
  50.     "PRM:/r2/c1/c2-Joint2:j2",          // LFLEG J2
  51.     "PRM:/r2/c1/c2/c3-Joint2:j3",       // LFLEG J3
  52.     "PRM:/r5/c1-Joint2:j1",             // RRLEG J1 (Right Rear Leg)
  53.     "PRM:/r5/c1/c2-Joint2:j2",          // RRLEG J2
  54.     "PRM:/r5/c1/c2/c3-Joint2:j3",       // RRLEG J3
  55.     "PRM:/r3/c1-Joint2:j1",             // LRLEG J1 (Left Rear Leg)
  56.     "PRM:/r3/c1/c2-Joint2:j2",          // LRLEG J2
  57.     "PRM:/r3/c1/c2/c3-Joint2:j3",       // LRLEG J3
  58. };
  59.  
  60. class MoNetAgent;
  61.  
  62. class MoNetAgentManager {
  63. public:
  64.     MoNetAgentManager();
  65.     ~MoNetAgentManager() {}
  66.  
  67.     void Init();
  68.     void Start(OSubject* effector);
  69.  
  70.     void RegisterMoNetAgent(MoNetAgent* m);
  71.  
  72.     void NotifyCommand(const ONotifyEvent& event, MoNetAgentResult* result);
  73.     void ReadyEffector(const OReadyEvent& event,  MoNetAgentResult* result);
  74.  
  75.     OPrimitiveID PrimitiveID(int idx) { return primitiveID[idx]; }
  76.     OSubject*    Effector()           { return effectorSubject;  }
  77.     RCRegion*    FindFreeCommandRegion();
  78.  
  79. private:
  80.     void OpenPrimitives();
  81.     void NewCommandVectorData();
  82.  
  83.     static const size_t NUM_COMMAND_VECTOR =  4;
  84.  
  85.     MoNetAgent*          activeMoNetAgent;
  86.     MoNetAgentCommand    activeAgentCommand;
  87.     list<MoNetAgent*>    moNetAgentList;
  88.  
  89.     OSubject*    effectorSubject;
  90.     OPrimitiveID primitiveID[NUM_JOINTS];
  91.  
  92.     RCRegion*    commandRegions[NUM_COMMAND_VECTOR];
  93. };
  94.  
  95. #endif // MoNetAgentManager_h_DEFINED
  96.