Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MantisArmInfo.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_MantisArmInfo_h
00002 #define INCLUDED_MantisArmInfo_h
00003 
00004 #include <cmath>
00005 #include <stdlib.h>
00006 #include "CommonInfo.h"
00007 using namespace RobotInfo;
00008 
00009 // see http://tekkotsu.org/porting.html#configuration for more information on TGT_HAS_* flags
00010 #if defined(TGT_MANTISARM)
00011 #  define TGT_IS_MANTISARM
00012 #  define TGT_HAS_ARMS 1
00013 #  define TGT_HAS_LEDS 6
00014 #endif
00015 
00016 //! Contains information about an Mantis Arm robot, such as number of joints, LEDs, etc.
00017 namespace MantisArmInfo {
00018 
00019   // *******************************
00020   //       ROBOT CONFIGURATION
00021   // *******************************
00022 
00023   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00024 
00025   const unsigned int FrameTime  = 32;    //!< time between frames in the motion system (milliseconds)
00026   const unsigned int NumFrames  = 1;     //!< the number of frames per buffer (don't forget also double buffered)
00027   const unsigned int SoundBufferTime = 32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00028   
00029   //!@name Output Types Information
00030   const unsigned NumWheels      =  0;
00031   
00032   const unsigned JointsPerArm   =  6;
00033   const unsigned NumArms        =  1;
00034   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00035   
00036   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00037   const unsigned NumLegs        =  0; //!< The number of legs
00038   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00039 
00040   const unsigned NumHeadJoints  =  0; //!< The number of joints in the pantilt
00041   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00042   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00043   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00044   const unsigned NumButtons     =  3; //!< the number of buttons that are available
00045   const unsigned NumSensors     =  0; //!< the number of sensors available
00046   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00047 
00048   const unsigned NumPIDJoints   = NumArmJoints + NumLegJoints + NumHeadJoints + NumTailJoints + NumMouthJoints; //!< servo pins
00049   const unsigned NumLEDs        = NumPIDJoints; //!< 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
00050   
00051   const unsigned NumOutputs     = NumWheels + NumPIDJoints + NumLEDs; //!< the total number of outputs
00052   const unsigned NumReferenceFrames = NumOutputs + NumLegs + NumArms + 1; //!< for the base, feet, gripper, camera, and IR distance rangefinder
00053 
00054         const unsigned FingerJointsPerArm = 0;
00055 
00056   using namespace Camera75DOF;
00057   
00058   const float BallOfFootRadius = 0; //!< radius of the ball of the foot
00059 
00060 
00061   // *******************************
00062   //         OUTPUT OFFSETS
00063   // *******************************
00064 
00065   //!Corresponds to entries in ERS7Info::PrimitiveName, defined at the end of this file
00066   //!@name Output Offsets
00067 
00068   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00069   const unsigned ArmOffset    = PIDJointOffset; //!< 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
00070   const unsigned LEDOffset    = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00071   const unsigned BaseFrameOffset  = NumOutputs;   //!< Use with kinematics to refer to base reference frame
00072   const unsigned FootFrameOffset  = BaseFrameOffset+1;  //!< Use with kinematics to refer to feet reference frames (add appropriate LegOrder_t to specify which paw)
00073     const unsigned GripperFrameOffset = FootFrameOffset+NumLegs; //!< Use with kinematics to refer to gripper reference frame
00074   const unsigned CameraFrameOffset = GripperFrameOffset+NumArms; //!< Use with kinematics to refer to camera reference frame
00075     
00076     const unsigned LeftIRFrameOffset = CameraFrameOffset+1; //!< Use with kinematics to refer to left IR distance rangefinder reference frame
00077   const unsigned CenterIRFrameOffset = LeftIRFrameOffset+1; //!< Use with kinematics to refer to center IR distance rangefinder reference frame
00078   const unsigned IRFrameOffset = CenterIRFrameOffset; //!< alias for CenterIRFrameOffset
00079   const unsigned RightIRFrameOffset = CenterIRFrameOffset+1; //!< Use with kinematics to refer to right IR distance rangefinder reference frame
00080 
00081   
00082   //! the ordering of arms
00083   enum ArmOrder_t {
00084     MdArmOrder = 0, //!< middle leg
00085   };
00086   
00087   //! The offsets within appendages (the legs)  Note that the ordering matches the actual physical ordering of joints on the appendage
00088   enum SEKOffset_t {
00089     SweepOffset = 0,
00090     ElevatorOffset,
00091     Twist1Offset,
00092     ElbowOffset,
00093     Twist2Offset,
00094     WristOffset
00095   };
00096   
00097   //! The offsets of appendages with tilt (elevation), pan (heading), and roll or nod joints (i.e. head/wrist)
00098   enum TPROffset_t {
00099     PanOffset = 0,    //!< pan/yaw/heading (horizontal)
00100     TiltOffset,     //!< tilt/pitch/elevation (vertical)
00101     NodOffset = TiltOffset, //!< replicated tilt (could be left undefined instead...)
00102     RollOffset      //!< spin/twist final axis
00103   };
00104   
00105   //! The offsets of the individual legs, add #REKOffset_t value to access specific joint
00106   /*! @hideinitializer */
00107   enum ArmOffset_t {
00108     MdArmOffset = ArmOffset+MdArmOrder*JointsPerArm, //!< beginning of right front leg's joints
00109   };
00110     
00111     //! The offsets of the individual LEDs
00112   /*! @hideinitializer */
00113   enum LEDOffset_t {
00114     ElevatorLEDOffset=LEDOffset,
00115     ShoulderLEDOffset,
00116     Twist1LEDOffset,
00117     ElbowLEDOffset,
00118     Twist2LEDOffset,
00119     WristLEDOffset
00120   };
00121     
00122     
00123   const LEDOffset_t RedLEDOffset = ElevatorLEDOffset;
00124   const LEDOffset_t YellowLEDOffset = ShoulderLEDOffset;
00125   const LEDOffset_t GreenLEDOffset = ElbowLEDOffset;
00126   const LEDOffset_t BlueLEDOffset = WristLEDOffset;
00127     
00128   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00129     
00130   const LEDBitMask_t RedLEDMask = 1<<(ElevatorLEDOffset-LEDOffset); //!< mask corresponding to RedLEDOffset
00131   const LEDBitMask_t YellowLEDMask = 1<<(ShoulderLEDOffset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00132   const LEDBitMask_t GreenLEDMask = 1<<(ElbowLEDOffset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00133   const LEDBitMask_t BlueLEDMask = (1<<(WristLEDOffset-LEDOffset)); //!< mask corresponding to BlueLEDOffset
00134     
00135   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00136   const LEDBitMask_t FaceLEDMask = 0;
00137   //! selects all of the leds
00138   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00139   //@}
00140     
00141     
00142     //! Offset needed so that the centroid of the robot is correct related to the bounding box
00143   const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(400,70,350);
00144     
00145   //! Half of the length, width, and height of the robot.
00146   const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(100,100,100);
00147   //@}
00148     
00149 
00150   // *******************************
00151   //          INPUT OFFSETS
00152   // *******************************
00153 
00154 
00155   //! The order in which inputs should be stored
00156   //!@name Input Offsets
00157 
00158   //! holds offsets to different buttons in WorldState::buttons[]
00159   /*! Should be a straight mapping to the ButtonSourceIDs
00160    *
00161    *  Note that the chest (power) button is not a normal button.  It kills
00162    *  power to the motors at a hardware level, and isn't sensed in the
00163    *  normal way.  If you want to know when it is pressed (and you are
00164    *  about to shut down) see PowerSrcID::PauseSID.
00165    *
00166    *  @see WorldState::buttons @see ButtonSourceID_t
00167    * @hideinitializer */
00168   enum ButtonOffset_t { GreenButOffset, RedButOffset, YellowButOffset };
00169 
00170   //! Provides a string name for each button
00171   const char* const buttonNames[NumButtons+1] = { "GreenBut", "RedBut", "YellowBut", NULL };
00172 
00173   //! holds offset to different sensor values in WorldState::sensors[]
00174   /*! @see WorldState::sensors[] */
00175   enum SensorOffset_t {};
00176 
00177   //! Provides a string name for each sensor
00178   const char* const sensorNames[NumSensors+1] = {
00179     NULL
00180   };
00181 
00182   //@}
00183   
00184   
00185   //! Names for each of the outputs
00186   const char* const outputNames[NumReferenceFrames+1] = {
00187     // servos:
00188     "elevator", "shoulder", "twist1", "elbow", "twist2", "wrist",
00189     
00190         // LEDs
00191     "LED:elevator", "LED:shoulder", "LED:twist1", "LED:elbow", "LED:twist2", "LED:wrist",
00192         
00193         // Reference frames
00194         "BaseFrame", "FingerFrame",
00195       
00196     NULL
00197   };
00198   
00199   //! provides polymorphic robot capability detection/mapping
00200   class MantisArmCapabilities : public Capabilities {
00201   public:
00202     //! constructor
00203     MantisArmCapabilities()
00204     : Capabilities(TargetName,NumReferenceFrames,outputNames,
00205              NumButtons,buttonNames,NumSensors,sensorNames,
00206              PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs,NumOutputs)
00207     {}
00208   };
00209     
00210   //! allocation declared in RobotInfo.cc
00211   extern const MantisArmCapabilities capabilities;
00212   
00213   
00214   //! offsets into DefaultPIDs, since Dynamixel servos don't actually use PID control, but a different set of parameters
00215   enum ServoParam_t {
00216     DYNAMIXEL_SLOPE = 0,  //!< compliance slope, the proportional control (P in PID)
00217     DYNAMIXEL_PUNCH,    //!< punch, a constant added to the slope once error exceeds compliance margin
00218     DYNAMIXEL_MARGIN    //!< compliance margin, the amount of error to tolerate before triggering a torque response
00219   };
00220   
00221   //! Dynamixel MX servos use PID control.
00222   const float DefaultPIDs[NumPIDJoints][3] = {
00223     {10,32,0},
00224     {10,32,0},
00225     {10,32,0},
00226     {10,32,0},
00227     {10,32,0},
00228     {10,32,0}
00229   };
00230   
00231   //!These values are our recommended maximum joint velocities, in rad/ms
00232   /*! a value <= 0 means infinite speed (e.g. LEDs) */
00233   const float MaxOutputSpeed[NumOutputs] = {
00234     // servos
00235     1.f, 1.f, 1.f, 1.f, 1.f, 1.f,
00236     // leds
00237     0,0,0,0,0,0
00238   };
00239 
00240   #ifndef RAD
00241     //!Just a little macro for converting degrees to radians
00242   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00243     //!a flag so we undef these after we're done - do you have a cleaner solution?
00244   #define __RI_RAD_FLAG
00245   #endif
00246   
00247   //! 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)
00248   const float outputRanges[NumOutputs][2] = {
00249     // servos
00250     {RAD(-100),RAD(100)}, 
00251     {RAD(-100),RAD(100)},
00252     {RAD(-100),RAD(100)},
00253     {RAD(-100),RAD(100)},
00254     {RAD(-100),RAD(100)},
00255     {RAD(-100),RAD(100)},   
00256     
00257     // LED
00258     {0,1},{0,1},
00259     {0,1},{0,1},
00260     {0,1},{0,1},
00261   };
00262   
00263   //! 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)
00264   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00265   const float mechanicalLimits[NumOutputs][2] = {
00266     // servos
00267     {RAD(-100),RAD(100)}, 
00268         {RAD(-100),RAD(100)},
00269     {RAD(-100),RAD(100)},
00270         {RAD(-100),RAD(100)},
00271     // LED
00272     {0,1},{0,1},
00273         {0,1},{0,1},
00274   };
00275 
00276 #ifdef __RI_RAD_FLAG
00277 #undef RAD
00278 #undef __RI_RAD_FLAG
00279 #endif
00280 }
00281 
00282 /*! @file
00283  * @brief Defines some capabilities of the Mantis arm Robots
00284  * @author ejt (Creator)
00285  */
00286 
00287 #endif

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