Loading...
Searching...
No Matches
Vertex.h
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, University of Toronto
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 University of Toronto 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/* Authors: Jonathan Gammell, Marlin Strub */
36
37#ifndef OMPL_GEOMETRIC_PLANNERS_INFORMEDTREES_BITSTAR_VERTEX_
38#define OMPL_GEOMETRIC_PLANNERS_INFORMEDTREES_BITSTAR_VERTEX_
39
40#include <memory>
41#include <vector>
42
43#include "ompl/base/OptimizationObjective.h"
44#include "ompl/base/SpaceInformation.h"
45#include "ompl/geometric/planners/informedtrees/BITstar.h"
46#include "ompl/geometric/planners/informedtrees/bitstar/SearchQueue.h"
47
48namespace ompl
49{
50 namespace geometric
51 {
65
68 {
69 public:
70 // ---
71 // Construction and destruction.
72 // ---
73
75 Vertex(ompl::base::SpaceInformationPtr spaceInformation, const CostHelper *const costHelpPtr,
76 SearchQueue *const queuePtr, const std::shared_ptr<const unsigned int> &approximationId,
77 bool root = false);
78
80 virtual ~Vertex();
81
82 // ---
83 // State access.
84 // ---
85
88
91
93 ompl::base::State const *state() const;
94
95 // ---
96 // Graph information access.
97 // ---
98
100 bool isRoot() const;
101
103 bool hasParent() const;
104
106 bool isInTree() const;
107
109 unsigned int getDepth() const;
110
113
116
118 bool isConsistent() const;
119
121 bool isPruned() const;
122
125
127 bool isExpandedOnCurrentSearch() const;
128
131
132 // ---
133 // Graph modification.
134 // ---
135
138 void addParent(const VertexPtr &newParent, const ompl::base::Cost &edgeInCost);
139
142 void removeParent(bool updateChildCosts);
143
145 bool hasChildren() const;
146
148 void getChildren(VertexConstPtrVector *children) const;
149
151 void getChildren(VertexPtrVector *children);
152
155 void addChild(const VertexPtr &newChild);
156
160 void removeChild(const VertexPtr &oldChild);
161
163 void blacklistChild(const VertexConstPtr &vertex);
164
166 void whitelistChild(const VertexConstPtr &vertex);
167
169 bool isBlacklistedAsChild(const VertexConstPtr &vertex) const;
170
172 bool isWhitelistedAsChild(const VertexConstPtr &vertex) const;
173
175 void clearBlacklist();
176
178 void clearWhitelist();
179
182
185
187 void registerExpansion();
188
191
193 void markPruned();
194
196 void markUnpruned();
197
198 // ---
199 // Edge queue lookups.
200 // ---
201
205
209
212
215
217 void removeFromEdgeQueueInLookup(const SearchQueue::EdgeQueueElemPtrVector::const_iterator &inEdge);
218
220 void removeFromEdgeQueueOutLookup(const SearchQueue::EdgeQueueElemPtrVector::const_iterator &outEdge);
221
224 BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueInLookupConstBegin();
225
228 BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueOutLookupConstBegin();
229
232 BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueInLookupConstEnd();
233
236 BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueOutLookupConstEnd();
237
240 unsigned int edgeQueueInLookupSize();
241
244 unsigned int edgeQueueOutLookupSize();
245
248
251
252 private:
253 // ---
254 // Internal bookkeeping.
255 // ---
256
259 void updateCostAndDepth(bool cascadeUpdates = true);
260
261 // ---
262 // Member variables.
263 // ---
264
267
269 ompl::base::SpaceInformationPtr si_;
270
272 const CostHelper *const costHelpPtr_;
273
275 SearchQueue *const queuePtr_;
276
278 ompl::base::State *state_;
279
281 bool isRoot_;
282
285 bool isPruned_{false};
286
288 unsigned int depth_{0u};
289
292 VertexPtr parentPtr_;
293
295 ompl::base::Cost edgeCost_;
296
298 ompl::base::Cost cost_;
299
301 ompl::base::Cost costAtExpansion_;
302
305 std::vector<VertexWeakPtr> children_;
306
308 SearchQueue::EdgeQueueElemPtrVector edgeQueueInLookup_;
309
311 SearchQueue::EdgeQueueElemPtrVector edgeQueueOutLookup_;
312
315 std::set<BITstar::VertexId> childIdBlacklist_;
316
318 std::set<BITstar::VertexId> childIdWhitelist_;
319
321 unsigned int lookupApproximationId_{0u};
322
324 unsigned int expansionApproximationId_{0u};
325
327 unsigned int expansionSearchId_{0u};
328
330 bool hasEverBeenExpandedAsRewiring_{false};
331
333 const std::shared_ptr<const unsigned int> currentSearchId_;
334
336 const std::shared_ptr<const unsigned int> currentApproximationId_;
337
339 void removeFromEdgeQueueInLookup(const SearchQueue::EdgeQueueElemPtrVector::iterator &iterToDelete);
340
342 void removeFromEdgeQueueOutLookup(const SearchQueue::EdgeQueueElemPtrVector::iterator &iterToDelete);
343
346 void clearLookupsIfOutdated();
347 }; // class Vertex
348 } // namespace geometric
349} // namespace ompl
350
351#endif // OMPL_GEOMETRIC_PLANNERS_INFORMEDTREES_BITSTAR_VERTEX_
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition Cost.h:48
Definition of an abstract state.
Definition State.h:50
A helper class to handle the various heuristic functions in one place.
Definition CostHelper.h:69
A queue of edges, sorted according to a sort key.
Definition SearchQueue.h:65
std::vector< EdgeQueueElemPtr > EdgeQueueElemPtrVector
A vector of edge queue pointers.
Definition SearchQueue.h:88
EdgeQueue::Element * EdgeQueueElemPtr
An element pointer into the edge queue binary heap.
Definition SearchQueue.h:85
The vertex of the underlying graphs in gBITstar BIT*.
Definition Vertex.h:68
void removeChild(const VertexPtr &oldChild)
Remove a child from this vertex. Does not change this vertex's cost or those of its descendants....
Definition Vertex.cpp:374
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueOutLookupConstEnd()
Get an iterator to the end of the outgoing edge queue entry vector. Will clear existing in/out lookup...
Definition Vertex.cpp:796
bool isConsistent() const
Whether the vertex is consistent.
Definition Vertex.cpp:491
bool hasParent() const
Returns whether this vertex has a parent.
Definition Vertex.cpp:173
void markPruned()
Mark the vertex as pruned.
Definition Vertex.cpp:531
Vertex(ompl::base::SpaceInformationPtr spaceInformation, const CostHelper *const costHelpPtr, SearchQueue *const queuePtr, const std::shared_ptr< const unsigned int > &approximationId, bool root=false)
Construct a vertex using space information, and helpers to compute various costs.
Definition Vertex.cpp:110
void removeFromEdgeQueueOutLookup(const SearchQueue::EdgeQueueElemPtr &outEdge)
Remove an outgoing edge queue entry by value.
Definition Vertex.cpp:713
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueInLookupConstBegin()
Get an iterator to the front of the incoming edge queue entry vector. Will clear existing in/out look...
Definition Vertex.cpp:651
void getChildren(VertexConstPtrVector *children) const
Get the children of a vertex as constant pointers.
Definition Vertex.cpp:303
void insertInEdgeQueueInLookup(const SearchQueue::EdgeQueueElemPtr &inEdge)
Add to the list of the edge queue entries that point in to this vertex. Will clear existing in/out lo...
Definition Vertex.cpp:546
virtual ~Vertex()
Destruct a vertex.
Definition Vertex.cpp:134
bool isBlacklistedAsChild(const VertexConstPtr &vertex) const
Returns true if the vertex is blacklisted as a child of this vertex.
Definition Vertex.cpp:450
bool isInTree() const
Get whether a vertex is in the search tree or a sample (i.e., a vertex of the RRG).
Definition Vertex.cpp:180
void blacklistChild(const VertexConstPtr &vertex)
Put the vertex on the blacklist of children.
Definition Vertex.cpp:440
bool hasEverBeenExpandedAsRewiring() const
Returns whether the vertex has ever been expanded as a rewiring.
Definition Vertex.cpp:511
void removeParent(bool updateChildCosts)
Remove the parent of this vertex. Will always update this vertex's cost, and can update the descenden...
Definition Vertex.cpp:271
void clearEdgeQueueInLookup()
Clear the pointers to all of the incoming edge queue entries.
Definition Vertex.cpp:644
void markUnpruned()
Mark the vertex as unpruned.
Definition Vertex.cpp:539
unsigned int edgeQueueOutLookupSize()
Get the number of edge queue entries outgoing from this vertex. Will clear existing in/out lookups if...
Definition Vertex.cpp:806
void addChild(const VertexPtr &newChild)
Add a child to this vertex. Does not change this vertex's cost or those of its descendants....
Definition Vertex.cpp:347
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueInLookupConstEnd()
Get an iterator to the end of the incoming edge queue entry vector. Will clear existing in/out lookup...
Definition Vertex.cpp:661
bool hasChildren() const
Get whether this vertex has any children.
Definition Vertex.cpp:296
bool isWhitelistedAsChild(const VertexConstPtr &vertex) const
Returns true if the vertex is blacklisted as a child of this vertex.
Definition Vertex.cpp:455
VertexConstPtr getParent() const
Get a const pointer to the parent of this vertex.
Definition Vertex.cpp:202
bool isPruned() const
Whether the vertex has been pruned.
Definition Vertex.cpp:496
void whitelistChild(const VertexConstPtr &vertex)
Put the vertex on the whitelist of children.
Definition Vertex.cpp:445
bool isRoot() const
Returns whether the vertex is the root of the search tree.
Definition Vertex.cpp:166
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueOutLookupConstBegin()
Get an iterator to the front of the outgoing edge queue entry vector. Will clear existing in/out look...
Definition Vertex.cpp:786
void clearBlacklist()
Clears the blacklist.
Definition Vertex.cpp:460
bool isExpandedOnCurrentApproximation() const
Returns whether the vertex is expanded on current approximation.
Definition Vertex.cpp:501
void registerExpansion()
Mark the vertex as expanded.
Definition Vertex.cpp:516
ompl::base::Cost getEdgeInCost() const
Get the incremental cost-to-come of a vertex.
Definition Vertex.cpp:477
void addParent(const VertexPtr &newParent, const ompl::base::Cost &edgeInCost)
Set the parent of this vertex, cannot be used to replace a previous parent. Will always update this v...
Definition Vertex.cpp:244
ompl::base::State * state()
The state of a vertex as a pointer.
Definition Vertex.cpp:156
void registerRewiringExpansion()
Mark expansion to vertices.
Definition Vertex.cpp:526
void clearWhitelist()
Clears the whitelist.
Definition Vertex.cpp:465
bool isExpandedOnCurrentSearch() const
Returns whether the vertex is expaned on current search.
Definition Vertex.cpp:506
void clearEdgeQueueOutLookup()
Clear the pointers to all of the outgoing edge queue entries.
Definition Vertex.cpp:779
ompl::base::Cost getCost() const
Get the cost-to-come of a vertex. Return infinity if the edge is disconnected.
Definition Vertex.cpp:470
void insertInEdgeQueueOutLookup(const SearchQueue::EdgeQueueElemPtr &outEdge)
Add to the list of the edge queue entries that point out of this vertex. Will clear existing in/out l...
Definition Vertex.cpp:681
BITstar::VertexId getId() const
The (unique) vertex ID.
Definition Vertex.cpp:142
unsigned int getDepth() const
Get the depth of the vertex from the root.
Definition Vertex.cpp:187
void removeFromEdgeQueueInLookup(const SearchQueue::EdgeQueueElemPtr &inEdge)
Remove an incoming edge queue entry by value to the member vector.
Definition Vertex.cpp:578
unsigned int edgeQueueInLookupSize()
Get the number of edge queue entries incoming to this vertex. Will clear existing in/out lookups if t...
Definition Vertex.cpp:671
std::vector< VertexConstPtr > VertexConstPtrVector
A vector of shared pointers to const vertices.
Definition BITstar.h:128
std::vector< VertexPtr > VertexPtrVector
A vector of shared pointers to vertices.
Definition BITstar.h:125
std::shared_ptr< const Vertex > VertexConstPtr
A shared pointer to a const vertex.
Definition BITstar.h:119
std::shared_ptr< Vertex > VertexPtr
A shared pointer to a vertex.
Definition BITstar.h:116
unsigned int VertexId
The vertex id type.
Definition BITstar.h:131
This namespace contains code that is specific to planning under geometric constraints.
Main namespace. Contains everything in this library.