All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
PlannerData.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, Rice University
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Rice University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Mark Moll */
36 
37 #ifndef OMPL_CONTROL_PLANNER_DATA_
38 #define OMPL_CONTROL_PLANNER_DATA_
39 
40 #include "ompl/base/PlannerData.h"
41 #include "ompl/control/SpaceInformation.h"
42 #include "ompl/control/Control.h"
43 #include <boost/serialization/base_object.hpp>
44 
45 namespace ompl
46 {
47  namespace control
48  {
61  {
62  public:
64  PlannerDataEdgeControl (const Control *c, double duration) : PlannerDataEdge(), c_(c), duration_(duration) {}
66  PlannerDataEdgeControl (const PlannerDataEdgeControl &rhs) : PlannerDataEdge(), c_(rhs.c_), duration_(rhs.duration_) {}
67 
68  virtual ~PlannerDataEdgeControl (void) {}
69 
70  virtual base::PlannerDataEdge* clone () const
71  {
72  return static_cast<base::PlannerDataEdge*>(new PlannerDataEdgeControl(*this));
73  }
74 
76  const Control* getControl (void) const { return c_; }
78  double getDuration (void) const { return duration_; }
79 
80  virtual bool operator == (const PlannerDataEdge &rhs) const
81  {
82  const PlannerDataEdgeControl *rhsc = static_cast<const PlannerDataEdgeControl*> (&rhs);
83  if (c_ == rhsc->c_)
84  return static_cast<const PlannerDataEdge>(*this) == rhs;
85  else
86  return false;
87  }
88 
89  protected:
90  friend class boost::serialization::access;
91  friend class PlannerDataStorage;
92  friend class PlannerData;
93 
94  PlannerDataEdgeControl() : PlannerDataEdge(), c_(NULL) {};
95 
96  template <class Archive>
97  void serialize(Archive & ar, const unsigned int /*version*/)
98  {
99  ar & boost::serialization::base_object<base::PlannerDataEdge>(*this);
100  ar & duration_;
101  // Serializing the control is handled by control::PlannerDataStorage
102  }
103 
104  const Control *c_;
105  double duration_;
106  };
107 
112  {
113  public:
114 
116  PlannerData(const SpaceInformationPtr &siC);
118  virtual ~PlannerData(void);
119 
123  virtual bool removeVertex (const base::PlannerDataVertex &st);
127  virtual bool removeVertex (unsigned int vIndex);
128 
130  virtual bool removeEdge (unsigned int v1, unsigned int v2);
133  virtual bool removeEdge (const base::PlannerDataVertex &v1, const base::PlannerDataVertex &v2);
134 
136  virtual void clear (void);
137 
145  virtual void decoupleFromPlanner(void);
146 
148  const SpaceInformationPtr& getSpaceInformation(void) const;
149 
151  virtual bool hasControls(void) const;
152 
153  protected:
158  std::set<Control*> decoupledControls_;
159 
160  private:
161  void freeMemory(void);
162  };
163  }
164 }
165 
166 #endif
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:164
Definition of an abstract control.
Definition: Control.h:48
virtual base::PlannerDataEdge * clone() const
Return a clone of this object, allocated from the heap.
Definition: PlannerData.h:70
std::set< Control * > decoupledControls_
A list of controls that are allocated during the decoupleFromPlanner method. These controls are freed...
Definition: PlannerData.h:158
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:111
Representation of an edge in PlannerData for planning with controls. This structure encodes a specifi...
Definition: PlannerData.h:60
PlannerData(const SpaceInformationPtr &siC)
Constructor. Accepts a SpaceInformationPtr for the space planned in.
Definition: PlannerData.cpp:39
double getDuration(void) const
Return the duration associated with this edge.
Definition: PlannerData.h:78
virtual bool hasControls(void) const
Returns true if this PlannerData instance has controls associated with it.
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition: PlannerData.h:60
SpaceInformationPtr siC_
The instance of control::SpaceInformation associated with this data.
Definition: PlannerData.h:155
PlannerDataEdgeControl(const Control *c, double duration)
Constructor. Accepts a control pointer and a duration.
Definition: PlannerData.h:64
const SpaceInformationPtr & getSpaceInformation(void) const
Return the instance of SpaceInformation used in this PlannerData.
const Control * getControl(void) const
Return the control associated with this edge.
Definition: PlannerData.h:76
virtual void decoupleFromPlanner(void)
Creates a deep copy of the states contained in the vertices of this PlannerData structure so that whe...
virtual bool removeVertex(const base::PlannerDataVertex &st)
Removes the vertex associated with the given data. If the vertex does not exist, false is returned...
Definition: PlannerData.cpp:53
A boost shared pointer wrapper for ompl::control::SpaceInformation.
virtual ~PlannerData(void)
Destructor.
Definition: PlannerData.cpp:43
virtual bool removeEdge(unsigned int v1, unsigned int v2)
Removes the edge between vertex indexes v1 and v2. Success is returned.
Definition: PlannerData.cpp:77
Base class for a PlannerData edge.
Definition: PlannerData.h:117
virtual void clear(void)
Clears the entire data structure.
PlannerDataEdgeControl(const PlannerDataEdgeControl &rhs)
Copy constructor.
Definition: PlannerData.h:66