Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ChiaraInfo.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_ChiaraInfo_h
00003 #define INCLUDED_ChiaraInfo_h
00004 
00005 #include <cmath>
00006 #include <stdlib.h>
00007 #include "CommonInfo.h"
00008 using namespace RobotInfo;
00009 
00010 // see http://tekkotsu.org/porting.html#configuration for more information on TGT_HAS_* flags
00011 #if defined(TGT_CHIARA)
00012 #  define TGT_IS_BIOLOID
00013 #  define TGT_IS_CHIARA
00014 #  define TGT_HAS_CAMERA 1
00015 #  define TGT_HAS_LEDS 11
00016 #  define TGT_HAS_BUTTONS 3
00017 #  define TGT_HAS_LEGS 6
00018 #  define TGT_HAS_SEK_LEGS 6
00019 #  define TGT_HAS_ARMS 1
00020 #  define TGT_HAS_HEAD 1
00021 #  define TGT_HAS_POWER_STATUS
00022 #  define TGT_HAS_IR_DISTANCE 3
00023 #endif
00024 
00025 //! Contains information about an Chiara hexapod robot, such as number of joints, LEDs, etc.
00026 namespace ChiaraInfo {
00027 
00028   // *******************************
00029   //       ROBOT CONFIGURATION
00030   // *******************************
00031 
00032   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00033 
00034   const unsigned int FrameTime=32;        //!< time between frames in the motion system (milliseconds)
00035   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00036   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00037   
00038   //!@name Output Types Information
00039   const unsigned NumWheels      =  0;
00040   
00041   const unsigned FingerJointsPerArm = 2;
00042   const unsigned JointsPerArm   =  6;
00043   const unsigned NumArms        =  1;
00044   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00045   
00046   const unsigned JointsPerLeg   =  3; //!< The number of joints per leg
00047   const unsigned NumLegs        =  6; //!< The number of legs
00048   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00049   const unsigned NumHeadJoints  =  2; //!< The number of joints in the pantilt
00050   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00051   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00052   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00053   const unsigned NumButtons     =  3; //!< the number of buttons that are available
00054   const unsigned NumSensors     =  11;  //!< the number of sensors available
00055   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00056 
00057   const unsigned NumLEDs        =  NumLegs + 1 + 4; //!< There's an LED on every dynamixel, but can't see most of them, so save some computational resources and only expose the visible ones: knees and pan
00058   const unsigned NumPIDJoints   = NumArmJoints + 1 + NumLegJoints + NumHeadJoints+NumTailJoints+NumMouthJoints;; //!< servo pins
00059   
00060   const unsigned NumOutputs     = NumWheels + NumPIDJoints + NumLEDs; //!< the total number of outputs
00061   const unsigned NumReferenceFrames = NumOutputs + 1 + NumLegs + NumArms + 1 + 3; //!< for the base, feet, gripper, camera, and IR distance rangefinder
00062 
00063   using namespace Camera75DOF;
00064   
00065   const float BallOfFootRadius=0; //!< radius of the ball of the foot
00066   //@}
00067 
00068 
00069   // *******************************
00070   //         OUTPUT OFFSETS
00071   // *******************************
00072 
00073   //!Corresponds to entries in ERS7Info::PrimitiveName, defined at the end of this file
00074   //!@name Output Offsets
00075 
00076   
00077   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00078   const unsigned RFrRotatorOffset = PIDJointOffset; //!< The right front leg's rotator joint
00079   const unsigned LegOffset   = RFrRotatorOffset+1;           //!< the offset of the beginning of the regular leg joints (after the 1 rotator joint for the right front leg):  #NumLegs of #JointsPerLeg each, in #LegOrder_t order; see #LegOffset_t
00080   const unsigned ArmOffset  = LegOffset+NumLegJoints;   //!< the offset of the beginning of the arm joints, add #TPROffset_t to get specific joint
00081   const unsigned HeadOffset  = ArmOffset+NumArmJoints;   //!< the offset of the beginning of the head joints, add #TPROffset_t to get specific joint
00082 
00083   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00084 
00085   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00086   const unsigned FootFrameOffset    = BaseFrameOffset+1; //!< Use with kinematics to refer to feet reference frames (add appropriate LegOrder_t to specify which paw)
00087   const unsigned GripperFrameOffset = FootFrameOffset+NumLegs; //!< Use with kinematics to refer to gripper reference frame
00088   const unsigned CameraFrameOffset = GripperFrameOffset+NumArms; //!< Use with kinematics to refer to camera reference frame
00089   
00090   const unsigned LeftIRFrameOffset = CameraFrameOffset+1; //!< Use with kinematics to refer to left IR distance rangefinder reference frame
00091   const unsigned CenterIRFrameOffset = LeftIRFrameOffset+1; //!< Use with kinematics to refer to center IR distance rangefinder reference frame
00092   const unsigned IRFrameOffset = CenterIRFrameOffset; //!< alias for CenterIRFrameOffset
00093   const unsigned RightIRFrameOffset = CenterIRFrameOffset+1; //!< Use with kinematics to refer to right IR distance rangefinder reference frame
00094 
00095   //! the ordering of legs
00096   enum LegOrder_t {
00097     RFrLegOrder = 0, //!< right front leg
00098     LFrLegOrder,       //!< left front leg
00099     RMdLegOrder,     //!< right middle leg
00100     LMdLegOrder,     //!< left middle leg
00101     RBkLegOrder,      //!< right back leg
00102     LBkLegOrder     //!< left back leg
00103   };
00104   
00105   //! The offsets within appendages (the legs)  Note that the ordering matches the actual physical ordering of joints on the appendage
00106   enum SEKOffset_t {
00107     SweepOffset=0, //!< moves leg forward or backward along body
00108     ElevatorOffset,  //!< moves leg toward or away from body
00109     KneeOffset       //!< moves knee
00110   };
00111   
00112   //! The offsets of appendages with tilt (elevation), pan (heading), and roll or nod joints (i.e. head/wrist)
00113   enum TPROffset_t {
00114     PanOffset=0, //!< pan/yaw/heading (horizontal)
00115     TiltOffset,      //!< tilt/pitch/elevation (vertical)
00116     NodOffset = TiltOffset, //!< replicated tilt (could be left undefined instead...)
00117     RollOffset //!< spin/twist final axis (can be applied to WristOffset, but Chiara neck only has pan/tilt)
00118   };
00119   
00120   //! The offsets of the individual legs, add #REKOffset_t value to access specific joint
00121   /*! @hideinitializer */
00122   enum LegOffset_t {
00123     RFrLegOffset = LegOffset+RFrLegOrder*JointsPerLeg, //!< beginning of right front leg's joints
00124     LFrLegOffset = LegOffset+LFrLegOrder*JointsPerLeg, //!< beginning of left front leg's joints
00125     RMdLegOffset = LegOffset+RMdLegOrder*JointsPerLeg, //!< beginning of right front leg's joints
00126     LMdLegOffset = LegOffset+LMdLegOrder*JointsPerLeg, //!< beginning of left front leg's joints
00127     RBkLegOffset = LegOffset+RBkLegOrder*JointsPerLeg,  //!< beginning of right back leg's joints
00128     LBkLegOffset = LegOffset+LBkLegOrder*JointsPerLeg, //!< beginning of left back leg's joints
00129   };
00130   
00131   //! These are 'absolute' offsets for the arm joints, don't need to add to ArmOffset like TPROffset_t values do
00132   enum ArmOffset_t {
00133     ArmShoulderOffset=ArmOffset,
00134     ArmElbowOffset,
00135     WristOffset,
00136     WristYawOffset = WristOffset,
00137     WristPitchOffset,
00138     WristRollOffset,
00139     GripperOffset
00140   };
00141   
00142   //! These are 'absolute' offsets for the neck joints, don't need to add to HeadOffset like TPROffset_t values do
00143   enum HeadOffset_t {
00144     HeadPanOffset = HeadOffset,      //!< pan/heading (horizontal)
00145     HeadTiltOffset, //!< tilt/elevation (vertical)
00146   };
00147   
00148   //! The offsets of the individual LEDs, one LED on each dynamixel servo, these match the servo order, so this is empty
00149   /*! @hideinitializer */
00150   enum LEDOffset_t {
00151     BlueLEDOffset = LEDOffset, //!< The blue LED on the back of the robot (closest to rear button panel)
00152     GreenLEDOffset, //!< The green LED on the back of the robot (second closest to rear button panel)
00153     YellowLEDOffset, //!< The yellow LED on the back of the robot (second closest to neck)
00154     RedLEDOffset, //!< The red LED on the back of the robot (closest to neck)
00155     RFrKneeLEDOffset, //!< Small LED on the knee servo
00156     LFrKneeLEDOffset, //!< Small LED on the knee servo
00157     RMdKneeLEDOffset, //!< Small LED on the knee servo
00158     LMdKneeLEDOffset, //!< Small LED on the knee servo
00159     RBkKneeLEDOffset, //!< Small LED on the knee servo
00160     LBkKneeLEDOffset, //!< Small LED on the knee servo
00161     HeadLEDOffset  //!< Small LED on the camera's pan servo
00162   };
00163   
00164   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00165   
00166   const LEDBitMask_t BlueLEDMask = 1<<(BlueLEDOffset-LEDOffset); //!< mask corresponding to BlueLEDOffset
00167   const LEDBitMask_t GreenLEDMask = 1<<(GreenLEDOffset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00168   const LEDBitMask_t YellowLEDMask = 1<<(YellowLEDOffset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00169   const LEDBitMask_t RedLEDMask = 1<<(RedLEDOffset-LEDOffset); //!< mask corresponding to RedLEDOffset
00170   const LEDBitMask_t RFrKneeLEDMask = 1<<(RFrKneeLEDOffset-LEDOffset); //!< mask corresponding to RFrKneeLEDOffset
00171   const LEDBitMask_t LFrKneeLEDMask = 1<<(LFrKneeLEDOffset-LEDOffset); //!< mask corresponding to LFrKneeLEDOffset
00172   const LEDBitMask_t RMdKneeLEDMask = 1<<(RMdKneeLEDOffset-LEDOffset); //!< mask corresponding to RMdKneeLEDOffset
00173   const LEDBitMask_t LMdKneeLEDMask = 1<<(LMdKneeLEDOffset-LEDOffset); //!< mask corresponding to LMdKneeLEDOffset
00174   const LEDBitMask_t RBkKneeLEDMask = 1<<(RBkKneeLEDOffset-LEDOffset); //!< mask corresponding to RBkKneeLEDOffset
00175   const LEDBitMask_t LBkKneeLEDMask = 1<<(LBkKneeLEDOffset-LEDOffset); //!< mask corresponding to LBkKneeLEDOffset
00176   const LEDBitMask_t HeadLEDMask = 1<<(HeadLEDOffset-LEDOffset); //!< mask corresponding to HeadLEDOffset
00177   
00178   //! LEDs for the "face panel" -- on the Chiara this is just HeadLEDMask
00179   const LEDBitMask_t FaceLEDMask = HeadLEDMask;
00180   //! selects all of the leds
00181   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00182   //@}
00183 
00184 
00185   //! Offset needed so that the centroid of the robot is correct relative to the bounding box
00186   const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(0,0,0); 
00187 
00188   //! Half of the length, width, and height of the robot
00189   const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(304.8/2, 304.8/2, 0);
00190 
00191   // *******************************
00192   //          INPUT OFFSETS
00193   // *******************************
00194 
00195 
00196   //! The order in which inputs should be stored
00197   //!@name Input Offsets
00198 
00199   //! holds offsets to different buttons in WorldState::buttons[]
00200   /*! Should be a straight mapping to the ButtonSourceIDs
00201    *
00202    *  Note that the chest (power) button is not a normal button.  It kills
00203    *  power to the motors at a hardware level, and isn't sensed in the
00204    *  normal way.  If you want to know when it is pressed (and you are
00205    *  about to shut down) see PowerSrcID::PauseSID.
00206    *
00207    *  @see WorldState::buttons @see ButtonSourceID_t
00208    * @hideinitializer */
00209   enum ButtonOffset_t { GreenButOffset, RedButOffset, YellowButOffset };
00210 
00211   //! Provides a string name for each button
00212   const char* const buttonNames[NumButtons+1] = { "GreenBut", "RedBut", "YellowBut", NULL };
00213 
00214   //! holds offset to different sensor values in WorldState::sensors[]
00215   /*! @see WorldState::sensors[] */
00216   enum SensorOffset_t {
00217     LeftIRDistOffset,
00218     CenterIRDistOffset,
00219     IRDistOffset = CenterIRDistOffset,
00220     RightIRDistOffset,
00221     LeftLuminosityOffset,
00222     CenterLuminosityOffset,
00223     RightLuminosityOffset,
00224     MicVolumeOffset,
00225     MicSpikeCountOffset,
00226     PowerRemainOffset, //! estimate of power capacity as percentage, 0-1
00227     PowerThermoOffset, //!< degrees Celcius
00228     PowerVoltageOffset, //!< volts
00229   };
00230 
00231   //! Provides a string name for each sensor
00232   const char* const sensorNames[NumSensors+1] = {
00233     "LeftIRDist", "CenterIRDist", "RightIRDist",
00234     "LeftLuminosity", "CenterLuminosity", "RightLuminosity",
00235     "MicVolume", "MicSpikeCount",
00236     "PowerRemain", "PowerThermo", "PowerVoltage", NULL
00237   };
00238 
00239   //@}
00240   
00241   
00242   //! Names for each of the outputs
00243   const char* const outputNames[NumReferenceFrames+1] = {
00244     // servos:
00245     "RFr:rotor",
00246     "RFr:sweep","RFr:elvtr","RFr:knee",
00247     "LFr:sweep","LFr:elvtr","LFr:knee",
00248     "RMd:sweep","RMd:elvtr","RMd:knee",
00249     "LMd:sweep","LMd:elvtr","LMd:knee",
00250     "RBk:sweep","RBk:elvtr","RBk:knee",
00251     "LBk:sweep","LBk:elvtr","LBk:knee",
00252     "ARM:shldr","ARM:elbow","ARM:wristYaw","ARM:wristPitch","ARM:wristRoll","ARM:gripper",
00253     "NECK:pan","NECK:tilt",
00254     
00255     // note we don't expose ALL of the dynamixel LEDs... can't see most of them anyway,
00256     // so don't bother wasting storage/computation... these are the more visible ones:
00257     "LED:blue", "LED:green", "LED:yellow", "LED:red",
00258     "LED:RFr:knee","LED:LFr:knee",
00259     "LED:RMd:knee","LED:LMd:knee",
00260     "LED:RBk:knee","LED:LBk:knee",
00261     "LED:NECK:pan",
00262     
00263     // reference frames:
00264     "BaseFrame",
00265     "RFrFootFrame",
00266     "LFrFootFrame",
00267     "RMdFootFrame",
00268     "LMdFootFrame",
00269     "RBkFootFrame",
00270     "LBkFootFrame",
00271     "GripperFrame",
00272     "CameraFrame",
00273     "LeftIRFrame",
00274     "CenterIRFrame",
00275     "RightIRFrame",
00276     NULL
00277   };
00278   
00279   //! provides polymorphic robot capability detection/mapping
00280   class ChiaraCapabilities : public Capabilities {
00281   public:
00282     //! constructor
00283     ChiaraCapabilities()
00284     : Capabilities(TargetName,NumReferenceFrames,outputNames,NumButtons,buttonNames,NumSensors,sensorNames,PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs,NumOutputs)
00285     {
00286       frameToIndex["ARM:Wrist"] = WristYawOffset;
00287       frameToIndex["NECK:nod"] = HeadTiltOffset;
00288       frameToIndex["IRFrame"] = IRFrameOffset; // aliased to the center IR sensor
00289       sensorToIndex["IRDist"]=IRDistOffset; // aliased to the center IR sensor
00290     }
00291   };
00292   //! allocation declared in RobotInfo.cc
00293   extern const ChiaraCapabilities capabilities;
00294 
00295   //! Dynamixel servos don't use PID control.  Instead, these values indicate compliance slope (P), punch (add to P*error), compliance margin (min error to start applying torque) (see ServoParam_t)
00296   /*! I believe the torque calculation goes something like: torque = (error<compliance) ? 0 : punch + P*error
00297    *  Dynamixel servos allow different values to be supplied for CW vs. CCW motion, but we just use the same value for each */
00298   const float DefaultPIDs[NumPIDJoints][3] = {
00299     {32,32,0},
00300     {32,32,0}, {32,32,0}, {32,32,0}, 
00301     {32,32,0}, {32,32,0}, {32,32,0}, 
00302     {32,32,0}, {32,32,0}, {32,32,0}, 
00303     {32,32,0}, {32,32,0}, {32,32,0}, 
00304     {32,32,0}, {32,32,0}, {32,32,0}, 
00305     {32,32,0}, {32,32,0}, {32,32,0}, 
00306     {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, 
00307     {32,32,0}, {32,32,0},
00308   };
00309   
00310   //!These values are our recommended maximum joint velocities, in rad/sec
00311   /*! a value <= 0 means infinite speed (e.g. LEDs)
00312    *  
00313    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00314    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00315    *  
00316    *  These values were obtained from the administrators of the Sony OPEN-R BBS */
00317   const float MaxOutputSpeed[NumOutputs] = {
00318     // servos
00319     0.4f,
00320     0.4f,0.4f,0.4f,
00321     0.4f,0.4f,0.4f,
00322     0.4f,0.4f,0.4f,
00323     0.4f,0.4f,0.4f,
00324     0.4f,0.4f,0.4f,
00325     0.4f,0.4f,0.4f,
00326     0.4f,0.4f,0.4f,0.4f,0.4f,0.4f,
00327     0.4f,0.4f,
00328     // leds
00329     0,0,
00330     0,0,
00331     0,0,
00332     0,
00333     0,0,0,0,
00334   };
00335 
00336   #ifndef RAD
00337     //!Just a little macro for converting degrees to radians
00338   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00339     //!a flag so we undef these after we're done - do you have a cleaner solution?
00340   #define __RI_RAD_FLAG
00341   #endif
00342   
00343   //! This table holds the software limits of each of the outputs, first index is the output offset, second index is MinMaxRange_t (i.e. MinRange or MaxRange)
00344   const float outputRanges[NumOutputs][2] = {
00345     // servos
00346     {RAD(-17),RAD(90)},
00347     {RAD(-102),RAD(67)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // right front
00348     {RAD(-53),RAD(58)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // left front
00349     {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // right mid
00350     {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // left mid
00351     {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // right back
00352     {RAD(-73),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // left back   
00353     {RAD(-95),RAD(95)}, {RAD(-95),RAD(95)}, {RAD(-100),RAD(100)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)},
00354     {RAD(-150),RAD(150)}, {RAD(-92),RAD(75)}, 
00355     
00356     // LED
00357     {0,1}, {0,1},
00358     {0,1}, {0,1},
00359     {0,1}, {0,1},
00360     {0,1}, 
00361     {0,1}, {0,1}, {0,1}, {0,1},
00362   };
00363 
00364   //! This table holds the mechanical limits of each of the outputs, first index is the output offset, second index is MinMaxRange_t (i.e. MinRange or MaxRange)
00365   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00366   const float mechanicalLimits[NumOutputs][2] = {
00367     // servos
00368     {RAD(-17),RAD(90)},
00369     {RAD(-102),RAD(67)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // right front
00370     {RAD(-53),RAD(58)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // left front
00371     {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // right mid
00372     {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // left mid
00373     {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // right back
00374     {RAD(-73),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)}, // left back   
00375     {RAD(-95),RAD(95)}, {RAD(-95),RAD(95)}, {RAD(-100),RAD(100)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)},
00376     {RAD(-150),RAD(150)}, {RAD(-92),RAD(75)},     
00377 
00378     // LED
00379     {0,1}, {0,1},
00380     {0,1}, {0,1},
00381     {0,1}, {0,1},
00382     {0,1}, 
00383     {0,1}, {0,1}, {0,1}, {0,1},
00384   };
00385 
00386 #ifdef __RI_RAD_FLAG
00387 #undef RAD
00388 #undef __RI_RAD_FLAG
00389 #endif
00390 }
00391 
00392 /*! @file
00393  * @brief Defines some capabilities of the Chiara hexapod robots
00394  * @author ejt (Creator)
00395  */
00396 
00397 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3