00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2008, Willow Garage, Inc. 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 Willow Garage 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_KPIECE1_ 00038 #define OMPL_GEOMETRIC_PLANNERS_KPIECE_KPIECE1_ 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 00049 00076 class KPIECE1 : public base::Planner 00077 { 00078 public: 00079 00081 KPIECE1(const base::SpaceInformationPtr &si) : base::Planner(si, "KPIECE1"), 00082 disc_(boost::bind(&KPIECE1::freeMotion, this, _1)) 00083 { 00084 type_ = base::PLAN_TO_GOAL_ANY; 00085 00086 goalBias_ = 0.05; 00087 badScoreFactor_ = 0.5; 00088 goodScoreFactor_ = 0.9; 00089 minValidPathFraction_ = 0.2; 00090 maxDistance_ = 0.0; 00091 } 00092 00093 virtual ~KPIECE1(void) 00094 { 00095 } 00096 00097 virtual bool solve(const base::PlannerTerminationCondition &ptc); 00098 00099 virtual void clear(void); 00100 00110 void setGoalBias(double goalBias) 00111 { 00112 goalBias_ = goalBias; 00113 } 00114 00116 double getGoalBias(void) const 00117 { 00118 return goalBias_; 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 disc_.setBorderFraction(bp); 00146 } 00147 00150 double getBorderFraction(void) const 00151 { 00152 return disc_.getBorderFraction(); 00153 } 00154 00161 void setMinValidPathFraction(double fraction) 00162 { 00163 minValidPathFraction_ = fraction; 00164 } 00165 00167 double getMinValidPathFraction(void) const 00168 { 00169 return minValidPathFraction_; 00170 } 00171 00178 void setCellScoreFactor(double good, double bad) 00179 { 00180 goodScoreFactor_ = good; 00181 badScoreFactor_ = bad; 00182 } 00183 00186 double getGoodCellScoreFactor(void) const 00187 { 00188 return goodScoreFactor_; 00189 } 00190 00193 double getBadCellScoreFactor(void) const 00194 { 00195 return badScoreFactor_; 00196 } 00197 00200 void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator) 00201 { 00202 projectionEvaluator_ = projectionEvaluator; 00203 } 00204 00207 void setProjectionEvaluator(const std::string &name) 00208 { 00209 projectionEvaluator_ = si_->getStateSpace()->getProjection(name); 00210 } 00211 00213 const base::ProjectionEvaluatorPtr& getProjectionEvaluator(void) const 00214 { 00215 return projectionEvaluator_; 00216 } 00217 00218 virtual void setup(void); 00219 00220 virtual void getPlannerData(base::PlannerData &data) const; 00221 00222 protected: 00223 00225 class Motion 00226 { 00227 public: 00228 00229 Motion(void) : state(NULL), parent(NULL) 00230 { 00231 } 00232 00234 Motion(const base::SpaceInformationPtr &si) : state(si->allocState()), parent(NULL) 00235 { 00236 } 00237 00238 ~Motion(void) 00239 { 00240 } 00241 00243 base::State *state; 00244 00246 Motion *parent; 00247 }; 00248 00250 void freeMotion(Motion *motion); 00251 00253 base::StateSamplerPtr sampler_; 00254 00256 Discretization<Motion> disc_; 00257 00261 base::ProjectionEvaluatorPtr projectionEvaluator_; 00262 00266 double goodScoreFactor_; 00267 00271 double badScoreFactor_; 00272 00274 double goalBias_; 00275 00281 double minValidPathFraction_; 00282 00284 double maxDistance_; 00285 00287 RNG rng_; 00288 }; 00289 00290 } 00291 } 00292 00293 #endif