Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

GrasperRequest.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_GrasperRequest_h_
00003 #define INCLUDED_GrasperRequest_h_
00004 
00005 #include "Behaviors/StateNode.h"
00006 #include "DualCoding/ShapeRoot.h"
00007 #include "Planners/Manipulation/ShapeSpacePlanner2DR.h"
00008 #include "Planners/Manipulation/ShapeSpacePlanner3DR.h"
00009 
00010 using namespace std;
00011 using namespace DualCoding;
00012 
00013 //! Request to the @a Grasper to manipulate something
00014 
00015 class GrasperRequest {
00016 public:
00017 #ifdef TGT_CALLIOPE
00018   typedef ShapeSpacePlanner3DR<NumArmJoints> Planner;
00019   typedef Planner::NodeType_t NodeType_t;
00020   typedef PlannerObstacle3D PlannerObstacle;
00021 #else
00022   typedef ShapeSpacePlanner2DR<NumArmJoints> Planner;
00023   typedef Planner::NodeType_t NodeType_t;
00024   typedef PlannerObstacle2D PlannerObstacle;
00025 #endif
00026   typedef NodeType_t::NodeValue_t NodeValue_t;
00027   
00028 private:
00029   friend class Grasper;
00030   
00031   typedef unsigned int GrasperVerbosity_t;
00032   
00033   //! The planner obstacle used when we treat the manipulating object as an obstacle to the planner
00034   PlannerObstacle* objectPlannerObstacle;
00035   
00036 public:
00037   
00038   //! What we're asking the @a Grasper to do
00039   enum GrasperRequestType_t {
00040     checkGraspable, //!< Check whether @a object is graspable; don't actually move
00041     checkMovable, //!< Check whether @a object can be moved to @a targetLocation; don't actually move
00042     checkRestable,  //!< Check whether @a the arm can be moved to the resting position; don't actually move
00043     computeReach, //!< Compute and return a path for the arm to reach to a point
00044     reach,    //!< Move the arm to @a targetLocation, then rest
00045     grasp,    //!< Approach and grasp @o object, then rest the arm
00046     touch,    //!< Grasp the @a object but don't rest the arm afterwards
00047     release,    //!< Release and disengage from whatever the arm is holding
00048     moveTo,   //!< Move @a object to @a targetLocation
00049     rest,   //!< Move the arm (and possibly the body) to a resting position
00050     //todo
00051     sweep,    //!< Sweep arm along an arc (to clear a region of the workspace)
00052     computeMove,  //!< Compute and return a path for moving @a object to @a targetLocation
00053     computeRest   //!< Compute and return a path for moving the arm to the resting position
00054   };
00055   
00056   //! What error is the Grasper going to return
00057   enum GrasperErrorType_t {
00058     noError = 0,
00059     someError,    //!< Generic error will match anything but noError in a GrasperTrans
00060     invalidRequest, 
00061     noGraspState,
00062     noGraspPath,
00063     noTargetState,
00064     noTargetPath,
00065     noRestPath,
00066     badGrasp,
00067     badMove,
00068     pickUpUnreachable,
00069     dropOffUnreachable
00070   };
00071   
00072   //! What path we want to return in the @a GrasperEvent
00073   enum GrasperPathType_t {
00074     noPath,   //!< Don't return any path
00075     moveFree,   //!< Return the unconstrained path to acquire @a object
00076     moveConstrained,  //!< Return the constrained path to move @a object to @a targetLocation
00077     disengage   //!< Return the path to disengage from the object and move the arm to the rest position
00078   };
00079   
00080   //! The kind of rest state to reach. stationary means none, settleArm moves the arm to the arm configuration in @a armRestState, settleBodyAndArm does settleArm and resets the ground plane
00081   enum GrasperRestType_t {
00082     stationary,
00083     settleArm,
00084     settleBodyAndArm
00085   };
00086   
00087   ~GrasperRequest();
00088   
00089   //! Constructor
00090   GrasperRequest(GrasperRequestType_t _type);
00091   
00092   //! Copy constructor
00093   GrasperRequest(const GrasperRequest &req);
00094   
00095   //! Validate the GrasperRequest and return an error code if there is a problem
00096   GrasperErrorType_t validateRequest();
00097   
00098   //! The type of this Grasper request
00099   GrasperRequestType_t requestType;
00100   
00101   //! The rest type for this request
00102   GrasperRestType_t restType;
00103   
00104   //! The rest arm configuration 
00105   NodeValue_t armRestState;
00106   
00107   GrasperVerbosity_t setVerbosity;   //!< Verbosity elements to force on
00108   GrasperVerbosity_t clearVerbosity;   //!< Verbosity elements to force off
00109   
00110   //RRT PARAMETERS
00111   //! Offset of the end effector in the Kinematic chain to use (typically GripperFrameOffset)
00112   unsigned int effectorOffset;
00113   //! The maximum number of iterations the RRT should undergo
00114   unsigned int rrtMaxIterations;
00115   //! The amount to inflate obstacles for safe planning (mm)
00116   float rrtInflation;
00117   //! The amount to move each joint while extending
00118   NodeValue_t rrtInterpolationStep;
00119   
00120   //! Factor to change how fast arm movements will be executed
00121   float armTimeFactor;
00122   
00123   //! Whether to open the gripper upon resting
00124   bool openGripperOnRest;
00125   
00126   //! The object to manipulate
00127   ShapeRoot object;
00128   
00129   //! Where to place the object
00130   ShapeRoot targetLocation;
00131   
00132   //! Vector of ranges of egocentric angles in which the gripper is allowed to end up
00133   std::vector<std::pair<float, float> > gripperAngleRangesX;
00134   
00135   //! Vector of ranges of egocentric angles in which the gripper is allowed to end up
00136   std::vector<std::pair<float, float> > gripperAngleRangesY;
00137   
00138   //! Vector of ranges of egocentric angles in which the gripper is allowed to end up
00139   std::vector<std::pair<float, float> > gripperAngleRangesZ;
00140   
00141   //! Maximum number of angles to allow the gripper to have in angle ranges
00142   int maxNumberOfAngles;
00143   
00144   //! Resolution of angles to use within gripperAngleRanges
00145   float angleResolution;
00146   
00147   //! vector of objects to be swept
00148   std::vector<ShapeRoot> sweepObjects;
00149   
00150   //! List of obstacles in the environment
00151   std::vector<ShapeRoot> envObstacles;
00152   
00153   //! The list of obstacles for the planner to use
00154   std::vector<PlannerObstacle*> plannerObstacles;
00155   
00156   //! The predicate-constrained path
00157   std::vector<NodeValue_t> moveConstrainedPath;
00158   //! The "acquire" path which is not predicate-constrained
00159   std::vector<NodeValue_t> moveFreePath;
00160   //! The "disengage" path which is not predicate-constrained
00161   std::vector<NodeValue_t> disengagePath;
00162   
00163   //! The desired predicate to use during planning for @a moveConstrainedPath
00164   AdmissibilityPredicate<NodeType_t> *predicate;
00165   
00166   //! If true, the planned path is displayed in the shape space
00167   bool displayPath;
00168   
00169   //! If true, the RRT search tree is displayed in the shape space
00170   bool displayTree;
00171   
00172   //! The Behavior making this request; used for posting grasper events
00173   BehaviorBase* requestingBehavior;
00174   
00175   //! Verbosity value computed by Grasper::executeRequest
00176   GrasperVerbosity_t verbosity;
00177   
00178   GrasperPathType_t populateEventPathWith;
00179   
00180 protected:
00181   unsigned int requestID;
00182   GrasperRequest& operator=(const GrasperRequest&); //!< don't call this
00183 };
00184 
00185 typedef GrasperRequest::GrasperErrorType_t GraspError;
00186 
00187 #endif

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