Loading...
Searching...
No Matches
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
45namespace ompl
46{
47 namespace control
48 {
61 {
62 public:
64 PlannerDataEdgeControl(const Control *c, double duration) : c_(c), duration_(duration)
65 {
66 }
67
68 PlannerDataEdgeControl(const PlannerDataEdgeControl &rhs) : c_(rhs.c_), duration_(rhs.duration_)
69 {
70 }
71
72 ~PlannerDataEdgeControl() override = default;
73
74 base::PlannerDataEdge *clone() const override
75 {
76 return static_cast<base::PlannerDataEdge *>(new PlannerDataEdgeControl(*this));
77 }
78
80 const Control *getControl() const
81 {
82 return c_;
83 }
84
85 double getDuration() const
86 {
87 return duration_;
88 }
89
90 bool operator==(const PlannerDataEdge &rhs) const override
91 {
92 const auto *rhsc = static_cast<const PlannerDataEdgeControl *>(&rhs);
93 if (c_ == rhsc->c_)
94 return static_cast<const PlannerDataEdge>(*this) == rhs;
95 return false;
96 }
97
98 protected:
99 friend class boost::serialization::access;
100 friend class PlannerDataStorage;
101 friend class PlannerData;
102
103 PlannerDataEdgeControl() = default;
104
105 template <class Archive>
106 void serialize(Archive &ar, const unsigned int /*version*/)
107 {
108 ar &boost::serialization::base_object<base::PlannerDataEdge>(*this);
109 ar & duration_;
110 // Serializing the control is handled by control::PlannerDataStorage
111 }
112
113 const Control *c_{nullptr};
114 double duration_;
115 };
116
121 {
122 public:
126 ~PlannerData() override;
127
131 bool removeVertex(const base::PlannerDataVertex &st) override;
135 bool removeVertex(unsigned int vIndex) override;
136
138 bool removeEdge(unsigned int v1, unsigned int v2) override;
141 bool removeEdge(const base::PlannerDataVertex &v1, const base::PlannerDataVertex &v2) override;
142
144 void clear() override;
145
153 void decoupleFromPlanner() override;
154
157
159 bool hasControls() const override;
160
161 protected:
166 std::set<Control *> decoupledControls_;
167
168 private:
169 void freeMemory();
170 };
171 } // namespace control
172} // namespace ompl
173
174#endif
Base class for a PlannerData edge.
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition PlannerData.h:59
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique,...
A shared pointer wrapper for ompl::base::SpaceInformation.
Definition of an abstract control.
Definition Control.h:48
Representation of an edge in PlannerData for planning with controls. This structure encodes a specifi...
Definition PlannerData.h:61
const Control * getControl() const
Return the control associated with this edge.
Definition PlannerData.h:80
double getDuration() const
Return the duration associated with this edge.
Definition PlannerData.h:85
base::PlannerDataEdge * clone() const override
Return a clone of this object, allocated from the heap.
Definition PlannerData.h:74
PlannerDataEdgeControl(const PlannerDataEdgeControl &rhs)
Copy constructor.
Definition PlannerData.h:68
PlannerDataEdgeControl(const Control *c, double duration)
Constructor. Accepts a control pointer and a duration.
Definition PlannerData.h:64
bool removeVertex(const base::PlannerDataVertex &st) override
Removes the vertex associated with the given data. If the vertex does not exist, false is returned....
std::set< Control * > decoupledControls_
A list of controls that are allocated during the decoupleFromPlanner method. These controls are freed...
PlannerData(const SpaceInformationPtr &siC)
Constructor. Accepts a SpaceInformationPtr for the space planned in.
void decoupleFromPlanner() override
Creates a deep copy of the states contained in the vertices of this PlannerData structure so that whe...
void clear() override
Clears the entire data structure.
const SpaceInformationPtr & getSpaceInformation() const
Return the instance of SpaceInformation used in this PlannerData.
bool hasControls() const override
Returns true if this PlannerData instance has controls associated with it.
~PlannerData() override
Destructor.
SpaceInformationPtr siC_
The instance of control::SpaceInformation associated with this data.
bool removeEdge(unsigned int v1, unsigned int v2) override
Removes the edge between vertex indexes v1 and v2. Success is returned.
This namespace contains sampling based planning routines used by planning under differential constrai...
Definition Control.h:45
Main namespace. Contains everything in this library.