Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

HandEyeZInfo.h

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

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