All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
BKPIECE1.h
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2008, Rice University,
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the Rice University nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00035 /* Author: Ioan Sucan */
00036 
00037 #ifndef OMPL_GEOMETRIC_PLANNERS_KPIECE_BKPIECE1_
00038 #define OMPL_GEOMETRIC_PLANNERS_KPIECE_BKPIECE1_
00039 
00040 #include "ompl/geometric/planners/PlannerIncludes.h"
00041 #include "ompl/geometric/planners/kpiece/Discretization.h"
00042 
00043 namespace ompl
00044 {
00045 
00046     namespace geometric
00047     {
00048 
00080         class BKPIECE1 : public base::Planner
00081         {
00082         public:
00083 
00085             BKPIECE1(const base::SpaceInformationPtr &si) : base::Planner(si, "BKPIECE1"),
00086                                                             dStart_(boost::bind(&BKPIECE1::freeMotion, this, _1)),
00087                                                             dGoal_(boost::bind(&BKPIECE1::freeMotion, this, _1))
00088             {
00089                 specs_.recognizedGoal = base::GOAL_SAMPLEABLE_REGION;
00090 
00091                 minValidPathFraction_ = 0.5;
00092                 badScoreFactor_ = 0.5;
00093                 goodScoreFactor_ = 0.9;
00094                 maxDistance_ = 0.0;
00095             }
00096 
00097             virtual ~BKPIECE1(void)
00098             {
00099             }
00100 
00103             void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
00104             {
00105                 projectionEvaluator_ = projectionEvaluator;
00106             }
00107 
00110             void setProjectionEvaluator(const std::string &name)
00111             {
00112                 projectionEvaluator_ = si_->getStateSpace()->getProjection(name);
00113             }
00114 
00116             const base::ProjectionEvaluatorPtr& getProjectionEvaluator(void) const
00117             {
00118                 return projectionEvaluator_;
00119             }
00120 
00126             void setRange(double distance)
00127             {
00128                 maxDistance_ = distance;
00129             }
00130 
00132             double getRange(void) const
00133             {
00134                 return maxDistance_;
00135             }
00136 
00143             void setBorderFraction(double bp)
00144             {
00145                 dStart_.setBorderFraction(bp);
00146                 dGoal_.setBorderFraction(bp);
00147             }
00148 
00151             double getBorderFraction(void) const
00152             {
00153                 return dStart_.getBorderFraction();
00154             }
00155 
00162             void setCellScoreFactor(double good, double bad)
00163             {
00164                 goodScoreFactor_ = good;
00165                 badScoreFactor_ = bad;
00166             }
00167 
00170             double getGoodCellScoreFactor(void) const
00171             {
00172                 return goodScoreFactor_;
00173             }
00174 
00177             double getBadCellScoreFactor(void) const
00178             {
00179                 return badScoreFactor_;
00180             }
00181 
00188             void setMinValidPathFraction(double fraction)
00189             {
00190                 minValidPathFraction_ = fraction;
00191             }
00192 
00194             double getMinValidPathFraction(void) const
00195             {
00196                 return minValidPathFraction_;
00197             }
00198 
00199             virtual void setup(void);
00200 
00201             virtual bool solve(const base::PlannerTerminationCondition &ptc);
00202             virtual void clear(void);
00203 
00204             virtual void getPlannerData(base::PlannerData &data) const;
00205 
00206         protected:
00207 
00209             class Motion
00210             {
00211             public:
00212 
00213                 Motion(void) : root(NULL), state(NULL), parent(NULL)
00214                 {
00215                 }
00216 
00218                 Motion(const base::SpaceInformationPtr &si) : root(NULL), state(si->allocState()), parent(NULL)
00219                 {
00220                 }
00221 
00222                 ~Motion(void)
00223                 {
00224                 }
00225 
00227                 const base::State   *root;
00228 
00230                 base::State         *state;
00231 
00233                 Motion              *parent;
00234             };
00235 
00237             void freeMotion(Motion *motion);
00238 
00240             base::ValidStateSamplerPtr                 sampler_;
00241 
00243             base::ProjectionEvaluatorPtr               projectionEvaluator_;
00244 
00246             Discretization<Motion>                     dStart_;
00247 
00249             Discretization<Motion>                     dGoal_;
00250 
00254             double                                     goodScoreFactor_;
00255 
00259             double                                     badScoreFactor_;
00260 
00266             double                                     minValidPathFraction_;
00267 
00269             double                                     maxDistance_;
00270 
00272             RNG                                        rng_;
00273         };
00274 
00275     }
00276 }
00277 
00278 
00279 #endif