home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2003 March / VPR0303A.ISO / AIBO / MoNet / MotionAgents / NeutralAgent.h < prev    next >
C/C++ Source or Header  |  2002-12-19  |  3KB  |  124 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 NeutralAgent_h_DEFINED
  13. #define NeutralAgent_h_DEFINED
  14.  
  15. #include <MoNetData.h>
  16. #include "MoNetAgent.h"
  17.  
  18. const double BROADBASE_ANGLE[] = {
  19.     45,   // TILT
  20.     0,    // PAN
  21.     0,    // ROLL
  22.  
  23.     117,  // RFLEG J1
  24.     90,   // RFLEG J2
  25.     30,   // RFLEG J3
  26.  
  27.     117,  // LFLEG J1
  28.     90,   // LFLEG J2
  29.     30,   // LFLEG J3
  30.     
  31.     -117, // RRLEG J1
  32.     70,   // RRLEG J2
  33.     30,   // RRLEG J3
  34.  
  35.     -117, // LRLEG J1
  36.     70,   // LRLEG J2
  37.     30    // LRLEG J3
  38. };
  39.  
  40. const double SLEEPING_ANGLE[] = {
  41.     -10,  // TILT
  42.     0,    // PAN
  43.     0,    // ROLL
  44.  
  45.     60,   // RFLEG J1
  46.     0,    // RFLEG J2
  47.     30,   // RFLEG J3
  48.  
  49.     60,   // LFLEG J1
  50.     0,    // LFLEG J2
  51.     30,   // LFLEG J3
  52.  
  53.     -117, // RRLEG J1
  54.     0,    // RRLEG J2
  55.     147,  // RRLEG J3
  56.  
  57.     -117, // LRLEG J1
  58.     0,    // LRLEG J2
  59.     147   // LRLEG J3
  60. };
  61.  
  62. enum NeutralAgentState {
  63.     NAS_IDLE,
  64.     NAS_ADJUSTING_DIFF_JOINT_VALUE,
  65.     NAS_MOVING_TO_BROADBASE,
  66.     NAS_MOVING_TO_SLEEPING
  67. };
  68.  
  69. class NeutralAgent : public MoNetAgent {
  70. public:
  71.     NeutralAgent();
  72.     virtual ~NeutralAgent() {}
  73.  
  74.     virtual bool AreYou(MoNetAgentID agent);
  75.     virtual void Init();
  76.     virtual void NotifyCommand(const MoNetAgentCommand& command,
  77.                                MoNetAgentResult* result);
  78.     virtual void ReadyEffector(const MoNetAgentCommand& command,
  79.                                MoNetAgentResult* result);
  80.  
  81. private:
  82.     static const word   TILT_PGAIN = 0x000a;
  83.     static const word   TILT_IGAIN = 0x0008;
  84.     static const word   TILT_DGAIN = 0x000c;
  85.  
  86.     static const word   PAN_PGAIN  = 0x000d;
  87.     static const word   PAN_IGAIN  = 0x0008;
  88.     static const word   PAN_DGAIN  = 0x000b;
  89.  
  90.     static const word   ROLL_PGAIN = 0x000a;
  91.     static const word   ROLL_IGAIN = 0x0008;
  92.     static const word   ROLL_DGAIN = 0x000c;
  93.  
  94.     static const word   J1_PGAIN   = 0x0016;
  95.     static const word   J1_IGAIN   = 0x0004;
  96.     static const word   J1_DGAIN   = 0x0008;
  97.  
  98.     static const word   J2_PGAIN   = 0x0014;
  99.     static const word   J2_IGAIN   = 0x0004;
  100.     static const word   J2_DGAIN   = 0x0006;
  101.  
  102.     static const word   J3_PGAIN   = 0x0023;
  103.     static const word   J3_IGAIN   = 0x0004;
  104.     static const word   J3_DGAIN   = 0x0005;
  105.  
  106.     static const word   PSHIFT     = 0x000e;
  107.     static const word   ISHIFT     = 0x0002;
  108.     static const word   DSHIFT     = 0x000f;
  109.  
  110.     static const int BROADBASE_MAX_COUNTER = 192; // 32ms * 192 = 6144ms
  111.     static const int SLEEPING_MAX_COUNTER  = 192; // 32ms * 192 = 6144ms
  112.  
  113.     MoNetStatus AdjustDiffJointValue(OVRSyncKey syncKey);
  114.     MoNetStatus MoveToBroadBase();
  115.     MoNetStatus MoveToSleeping();
  116.  
  117.     void SetJointGain();
  118.     void SetJointValue(RCRegion* rgn, int idx, double start, double end);
  119.  
  120.     NeutralAgentState neutralAgentState;
  121. };
  122.  
  123. #endif // NeutralAgent_h_DEFINED
  124.