All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Goal.h
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_BASE_GOAL_
00038 #define OMPL_BASE_GOAL_
00039 
00040 #include "ompl/base/State.h"
00041 #include "ompl/base/SpaceInformation.h"
00042 #include "ompl/base/Path.h"
00043 #include "ompl/util/ClassForward.h"
00044 #include <iostream>
00045 #include <boost/noncopyable.hpp>
00046 #include <boost/concept_check.hpp>
00047 
00048 namespace ompl
00049 {
00050     namespace base
00051     {
00052 
00054         ClassForward(Goal);
00055 
00060         class Goal : private boost::noncopyable
00061         {
00062         public:
00063 
00065             Goal(const SpaceInformationPtr &si);
00066 
00068             virtual ~Goal(void)
00069             {
00070             }
00071 
00073             template<class T>
00074             T* as(void)
00075             {
00077                 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, Goal*>));
00078 
00079                 return static_cast<T*>(this);
00080             }
00081 
00083             template<class T>
00084             const T* as(void) const
00085             {
00087                 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, Goal*>));
00088 
00089                 return static_cast<const T*>(this);
00090             }
00091 
00093             const SpaceInformationPtr& getSpaceInformation(void) const
00094             {
00095                 return si_;
00096             }
00097 
00100             virtual bool isSatisfied(const State *st) const = 0;
00101 
00113             virtual bool isSatisfied(const State *st, double *distance) const;
00114 
00124             bool isSatisfied(const State *st, double pathLength, double *distance) const;
00125 
00132             virtual bool isStartGoalPairValid(const State * /* start */, const State * /* goal */) const
00133             {
00134                 return true;
00135             }
00136 
00138             bool isAchieved(void) const
00139             {
00140                 return path_;
00141             }
00142 
00144             double getMaximumPathLength(void) const
00145             {
00146                 return maximumPathLength_;
00147             }
00148 
00153             void setMaximumPathLength(double maximumPathLength)
00154             {
00155                 maximumPathLength_ = maximumPathLength;
00156             }
00157 
00162             const PathPtr& getSolutionPath(void) const
00163             {
00164                 return path_;
00165             }
00166 
00168             void setSolutionPath(const PathPtr &path, bool approximate = false)
00169             {
00170                 path_ = path;
00171                 approximate_ = approximate;
00172             }
00173 
00175             void clearSolutionPath(void)
00176             {
00177                 path_.reset();
00178             }
00179 
00183             double getDifference(void) const
00184             {
00185                 return difference_;
00186             }
00187 
00190             void setDifference(double difference)
00191             {
00192                 difference_ = difference;
00193             }
00194 
00198             bool isApproximate(void) const
00199             {
00200                 return approximate_;
00201             }
00202 
00204             virtual void print(std::ostream &out = std::cout) const
00205             {
00206                 out << "Goal memory address " << this << std::endl;
00207             }
00208 
00209         protected:
00210 
00212             SpaceInformationPtr      si_;
00213 
00215             double                   maximumPathLength_;
00216 
00218             PathPtr                  path_;
00219 
00221             double                   difference_;
00222 
00224             bool                     approximate_;
00225 
00226         };
00227 
00228     }
00229 }
00230 
00231 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator