All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
LazyRRT.h
00001 
00002 /*********************************************************************
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (c) 2008, Willow Garage, Inc.
00006 *  All rights reserved.
00007 *
00008 *  Redistribution and use in source and binary forms, with or without
00009 *  modification, are permitted provided that the following conditions
00010 *  are met:
00011 *
00012 *   * Redistributions of source code must retain the above copyright
00013 *     notice, this list of conditions and the following disclaimer.
00014 *   * Redistributions in binary form must reproduce the above
00015 *     copyright notice, this list of conditions and the following
00016 *     disclaimer in the documentation and/or other materials provided
00017 *     with the distribution.
00018 *   * Neither the name of the Willow Garage nor the names of its
00019 *     contributors may be used to endorse or promote products derived
00020 *     from this software without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 *  POSSIBILITY OF SUCH DAMAGE.
00034 *********************************************************************/
00035 
00036 /* Author: Ioan Sucan */
00037 
00038 #ifndef OMPL_GEOMETRIC_PLANNERS_RRT_LAZY_RRT_
00039 #define OMPL_GEOMETRIC_PLANNERS_RRT_LAZY_RRT_
00040 
00041 #include "ompl/geometric/planners/PlannerIncludes.h"
00042 #include "ompl/datastructures/NearestNeighbors.h"
00043 #include <vector>
00044 
00045 namespace ompl
00046 {
00047 
00048     namespace geometric
00049     {
00050 
00081         class LazyRRT : public base::Planner
00082         {
00083         public:
00084 
00086             LazyRRT(const base::SpaceInformationPtr &si) : base::Planner(si, "LazyRRT")
00087             {
00088                 type_ = base::PLAN_TO_GOAL_ANY;
00089 
00090                 goalBias_ = 0.05;
00091                 maxDistance_ = 0.0;
00092             }
00093 
00094             virtual ~LazyRRT(void)
00095             {
00096                 freeMemory();
00097             }
00098 
00099             virtual void getPlannerData(base::PlannerData &data) const;
00100 
00101             virtual bool solve(const base::PlannerTerminationCondition &ptc);
00102 
00103             virtual void clear(void);
00104 
00114             void setGoalBias(double goalBias)
00115             {
00116                 goalBias_ = goalBias;
00117             }
00118 
00120             double getGoalBias(void) const
00121             {
00122                 return goalBias_;
00123             }
00124 
00130             void setRange(double distance)
00131             {
00132                 maxDistance_ = distance;
00133             }
00134 
00136             double getRange(void) const
00137             {
00138                 return maxDistance_;
00139             }
00140 
00142             template<template<typename T> class NN>
00143             void setNearestNeighbors(void)
00144             {
00145                 nn_.reset(new NN<Motion*>());
00146             }
00147 
00148             virtual void setup(void);
00149 
00150         protected:
00151 
00153             class Motion
00154             {
00155             public:
00156 
00157                 Motion(void) : state(NULL), parent(NULL), valid(false)
00158                 {
00159                 }
00160 
00162                 Motion(const base::SpaceInformationPtr &si) : state(si->allocState()), parent(NULL), valid(false)
00163                 {
00164                 }
00165 
00166                 ~Motion(void)
00167                 {
00168                 }
00169 
00171                 base::State          *state;
00172 
00174                 Motion               *parent;
00175 
00177                 bool                  valid;
00178 
00180                 std::vector<Motion*>  children;
00181             };
00182 
00184             void freeMemory(void);
00185 
00187             void removeMotion(Motion *motion);
00188 
00190             double distanceFunction(const Motion* a, const Motion* b) const
00191             {
00192                 return si_->distance(a->state, b->state);
00193             }
00194 
00196             base::ManifoldStateSamplerPtr                  sampler_;
00197 
00199             boost::shared_ptr< NearestNeighbors<Motion*> > nn_;
00200 
00202             double                                         goalBias_;
00203 
00205             double                                         maxDistance_;
00206 
00208             RNG                                            rng_;
00209 
00210         };
00211 
00212     }
00213 }
00214 
00215 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator