Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

HandEyeInfo.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_HandEyeInfo_h
00003 #define INCLUDED_HandEyeInfo_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_HANDEYE)
00012 #  define TGT_IS_BIOLOID
00013 #  define TGT_IS_HANDEYE
00014 #  define TGT_HAS_CAMERA 1
00015 //UPGRADE: set TGT_HAS_LEDS to 7
00016 #  define TGT_HAS_LEDS 5
00017 #  define TGT_HAS_ARMS 1
00018 #  define TGT_HAS_HEAD 1
00019 #  define WALKMC_NO_WARN_NOOP
00020 #endif
00021 
00022 //! Declares configuration of the HandEye planar arm robot, such as number of joints, LEDs, etc.
00023 namespace HandEyeInfo {
00024 
00025   // *******************************
00026   //       ROBOT CONFIGURATION
00027   // *******************************
00028 
00029   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00030 
00031   const unsigned int FrameTime=32;        //!< time between frames in the motion system (milliseconds)
00032   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00033   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00034   
00035   //!@name Output Types Information
00036   const unsigned NumWheels      =  0;
00037   
00038   const unsigned JointsPerArm   =  3; // UPGRADE: 5;
00039   const unsigned NumArms        =  1;
00040   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00041   
00042   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00043   const unsigned NumLegs        =  0; //!< The number of legs
00044   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00045   const unsigned NumHeadJoints  =  2; //!< The number of joints in the pantilt
00046   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00047   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00048   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00049   const unsigned NumButtons     =  3; //!< the number of buttons that are available
00050   const unsigned NumSensors     =  2;  //!< the number of sensors available
00051   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00052 
00053   // UPGRADE: NumLEDs to 7
00054   const unsigned NumLEDs        =  5; //!< The number of LEDs which can be controlled (one per dynamixel servo)
00055   const unsigned NumPIDJoints   = NumWheels + NumArmJoints + NumLegJoints + NumHeadJoints + NumTailJoints + NumMouthJoints;; //!< servo pins
00056   
00057   const unsigned NumOutputs     = NumWheels + NumPIDJoints + NumLEDs; //!< the total number of outputs
00058   const unsigned NumReferenceFrames = NumOutputs + 1 + NumArms + 1; //!< for the base, gripper (* NumArms), and camera reference frames
00059 
00060   using namespace Camera75DOF;
00061   //@}
00062 
00063 
00064   // *******************************
00065   //         OUTPUT OFFSETS
00066   // *******************************
00067 
00068   //!Corresponds to entries in ERS7Info::PrimitiveName, defined at the end of this file
00069   //!@name Output Offsets
00070 
00071   
00072   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00073   
00074   const unsigned ArmOffset   = PIDJointOffset;  //!< beginning of arm joints, don't add anything, just use ArmOffset_t entries directly
00075   
00076   const unsigned HeadOffset  = ArmOffset+NumArmJoints;   //!< the offset of the beginning of the head joints, add TPROffset_t to get specific joint
00077 
00078   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00079 
00080   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00081   const unsigned GripperFrameOffset    = BaseFrameOffset+1; //!< Use with kinematics to refer to paw reference frames (add appropriate LegOrder_t to specify which paw)
00082   const unsigned CameraFrameOffset = GripperFrameOffset+NumArms; //!< Use with kinematics to refer to camera reference frame
00083 
00084   //! These are 'absolute' offsets for the arm joints
00085   enum ArmOffset_t {
00086     ArmShoulderOffset = ArmOffset,
00087     ArmElbowOffset,
00088     WristOffset,
00089     WristYawOffset = WristOffset,
00090     //WristPitchOffset,
00091     //WristRollOffset,
00092     //GripperOffset
00093   };
00094   
00095   //! The offsets of appendages with pan (heading), tilt (elevation), note that this should be added to HeadOffset, otherwise use HeadOffset_t (#HeadPanOffset and #HeadTiltOffset)
00096   enum TPROffset_t {
00097     PanOffset = 0,      //!< pan/heading (horizontal)
00098     TiltOffset, //!< tilt/elevation (vertical)
00099   };
00100   
00101   //! These are 'absolute' offsets for the neck joints, don't need to add to HeadOffset like TPROffset_t values do
00102   enum HeadOffset_t {
00103     HeadPanOffset = HeadOffset,      //!< pan/heading (horizontal)
00104     HeadTiltOffset, //!< tilt/elevation (vertical)
00105   };
00106   
00107   //! The offsets of the individual LEDs
00108   /*! @hideinitializer */
00109   enum LEDOffset_t {
00110     ArmShoulderLEDOffset = LEDOffset, //!< Small led on the shoulder servo
00111     ArmElbowLEDOffset, //!< Small LED on the elbow servo
00112     ArmWristLEDOffset, //!< Small LED on the wrist servo
00113     NeckPanLEDOffset, //!< Small LED on the neck pan servo
00114     NeckTiltLEDOffset //!< Small LED on the neck tilt servo
00115 };
00116   
00117   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00118 
00119   const LEDBitMask_t ArmShoulderLEDMask = 1 << (ArmShoulderLEDOffset-LEDOffset); //!< Mask corresponding to ArmShoulderLEDOffset
00120   const LEDBitMask_t ArmElbowLEDMask    = 1 << (ArmElbowLEDOffset-LEDOffset); //!< Mask corresponding to ArmElbowLEDOffset
00121   const LEDBitMask_t ArmWristLEDMask    = 1 << (ArmWristLEDOffset-LEDOffset); //!< Mask corresponding to ArmWristLEDOffset
00122   const LEDBitMask_t NeckPanLEDMask     = 1 << (NeckPanLEDOffset-LEDOffset); //!< Mask corresponding to NeckPanLEDOffset
00123   const LEDBitMask_t NeckTiltLEDMask    = 1 << (NeckTiltLEDOffset-LEDOffset); //!< Mask corresponding to NeckTiltLEDOffset
00124 
00125   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00126   const LEDBitMask_t FaceLEDMask = NeckPanLEDMask | NeckTiltLEDMask;
00127   //! selects all of the leds
00128   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00129   //@}
00130 
00131 
00132   //! Offset needed so that the centroid of the robot is correct relative to the bounding box
00133   const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(0,0,0); 
00134 
00135   //! Half of the length, width, and height of the robot
00136   const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(304.8/2, 304.8/2, 0);
00137 
00138   // *******************************
00139   //          INPUT OFFSETS
00140   // *******************************
00141 
00142 
00143   //! The order in which inputs should be stored
00144   //!@name Input Offsets
00145 
00146   //! holds offsets to different buttons in WorldState::buttons[]
00147   /*! Should be a straight mapping to the ButtonSourceIDs
00148    *
00149    *  @see WorldState::buttons @see ButtonSourceID_t
00150    * @hideinitializer */
00151   enum ButtonOffset_t { GreenButOffset, RedButOffset, YellowButOffset };
00152 
00153   //! Provides a string name for each button
00154   const char* const buttonNames[NumButtons+1] = { "GreenBut", "RedBut", "YellowBut", NULL };
00155 
00156   //! holds offset to different sensor values in WorldState::sensors[]
00157   /*! @see WorldState::sensors[] */
00158   enum SensorOffset_t {
00159     PowerThermoOffset, //!< degrees Celcius
00160     PowerVoltageOffset, //!< volts
00161   };
00162   
00163   //! Provides a string name for each sensor
00164   const char* const sensorNames[NumSensors+1] = {
00165     "PowerThermo","PowerVoltage", NULL
00166   };
00167   
00168   //@}
00169 
00170 
00171   //! Names for each of the outputs
00172   const char* const outputNames[NumReferenceFrames+1] = {
00173     "ARM:shldr","ARM:elbow","ARM:wrist",// UPGRADE: "ARM:wristPitch","ARM:gripper",
00174     "NECK:pan", "NECK:tilt",
00175 
00176     "LED:ARM:shldr",
00177     "LED:ARM:elbow",
00178     "LED:ARM:wrist",
00179     "LED:NECK:pan",
00180     "LED:NECK:tilt",
00181     //"LED:00005", // UPGRADE
00182     //"LED:00006", // UPGRADE
00183     
00184     "BaseFrame",
00185     "GripperFrame",
00186     "CameraFrame",
00187     NULL
00188   };
00189   
00190   //! provides polymorphic robot capability detection/mapping
00191   class HandEyeCapabilities : public Capabilities {
00192   public:
00193     //! constructor
00194     HandEyeCapabilities()
00195     : Capabilities(TargetName,NumReferenceFrames,outputNames,NumButtons,buttonNames,NumSensors,sensorNames,PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs,NumOutputs)
00196     {
00197       frameToIndex["ARM:WristYaw"] = WristYawOffset; // UPGRADE: may want to reverse this, so "WristYaw" is the official display name, and "Wrist" is the alias
00198       frameToIndex["NECK:nod"] = HeadTiltOffset;
00199     }
00200   };
00201   //! allocation declared in RobotInfo.cc
00202   extern const HandEyeCapabilities capabilities;
00203   
00204   //! 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)
00205   /*! I believe the torque calculation goes something like: torque = (error<compliance) ? 0 : punch + P*error
00206    *  Dynamixel servos allow different values to be supplied for CW vs. CCW motion, but we just use the same value for each */
00207   const float DefaultPIDs[NumPIDJoints][3] = {
00208     {32,32,0}, {32,32,0}, {32,32,0}, // UPGRADE: {32,32,0}, {32,32,0}, 
00209     {32,32,0}, {32,32,0},
00210   };
00211   
00212   //!These values are our recommended maximum joint velocities, in rad/ms
00213   /*! a value <= 0 means infinite speed (e.g. LEDs)
00214    *  
00215    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00216    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00217    */
00218   const float MaxOutputSpeed[NumOutputs] = {
00219     // servos
00220     0.0008, 0.0008, 0.0008, 0.0008, 0.0008,// UPGRADE: 0,0,
00221     // leds
00222     0,0,0,0,0,// UPGRADE: 0,0,
00223   };
00224 
00225   #ifndef RAD
00226     //!Just a little macro for converting degrees to radians
00227   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00228     //!a flag so we undef these after we're done - do you have a cleaner solution?
00229   #define __RI_RAD_FLAG
00230   #endif
00231   
00232   //! 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)
00233   const float outputRanges[NumOutputs][2] = {
00234     // servos
00235     {RAD(-130),RAD(130)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, //UPGRADE: {0,RAD(300)}, {0,RAD(300)}, 
00236     {RAD(-63),RAD(63)}, {RAD(-95),RAD(68)},
00237 
00238     // LED
00239     {0,1}, {0,1}, {0,1}, // UPGRADE: {0,1}, {0,1}, 
00240     {0,1}, {0,1},
00241   };
00242 
00243   //! 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)
00244   const float mechanicalLimits[NumOutputs][2] = {
00245     // servos
00246     {RAD(-130),RAD(130)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, //UPGRADE: {0,RAD(300)}, {0,RAD(300)}, 
00247     {RAD(-63),RAD(63)}, {RAD(-95),RAD(68)},
00248     
00249     // LED
00250     {0,1}, {0,1}, {0,1}, // UPGRADE: {0,1}, {0,1}, 
00251     {0,1}, {0,1},
00252   };
00253 
00254 #ifdef __RI_RAD_FLAG
00255 #undef RAD
00256 #undef __RI_RAD_FLAG
00257 #endif
00258 }
00259 
00260 /*! @file
00261  * @brief Defines some capabilities of the HandEye planar arm robot
00262  * @author ejt (Creator)
00263  */
00264 
00265 #endif

Tekkotsu v5.1CVS
Generated Fri Mar 16 05:26:41 2012 by Doxygen 1.6.3