ompl/control/PlannerData.h
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2011, 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: Mark Moll */
00036 
00037 #ifndef OMPL_CONTROL_PLANNER_DATA_
00038 #define OMPL_CONTROL_PLANNER_DATA_
00039 
00040 #include "ompl/base/PlannerData.h"
00041 #include "ompl/control/SpaceInformation.h"
00042 #include "ompl/control/Control.h"
00043 #include <boost/serialization/base_object.hpp>
00044 
00045 namespace ompl
00046 {
00047     namespace control
00048     {
00060         class PlannerDataEdgeControl : public base::PlannerDataEdge
00061         {
00062         public:
00064             PlannerDataEdgeControl(const Control *c, double duration) : PlannerDataEdge(), c_(c), duration_(duration) {}
00066             PlannerDataEdgeControl(const PlannerDataEdgeControl &rhs) : PlannerDataEdge(), c_(rhs.c_), duration_(rhs.duration_) {}
00067 
00068             virtual ~PlannerDataEdgeControl() {}
00069 
00070             virtual base::PlannerDataEdge* clone() const
00071             {
00072                 return static_cast<base::PlannerDataEdge*>(new PlannerDataEdgeControl(*this));
00073             }
00074 
00076             const Control* getControl() const { return c_; }
00078             double getDuration() const { return duration_; }
00079 
00080             virtual bool operator==(const PlannerDataEdge &rhs) const
00081             {
00082                 const PlannerDataEdgeControl *rhsc = static_cast<const PlannerDataEdgeControl*> (&rhs);
00083                 if (c_ == rhsc->c_)
00084                     return static_cast<const PlannerDataEdge>(*this) == rhs;
00085                 else
00086                     return false;
00087             }
00088 
00089         protected:
00090             friend class boost::serialization::access;
00091             friend class PlannerDataStorage;
00092             friend class PlannerData;
00093 
00094             PlannerDataEdgeControl() : PlannerDataEdge(), c_(NULL) {};
00095 
00096             template <class Archive>
00097             void serialize(Archive &ar, const unsigned int /*version*/)
00098             {
00099                 ar & boost::serialization::base_object<base::PlannerDataEdge>(*this);
00100                 ar & duration_;
00101                 // Serializing the control is handled by control::PlannerDataStorage
00102             }
00103 
00104             const Control *c_;
00105             double duration_;
00106         };
00107 
00111         class PlannerData : public base::PlannerData
00112         {
00113         public:
00114 
00116             PlannerData(const SpaceInformationPtr &siC);
00118             virtual ~PlannerData();
00119 
00123             virtual bool removeVertex(const base::PlannerDataVertex &st);
00127             virtual bool removeVertex(unsigned int vIndex);
00128 
00130             virtual bool removeEdge(unsigned int v1, unsigned int v2);
00133             virtual bool removeEdge(const base::PlannerDataVertex &v1, const base::PlannerDataVertex &v2);
00134 
00136             virtual void clear();
00137 
00145             virtual void decoupleFromPlanner();
00146 
00148             const SpaceInformationPtr& getSpaceInformation() const;
00149 
00151             virtual bool hasControls() const;
00152 
00153         protected:
00155             SpaceInformationPtr  siC_;
00158             std::set<Control*> decoupledControls_;
00159 
00160         private:
00161             void freeMemory();
00162         };
00163     }
00164 }
00165 
00166 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines