Loading...
Searching...
No Matches
State.h
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2019, University of Oxford
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: Marlin Strub
36
37#ifndef OMPL_GEOMETRIC_PLANNERS_INFORMEDTREES_EITSTAR_STATE_
38#define OMPL_GEOMETRIC_PLANNERS_INFORMEDTREES_EITSTAR_STATE_
39
40#include <memory>
41#include <set>
42#include <utility>
43
44#include "ompl/base/Cost.h"
45#include "ompl/base/SpaceInformation.h"
46#include "ompl/base/State.h"
47
48#include "ompl/geometric/planners/informedtrees/eitstar/Vertex.h"
49
50namespace ompl
51{
52 namespace geometric
53 {
54 namespace eitstar
55 {
57 class State : public std::enable_shared_from_this<State> // Inheritance must be public here.
58 {
59 public:
62 State(const std::shared_ptr<ompl::base::SpaceInformation> &spaceInfo,
63 const std::shared_ptr<ompl::base::OptimizationObjective> &objective);
64
66 ~State();
67
69 std::size_t getId() const;
70
72 ompl::base::State *raw() const;
73
75 bool hasForwardVertex() const;
76
78 bool hasReverseVertex() const;
79
81 std::shared_ptr<Vertex> asForwardVertex();
82
84 std::shared_ptr<Vertex> asReverseVertex();
85
87 void blacklist(const std::shared_ptr<State> &state);
88
90 void whitelist(const std::shared_ptr<State> &state);
91
93 bool isBlacklisted(const std::shared_ptr<State> &state) const;
94
96 bool isWhitelisted(const std::shared_ptr<State> &state) const;
97
100 void setEstimatedEffortToGo(std::size_t effort);
101
105
109
113
117
120
122 void setLowerBoundEffortToCome(unsigned int effort);
123
125 void setInadmissibleEffortToCome(unsigned int effort);
126
129 unsigned int getEstimatedEffortToGo() const;
130
134
138
142
146
149
152 unsigned int getLowerBoundEffortToCome() const;
153
156 unsigned int getInadmissibleEffortToCome() const;
157
159 const std::vector<std::weak_ptr<State>> getSourcesOfIncomingEdgesInForwardQueue() const;
160
162 void addToSourcesOfIncomingEdgesInForwardQueue(const std::shared_ptr<State> &state) const;
163
165 void removeFromSourcesOfIncomingEdgesInForwardQueue(const std::shared_ptr<State> &state) const;
166
169
171 void setIncomingCollisionCheckResolution(const std::shared_ptr<State> &source,
172 std::size_t numChecks) const;
173
175 std::size_t getIncomingCollisionCheckResolution(const std::shared_ptr<State> &source) const;
176
177 private:
180
182 const std::size_t id_;
183
186 unsigned int estimatedEffortToGo_{std::numeric_limits<unsigned int>::max()};
187
190 ompl::base::Cost estimatedCostToGo_;
191
193 unsigned int lowerBoundEffortToCome_{std::numeric_limits<unsigned int>::max()};
194
196 unsigned int inadmissibleEffortToCome_{std::numeric_limits<unsigned int>::max()};
197
200 ompl::base::Cost admissibleCostToGo_;
201
204 ompl::base::Cost lowerBoundCostToGo_;
205
208 ompl::base::Cost lowerBoundCostToCome_;
209
211 ompl::base::Cost currentCostToCome_;
212
214 ompl::base::State *state_;
215
217 std::weak_ptr<Vertex> forwardVertex_{};
218
220 std::weak_ptr<Vertex> reverseVertex_{};
221
223 mutable std::pair<std::size_t, std::vector<std::weak_ptr<State>>> neighbors_{};
224
226 std::set<std::size_t> blacklist_{}; // Maybe this would be faster as vector?
227
229 std::set<std::size_t> whitelist_{}; // Maybe this would be faster as vector?
230
232 mutable std::vector<std::weak_ptr<State>> sourcesOfIncomingEdgesInForwardQueue_{};
233
237 mutable std::map<std::size_t, std::size_t> incomingCollisionCheckResolution_{};
238
240 std::shared_ptr<ompl::base::SpaceInformation> spaceInfo_;
241
243 std::shared_ptr<ompl::base::OptimizationObjective> objective_;
244 };
245
246 } // namespace eitstar
247
248 } // namespace geometric
249
250} // namespace ompl
251
252#endif // OMPL_GEOMETRIC_PLANNERS_INFORMEDTREES_EITSTAR_STATE_
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
void setAdmissibleCostToGo(ompl::base::Cost cost)
Set the admissible estimate of the cost to go from this state to the goal through the current RGG.
Definition State.cpp:177
ompl::base::Cost getLowerBoundCostToCome() const
Returns the lower bound cost to come from the start to this state through the continuous state space.
Definition State.cpp:227
std::size_t getIncomingCollisionCheckResolution(const std::shared_ptr< State > &source) const
Returns the number of collision checks already performed on the edge incoming from source.
Definition State.cpp:284
ompl::base::Cost getAdmissibleCostToGo() const
Returns the admissible estimate of the cost to go from this state to the goal through the current RGG...
Definition State.cpp:217
std::size_t getId() const
Returns the state's unique id.
Definition State.cpp:77
bool hasForwardVertex() const
Returns whether the state has an associated forward vertex.
Definition State.cpp:87
friend class RandomGeometricGraph
Grant access to the state internals to the random geometric graph.
Definition State.h:179
std::shared_ptr< Vertex > asReverseVertex()
Returns the state as a reverse vertex.
Definition State.cpp:122
~State()
Destructs this state, freeing the associated memory.
Definition State.cpp:72
void setEstimatedEffortToGo(std::size_t effort)
Set the estimated effort (number of collision detections) to go from this state to the goal through t...
Definition State.cpp:167
void removeFromSourcesOfIncomingEdgesInForwardQueue(const std::shared_ptr< State > &state) const
Removes a source from sources of incoming edges in forward queue.
Definition State.cpp:257
void setInadmissibleEffortToCome(unsigned int effort)
Sets the inadmissible effort to come to this state through the continuous state space.
Definition State.cpp:202
unsigned int getLowerBoundEffortToCome() const
Returns the lower bound effort to come from the start to this state through the continuous state spac...
Definition State.cpp:237
void blacklist(const std::shared_ptr< State > &state)
Blacklists the given state as neighbor.
Definition State.cpp:147
void setLowerBoundCostToCome(ompl::base::Cost cost)
Set the lower bound cost to come from the start to this state through the continuous state space.
Definition State.cpp:187
std::shared_ptr< Vertex > asForwardVertex()
Returns the state as a reverse vertex.
Definition State.cpp:97
ompl::base::State * raw() const
Returns the raw OMPL version of this state.
Definition State.cpp:82
void resetSourcesOfIncomingEdgesInForwardQueue()
Resets the sources of incoming edges in the forward queue.
Definition State.cpp:273
ompl::base::Cost getLowerBoundCostToGo() const
Returns the lower bound cost to go from this state to the goal through the continuous state space.
Definition State.cpp:222
bool isWhitelisted(const std::shared_ptr< State > &state) const
Returns whether the given has been whitelisted.
Definition State.cpp:162
void setCurrentCostToCome(ompl::base::Cost cost)
Set the current cost to come from the start to this state.
Definition State.cpp:192
void setLowerBoundCostToGo(ompl::base::Cost cost)
Set the lower bound cost to go from this state to the goal through the continuous state space.
Definition State.cpp:182
void setLowerBoundEffortToCome(unsigned int effort)
Sets the lower bound effort to come to this state through the continuous state space.
Definition State.cpp:197
unsigned int getEstimatedEffortToGo() const
Get the estimated effort (number of collision detections) to go from this state to the goal through t...
Definition State.cpp:207
void whitelist(const std::shared_ptr< State > &state)
Whitelists the given state as neighbor.
Definition State.cpp:152
void addToSourcesOfIncomingEdgesInForwardQueue(const std::shared_ptr< State > &state) const
Adds a source to sources of incoming edges in forward queue.
Definition State.cpp:252
unsigned int getInadmissibleEffortToCome() const
Returns the inadmissible effort to come from the start to this state through the continuous state spa...
Definition State.cpp:242
bool isBlacklisted(const std::shared_ptr< State > &state) const
Returns whether the given state has been blacklisted.
Definition State.cpp:157
ompl::base::Cost getEstimatedCostToGo() const
Returns the best estimate of the cost to go from this state to the goal through the current RGG.
Definition State.cpp:212
void setEstimatedCostToGo(ompl::base::Cost cost)
Set the best estimate of the cost to go from this state to the goal through the current RGG.
Definition State.cpp:172
State(const std::shared_ptr< ompl::base::SpaceInformation > &spaceInfo, const std::shared_ptr< ompl::base::OptimizationObjective > &objective)
Constructs the state, allocating the associated memory using information about the underlying space.
Definition State.cpp:54
ompl::base::Cost getCurrentCostToCome() const
Returns the current cost to come from the start to this state.
Definition State.cpp:232
void setIncomingCollisionCheckResolution(const std::shared_ptr< State > &source, std::size_t numChecks) const
Sets the number of collision checks already performed on the edge incoming from source.
Definition State.cpp:278
bool hasReverseVertex() const
Returns whether the state has an associated reverse vertex.
Definition State.cpp:92
const std::vector< std::weak_ptr< State > > getSourcesOfIncomingEdgesInForwardQueue() const
Returns the sources of incoming edges in forward queue.
Definition State.cpp:247
This namespace contains code that is specific to planning under geometric constraints.
Main namespace. Contains everything in this library.