Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ShapeSpacePlannerXY.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _SHAPE_SPACE_PLANNER_XY_H_
00003 #define _SHAPE_SPACE_PLANNER_XY_H_
00004 
00005 #include "Planners/RRT/ShapeSpacePlannerBase.h"
00006 
00007 class ShapeSpacePlannerXY;
00008 
00009 //================ RRTNodeXY ================
00010 
00011 class RRTNodeXY : public RRTNodeBase {
00012 public:
00013   typedef std::pair<float,float> NodeValue_t;
00014   typedef GenericRRTBase::PlannerResult<2> PlannerResult;
00015   NodeValue_t q;
00016   
00017   //! Constructor
00018   RRTNodeXY(const NodeValue_t &_q, unsigned int _parent) : RRTNodeBase(_parent), q(_q) {};
00019   
00020   //! Destructor
00021   virtual ~RRTNodeXY() {}
00022   
00023   //! Collision checker to be called by RRT search algorithm
00024   class CollisionChecker : public ShapeSpaceCollisionCheckerBase<2> {
00025   public:
00026     CollisionChecker(ShapeSpace &shs,
00027                      const Shape<PolygonData> &_worldBounds,
00028                      float _inflation, float _robotRadius) :
00029     ShapeSpaceCollisionCheckerBase<2>(shs, _worldBounds, _inflation), robotRadius(_robotRadius) {}
00030     
00031     float robotRadius;
00032     
00033     virtual bool collides(const NodeValue_t &qnew, PlannerResult* result=NULL) const;
00034     
00035   };
00036   
00037   static const unsigned int maxInterpolations = 10; //!< Maximum number of interpolation steps in interpolate() when @a truncate is true
00038   
00039   virtual float distance(const NodeValue_t &target);
00040   static void generateSample(const NodeValue_t &lower, const NodeValue_t &upper, NodeValue_t &sample);
00041   static Interp_t interpolate(const NodeValue_t &start, const NodeValue_t &target, const NodeValue_t &interp, 
00042                               bool truncate, CollisionChecker *cc, NodeValue_t &reached, bool searchingBackwards);
00043   
00044   virtual std::string toString() const;
00045   
00046 };
00047 
00048 //================ ShapeSpacePlannerXY ================
00049 
00050 //! Plans a path in a 2D linear space, assuming the robot has circular shape
00051 class ShapeSpacePlannerXY : public GenericRRT<RRTNodeXY, 2> {
00052 public:
00053   typedef RRTNodeXY NodeType_t;
00054   typedef NodeType_t::NodeValue_t NodeValue_t;
00055   typedef GenericRRTBase::PlannerResult<2> PlannerResult;
00056   
00057   ShapeSpacePlannerXY(DualCoding::ShapeSpace &shs,
00058                       const DualCoding::Shape<DualCoding::PolygonData> &worldBounds=Shape<PolygonData>(),
00059                       float inflation=0, float _robotRadius=6*25.4f);
00060   
00061   virtual ~ShapeSpacePlannerXY() {}
00062   
00063   using GenericRRT<NodeType_t, 2>::planPath;
00064   PlannerResult
00065   planPath(const Point &start,
00066            const Point &end,
00067            unsigned int _maxIterations=4000,
00068            std::vector<NodeValue_t> *pathResult=NULL,
00069            std::vector<NodeType_t> *treeStartResult=NULL,
00070            std::vector<NodeType_t> *treeEndResult=NULL);
00071   
00072   float robotRadius; //!< radius in mm of the CircularObstacle describing the robot
00073   
00074   static void plotPath(const std::vector<NodeValue_t> &path,
00075            Shape<GraphicsData> &graphics,
00076            rgb color = rgb(0,0,255));
00077 
00078   static void plotTree(const std::vector<NodeType_t> &tree,
00079            Shape<GraphicsData> &graphics,
00080            rgb color = rgb(0,0,255));
00081 
00082 };
00083 
00084 #endif

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